fix(segmented_button): publish on_context without widget context_menu

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
This commit is contained in:
Lionel DARNIS 2026-07-04 19:41:28 +02:00
parent 2fe2d35286
commit 3e4ab4576d

View file

@ -1752,20 +1752,25 @@ where
} }
// Present a context menu on a right click event. // Present a context menu on a right click event.
if self.context_menu.is_some() // Yoda: on_context must fire even without a widget-side
&& let Some(on_context) = self.on_context.as_ref() // 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) && (right_button_released(event)
|| (touch_lifted(event) && fingers_pressed == 2)) || (touch_lifted(event) && fingers_pressed == 2))
{ {
state.show_context = Some(key); if self.context_menu.is_some() {
state.context_cursor = cursor_position.position().unwrap_or_default(); state.show_context = Some(key);
state.context_cursor =
cursor_position.position().unwrap_or_default();
state.menu_state.inner.with_data_mut(|data| { state.menu_state.inner.with_data_mut(|data| {
// Clear stale MenuBounds from any previous context menu before opening a new one. // Clear stale MenuBounds from any previous context menu before opening a new one.
data.reset(); data.reset();
data.open = true; data.open = true;
data.view_cursor = cursor_position; data.view_cursor = cursor_position;
}); });
}
shell.publish(on_context(key)); shell.publish(on_context(key));
shell.capture_event(); shell.capture_event();
@ -1776,10 +1781,12 @@ where
target_os = "linux", target_os = "linux",
feature = "surface-message" feature = "surface-message"
))] ))]
if matches!( if self.context_menu.is_some()
crate::app::cosmic::WINDOWING_SYSTEM.get(), && matches!(
Some(crate::app::cosmic::WindowingSystem::Wayland) crate::app::cosmic::WINDOWING_SYSTEM.get(),
) { Some(crate::app::cosmic::WindowingSystem::Wayland)
)
{
self.create_popup( self.create_popup(
layout, layout,
cursor_position, cursor_position,