diff --git a/include/AModule.hpp b/include/AModule.hpp index c15efb006..2829599b0 100644 --- a/include/AModule.hpp +++ b/include/AModule.hpp @@ -6,6 +6,7 @@ #include #include "IModule.hpp" +#include "gtkmm/button.h" namespace waybar { @@ -35,7 +36,7 @@ class AModule : public IModule { const std::string name_; const Json::Value &config_; - Gtk::EventBox event_box_; + Gtk::Button event_box_; virtual bool handleToggle(GdkEventButton *const &ev); virtual bool handleScroll(GdkEventScroll *); diff --git a/src/AModule.cpp b/src/AModule.cpp index a451c3d60..d1749f2c6 100644 --- a/src/AModule.cpp +++ b/src/AModule.cpp @@ -36,8 +36,30 @@ AModule::AModule(const Json::Value& config, const std::string& name, const std:: config[eventEntry.second].isString(); }) != eventMap_.cend(); + event_box_.set_relief(Gtk::RELIEF_NONE); + if (enable_click || hasUserEvent) { event_box_.add_events(Gdk::BUTTON_PRESS_MASK); + + // TODO: not ideal? + // seems like specifically click event of gtk button needs to be captured like this? + // construct the specific GdkEventButton manually + // and pass it through the generic handling is the idea + event_box_.signal_pressed().connect([this] { + GdkEventButton eventInstance; + eventInstance.button = 1; + eventInstance.type = GDK_BUTTON_PRESS; + GdkEventButton* event = &eventInstance; + this->handleToggle(event); + }); + event_box_.signal_released().connect([this] { + GdkEventButton eventInstance; + eventInstance.button = 1; + eventInstance.type = GDK_BUTTON_RELEASE; + GdkEventButton* event = &eventInstance; + this->handleToggle(event); + }); + event_box_.signal_button_press_event().connect(sigc::mem_fun(*this, &AModule::handleToggle)); }