revert keyboard focus back to working code

This commit is contained in:
IoIxD 2026-07-04 23:03:57 -07:00
commit fdd3706768
2 changed files with 31 additions and 12 deletions

View file

@ -72,12 +72,27 @@ pub fn run_winit() -> Result<(), Box<dyn std::error::Error>> {
}; };
if event.state() == ButtonState::Pressed { if event.state() == ButtonState::Pressed {
if let Some((surface, _)) = state.surface_under(state.pointer_location) { if let Some(surface) = state.focused_surface() {
{
if let Some(ref surface) = surface.surface {
keyboard.set_focus( keyboard.set_focus(
&mut state, &mut state,
Some(surface), Some(surface.wl_surface().clone()),
SERIAL_COUNTER.next_serial(), 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 { } else {
keyboard.set_focus(&mut state, None, SERIAL_COUNTER.next_serial()); keyboard.set_focus(&mut state, None, SERIAL_COUNTER.next_serial());
} }

View file

@ -226,6 +226,12 @@ impl State {
// None // 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( pub fn surface_under(
&self, &self,
pos: Point<f64, Logical>, pos: Point<f64, Logical>,
@ -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<AppWrapper> { pub fn focused_surface(&mut self) -> Option<AppWrapper> {
let space = self.space.lock(); let space = self.space.lock();
// let mut surfaces = vec![]; // let mut surfaces = vec![];
@ -259,6 +259,10 @@ impl State {
} }
None 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<f64, Logical>) { pub fn motion_event(&mut self, ev: MotionEvent, locationrel: Point<f64, Logical>) {