From 230dd8b13b024eb039613c579f940802ea5857e5 Mon Sep 17 00:00:00 2001 From: Jake Stanger Date: Tue, 19 Nov 2024 22:23:57 +0000 Subject: [PATCH] fix(workspaces): clicking currently focused workspace attempts to focus it Resolves #731 --- src/modules/workspaces.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/modules/workspaces.rs b/src/modules/workspaces.rs index 7fb01be..1bb8bd3 100644 --- a/src/modules/workspaces.rs +++ b/src/modules/workspaces.rs @@ -133,26 +133,27 @@ fn create_button( let button = new_icon_button(label, icon_theme, icon_size); button.set_widget_name(name); - let style_context = button.style_context(); - style_context.add_class("item"); + button.add_class("item"); if visibility.is_visible() { - style_context.add_class("visible"); + button.add_class("visible"); } if visibility.is_focused() { - style_context.add_class("focused"); + button.add_class("focused"); } if !visibility.is_visible() { - style_context.add_class("inactive"); + button.add_class("inactive"); } { let tx = tx.clone(); let name = name.to_string(); - button.connect_clicked(move |_item| { - try_send!(tx, name.clone()); + button.connect_clicked(move |button| { + if !button.style_context().has_class("focused") { + try_send!(tx, name.clone()); + } }); }