add workspace clicks

This commit is contained in:
2025-12-10 02:49:17 +01:00
parent 45d932329a
commit a01bb7554b
5 changed files with 75 additions and 8 deletions

View File

@@ -2,6 +2,8 @@
#include <exception>
#include <gtkmm/widget.h>
#include <gtkmm/gestureclick.h>
#include <gdk/gdk.h>
#include <sigc++/functors/mem_fun.h>
WorkspaceIndicator::WorkspaceIndicator(HyprlandService &service, int monitorId)
@@ -79,6 +81,23 @@ void WorkspaceIndicator::rebuild()
auto label = Gtk::make_managed<Gtk::Label>(display);
label->add_css_class("workspace-pill");
// Make the label clickable using a gesture click (primary button)
auto gesture = Gtk::GestureClick::create();
gesture->set_button(GDK_BUTTON_PRIMARY);
// Use a lambda to capture the workspace slot id
gesture->signal_released().connect([this, workspaceId](int /*n_press*/, double /*x*/, double /*y*/)
{
try
{
m_service.switchToWorkspace(m_monitorId, workspaceId);
}
catch (const std::exception &ex)
{
std::cerr << "[WorkspaceIndicator] switchToWorkspace failed: " << ex.what() << std::endl;
}
});
label->add_controller(gesture);
if (state != nullptr)
{
if (state->focused)