feat(Label): on-click-right

This commit is contained in:
Alexis 2018-11-24 15:56:16 +01:00
parent a17220054d
commit 8f8ec3b999

View File

@ -21,17 +21,12 @@ waybar::ALabel::ALabel(const Json::Value& config, const std::string format, uint
} }
// configure events' user commands // configure events' user commands
if (config_["on-click"].isString()) { if (config_["on-click"].isString() || config_["on-click-right"].isString()) {
event_box_.add_events(Gdk::BUTTON_PRESS_MASK); event_box_.add_events(Gdk::BUTTON_PRESS_MASK);
event_box_.signal_button_press_event().connect( event_box_.signal_button_press_event().connect(
sigc::mem_fun(*this, &ALabel::handleToggle)); sigc::mem_fun(*this, &ALabel::handleToggle));
} }
if (config_["on-scroll-up"].isString()) { if (config_["on-scroll-up"].isString() || config_["on-scroll-down"].isString()) {
event_box_.add_events(Gdk::SCROLL_MASK);
event_box_.signal_scroll_event().connect(
sigc::mem_fun(*this, &ALabel::handleScroll));
}
if (config_["on-scroll-down"].isString()) {
event_box_.add_events(Gdk::SCROLL_MASK); event_box_.add_events(Gdk::SCROLL_MASK);
event_box_.signal_scroll_event().connect( event_box_.signal_scroll_event().connect(
sigc::mem_fun(*this, &ALabel::handleScroll)); sigc::mem_fun(*this, &ALabel::handleScroll));
@ -45,6 +40,8 @@ auto waybar::ALabel::update() -> void {
bool waybar::ALabel::handleToggle(GdkEventButton* const& e) { bool waybar::ALabel::handleToggle(GdkEventButton* const& e) {
if (config_["on-click"].isString() && e->button == 1) { if (config_["on-click"].isString() && e->button == 1) {
waybar::util::command::forkExec(config_["on-click"].asString()); waybar::util::command::forkExec(config_["on-click"].asString());
} else if (config_["on-click-right"].isString() && e->button == 3) {
waybar::util::command::forkExec(config_["on-click-right"].asString());
} else { } else {
alt = !alt; alt = !alt;
if (alt) { if (alt) {