From b4519c081943b6515604f28504b49aa97efbf8b5 Mon Sep 17 00:00:00 2001 From: Pol Rivero <65060696+pol-rivero@users.noreply.github.com> Date: Fri, 24 Jan 2025 18:26:04 +0100 Subject: [PATCH] workspace taskbars: Use sigc::mem_fun instead of lambda --- include/modules/hyprland/workspace.hpp | 2 +- src/modules/hyprland/workspace.cpp | 16 ++++------------ 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/include/modules/hyprland/workspace.hpp b/include/modules/hyprland/workspace.hpp index b5ff3b41..a46d24e6 100644 --- a/include/modules/hyprland/workspace.hpp +++ b/include/modules/hyprland/workspace.hpp @@ -88,7 +88,7 @@ class Workspace { Gtk::Label m_labelAfter; void updateTaskbar(const std::string& workspace_icon); - static void focusWindow(WindowAddress const& addr); + bool handleClick(const GdkEventButton* event_button, WindowAddress const& addr) const; }; } // namespace waybar::modules::hyprland diff --git a/src/modules/hyprland/workspace.cpp b/src/modules/hyprland/workspace.cpp index cbcfbce9..515ed18f 100644 --- a/src/modules/hyprland/workspace.cpp +++ b/src/modules/hyprland/workspace.cpp @@ -252,14 +252,7 @@ void Workspace::updateTaskbar(const std::string &workspace_icon) { auto event_box = Gtk::manage(new Gtk::EventBox()); event_box->add(*window_box); event_box->signal_button_press_event().connect( - [window_repr](GdkEventButton const *bt) { - if (bt->type == GDK_BUTTON_PRESS) { - focusWindow(window_repr.address); - return true; - } - return false; - }, - false); + sigc::bind(sigc::mem_fun(*this, &Workspace::handleClick), window_repr.address)); auto text_before = fmt::format(fmt::runtime(m_workspaceManager.taskbarFormatBefore()), fmt::arg("title", window_repr.window_title)); @@ -297,12 +290,11 @@ void Workspace::updateTaskbar(const std::string &workspace_icon) { } } -void Workspace::focusWindow(WindowAddress const &addr) { - try { +bool Workspace::handleClick(const GdkEventButton *event_button, WindowAddress const &addr) const { + if (event_button->type == GDK_BUTTON_PRESS) { IPC::getSocket1Reply("dispatch focuswindow address:0x" + addr); - } catch (const std::exception &e) { - spdlog::error("Failed to dispatch window: {}", e.what()); } + return true; } } // namespace waybar::modules::hyprland