From fdd3706768216556ab7482cc4fb5bd74f931f135 Mon Sep 17 00:00:00 2001 From: IoIxD Date: Sat, 4 Jul 2026 23:03:57 -0700 Subject: [PATCH] revert keyboard focus back to working code --- src/backend/winit.rs | 27 +++++++++++++++++++++------ src/state/mod.rs | 16 ++++++++++------ 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/src/backend/winit.rs b/src/backend/winit.rs index 49e1e3e..9a9aed0 100644 --- a/src/backend/winit.rs +++ b/src/backend/winit.rs @@ -72,12 +72,27 @@ pub fn run_winit() -> Result<(), Box> { }; if event.state() == ButtonState::Pressed { - if let Some((surface, _)) = state.surface_under(state.pointer_location) { - keyboard.set_focus( - &mut state, - Some(surface), - SERIAL_COUNTER.next_serial(), - ); + if let Some(surface) = state.focused_surface() { + { + if let Some(ref surface) = surface.surface { + keyboard.set_focus( + &mut state, + Some(surface.wl_surface().clone()), + SERIAL_COUNTER.next_serial(), + ); + } + if let Some(ref surface) = surface.xsurface { + keyboard.set_focus( + &mut state, + surface.wl_surface(), + SERIAL_COUNTER.next_serial(), + ); + } + } + { + let mut space = state.space.lock(); + space.raise_element(&surface, true); + } } else { keyboard.set_focus(&mut state, None, SERIAL_COUNTER.next_serial()); } diff --git a/src/state/mod.rs b/src/state/mod.rs index 5406657..4640003 100644 --- a/src/state/mod.rs +++ b/src/state/mod.rs @@ -226,6 +226,12 @@ impl State { // None // } + pub fn button_event(&mut self, ev: ButtonEvent) { + let pointer = self.pointer.clone(); + pointer.button(self, &ev); + pointer.frame(self); + } + pub fn surface_under( &self, pos: Point, @@ -241,12 +247,6 @@ impl State { }) } - pub fn button_event(&mut self, ev: ButtonEvent) { - let pointer = self.pointer.clone(); - pointer.button(self, &ev); - pointer.frame(self); - } - pub fn focused_surface(&mut self) -> Option { let space = self.space.lock(); // let mut surfaces = vec![]; @@ -259,6 +259,10 @@ impl State { } None + // self.space + // .lock() + // .element_under(self.pointer_location) + // .and_then(|(window, _location)| Some(window.clone())) } pub fn motion_event(&mut self, ev: MotionEvent, locationrel: Point) {