swaywm / sway

i3-compatible Wayland compositor
https://swaywm.org
MIT License
14.12k stars 1.08k forks source link

Holding Ctrl does not modify Drag and Drop action #8219

Open mathsaey opened 2 weeks ago

mathsaey commented 2 weeks ago

Note I originally thought this was a firefox-specific issue, but it turns out to be more general. Thanks to @emersion for pointing this out.

Original Issue

Steps to reproduce

  1. Open firefox
  2. Go to https://jsfiddle.net/1z3k58pc/
  3. Drag the element at the top to the drop zone, don't drop it yet
  4. Hold ctrl to set the dropEffect to "copy"
  5. Drop the element over the drop zone.

Expected behavior: Holding ctrl should set the dropEffect to "copy", causing a copy of the element to be created in the drop zone.

Actual behavior: The element is moved to the drop zone. This is the case as the dropEffect element is set to "move", because firefox did not receive (or correctly handle) the ctrl keypress.

I initially thought this was a firefox bug (https://bugzilla.mozilla.org/show_bug.cgi?id=1904265). However, everything works as intended when running firefox inside mutter (on wayland). Thus, I am reporting it here.

In the debug log, I opened firefox (MOX_ENABLE_WAYLAND=1 firefox-bin --profile ~/.mozilla/firefox/0doofw58.cleanProfile 'https://jsfiddle.net/1z3k58pc/') and tried to do the drag and drop action three times. The first time, I did not hold ctrl while dragging, the other two times, I did hold ctrl; I reset the page using the "run" button on jsfiddle between each attempt.

Updated Issue

Sway does not modify the drag and drop action when the ctrl key is held. According to the spec, holding ctrl may change the drag and drop action to "copy", however, this is not the case in sway.

To reproduce:

  1. Open any app that supports drag and drop or copy and drop (e.g. a file manager, or use the firefox example above)
  2. Grab an item to drag
  3. Hold ctrl
  4. Drop the item in a valid place

The item is moved to the new location, not copied.

emersion commented 2 weeks ago

I don't believe Firefox is responsible for deciding to copy when Ctrl is pressed. I think that's up to Sway.

emersion commented 2 weeks ago

I don't believe Firefox is responsible for deciding to copy when Ctrl is pressed. I think that's up to Sway.

See https://wayland.app/protocols/wayland#wl_data_device_manager:enum:dnd_action

mathsaey commented 2 weeks ago

I originally thought this was a firefox issue, since the dnd was from firefox to firefox. You are right however; if I open Thunar and try to copy a file by dragging it to another thunar window while holding ctrl, it just moves the file instead.

I'll edit the title and add some more context to my original post. However, I'm not sure if this can still be considered a bug at this point, or if this boils down to a feature request?