Skip to content

Commit

Permalink
feat(Alexays#3182): style tray icon on hover (Alexays#3203)
Browse files Browse the repository at this point in the history
  • Loading branch information
haug1 authored and zjeffer committed May 7, 2024
1 parent 872b6d9 commit 73c986e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/modules/sni/item.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ class Item : public sigc::trackable {
void makeMenu();
bool handleClick(GdkEventButton* const& /*ev*/);
bool handleScroll(GdkEventScroll* const&);
bool handleMouseEnter(GdkEventCrossing* const&);
bool handleMouseLeave(GdkEventCrossing* const&);

// smooth scrolling threshold
gdouble scroll_threshold_ = 0;
Expand Down
13 changes: 13 additions & 0 deletions src/modules/sni/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <fstream>
#include <map>

#include "gdk/gdk.h"
#include "util/format.hpp"
#include "util/gtk_icon.hpp"

Expand Down Expand Up @@ -57,6 +58,8 @@ Item::Item(const std::string& bn, const std::string& op, const Json::Value& conf
event_box.add_events(Gdk::BUTTON_PRESS_MASK | Gdk::SCROLL_MASK | Gdk::SMOOTH_SCROLL_MASK);
event_box.signal_button_press_event().connect(sigc::mem_fun(*this, &Item::handleClick));
event_box.signal_scroll_event().connect(sigc::mem_fun(*this, &Item::handleScroll));
event_box.signal_enter_notify_event().connect(sigc::mem_fun(*this, &Item::handleMouseEnter));
event_box.signal_leave_notify_event().connect(sigc::mem_fun(*this, &Item::handleMouseLeave));
// initial visibility
event_box.show_all();
event_box.set_visible(show_passive_);
Expand All @@ -69,6 +72,16 @@ Item::Item(const std::string& bn, const std::string& op, const Json::Value& conf
cancellable_, interface);
}

bool Item::handleMouseEnter(GdkEventCrossing* const& e) {
event_box.set_state_flags(Gtk::StateFlags::STATE_FLAG_PRELIGHT);
return false;
}

bool Item::handleMouseLeave(GdkEventCrossing* const& e) {
event_box.unset_state_flags(Gtk::StateFlags::STATE_FLAG_PRELIGHT);
return false;
}

void Item::onConfigure(GdkEventConfigure* ev) { this->updateImage(); }

void Item::proxyReady(Glib::RefPtr<Gio::AsyncResult>& result) {
Expand Down

0 comments on commit 73c986e

Please sign in to comment.