seat: KeyboardHandle::has_focus

This commit is contained in:
Victor Berger 2018-11-17 19:08:47 +01:00
parent 630b659ae6
commit 03cf6ed35f
1 changed files with 14 additions and 1 deletions

View File

@ -11,7 +11,7 @@ use wayland_server::{
wl_keyboard::{Event, KeyState as WlKeyState, KeymapFormat, Request, WlKeyboard},
wl_surface::WlSurface,
},
NewResource, Resource,
Client, NewResource, Resource,
};
use xkbcommon::xkb;
pub use xkbcommon::xkb::{keysyms, Keysym};
@ -392,6 +392,19 @@ impl KeyboardHandle {
}
}
/// Check if given client currently has keyboard focus
pub fn has_focus(&self, client: &Client) -> bool {
self.arc
.internal
.lock()
.unwrap()
.focus
.as_ref()
.and_then(|f| f.client())
.map(|c| c.equals(client))
.unwrap_or(false)
}
/// Register a new keyboard to this handler
///
/// The keymap will automatically be sent to it