Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(#2989)!: hover for all modules #3139

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/AModule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <json/json.h>

#include "IModule.hpp"
#include "gtkmm/button.h"

namespace waybar {

Expand Down Expand Up @@ -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 *);
Expand Down
22 changes: 22 additions & 0 deletions src/AModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down