Program Listing for File hover_click.h

Return to documentation for file (include/miral/miral/hover_click.h)

/*
 * Copyright © Canonical Ltd.
 *
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 or 3 as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef MIRAL_HOVER_CLICK_H
#define MIRAL_HOVER_CLICK_H

namespace mir { class Server; }

#include <chrono>
#include <functional>

namespace miral
{
namespace live_config { class Store; }
class HoverClick
{
public:
    explicit HoverClick(live_config::Store& config_store);

    auto static enabled() -> HoverClick;

    auto static disabled() -> HoverClick;

    void operator()(mir::Server& server);

    HoverClick& enable();

    HoverClick& disable();

    HoverClick& hover_duration(std::chrono::milliseconds hover_duration);

    // Configures the distance in pixels the pointer has to move from the
    // initial hover click position to cancel it.
    // \note The default cancel displacement threshold is 10 pixels.
    HoverClick& cancel_displacement_threshold(int displacement);

    // Configures the distance in pixels the pointer has to move from the last
    // hover click or hover click cancel position to initiate a new hover
    // click.
    // \note The default reclick displacement threshold is 5 pixels.
    HoverClick& reclick_displacement_threshold(int displacement);

    HoverClick& on_hover_start(std::function<void()>&&);

    // Called immediately when a hover click is cancelled. Should be used to
    // indicate to the user that the hover click was cancelled.
    HoverClick& on_hover_cancel(std::function<void()>&&);

    // Called immediately after a hover click is successfully dispatched.
    // Should be used to indicate to the user that the hover click was
    // successful.
    HoverClick& on_click_dispatched(std::function<void()>&&);

private:
    struct Self;
    HoverClick(std::shared_ptr<Self> self);
    std::shared_ptr<Self> const self;
};
}

#endif