From 6e295ce9b2da125d396e7e32d0a4b3986944f1d3 Mon Sep 17 00:00:00 2001 From: trigg Date: Tue, 30 Dec 2025 16:09:42 +0000 Subject: [PATCH 1/8] - Add longtouch support for alternative actions - Split gestures into press and release to correctly allow cancelling --- src/panel/widgets/menu.cpp | 14 +++++++- .../notifications/notification-center.cpp | 15 +++++++- .../notifications/single-notification.cpp | 6 +++- src/panel/widgets/tray/item.cpp | 9 +++++ src/panel/widgets/volume.cpp | 15 ++++++++ src/panel/widgets/window-list/toplevel.cpp | 34 +++++++++++-------- 6 files changed, 75 insertions(+), 18 deletions(-) diff --git a/src/panel/widgets/menu.cpp b/src/panel/widgets/menu.cpp index 61cb6ad5..d7099848 100644 --- a/src/panel/widgets/menu.cpp +++ b/src/panel/widgets/menu.cpp @@ -129,12 +129,24 @@ WfMenuMenuItem::WfMenuMenuItem(WayfireMenu *_menu, Glib::RefPtrset_touch_only(true); + long_press->signal_pressed().connect( + [=] (double x, double y) + { + m_extra_actions_button.activate(); + long_press.set_state(Gtk::EventSequenceState::CLAIMED); + click_gesture.set_state(Gtk::EventSequenceState::DENIED); + }); click_gesture->set_button(3); click_gesture->signal_pressed().connect([=] (int count, double x, double y) { - m_extra_actions_button.activate(); click_gesture->set_state(Gtk::EventSequenceState::CLAIMED); }); + click_gesture->signal_released().connect([=] (int count, double x, double y) + { + m_extra_actions_button.activate(); + }); m_button.add_controller(click_gesture); } diff --git a/src/panel/widgets/notifications/notification-center.cpp b/src/panel/widgets/notifications/notification-center.cpp index a0a51eed..9e449804 100644 --- a/src/panel/widgets/notifications/notification-center.cpp +++ b/src/panel/widgets/notifications/notification-center.cpp @@ -29,12 +29,25 @@ void WayfireNotificationCenter::init(Gtk::Box *container) button->set_tooltip_text("Middle click to toggle DND mode."); auto click_gesture = Gtk::GestureClick::create(); + auto long_press = Gtk::GestureLongPress::create(); + long_press->set_touch_only(true); + long_press->signal_pressed().connect( + [=] (double x, double y) + { + dnd_enabled = !dnd_enabled; + updateIcon(); + long_press.set_state(Gtk::EventSequenceState::CLAIMED); + click_gesture.set_state(Gtk::EventSequenceState::DENIED); + }); click_gesture->set_button(2); click_gesture->signal_pressed().connect([=] (int count, double x, double y) + { + click_gesture->set_state(Gtk::EventSequenceState::CLAIMED); + }); + click_gesture->signal_released().connect([=] (int count, double x, double y) { dnd_enabled = !dnd_enabled; updateIcon(); - click_gesture->set_state(Gtk::EventSequenceState::CLAIMED); }); button->add_controller(click_gesture); diff --git a/src/panel/widgets/notifications/single-notification.cpp b/src/panel/widgets/notifications/single-notification.cpp index fbb5fb0b..f82b1443 100644 --- a/src/panel/widgets/notifications/single-notification.cpp +++ b/src/panel/widgets/notifications/single-notification.cpp @@ -147,9 +147,13 @@ WfSingleNotification::WfSingleNotification(const Notification & notification) click_gesture->signal_pressed().connect( [id = notification.id, action_key, click_gesture] (int count, double x, double y) { - Daemon::Instance()->invokeAction(id, action_key); click_gesture->set_state(Gtk::EventSequenceState::CLAIMED); }); + click_gesture->signal_released().connect( + [id = notification.id, action_key, click_gesture] (int count, double x, double y) + { + Daemon::Instance()->invokeAction(id, action_key); + }); default_action_ev_box.add_controller(click_gesture); } } diff --git a/src/panel/widgets/tray/item.cpp b/src/panel/widgets/tray/item.cpp index 4255fcb6..c3746b3b 100644 --- a/src/panel/widgets/tray/item.cpp +++ b/src/panel/widgets/tray/item.cpp @@ -95,6 +95,15 @@ void StatusNotifierItem::init_widget() }, true); auto click_gesture = Gtk::GestureClick::create(); + auto long_press = Gtk::GestureLongPress::create(); + long_press->set_touch_only(true); + long_press->signal_pressed().connect( + [=] (double x, double y) + { + popover.popup(); + long_press.set_state(Gtk::EventSequenceState::CLAIMED); + click_gesture.set_state(Gtk::EventSequenceState::DENIED); + }); click_gesture->set_button(0); click_gesture->signal_pressed().connect([=] (int count, double x, double y) { diff --git a/src/panel/widgets/volume.cpp b/src/panel/widgets/volume.cpp index d6bd8034..9fe0f6fc 100644 --- a/src/panel/widgets/volume.cpp +++ b/src/panel/widgets/volume.cpp @@ -296,8 +296,23 @@ void WayfireVolume::init(Gtk::Box *container) /* Middle click toggle mute */ auto middle_click_gesture = Gtk::GestureClick::create(); + auto long_press = Gtk::GestureLongPress::create(); + long_press->set_touch_only(true); + long_press->signal_pressed().connect( + [=] (double x, double y) + { + dnd_enabled = !dnd_enabled; + updateIcon(); + long_press.set_state(Gtk::EventSequenceState::CLAIMED); + middle_click_gesture.set_state(Gtk::EventSequenceState::DENIED); + } + ); middle_click_gesture->set_button(2); middle_click_gesture->signal_pressed().connect([=] (int count, double x, double y) + { + middle_click_gesture.set_state(Gtk::EventSequenceState::CLAIMED); + }); + middle_click_gesture->signal_release().connect([=] (int count, double x, double y) { bool muted = !(gvc_stream && gvc_mixer_stream_get_is_muted(gvc_stream)); gvc_mixer_stream_change_is_muted(gvc_stream, muted); diff --git a/src/panel/widgets/window-list/toplevel.cpp b/src/panel/widgets/window-list/toplevel.cpp index e5d2b0cd..b7f56025 100644 --- a/src/panel/widgets/window-list/toplevel.cpp +++ b/src/panel/widgets/window-list/toplevel.cpp @@ -115,30 +115,27 @@ class WayfireToplevel::impl button.add_controller(drag_gesture); auto click_gesture = Gtk::GestureClick::create(); + auto long_press = Gtk::GestureLongPress::create(); + long_press->set_touch_only(true); + long_press->signal_pressed().connect( + [=] (double x, double y) + { + popover.popup(); + long_press.set_state(Gtk::EventSequenceState::CLAIMED); + click_gesture.set_state(Gtk::EventSequenceState::DENIED); + }); click_gesture->set_button(0); click_gesture->signal_pressed().connect( [=] (int count, double x, double y) { - int butt = click_gesture->get_current_button(); - if (butt == 3) - { - popover.popup(); - click_gesture->set_state(Gtk::EventSequenceState::CLAIMED); - } else if (butt == 1) - { - // Don't action it now because the press might be a drag! - click_gesture->set_state(Gtk::EventSequenceState::CLAIMED); - } else if (butt = 2 && middle_click_close) - { - zwlr_foreign_toplevel_handle_v1_close(handle); - click_gesture->set_state(Gtk::EventSequenceState::CLAIMED); - } + click_gesture->set_state(Gtk::EventSequenceState::CLAIMED); }); click_gesture->signal_released().connect( [=] (int count, double x, double y) { - if (click_gesture->get_current_button() == 1) + int butt = click_gesture->get_current_button(); + if (butt == 1) { // Ah, it was a press after all! if (!ignore_next_click) @@ -147,8 +144,15 @@ class WayfireToplevel::impl } ignore_next_click = false; + } else if (butt == 2) + { + zwlr_foreign_toplevel_handle_v1_close(handle); + } else if (butt ==3 ) + { + popover.popup(); } }); + button.add_controller(long_click); button.add_controller(click_gesture); this->window_list = window_list; From 60df1747b6c0cbc8f7401a65af38840a42aedf6e Mon Sep 17 00:00:00 2001 From: trigg Date: Tue, 30 Dec 2025 16:12:21 +0000 Subject: [PATCH 2/8] - pay attention trigg --- src/panel/widgets/menu.cpp | 4 ++-- src/panel/widgets/notifications/notification-center.cpp | 4 ++-- src/panel/widgets/tray/item.cpp | 4 ++-- src/panel/widgets/volume.cpp | 6 +++--- src/panel/widgets/window-list/toplevel.cpp | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/panel/widgets/menu.cpp b/src/panel/widgets/menu.cpp index d7099848..94c9600c 100644 --- a/src/panel/widgets/menu.cpp +++ b/src/panel/widgets/menu.cpp @@ -135,8 +135,8 @@ WfMenuMenuItem::WfMenuMenuItem(WayfireMenu *_menu, Glib::RefPtrset_state(Gtk::EventSequenceState::CLAIMED); + click_gesture->set_state(Gtk::EventSequenceState::DENIED); }); click_gesture->set_button(3); click_gesture->signal_pressed().connect([=] (int count, double x, double y) diff --git a/src/panel/widgets/notifications/notification-center.cpp b/src/panel/widgets/notifications/notification-center.cpp index 9e449804..40d84181 100644 --- a/src/panel/widgets/notifications/notification-center.cpp +++ b/src/panel/widgets/notifications/notification-center.cpp @@ -36,8 +36,8 @@ void WayfireNotificationCenter::init(Gtk::Box *container) { dnd_enabled = !dnd_enabled; updateIcon(); - long_press.set_state(Gtk::EventSequenceState::CLAIMED); - click_gesture.set_state(Gtk::EventSequenceState::DENIED); + long_press->set_state(Gtk::EventSequenceState::CLAIMED); + click_gesture->set_state(Gtk::EventSequenceState::DENIED); }); click_gesture->set_button(2); click_gesture->signal_pressed().connect([=] (int count, double x, double y) diff --git a/src/panel/widgets/tray/item.cpp b/src/panel/widgets/tray/item.cpp index c3746b3b..deab1f4f 100644 --- a/src/panel/widgets/tray/item.cpp +++ b/src/panel/widgets/tray/item.cpp @@ -101,8 +101,8 @@ void StatusNotifierItem::init_widget() [=] (double x, double y) { popover.popup(); - long_press.set_state(Gtk::EventSequenceState::CLAIMED); - click_gesture.set_state(Gtk::EventSequenceState::DENIED); + long_press->set_state(Gtk::EventSequenceState::CLAIMED); + click_gesture->set_state(Gtk::EventSequenceState::DENIED); }); click_gesture->set_button(0); click_gesture->signal_pressed().connect([=] (int count, double x, double y) diff --git a/src/panel/widgets/volume.cpp b/src/panel/widgets/volume.cpp index 9fe0f6fc..052f41a8 100644 --- a/src/panel/widgets/volume.cpp +++ b/src/panel/widgets/volume.cpp @@ -303,14 +303,14 @@ void WayfireVolume::init(Gtk::Box *container) { dnd_enabled = !dnd_enabled; updateIcon(); - long_press.set_state(Gtk::EventSequenceState::CLAIMED); - middle_click_gesture.set_state(Gtk::EventSequenceState::DENIED); + long_press->set_state(Gtk::EventSequenceState::CLAIMED); + middle_click_gesture->set_state(Gtk::EventSequenceState::DENIED); } ); middle_click_gesture->set_button(2); middle_click_gesture->signal_pressed().connect([=] (int count, double x, double y) { - middle_click_gesture.set_state(Gtk::EventSequenceState::CLAIMED); + middle_click_gesture->set_state(Gtk::EventSequenceState::CLAIMED); }); middle_click_gesture->signal_release().connect([=] (int count, double x, double y) { diff --git a/src/panel/widgets/window-list/toplevel.cpp b/src/panel/widgets/window-list/toplevel.cpp index b7f56025..8b21ba00 100644 --- a/src/panel/widgets/window-list/toplevel.cpp +++ b/src/panel/widgets/window-list/toplevel.cpp @@ -121,8 +121,8 @@ class WayfireToplevel::impl [=] (double x, double y) { popover.popup(); - long_press.set_state(Gtk::EventSequenceState::CLAIMED); - click_gesture.set_state(Gtk::EventSequenceState::DENIED); + long_press->set_state(Gtk::EventSequenceState::CLAIMED); + click_gesture->set_state(Gtk::EventSequenceState::DENIED); }); click_gesture->set_button(0); click_gesture->signal_pressed().connect( From 6e0a38ef26bcab7df2616f4275a147824fe3a6a0 Mon Sep 17 00:00:00 2001 From: trigg Date: Tue, 30 Dec 2025 16:15:11 +0000 Subject: [PATCH 3/8] - use gestures --- src/panel/widgets/menu.cpp | 1 + src/panel/widgets/notifications/notification-center.cpp | 1 + src/panel/widgets/tray/item.cpp | 2 +- src/panel/widgets/volume.cpp | 1 + src/panel/widgets/window-list/toplevel.cpp | 2 +- 5 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/panel/widgets/menu.cpp b/src/panel/widgets/menu.cpp index 94c9600c..b5e4b2a0 100644 --- a/src/panel/widgets/menu.cpp +++ b/src/panel/widgets/menu.cpp @@ -147,6 +147,7 @@ WfMenuMenuItem::WfMenuMenuItem(WayfireMenu *_menu, Glib::RefPtradd_controller(long_press); button->add_controller(click_gesture); for (const auto & [id, _] : daemon->getNotifications()) diff --git a/src/panel/widgets/tray/item.cpp b/src/panel/widgets/tray/item.cpp index deab1f4f..1ef177aa 100644 --- a/src/panel/widgets/tray/item.cpp +++ b/src/panel/widgets/tray/item.cpp @@ -150,7 +150,7 @@ void StatusNotifierItem::init_widget() click_gesture->set_state(Gtk::EventSequenceState::CLAIMED); return; }); - + add_controller(long_press); add_controller(scroll_gesture); add_controller(click_gesture); } diff --git a/src/panel/widgets/volume.cpp b/src/panel/widgets/volume.cpp index 052f41a8..1084e019 100644 --- a/src/panel/widgets/volume.cpp +++ b/src/panel/widgets/volume.cpp @@ -318,6 +318,7 @@ void WayfireVolume::init(Gtk::Box *container) gvc_mixer_stream_change_is_muted(gvc_stream, muted); gvc_mixer_stream_push_volume(gvc_stream); }); + button.add_controller(long_press); button.add_controller(middle_click_gesture); /* Setup layout */ diff --git a/src/panel/widgets/window-list/toplevel.cpp b/src/panel/widgets/window-list/toplevel.cpp index 8b21ba00..16b2a5cd 100644 --- a/src/panel/widgets/window-list/toplevel.cpp +++ b/src/panel/widgets/window-list/toplevel.cpp @@ -152,7 +152,7 @@ class WayfireToplevel::impl popover.popup(); } }); - button.add_controller(long_click); + button.add_controller(long_press); button.add_controller(click_gesture); this->window_list = window_list; From efd771ab4f7524bac6a3e0da6eb8df9e0f92df13 Mon Sep 17 00:00:00 2001 From: trigg Date: Tue, 30 Dec 2025 16:17:15 +0000 Subject: [PATCH 4/8] - use correct actions --- src/panel/widgets/volume.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/panel/widgets/volume.cpp b/src/panel/widgets/volume.cpp index 1084e019..1685a60a 100644 --- a/src/panel/widgets/volume.cpp +++ b/src/panel/widgets/volume.cpp @@ -301,8 +301,9 @@ void WayfireVolume::init(Gtk::Box *container) long_press->signal_pressed().connect( [=] (double x, double y) { - dnd_enabled = !dnd_enabled; - updateIcon(); + bool muted = !(gvc_stream && gvc_mixer_stream_get_is_muted(gvc_stream)); + gvc_mixer_stream_change_is_muted(gvc_stream, muted); + gvc_mixer_stream_push_volume(gvc_stream); long_press->set_state(Gtk::EventSequenceState::CLAIMED); middle_click_gesture->set_state(Gtk::EventSequenceState::DENIED); } @@ -312,7 +313,7 @@ void WayfireVolume::init(Gtk::Box *container) { middle_click_gesture->set_state(Gtk::EventSequenceState::CLAIMED); }); - middle_click_gesture->signal_release().connect([=] (int count, double x, double y) + middle_click_gesture->signal_released().connect([=] (int count, double x, double y) { bool muted = !(gvc_stream && gvc_mixer_stream_get_is_muted(gvc_stream)); gvc_mixer_stream_change_is_muted(gvc_stream, muted); From cc82682ed26e6b785ffff6cb80bff6bfb9fa6ca4 Mon Sep 17 00:00:00 2001 From: trigg Date: Tue, 30 Dec 2025 16:19:43 +0000 Subject: [PATCH 5/8] - split press and release on tray items --- src/panel/widgets/tray/item.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/panel/widgets/tray/item.cpp b/src/panel/widgets/tray/item.cpp index 1ef177aa..fdb71514 100644 --- a/src/panel/widgets/tray/item.cpp +++ b/src/panel/widgets/tray/item.cpp @@ -106,6 +106,11 @@ void StatusNotifierItem::init_widget() }); click_gesture->set_button(0); click_gesture->signal_pressed().connect([=] (int count, double x, double y) + { + click_gesture->set_state(Gtk::EventSequenceState::CLAIMED); + return; + }); + click_gesture->signal_released().connect([=] (int count, double x, double y) { int butt = click_gesture->get_current_button(); const auto ev_coords = Glib::Variant>::create({0, 0}); @@ -140,14 +145,8 @@ void StatusNotifierItem::init_widget() } else if (butt == tertiary_click) { item_proxy->call("SecondaryActivate", ev_coords); - } else - { - // Don't claim other buttons - click_gesture->set_state(Gtk::EventSequenceState::DENIED); - return; } - click_gesture->set_state(Gtk::EventSequenceState::CLAIMED); return; }); add_controller(long_press); From 6db3d92ce52d975ec5112875e4baa7f4dd464451 Mon Sep 17 00:00:00 2001 From: trigg Date: Tue, 30 Dec 2025 16:26:43 +0000 Subject: [PATCH 6/8] - missed one --- src/panel/widgets/notifications/single-notification.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/panel/widgets/notifications/single-notification.cpp b/src/panel/widgets/notifications/single-notification.cpp index f82b1443..ae105a11 100644 --- a/src/panel/widgets/notifications/single-notification.cpp +++ b/src/panel/widgets/notifications/single-notification.cpp @@ -154,6 +154,7 @@ WfSingleNotification::WfSingleNotification(const Notification & notification) { Daemon::Instance()->invokeAction(id, action_key); }); + default_action_ev_box.add_controller(long_press); default_action_ev_box.add_controller(click_gesture); } } From 27ef71ab087d3d205c35ebdb65a3b0f8144149d8 Mon Sep 17 00:00:00 2001 From: trigg Date: Tue, 30 Dec 2025 16:27:16 +0000 Subject: [PATCH 7/8] - or not --- src/panel/widgets/notifications/single-notification.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/panel/widgets/notifications/single-notification.cpp b/src/panel/widgets/notifications/single-notification.cpp index ae105a11..f82b1443 100644 --- a/src/panel/widgets/notifications/single-notification.cpp +++ b/src/panel/widgets/notifications/single-notification.cpp @@ -154,7 +154,6 @@ WfSingleNotification::WfSingleNotification(const Notification & notification) { Daemon::Instance()->invokeAction(id, action_key); }); - default_action_ev_box.add_controller(long_press); default_action_ev_box.add_controller(click_gesture); } } From c8a4429e96545acf6758f1f5a425d31db6fe7757 Mon Sep 17 00:00:00 2001 From: trigg Date: Tue, 30 Dec 2025 16:30:38 +0000 Subject: [PATCH 8/8] - uncrustify --- src/panel/widgets/menu.cpp | 2 +- src/panel/widgets/notifications/notification-center.cpp | 2 +- src/panel/widgets/tray/item.cpp | 2 +- src/panel/widgets/volume.cpp | 3 +-- src/panel/widgets/window-list/toplevel.cpp | 4 ++-- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/panel/widgets/menu.cpp b/src/panel/widgets/menu.cpp index b5e4b2a0..cd86dc5e 100644 --- a/src/panel/widgets/menu.cpp +++ b/src/panel/widgets/menu.cpp @@ -129,7 +129,7 @@ WfMenuMenuItem::WfMenuMenuItem(WayfireMenu *_menu, Glib::RefPtrset_touch_only(true); long_press->signal_pressed().connect( [=] (double x, double y) diff --git a/src/panel/widgets/notifications/notification-center.cpp b/src/panel/widgets/notifications/notification-center.cpp index 5f96dcee..a930b3db 100644 --- a/src/panel/widgets/notifications/notification-center.cpp +++ b/src/panel/widgets/notifications/notification-center.cpp @@ -29,7 +29,7 @@ void WayfireNotificationCenter::init(Gtk::Box *container) button->set_tooltip_text("Middle click to toggle DND mode."); auto click_gesture = Gtk::GestureClick::create(); - auto long_press = Gtk::GestureLongPress::create(); + auto long_press = Gtk::GestureLongPress::create(); long_press->set_touch_only(true); long_press->signal_pressed().connect( [=] (double x, double y) diff --git a/src/panel/widgets/tray/item.cpp b/src/panel/widgets/tray/item.cpp index fdb71514..5fc2e276 100644 --- a/src/panel/widgets/tray/item.cpp +++ b/src/panel/widgets/tray/item.cpp @@ -95,7 +95,7 @@ void StatusNotifierItem::init_widget() }, true); auto click_gesture = Gtk::GestureClick::create(); - auto long_press = Gtk::GestureLongPress::create(); + auto long_press = Gtk::GestureLongPress::create(); long_press->set_touch_only(true); long_press->signal_pressed().connect( [=] (double x, double y) diff --git a/src/panel/widgets/volume.cpp b/src/panel/widgets/volume.cpp index 1685a60a..263012dc 100644 --- a/src/panel/widgets/volume.cpp +++ b/src/panel/widgets/volume.cpp @@ -306,8 +306,7 @@ void WayfireVolume::init(Gtk::Box *container) gvc_mixer_stream_push_volume(gvc_stream); long_press->set_state(Gtk::EventSequenceState::CLAIMED); middle_click_gesture->set_state(Gtk::EventSequenceState::DENIED); - } - ); + }); middle_click_gesture->set_button(2); middle_click_gesture->signal_pressed().connect([=] (int count, double x, double y) { diff --git a/src/panel/widgets/window-list/toplevel.cpp b/src/panel/widgets/window-list/toplevel.cpp index 16b2a5cd..5387b46a 100644 --- a/src/panel/widgets/window-list/toplevel.cpp +++ b/src/panel/widgets/window-list/toplevel.cpp @@ -115,7 +115,7 @@ class WayfireToplevel::impl button.add_controller(drag_gesture); auto click_gesture = Gtk::GestureClick::create(); - auto long_press = Gtk::GestureLongPress::create(); + auto long_press = Gtk::GestureLongPress::create(); long_press->set_touch_only(true); long_press->signal_pressed().connect( [=] (double x, double y) @@ -147,7 +147,7 @@ class WayfireToplevel::impl } else if (butt == 2) { zwlr_foreign_toplevel_handle_v1_close(handle); - } else if (butt ==3 ) + } else if (butt == 3) { popover.popup(); }