git.lucas.co / cce-gallery
widget gallery and compositor test bench

commit194bd982d485c7528ef077d0899f33a68a83b411
parent2bd353979d
authorLucas Galante <lsgalante12@gmail.com>
date2026-10-08 12:34
refactor(focus): drive focus through UiContext::focus_widget / unfocus_widget

A direct w.focus() / w.unfocus() left the window's record of focus (the Tab
walk, the accessibility tree) behind: on a widget that had let go, or beside
a newly focused one. The UiContext helpers do what the direct call did and
keep the record in step (cce-ui's global-state RFC, phase 2).

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

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

diff --git a/src/main.rs b/src/main.rs
index bc03f8d..d51a281 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1735,7 +1735,7 @@ impl cce_ui::engine::Application for State {
             if button == MouseButton::Left {
                 if let Some(old) = self.focused_widget {
                     if Some(old) != clicked_idx {
-                        self.roster.get_dyn_mut(old).unfocus();
+                        self.ui_context.unfocus_widget(self.roster.get_dyn_mut(old));
                         self.focused_widget = None;
                     }
                 }
@@ -1755,7 +1755,7 @@ impl cce_ui::engine::Application for State {
                     self.ui_context.drag_target = Some(id);
                 }
                 if button == MouseButton::Left {
-                    self.roster.get_dyn_mut(i).focus();
+                    self.ui_context.focus_widget(self.roster.get_dyn_mut(i));
                     self.focused_widget = Some(i);
                 }
             }