diff options
| -rw-r--r-- | Cargo.lock | 4 | ||||
| -rw-r--r-- | src/handlers/mod.rs | 34 |
2 files changed, 35 insertions, 3 deletions
@@ -3658,7 +3658,7 @@ checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c" [[package]] name = "smithay" version = "0.3.0" -source = "git+https://github.com/Smithay/smithay.git#eef07680c43e20cf4e528dd1222b3cadf6a32182" +source = "git+https://github.com/Smithay/smithay.git#b8292400ea7d137946099e941bf3985ade3ecf91" dependencies = [ "appendlist", "bitflags 2.6.0", @@ -3730,7 +3730,7 @@ dependencies = [ [[package]] name = "smithay-drm-extras" version = "0.1.0" -source = "git+https://github.com/Smithay/smithay.git#eef07680c43e20cf4e528dd1222b3cadf6a32182" +source = "git+https://github.com/Smithay/smithay.git#b8292400ea7d137946099e941bf3985ade3ecf91" dependencies = [ "drm", "libdisplay-info", diff --git a/src/handlers/mod.rs b/src/handlers/mod.rs index fcd1fb7d..f7340231 100644 --- a/src/handlers/mod.rs +++ b/src/handlers/mod.rs @@ -306,7 +306,39 @@ impl ClientDndGrabHandler for State { self.niri.queue_redraw_all(); } - fn dropped(&mut self, _seat: Seat<Self>) { + fn dropped(&mut self, target: Option<WlSurface>, validated: bool, _seat: Seat<Self>) { + trace!("client dropped, target: {target:?}, validated: {validated}"); + + // Activate the target output, since that's how Firefox drag-tab-into-new-window works for + // example. On successful drop, additionally activate the target window. + let mut activate_output = true; + if let Some(target) = validated.then_some(target).flatten() { + if let Some(root) = self.niri.root_surface.get(&target) { + if let Some((mapped, _)) = self.niri.layout.find_window_and_output(root) { + let window = mapped.window.clone(); + self.niri.layout.activate_window(&window); + activate_output = false; + } + } + } + + if activate_output { + // Find the output from cursor coordinates. + // + // FIXME: uhhh, we can't actually properly tell if the DnD comes from pointer or touch, + // and if it comes from touch, then what the coordinates are. Need to pass more + // parameters from Smithay I guess. + // + // Assume that hidden pointer means touch DnD. + if !self.niri.pointer_hidden { + // We can't even get the current pointer location because it's locked (we're deep + // in the grab call stack here). So use the last known one. + if let Some(output) = &self.niri.pointer_contents.output { + self.niri.layout.activate_output(output); + } + } + } + self.niri.dnd_icon = None; // FIXME: more granular self.niri.queue_redraw_all(); |
