forge
Explore
Log in

Don't you dare go Hollow

Update Smithay (DnD rework, primary GPU improvement)

Browse files at this commit

7ca46b44b2910d49b612fd06859560a4db2c1528Ivan MolodetskikhParent: f913219
Cargo.lockmodified+2 -2
@@ -3423,7 +3423,7 @@ checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c"
3423 [[package]]3423 [[package]]
3424 name = "smithay"3424 name = "smithay"
3425 version = "0.7.0"3425 version = "0.7.0"
3426-source = "git+https://github.com/Smithay/smithay.git#d743e1a317fa0f01d1c4cadd96d277a1ec7b59d9"3426+source = "git+https://github.com/Smithay/smithay.git#6329f5b21693c53b0370cc7f62523ea4d0a42073"
3427 dependencies = [3427 dependencies = [
3428 "aliasable",3428 "aliasable",
3429 "appendlist",3429 "appendlist",
@@ -3497,7 +3497,7 @@ dependencies = [
3497 [[package]]3497 [[package]]
3498 name = "smithay-drm-extras"3498 name = "smithay-drm-extras"
3499 version = "0.1.0"3499 version = "0.1.0"
3500-source = "git+https://github.com/Smithay/smithay.git#d743e1a317fa0f01d1c4cadd96d277a1ec7b59d9"3500+source = "git+https://github.com/Smithay/smithay.git#6329f5b21693c53b0370cc7f62523ea4d0a42073"
3501 dependencies = [3501 dependencies = [
3502 "drm",3502 "drm",
3503 "libdisplay-info",3503 "libdisplay-info",
src/handlers/mod.rsmodified+43 -27
@@ -13,16 +13,16 @@ use smithay::backend::allocator::dmabuf::Dmabuf;
13 use smithay::backend::drm::DrmNode;13 use smithay::backend::drm::DrmNode;
14 use smithay::backend::input::{InputEvent, TabletToolDescriptor};14 use smithay::backend::input::{InputEvent, TabletToolDescriptor};
15 use smithay::desktop::{PopupKind, PopupManager};15 use smithay::desktop::{PopupKind, PopupManager};
16-use smithay::input::pointer::{CursorIcon, CursorImageStatus, PointerHandle};16+use smithay::input::dnd::{self, DnDGrab, DndGrabHandler, DndTarget};
17+use smithay::input::pointer::{CursorIcon, CursorImageStatus, Focus, PointerHandle};
17 use smithay::input::{keyboard, Seat, SeatHandler, SeatState};18 use smithay::input::{keyboard, Seat, SeatHandler, SeatState};
18 use smithay::output::Output;19 use smithay::output::Output;
19 use smithay::reexports::rustix::fs::{fcntl_setfl, OFlags};20 use smithay::reexports::rustix::fs::{fcntl_setfl, OFlags};
20 use smithay::reexports::wayland_protocols_wlr::screencopy::v1::server::zwlr_screencopy_manager_v1::ZwlrScreencopyManagerV1;21 use smithay::reexports::wayland_protocols_wlr::screencopy::v1::server::zwlr_screencopy_manager_v1::ZwlrScreencopyManagerV1;
21-use smithay::reexports::wayland_server::protocol::wl_data_source::WlDataSource;
22 use smithay::reexports::wayland_server::protocol::wl_output::WlOutput;22 use smithay::reexports::wayland_server::protocol::wl_output::WlOutput;
23 use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface;23 use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface;
24 use smithay::reexports::wayland_server::Resource;24 use smithay::reexports::wayland_server::Resource;
25-use smithay::utils::{Logical, Point, Rectangle};25+use smithay::utils::{Logical, Point, Rectangle, Serial};
26 use smithay::wayland::compositor::{get_parent, with_states};26 use smithay::wayland::compositor::{get_parent, with_states};
27 use smithay::wayland::dmabuf::{DmabufGlobal, DmabufHandler, DmabufState, ImportNotifier};27 use smithay::wayland::dmabuf::{DmabufGlobal, DmabufHandler, DmabufState, ImportNotifier};
28 use smithay::wayland::drm_lease::{28 use smithay::wayland::drm_lease::{
@@ -41,8 +41,7 @@ use smithay::wayland::security_context::{
41 SecurityContext, SecurityContextHandler, SecurityContextListenerSource,41 SecurityContext, SecurityContextHandler, SecurityContextListenerSource,
42 };42 };
43 use smithay::wayland::selection::data_device::{43 use smithay::wayland::selection::data_device::{
44- set_data_device_focus, ClientDndGrabHandler, DataDeviceHandler, DataDeviceState,44+ set_data_device_focus, DataDeviceHandler, DataDeviceState, WaylandDndGrabHandler,
45- ServerDndGrabHandler,
46 };45 };
47 use smithay::wayland::selection::ext_data_control::{46 use smithay::wayland::selection::ext_data_control::{
48 DataControlHandler as ExtDataControlHandler, DataControlState as ExtDataControlState,47 DataControlHandler as ExtDataControlHandler, DataControlState as ExtDataControlState,
@@ -314,23 +313,51 @@ impl DataDeviceHandler for State {
314 }313 }
315 }314 }
316 315
317-impl ClientDndGrabHandler for State {316+impl WaylandDndGrabHandler for State {
318- fn started(317+ fn dnd_requested<S: dnd::Source>(
319 &mut self,318 &mut self,
320- _source: Option<WlDataSource>,319+ source: S,
321 icon: Option<WlSurface>,320 icon: Option<WlSurface>,
322- _seat: Seat<Self>,321+ seat: Seat<Self>,
322+ serial: Serial,
323+ type_: dnd::GrabType,
323 ) {324 ) {
324 self.niri.dnd_icon = icon.map(|surface| DndIcon {325 self.niri.dnd_icon = icon.map(|surface| DndIcon {
325 surface,326 surface,
326 offset: Point::new(0, 0),327 offset: Point::new(0, 0),
327 });328 });
329+
330+ match type_ {
331+ dnd::GrabType::Pointer => {
332+ let pointer = seat.get_pointer().unwrap();
333+ let start_data = pointer.grab_start_data().unwrap();
334+ let grab =
335+ DnDGrab::new_pointer(&self.niri.display_handle, start_data, source, seat);
336+ pointer.set_grab(self, grab, serial, Focus::Keep);
337+ }
338+ dnd::GrabType::Touch => {
339+ let touch = seat.get_touch().unwrap();
340+ let start_data = touch.grab_start_data().unwrap();
341+ let grab = DnDGrab::new_touch(&self.niri.display_handle, start_data, source, seat);
342+ touch.set_grab(self, grab, serial);
343+ }
344+ }
345+
328 // FIXME: more granular346 // FIXME: more granular
329 self.niri.queue_redraw_all();347 self.niri.queue_redraw_all();
330 }348 }
349+}
331 350
332- fn dropped(&mut self, target: Option<WlSurface>, validated: bool, _seat: Seat<Self>) {351+impl DndGrabHandler for State {
333- trace!("client dropped, target: {target:?}, validated: {validated}");352+ fn dropped(
353+ &mut self,
354+ target: Option<DndTarget<'_, Self>>,
355+ validated: bool,
356+ _seat: Seat<Self>,
357+ location: Point<f64, Logical>,
358+ ) {
359+ let target: Option<&WlSurface> = target.map(DndTarget::into_inner);
360+ trace!("dnd dropped, target: {target:?}, validated: {validated}");
334 361
335 // End DnD before activating a specific window below so that it takes precedence.362 // End DnD before activating a specific window below so that it takes precedence.
336 self.niri.layout.dnd_end();363 self.niri.layout.dnd_end();
@@ -339,7 +366,7 @@ impl ClientDndGrabHandler for State {
339 // example. On successful drop, additionally activate the target window.366 // example. On successful drop, additionally activate the target window.
340 let mut activate_output = true;367 let mut activate_output = true;
341 if let Some(target) = validated.then_some(target).flatten() {368 if let Some(target) = validated.then_some(target).flatten() {
342- let root = self.niri.find_root_shell_surface(&target);369+ let root = self.niri.find_root_shell_surface(target);
343 if let Some((mapped, _)) = self.niri.layout.find_window_and_output(&root) {370 if let Some((mapped, _)) = self.niri.layout.find_window_and_output(&root) {
344 let window = mapped.window.clone();371 let window = mapped.window.clone();
345 self.niri.layout.activate_window(&window);372 self.niri.layout.activate_window(&window);
@@ -349,19 +376,10 @@ impl ClientDndGrabHandler for State {
349 }376 }
350 377
351 if activate_output {378 if activate_output {
352- // Find the output from cursor coordinates.379+ // Find the output from drop coordinates.
353- //380+ if let Some((output, _)) = self.niri.output_under(location) {
354- // FIXME: uhhh, we can't actually properly tell if the DnD comes from pointer or touch,381+ let output = output.clone();
355- // and if it comes from touch, then what the coordinates are. Need to pass more382+ self.niri.layout.focus_output(&output);
356- // parameters from Smithay I guess.
357- //
358- // Assume that hidden pointer means touch DnD.
359- if self.niri.pointer_visibility.is_visible() {
360- // We can't even get the current pointer location because it's locked (we're deep
361- // in the grab call stack here). So use the last known one.
362- if let Some(output) = &self.niri.pointer_contents.output {
363- self.niri.layout.focus_output(output);
364- }
365 }383 }
366 }384 }
367 385
@@ -371,8 +389,6 @@ impl ClientDndGrabHandler for State {
371 }389 }
372 }390 }
373 391
374-impl ServerDndGrabHandler for State {}
375-
376 delegate_data_device!(State);392 delegate_data_device!(State);
377 393
378 impl PrimarySelectionHandler for State {394 impl PrimarySelectionHandler for State {
src/handlers/xdg_shell.rsmodified+2 -3
@@ -24,7 +24,6 @@ use smithay::wayland::compositor::{
24 };24 };
25 use smithay::wayland::dmabuf::get_dmabuf;25 use smithay::wayland::dmabuf::get_dmabuf;
26 use smithay::wayland::input_method::InputMethodSeat;26 use smithay::wayland::input_method::InputMethodSeat;
27-use smithay::wayland::selection::data_device::DnDGrab;
28 use smithay::wayland::shell::kde::decoration::{KdeDecorationHandler, KdeDecorationState};27 use smithay::wayland::shell::kde::decoration::{KdeDecorationHandler, KdeDecorationState};
29 use smithay::wayland::shell::wlr_layer::{self, Layer};28 use smithay::wayland::shell::wlr_layer::{self, Layer};
30 use smithay::wayland::shell::xdg::decoration::XdgDecorationHandler;29 use smithay::wayland::shell::xdg::decoration::XdgDecorationHandler;
@@ -85,7 +84,7 @@ impl XdgShellHandler for State {
85 if focus.id().same_client_as(&wl_surface.id()) {84 if focus.id().same_client_as(&wl_surface.id()) {
86 // Deny move requests from DnD grabs to work around85 // Deny move requests from DnD grabs to work around
87 // https://gitlab.gnome.org/GNOME/gtk/-/issues/711386 // https://gitlab.gnome.org/GNOME/gtk/-/issues/7113
88- let is_dnd_grab = grab.as_any().is::<DnDGrab<Self>>();87+ let is_dnd_grab = Self::is_dnd_grab(grab.as_any());
89 88
90 if !is_dnd_grab {89 if !is_dnd_grab {
91 grab_start_data =90 grab_start_data =
@@ -105,7 +104,7 @@ impl XdgShellHandler for State {
105 if focus.id().same_client_as(&wl_surface.id()) {104 if focus.id().same_client_as(&wl_surface.id()) {
106 // Deny move requests from DnD grabs to work around105 // Deny move requests from DnD grabs to work around
107 // https://gitlab.gnome.org/GNOME/gtk/-/issues/7113106 // https://gitlab.gnome.org/GNOME/gtk/-/issues/7113
108- let is_dnd_grab = grab.as_any().is::<DnDGrab<Self>>();107+ let is_dnd_grab = Self::is_dnd_grab(grab.as_any());
109 108
110 if !is_dnd_grab {109 if !is_dnd_grab {
111 grab_start_data =110 grab_start_data =
src/input/mod.rsmodified+19 -13
@@ -19,6 +19,7 @@ use smithay::backend::input::{
19 TabletToolTipState, TouchEvent,19 TabletToolTipState, TouchEvent,
20 };20 };
21 use smithay::backend::libinput::LibinputInputBackend;21 use smithay::backend::libinput::LibinputInputBackend;
22+use smithay::input::dnd::DnDGrab;
22 use smithay::input::keyboard::{keysyms, FilterResult, Keysym, Layout, ModifiersState};23 use smithay::input::keyboard::{keysyms, FilterResult, Keysym, Layout, ModifiersState};
23 use smithay::input::pointer::{24 use smithay::input::pointer::{
24 AxisFrame, ButtonEvent, CursorIcon, CursorImageStatus, Focus, GestureHoldBeginEvent,25 AxisFrame, ButtonEvent, CursorIcon, CursorImageStatus, Focus, GestureHoldBeginEvent,
@@ -31,10 +32,11 @@ use smithay::input::touch::{
31 };32 };
32 use smithay::input::SeatHandler;33 use smithay::input::SeatHandler;
33 use smithay::output::Output;34 use smithay::output::Output;
35+use smithay::reexports::wayland_server::protocol::wl_data_source::WlDataSource;
36+use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface;
34 use smithay::utils::{Logical, Point, Rectangle, Transform, SERIAL_COUNTER};37 use smithay::utils::{Logical, Point, Rectangle, Transform, SERIAL_COUNTER};
35 use smithay::wayland::keyboard_shortcuts_inhibit::KeyboardShortcutsInhibitor;38 use smithay::wayland::keyboard_shortcuts_inhibit::KeyboardShortcutsInhibitor;
36 use smithay::wayland::pointer_constraints::{with_pointer_constraint, PointerConstraint};39 use smithay::wayland::pointer_constraints::{with_pointer_constraint, PointerConstraint};
37-use smithay::wayland::selection::data_device::DnDGrab;
38 use smithay::wayland::tablet_manager::{TabletDescriptor, TabletSeatTrait};40 use smithay::wayland::tablet_manager::{TabletDescriptor, TabletSeatTrait};
39 use touch_overview_grab::TouchOverviewGrab;41 use touch_overview_grab::TouchOverviewGrab;
40 42
@@ -2583,10 +2585,9 @@ impl State {
2583 self.niri.maybe_activate_pointer_constraint();2585 self.niri.maybe_activate_pointer_constraint();
2584 2586
2585 // Inform the layout of an ongoing DnD operation.2587 // Inform the layout of an ongoing DnD operation.
2586- let mut is_dnd_grab = false;2588+ let is_dnd_grab = pointer
2587- pointer.with_grab(|_, grab| {2589+ .with_grab(|_, grab| Self::is_dnd_grab(grab.as_any()))
2588- is_dnd_grab = grab.as_any().is::<DnDGrab<Self>>();2590+ .unwrap_or(false);
2589- });
2590 if is_dnd_grab {2591 if is_dnd_grab {
2591 if let Some((output, pos_within_output)) = self.niri.output_under(new_pos) {2592 if let Some((output, pos_within_output)) = self.niri.output_under(new_pos) {
2592 let output = output.clone();2593 let output = output.clone();
@@ -2682,10 +2683,9 @@ impl State {
2682 self.niri.tablet_cursor_location = None;2683 self.niri.tablet_cursor_location = None;
2683 2684
2684 // Inform the layout of an ongoing DnD operation.2685 // Inform the layout of an ongoing DnD operation.
2685- let mut is_dnd_grab = false;2686+ let is_dnd_grab = pointer
2686- pointer.with_grab(|_, grab| {2687+ .with_grab(|_, grab| Self::is_dnd_grab(grab.as_any()))
2687- is_dnd_grab = grab.as_any().is::<DnDGrab<Self>>();2688+ .unwrap_or(false);
2688- });
2689 if is_dnd_grab {2689 if is_dnd_grab {
2690 if let Some((output, pos_within_output)) = self.niri.output_under(pos) {2690 if let Some((output, pos_within_output)) = self.niri.output_under(pos) {
2691 let output = output.clone();2691 let output = output.clone();
@@ -4212,10 +4212,9 @@ impl State {
4212 );4212 );
4213 4213
4214 // Inform the layout of an ongoing DnD operation.4214 // Inform the layout of an ongoing DnD operation.
4215- let mut is_dnd_grab = false;4215+ let is_dnd_grab = handle
4216- handle.with_grab(|_, grab| {4216+ .with_grab(|_, grab| Self::is_dnd_grab(grab.as_any()))
4217- is_dnd_grab = grab.as_any().is::<DnDGrab<Self>>();4217+ .unwrap_or(false);
4218- });
4219 if is_dnd_grab {4218 if is_dnd_grab {
4220 if let Some((output, pos_within_output)) = self.niri.output_under(pos) {4219 if let Some((output, pos_within_output)) = self.niri.output_under(pos) {
4221 let output = output.clone();4220 let output = output.clone();
@@ -4256,6 +4255,13 @@ impl State {
4256 self.do_action(action, true);4255 self.do_action(action, true);
4257 }4256 }
4258 }4257 }
4258+
4259+ pub fn is_dnd_grab(grab: &dyn Any) -> bool {
4260+ // Normal DnD
4261+ grab.is::<DnDGrab<Self, WlDataSource, WlSurface>>()
4262+ // Null-source DnD: weston-dnd --self-only
4263+ || grab.is::<DnDGrab<Self, WlSurface, WlSurface>>()
4264+ }
4259 }4265 }
4260 4266
4261 /// Check whether the key should be intercepted and mark intercepted4267 /// Check whether the key should be intercepted and mark intercepted