forge
Explore
Log in

Don't you dare go Hollow

Deny toplevel move from DnD grabs

Browse files at this commit

6ecbf2db8a31484fe88b8faa399b9832da6c8a6aIvan MolodetskikhParent: c9be905
Work around https://gitlab.gnome.org/GNOME/gtk/-/issues/7113
src/handlers/xdg_shell.rsmodified+26 -8
@@ -23,6 +23,7 @@ use smithay::wayland::compositor::{
23 };23 };
24 use smithay::wayland::dmabuf::get_dmabuf;24 use smithay::wayland::dmabuf::get_dmabuf;
25 use smithay::wayland::input_method::InputMethodSeat;25 use smithay::wayland::input_method::InputMethodSeat;
26+use smithay::wayland::selection::data_device::DnDGrab;
26 use smithay::wayland::shell::kde::decoration::{KdeDecorationHandler, KdeDecorationState};27 use smithay::wayland::shell::kde::decoration::{KdeDecorationHandler, KdeDecorationState};
27 use smithay::wayland::shell::wlr_layer::{self, Layer};28 use smithay::wayland::shell::wlr_layer::{self, Layer};
28 use smithay::wayland::shell::xdg::decoration::XdgDecorationHandler;29 use smithay::wayland::shell::xdg::decoration::XdgDecorationHandler;
@@ -75,27 +76,44 @@ impl XdgShellHandler for State {
75 76
76 // See if this comes from a pointer grab.77 // See if this comes from a pointer grab.
77 let pointer = self.niri.seat.get_pointer().unwrap();78 let pointer = self.niri.seat.get_pointer().unwrap();
78- if pointer.has_grab(serial) {79+ pointer.with_grab(|grab_serial, grab| {
79- if let Some(start_data) = pointer.grab_start_data() {80+ if grab_serial == serial {
81+ let start_data = grab.start_data();
80 if let Some((focus, _)) = &start_data.focus {82 if let Some((focus, _)) = &start_data.focus {
81 if focus.id().same_client_as(&wl_surface.id()) {83 if focus.id().same_client_as(&wl_surface.id()) {
82- grab_start_data = Some(PointerOrTouchStartData::Pointer(start_data));84+ // Deny move requests from DnD grabs to work around
85+ // https://gitlab.gnome.org/GNOME/gtk/-/issues/7113
86+ let is_dnd_grab = grab.as_any().downcast_ref::<DnDGrab<Self>>().is_some();
87+
88+ if !is_dnd_grab {
89+ grab_start_data =
90+ Some(PointerOrTouchStartData::Pointer(start_data.clone()));
91+ }
83 }92 }
84 }93 }
85 }94 }
86- }95+ });
87 96
88 // See if this comes from a touch grab.97 // See if this comes from a touch grab.
89 if let Some(touch) = self.niri.seat.get_touch() {98 if let Some(touch) = self.niri.seat.get_touch() {
90- if touch.has_grab(serial) {99+ touch.with_grab(|grab_serial, grab| {
91- if let Some(start_data) = touch.grab_start_data() {100+ if grab_serial == serial {
101+ let start_data = grab.start_data();
92 if let Some((focus, _)) = &start_data.focus {102 if let Some((focus, _)) = &start_data.focus {
93 if focus.id().same_client_as(&wl_surface.id()) {103 if focus.id().same_client_as(&wl_surface.id()) {
94- grab_start_data = Some(PointerOrTouchStartData::Touch(start_data));104+ // Deny move requests from DnD grabs to work around
105+ // https://gitlab.gnome.org/GNOME/gtk/-/issues/7113
106+ let is_dnd_grab =
107+ grab.as_any().downcast_ref::<DnDGrab<Self>>().is_some();
108+
109+ if !is_dnd_grab {
110+ grab_start_data =
111+ Some(PointerOrTouchStartData::Touch(start_data.clone()));
112+ }
95 }113 }
96 }114 }
97 }115 }
98- }116+ });
99 }117 }
100 118
101 let Some(start_data) = grab_start_data else {119 let Some(start_data) = grab_start_data else {