Drag and drop: files can be dragged between windows and within one
CI / test (push) Canceled after 4m0s
CI / test (push) Canceled after 4m0s
The compositor ignored wl_data_device.start_drag, so no drag ever reached a window: Dolphin, GNOME Files, Chrome tabs and text could not be dropped anywhere, not even inside the window they started in. Now (compositor/wayland/dnd.mbt, compositor/host/dnd.mbt): - start_drag while a button is held on the client turns the pointer into the drag (the origin gets wl_pointer.leave); a request that arrives after the release is cancelled at once. - The surface under the pointer (windows, subsurfaces, menus) gets data_offer + offer + source_actions + enter, then motion and leave; a drag without a source stays inside its own client. - accept -> source.target, set_actions -> copy/move/ask agreed and sent as offer.action and source.action (version 3), version 1/2 clients copy. - Release drops when the target accepted a type and an action: drop, dnd_drop_performed, and finish -> dnd_finished; otherwise cancelled + leave. Escape cancels. The window dropped on becomes active, so Dolphin's Copy/Move Here menu opens as a menu of a focused window. - The drag icon is drawn under the pointer at its hotspot (attach offsets and wl_surface.offset), above windows and menus. - A source, icon or client going away ends or updates the drag. Tests: compositor/host/dnd_test.mbt (fail on the previous commit). Checked headless with real Dolphin 23.08 (Qt 5.15) and GNOME Files 46 on both the native build and the wasm build: Files -> Dolphin, Dolphin -> Files, Dolphin -> Dolphin (Move/Copy/Link menu) and a move into a folder inside Files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DPL5hjWb2dWbR1K7qoMgWP
This commit is contained in:
5 files changed
+1046
-4
No files matched your search
@@ -176,6 +176,16 @@ pub(all) struct ChandraCompositor {
|
||||
/// pointer (`leave_pointer`: a window move, the overview, a screenshot).
|
||||
mut ptr_grab : Bool
|
||||
mut grab_buttons : Int
|
||||
/// A client's drag and drop is going (dnd.mbt): the pointer is the drag until the release.
|
||||
/// Its icon (drawn with its top-left at pointer + (dnd_icon_x, dnd_icon_y)).
|
||||
mut dnd : Bool
|
||||
mut dnd_icon : @scene.ShmBufferSnapshot?
|
||||
mut dnd_icon_x : Int
|
||||
mut dnd_icon_y : Int
|
||||
/// The window (or menu) the drag is over.
|
||||
mut dnd_over : UInt64?
|
||||
/// Time of the last input event (wl_pointer / wl_data_device times).
|
||||
mut input_time : UInt
|
||||
mut kbd_win : UInt64?
|
||||
mut mods : UInt
|
||||
/// A Super key is down and nothing else was pressed since: releasing it is a Super tap (the
|
||||
@@ -357,6 +367,12 @@ pub fn ChandraCompositor::new(
|
||||
press_fwd: false,
|
||||
ptr_grab: false,
|
||||
grab_buttons: 0,
|
||||
dnd: false,
|
||||
dnd_icon: None,
|
||||
dnd_icon_x: 0,
|
||||
dnd_icon_y: 0,
|
||||
dnd_over: None,
|
||||
input_time: 0U,
|
||||
kbd_win: None,
|
||||
mods: 0U,
|
||||
super_solo: false,
|
||||
@@ -714,6 +730,23 @@ pub fn ChandraCompositor::step(self : ChandraCompositor) -> Unit {
|
||||
}
|
||||
None => release_snapshot(snap)
|
||||
}
|
||||
@wayland.CompositorEvent::DragStarted(win) => self.dnd_start(win, self.input_time)
|
||||
@wayland.CompositorEvent::DragIcon(snap, dx, dy) =>
|
||||
if self.dnd {
|
||||
release_snapshot(self.dnd_icon)
|
||||
self.dnd_icon = snap
|
||||
self.dnd_icon_x = dx
|
||||
self.dnd_icon_y = dy
|
||||
self.damage.mark_full()
|
||||
} else {
|
||||
release_snapshot(snap)
|
||||
}
|
||||
@wayland.CompositorEvent::DragIconMoved(dx, dy) => {
|
||||
self.dnd_icon_x = dx
|
||||
self.dnd_icon_y = dy
|
||||
self.damage.mark_full()
|
||||
}
|
||||
@wayland.CompositorEvent::DragEnded => if self.dnd { self.dnd_finish(self.input_time) }
|
||||
@wayland.CompositorEvent::SubsurfaceUnmapped(wid, sid) =>
|
||||
match self.windows.get(wid) {
|
||||
Some(win) =>
|
||||
@@ -1048,6 +1081,11 @@ fn ChandraCompositor::build_scene(
|
||||
None => ()
|
||||
}
|
||||
}
|
||||
// The drag icon, over every window and menu.
|
||||
match self.dnd_icon_node() {
|
||||
Some(n) => scene.popups.push(n)
|
||||
None => ()
|
||||
}
|
||||
|
||||
self.shell.layout_sel = match self.layout_mode {
|
||||
@wm.LayoutMode::Tiling => 0
|
||||
@@ -1877,6 +1915,11 @@ pub fn ChandraCompositor::handle_input(
|
||||
if self.grab_input(ev) {
|
||||
return
|
||||
}
|
||||
self.input_time = time_ms
|
||||
// A drag and drop has the pointer (and Escape) until it is dropped.
|
||||
if self.dnd_input(ev, time_ms) {
|
||||
return
|
||||
}
|
||||
match ev {
|
||||
Key(code, pressed) => {
|
||||
self.track_modifier_key(code, pressed)
|
||||
|
||||
Reference in new issue
Block a user