From 3e4ab4576d66d27d842f0589e055fc10cb0fbb25 Mon Sep 17 00:00:00 2001 From: Lionel DARNIS Date: Sat, 4 Jul 2026 19:41:28 +0200 Subject: [PATCH] fix(segmented_button): publish on_context without widget context_menu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Upstream's popup refactor gated the on_context callback behind context_menu.is_some(), silencing consumers that provide their own dialog (cosmic-term tab rename). Publish the message unconditionally; keep menu state + popup creation gated on an actual context_menu. Leyoda 2026 – GPLv3 --- src/widget/segmented_button/widget.rs | 35 ++++++++++++++++----------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/src/widget/segmented_button/widget.rs b/src/widget/segmented_button/widget.rs index 49778367..8c3a4ae2 100644 --- a/src/widget/segmented_button/widget.rs +++ b/src/widget/segmented_button/widget.rs @@ -1752,20 +1752,25 @@ where } // Present a context menu on a right click event. - if self.context_menu.is_some() - && let Some(on_context) = self.on_context.as_ref() + // Yoda: on_context must fire even without a widget-side + // context_menu — consumers (cosmic-term tab rename) rely + // on the message alone and provide their own dialog. + if let Some(on_context) = self.on_context.as_ref() && (right_button_released(event) || (touch_lifted(event) && fingers_pressed == 2)) { - state.show_context = Some(key); - state.context_cursor = cursor_position.position().unwrap_or_default(); + if self.context_menu.is_some() { + state.show_context = Some(key); + state.context_cursor = + cursor_position.position().unwrap_or_default(); - state.menu_state.inner.with_data_mut(|data| { - // Clear stale MenuBounds from any previous context menu before opening a new one. - data.reset(); - data.open = true; - data.view_cursor = cursor_position; - }); + state.menu_state.inner.with_data_mut(|data| { + // Clear stale MenuBounds from any previous context menu before opening a new one. + data.reset(); + data.open = true; + data.view_cursor = cursor_position; + }); + } shell.publish(on_context(key)); shell.capture_event(); @@ -1776,10 +1781,12 @@ where target_os = "linux", feature = "surface-message" ))] - if matches!( - crate::app::cosmic::WINDOWING_SYSTEM.get(), - Some(crate::app::cosmic::WindowingSystem::Wayland) - ) { + if self.context_menu.is_some() + && matches!( + crate::app::cosmic::WINDOWING_SYSTEM.get(), + Some(crate::app::cosmic::WindowingSystem::Wayland) + ) + { self.create_popup( layout, cursor_position,