feat: enforce xdg popup grabs
This commit is contained in:
1 parent
0cc0488257
commit
8fea6f85ee
1 file changed
+30
-2
@@ -1,6 +1,7 @@
|
|||||||
use smithay::{
|
use smithay::{
|
||||||
desktop::{
|
desktop::{
|
||||||
PopupKind, PopupManager, Space, Window, find_popup_root_surface, get_popup_toplevel_coords,
|
PopupKeyboardGrab, PopupKind, PopupManager, PopupPointerGrab, Space, Window,
|
||||||
|
find_popup_root_surface, get_popup_toplevel_coords,
|
||||||
},
|
},
|
||||||
input::{
|
input::{
|
||||||
Seat,
|
Seat,
|
||||||
@@ -135,7 +136,34 @@ impl XdgShellHandler for Ferese {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn grab(&mut self, _: PopupSurface, _: wl_seat::WlSeat, _: Serial) {}
|
fn grab(&mut self, surface: PopupSurface, seat: wl_seat::WlSeat, serial: Serial) {
|
||||||
|
let Some(seat) = Seat::from_resource(&seat) else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
let popup = PopupKind::Xdg(surface);
|
||||||
|
let Ok(root) = find_popup_root_surface(&popup) else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
let popup_grab = match self.popups.grab_popup(root, popup, &seat, serial) {
|
||||||
|
Ok(grab) => grab,
|
||||||
|
Err(error) => {
|
||||||
|
tracing::debug!(?error, "rejected xdg popup grab");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if let Some(pointer) = seat.get_pointer() {
|
||||||
|
pointer.set_grab(
|
||||||
|
self,
|
||||||
|
PopupPointerGrab::new(&popup_grab),
|
||||||
|
serial,
|
||||||
|
Focus::Keep,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if let Some(keyboard) = seat.get_keyboard() {
|
||||||
|
keyboard.set_grab(self, PopupKeyboardGrab::new(&popup_grab), serial);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_grab(
|
fn check_grab(
|
||||||
|
|||||||
Reference in new issue
Block a user