From 7f71a383c4ec1a2cc31c3af6f64bb2215ff6f995 Mon Sep 17 00:00:00 2001 From: BowDown097 <42720004+BowDown097@users.noreply.github.com> Date: Sun, 15 Dec 2024 07:00:42 -0800 Subject: [PATCH 1/2] feat(launcher): open new window on middle-click --- src/modules/launcher/item.rs | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/modules/launcher/item.rs b/src/modules/launcher/item.rs index 1e2203bf..3b2fa37a 100644 --- a/src/modules/launcher/item.rs +++ b/src/modules/launcher/item.rs @@ -7,6 +7,7 @@ use crate::modules::launcher::{ItemEvent, LauncherUpdate}; use crate::modules::ModuleUpdateEvent; use crate::{read_lock, try_send}; use glib::Propagation; +use gtk::gdk::{BUTTON_MIDDLE, BUTTON_PRIMARY}; use gtk::prelude::*; use gtk::{Button, IconTheme, Image, Label, Orientation}; use indexmap::IndexMap; @@ -201,20 +202,27 @@ impl ItemButton { let app_id = item.app_id.clone(); let tx = controller_tx.clone(); let menu_state = menu_state.clone(); - button.connect_clicked(move |button| { - // lazy check :| TODO: Improve this - let style_context = button.style_context(); - if style_context.has_class("open") { - let menu_state = read_lock!(menu_state); - - if style_context.has_class("focused") && menu_state.num_windows == 1 { - try_send!(tx, ItemEvent::MinimizeItem(app_id.clone())); + + button.connect_button_release_event(move |button, event| { + if event.button() == BUTTON_PRIMARY { + // lazy check :| TODO: Improve this + let style_context = button.style_context(); + if style_context.has_class("open") { + let menu_state = read_lock!(menu_state); + + if style_context.has_class("focused") && menu_state.num_windows == 1 { + try_send!(tx, ItemEvent::MinimizeItem(app_id.clone())); + } else { + try_send!(tx, ItemEvent::FocusItem(app_id.clone())); + } } else { - try_send!(tx, ItemEvent::FocusItem(app_id.clone())); + try_send!(tx, ItemEvent::OpenItem(app_id.clone())); } - } else { + } else if event.button() == BUTTON_MIDDLE { try_send!(tx, ItemEvent::OpenItem(app_id.clone())); } + + Propagation::Proceed }); } From 7bff8c0a7fd16dd927e956af4b6f0ae717344495 Mon Sep 17 00:00:00 2001 From: BowDown097 <42720004+BowDown097@users.noreply.github.com> Date: Sun, 15 Dec 2024 12:44:36 -0800 Subject: [PATCH 2/2] docs(launcher): note middle click functionality --- docs/modules/Launcher.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/modules/Launcher.md b/docs/modules/Launcher.md index c6faabad..4a68c30b 100644 --- a/docs/modules/Launcher.md +++ b/docs/modules/Launcher.md @@ -3,7 +3,8 @@ Windows-style taskbar that displays running windows, grouped by program. Hovering over a program with multiple windows open shows a popup with each window. -Clicking an icon/popup item focuses or launches the program. +Left clicking an icon/popup item focuses the program if it has any open instances or otherwise launches a new instance of the program. +Middle clicking an icon always launches a new instance of the program. Optionally displays a launchable set of favourites. ![Screenshot showing several open applications, including a popup showing multiple terminal windows.](https://f.jstanger.dev/github/ironbar/launcher.png) @@ -113,4 +114,4 @@ start: | `.popup-launcher` | Popup container | | `.popup-launcher .popup-item` | Window button in popup | -For more information on styling, please see the [styling guide](styling-guide). \ No newline at end of file +For more information on styling, please see the [styling guide](styling-guide).