git.lucas.co / cce-display-manager
login greeter
git clone https://git.lucas.co/cce-display-manager.git

commit5342b64e1d603151d345713c5c8b0675a41cd4c9
parentcf03945de9
authorLucas Galante <lsgalante12@gmail.com>
date2026-10-07 10:12
Route clicks and hover to the shared context menu while it is open

A right-click on the username or password box opens cce-ui's shared
context menu, and cce-ui leaves routing to it to the app: no click
outside it closed it, and its rows did nothing. While it is open a press
now goes to the menu first -- ahead of the authenticating gate, so a
menu left open when a login starts can still be dismissed -- and the
pointer drives its row highlight.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

 src/main.rs | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/src/main.rs b/src/main.rs
index c89cc3d..d638274 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -932,17 +932,37 @@ impl cce_ui::engine::Application for State {
         let ly = pos.y as f32;
         self.cursor_x = lx;
         self.cursor_y = ly;
+        // The shared context menu (the username / password box's) gets the
+        // pointer to itself while open: its row highlight.
+        if cce_ui::widget::context_menu::is_visible() {
+            if cce_ui::widget::context_menu::cursor_moved(lx, ly) {
+                *needs_rebuild = true;
+            }
+            return;
+        }
         if self.widgets_cursor_moved(lx, ly) {
             *needs_rebuild = true;
         }
     }
 
     fn handle_mouse_input(&mut self, button: MouseButton, state: ElementState, pos: LogicalPosition, needs_rebuild: &mut bool) -> Option<Self::Message> {
+        let lx = pos.x as f32;
+        let ly = pos.y as f32;
+        // The shared context menu a right-click on the username or password box
+        // opens takes every click while open: a row runs, a press anywhere else
+        // dismisses it. Ahead of the authenticating gate, so a menu still open
+        // when a login starts can be dismissed. The toolkit leaves this routing to
+        // the app; without it the menu could not be closed by clicking outside it,
+        // and its rows did nothing.
+        if cce_ui::widget::context_menu::is_visible() {
+            if cce_ui::widget::context_menu::mouse_input(button, state, lx, ly, Some(&mut self.ui_context)) {
+                *needs_rebuild = true;
+            }
+            return None;
+        }
         if self.is_authenticating {
             return None;
         }
-        let lx = pos.x as f32;
-        let ly = pos.y as f32;
         let mut changed = false;
         if self.widgets_mouse_input(button, state, lx, ly) {
             changed = true;