deine cousine
This commit is contained in:
@@ -22,14 +22,16 @@ WorkspaceIndicator::WorkspaceIndicator(HyprlandService &service, int monitorId)
|
||||
auto label = Gtk::make_managed<Gtk::Label>(std::to_string(i));
|
||||
label->add_css_class("workspace-pill");
|
||||
|
||||
// create and store a gesture controller once to avoid duplicate handlers
|
||||
auto gesture = Gtk::GestureClick::create();
|
||||
gesture->set_button(GDK_BUTTON_PRIMARY);
|
||||
gesture->signal_released().connect(
|
||||
[this, i, &service](int, double, double) {
|
||||
service.switchToWorkspace(
|
||||
[this, i](int, double, double) {
|
||||
this->service.switchToWorkspace(
|
||||
i + this->monitorId * HyprlandService::kWorkspaceSlotCount);
|
||||
});
|
||||
label->add_controller(gesture);
|
||||
workspaceGestures[i] = gesture;
|
||||
|
||||
workspaceLabels[i] = label;
|
||||
append(*label);
|
||||
@@ -54,19 +56,12 @@ void WorkspaceIndicator::on_workspace_update() {
|
||||
|
||||
void WorkspaceIndicator::on_monitor_update() { rebuild(); }
|
||||
|
||||
void WorkspaceIndicator::refreshLabel(Gtk::Label *label, HyprlandService::WorkspaceState state) {
|
||||
void WorkspaceIndicator::refreshLabel(Gtk::Label *label, const HyprlandService::WorkspaceState &state) {
|
||||
label->remove_css_class("workspace-pill-active");
|
||||
label->remove_css_class("workspace-pill-focused");
|
||||
label->remove_css_class("workspace-pill-urgent");
|
||||
|
||||
auto gesture = Gtk::GestureClick::create();
|
||||
gesture->set_button(GDK_BUTTON_PRIMARY);
|
||||
gesture->signal_released().connect(
|
||||
[this, state](int, double, double) {
|
||||
service.switchToWorkspace(state.hyprId);
|
||||
});
|
||||
label->add_controller(gesture);
|
||||
|
||||
// controller created once in constructor and reused
|
||||
if (state.urgentWindows.size() > 0) {
|
||||
label->add_css_class("workspace-pill-urgent");
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user