mirror of
https://github.com/Smithay/smithay.git
synced 2024-09-28 03:21:14 +02:00
Call KeyboardGrab::unset
in KeyboardHandle::*_grab
This was already supposed to happen, but I hadn't noticed that these functions don't delegate to a method of the innter handle, like they do with touch. This is a breaking API change, since these functions then need to take `&mut D`. But this seems reasonable since the equivalents for pointer/touch already require that, and `&mut D` should be available to call wherever these are used.
This commit is contained in:
parent
2e672566e3
commit
7cc8d1bb3c
6 changed files with 22 additions and 11 deletions
|
@ -414,7 +414,7 @@ impl<BackendData: Backend> XdgShellHandler for AnvilState<BackendData> {
|
|||
return;
|
||||
}
|
||||
keyboard.set_focus(self, grab.current_grab(), serial);
|
||||
keyboard.set_grab(PopupKeyboardGrab::new(&grab), serial);
|
||||
keyboard.set_grab(self, PopupKeyboardGrab::new(&grab), serial);
|
||||
}
|
||||
if let Some(pointer) = seat.get_pointer() {
|
||||
if pointer.is_grabbed()
|
||||
|
|
|
@ -382,7 +382,7 @@ where
|
|||
&& (keyboard.has_grab(self.serial)
|
||||
|| keyboard.has_grab(self.previous_serial.unwrap_or(self.serial)))
|
||||
{
|
||||
keyboard.unset_grab();
|
||||
keyboard.unset_grab(data);
|
||||
keyboard.set_focus(data, Some(self.root.clone()), serial);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -812,13 +812,21 @@ impl<D: SeatHandler + 'static> KeyboardHandle<D> {
|
|||
/// Change the current grab on this keyboard to the provided grab
|
||||
///
|
||||
/// Overwrites any current grab.
|
||||
pub fn set_grab<G: KeyboardGrab<D> + 'static>(&self, grab: G, serial: Serial) {
|
||||
self.arc.internal.lock().unwrap().grab = GrabStatus::Active(serial, Box::new(grab));
|
||||
pub fn set_grab<G: KeyboardGrab<D> + 'static>(&self, data: &mut D, grab: G, serial: Serial) {
|
||||
let mut inner = self.arc.internal.lock().unwrap();
|
||||
if let GrabStatus::Active(_, handler) = &mut inner.grab {
|
||||
handler.unset(data);
|
||||
}
|
||||
inner.grab = GrabStatus::Active(serial, Box::new(grab));
|
||||
}
|
||||
|
||||
/// Remove any current grab on this keyboard, resetting it to the default behavior
|
||||
pub fn unset_grab(&self) {
|
||||
self.arc.internal.lock().unwrap().grab = GrabStatus::None;
|
||||
pub fn unset_grab(&self, data: &mut D) {
|
||||
let mut inner = self.arc.internal.lock().unwrap();
|
||||
if let GrabStatus::Active(_, handler) = &mut inner.grab {
|
||||
handler.unset(data);
|
||||
}
|
||||
inner.grab = GrabStatus::None;
|
||||
}
|
||||
|
||||
/// Check if this keyboard is currently grabbed with this serial
|
||||
|
|
|
@ -264,8 +264,11 @@ where
|
|||
}
|
||||
zwp_input_method_v2::Request::GrabKeyboard { keyboard } => {
|
||||
let input_method = data.handle.inner.lock().unwrap();
|
||||
data.keyboard_handle
|
||||
.set_grab(input_method.keyboard_grab.clone(), SERIAL_COUNTER.next_serial());
|
||||
data.keyboard_handle.set_grab(
|
||||
state,
|
||||
input_method.keyboard_grab.clone(),
|
||||
SERIAL_COUNTER.next_serial(),
|
||||
);
|
||||
let instance = data_init.init(
|
||||
keyboard,
|
||||
InputMethodKeyboardUserData {
|
||||
|
|
|
@ -101,13 +101,13 @@ impl<D: SeatHandler + 'static> Dispatch<ZwpInputMethodKeyboardGrabV2, InputMetho
|
|||
for InputMethodManagerState
|
||||
{
|
||||
fn destroyed(
|
||||
_state: &mut D,
|
||||
state: &mut D,
|
||||
_client: ClientId,
|
||||
_object: &ZwpInputMethodKeyboardGrabV2,
|
||||
data: &InputMethodKeyboardUserData<D>,
|
||||
) {
|
||||
data.handle.inner.lock().unwrap().grab = None;
|
||||
data.keyboard_handle.unset_grab();
|
||||
data.keyboard_handle.unset_grab(state);
|
||||
}
|
||||
|
||||
fn request(
|
||||
|
|
|
@ -66,7 +66,7 @@ pub trait XWaylandKeyboardGrabHandler: SeatHandler {
|
|||
/// has a keyboard.
|
||||
fn grab(&mut self, _surface: wl_surface::WlSurface, seat: Seat<Self>, grab: XWaylandKeyboardGrab<Self>) {
|
||||
if let Some(keyboard) = seat.get_keyboard() {
|
||||
keyboard.set_grab(grab, SERIAL_COUNTER.next_serial());
|
||||
keyboard.set_grab(self, grab, SERIAL_COUNTER.next_serial());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue