2019-06-15 12:57:52 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <glibmm/dispatcher.h>
|
|
|
|
#include <glibmm/markup.h>
|
|
|
|
#include <gtkmm/eventbox.h>
|
|
|
|
#include <json/json.h>
|
2020-05-27 07:10:38 +00:00
|
|
|
|
2019-06-15 12:57:52 +00:00
|
|
|
#include "IModule.hpp"
|
|
|
|
|
|
|
|
namespace waybar {
|
|
|
|
|
|
|
|
class AModule : public IModule {
|
|
|
|
public:
|
|
|
|
virtual ~AModule();
|
2023-03-02 13:57:07 +00:00
|
|
|
auto update() -> void override;
|
2023-01-23 08:25:02 +00:00
|
|
|
virtual auto refresh(int) -> void{};
|
2023-03-02 13:57:07 +00:00
|
|
|
operator Gtk::Widget &() override;
|
2023-04-03 07:41:24 +00:00
|
|
|
auto doAction(const std::string &name) -> void override;
|
2019-06-15 12:57:52 +00:00
|
|
|
|
2023-10-17 16:11:48 +00:00
|
|
|
/// Emitting on this dispatcher triggers a update() call
|
2019-06-15 12:57:52 +00:00
|
|
|
Glib::Dispatcher dp;
|
|
|
|
|
|
|
|
protected:
|
2023-02-28 12:32:28 +00:00
|
|
|
// Don't need to make an object directly
|
|
|
|
// Derived classes are able to use it
|
|
|
|
AModule(const Json::Value &, const std::string &, const std::string &, bool enable_click = false,
|
|
|
|
bool enable_scroll = false);
|
|
|
|
|
2019-06-15 12:57:52 +00:00
|
|
|
enum SCROLL_DIR { NONE, UP, DOWN, LEFT, RIGHT };
|
|
|
|
|
|
|
|
SCROLL_DIR getScrollDir(GdkEventScroll *e);
|
2022-04-06 06:37:19 +00:00
|
|
|
bool tooltipEnabled();
|
2019-06-15 12:57:52 +00:00
|
|
|
|
2022-04-06 06:37:19 +00:00
|
|
|
const std::string name_;
|
2019-06-15 12:57:52 +00:00
|
|
|
const Json::Value &config_;
|
2022-04-06 06:37:19 +00:00
|
|
|
Gtk::EventBox event_box_;
|
2019-06-15 12:57:52 +00:00
|
|
|
|
|
|
|
virtual bool handleToggle(GdkEventButton *const &ev);
|
|
|
|
virtual bool handleScroll(GdkEventScroll *);
|
2023-08-16 15:14:49 +00:00
|
|
|
virtual bool handleRelease(GdkEventButton *const &ev);
|
2019-06-15 12:57:52 +00:00
|
|
|
|
|
|
|
private:
|
2023-08-16 15:14:49 +00:00
|
|
|
bool handleUserEvent(GdkEventButton *const &ev);
|
|
|
|
|
2019-06-15 12:57:52 +00:00
|
|
|
std::vector<int> pid_;
|
2022-04-06 06:37:19 +00:00
|
|
|
gdouble distance_scrolled_y_;
|
|
|
|
gdouble distance_scrolled_x_;
|
2023-02-28 12:32:28 +00:00
|
|
|
std::map<std::string, std::string> eventActionMap_;
|
2022-03-29 09:26:05 +00:00
|
|
|
static const inline std::map<std::pair<uint, GdkEventType>, std::string> eventMap_{
|
2022-04-06 06:37:19 +00:00
|
|
|
{std::make_pair(1, GdkEventType::GDK_BUTTON_PRESS), "on-click"},
|
2023-08-16 15:12:32 +00:00
|
|
|
{std::make_pair(1, GdkEventType::GDK_BUTTON_RELEASE), "on-click-release"},
|
2022-04-06 06:37:19 +00:00
|
|
|
{std::make_pair(1, GdkEventType::GDK_2BUTTON_PRESS), "on-double-click"},
|
|
|
|
{std::make_pair(1, GdkEventType::GDK_3BUTTON_PRESS), "on-triple-click"},
|
|
|
|
{std::make_pair(2, GdkEventType::GDK_BUTTON_PRESS), "on-click-middle"},
|
2023-08-16 15:12:32 +00:00
|
|
|
{std::make_pair(2, GdkEventType::GDK_BUTTON_RELEASE), "on-click-middle-release"},
|
2022-04-06 06:37:19 +00:00
|
|
|
{std::make_pair(2, GdkEventType::GDK_2BUTTON_PRESS), "on-double-click-middle"},
|
|
|
|
{std::make_pair(2, GdkEventType::GDK_3BUTTON_PRESS), "on-triple-click-middle"},
|
|
|
|
{std::make_pair(3, GdkEventType::GDK_BUTTON_PRESS), "on-click-right"},
|
2023-08-16 15:12:32 +00:00
|
|
|
{std::make_pair(3, GdkEventType::GDK_BUTTON_RELEASE), "on-click-right-release"},
|
2022-04-06 06:37:19 +00:00
|
|
|
{std::make_pair(3, GdkEventType::GDK_2BUTTON_PRESS), "on-double-click-right"},
|
|
|
|
{std::make_pair(3, GdkEventType::GDK_3BUTTON_PRESS), "on-triple-click-right"},
|
|
|
|
{std::make_pair(8, GdkEventType::GDK_BUTTON_PRESS), "on-click-backward"},
|
2023-08-16 15:12:32 +00:00
|
|
|
{std::make_pair(8, GdkEventType::GDK_BUTTON_RELEASE), "on-click-backward-release"},
|
2022-04-06 06:37:19 +00:00
|
|
|
{std::make_pair(8, GdkEventType::GDK_2BUTTON_PRESS), "on-double-click-backward"},
|
2022-08-06 10:52:00 +00:00
|
|
|
{std::make_pair(8, GdkEventType::GDK_3BUTTON_PRESS), "on-triple-click-backward"},
|
2022-04-06 06:37:19 +00:00
|
|
|
{std::make_pair(9, GdkEventType::GDK_BUTTON_PRESS), "on-click-forward"},
|
2023-08-16 15:12:32 +00:00
|
|
|
{std::make_pair(9, GdkEventType::GDK_BUTTON_RELEASE), "on-click-forward-release"},
|
2022-04-06 06:37:19 +00:00
|
|
|
{std::make_pair(9, GdkEventType::GDK_2BUTTON_PRESS), "on-double-click-forward"},
|
2022-08-06 10:52:00 +00:00
|
|
|
{std::make_pair(9, GdkEventType::GDK_3BUTTON_PRESS), "on-triple-click-forward"}};
|
2019-06-15 12:57:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace waybar
|