Unfocus window on X11 side when keyboard focus is lost
Closes #69 (nice)
This commit is contained in:
parent
a713cf46cb
commit
b0ee6db9fa
4 changed files with 95 additions and 42 deletions
|
|
@ -525,6 +525,24 @@ impl HandleEvent for Keyboard {
|
|||
self.server.enter(serial, &data.server, keys);
|
||||
}
|
||||
}
|
||||
client::wl_keyboard::Event::Leave { serial, surface } => {
|
||||
if !surface.is_alive() {
|
||||
return;
|
||||
}
|
||||
let key: ObjectKey = surface.data().copied().unwrap();
|
||||
if let Some(data) = state
|
||||
.objects
|
||||
.get(key)
|
||||
.map(|o| <_ as AsRef<SurfaceData>>::as_ref(o))
|
||||
{
|
||||
if state.to_focus == Some(data.window.unwrap()) {
|
||||
state.to_focus.take();
|
||||
} else {
|
||||
state.unfocus = true;
|
||||
}
|
||||
self.server.leave(serial, &data.server);
|
||||
}
|
||||
}
|
||||
_ => simple_event_shunt! {
|
||||
self.server, event: client::wl_keyboard::Event => [
|
||||
Keymap {
|
||||
|
|
@ -532,18 +550,6 @@ impl HandleEvent for Keyboard {
|
|||
|fd| fd.as_fd(),
|
||||
size
|
||||
},
|
||||
Leave {
|
||||
serial,
|
||||
|surface| {
|
||||
if !surface.is_alive() {
|
||||
return;
|
||||
}
|
||||
let Some(surface_data) = state.get_server_surface_from_client(surface) else {
|
||||
return;
|
||||
};
|
||||
surface_data
|
||||
}
|
||||
},
|
||||
Key {
|
||||
serial,
|
||||
time,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue