vscode: Drag and drop does not work in Wayland

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.69.2
  • OS Version: Manjaro Linux, Kernel: 5.15, Wayland, WM: sway

Steps to Reproduce:

  1. Add --enable-features=UseOzonePlatform --ozone-platform=wayland to code-flags.conf
  2. Open code
  3. Attempt to drag tabs, files, or anything else
  4. Does not give any indication that they are being dragged, and the elements to not get moved around

I am unable to re-order windows, create multiple panes with drag and drop, etc

It works if I do not add the flags. The issue is I need the flags for scaling in Wayland.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 79
  • Comments: 77 (7 by maintainers)

Commits related to this issue

Most upvoted comments

I’m also seeing an issue like this with Plasma 6 RC2 on Wayland. Running vscode on XWayland does seem to work, but has other issues (like rendering glitches). A few things like text do work, but I can’t drag a tab.

When I try, VSCode acts like it’s working (you get the ‘shine’ that indicates the tab will get tiled, for example). But when I release my mouse, nothing happens.

The about window has the following:

Version: 1.86.2
Commit: 903b1e9d8990623e3d7da1df3d33db3e42d80eda
Date: 2024-02-13T19:41:37.860Z
Electron: 27.2.3
ElectronBuildId: 26908389
Chromium: 118.0.5993.159
Node.js: 18.17.1
V8: 11.8.172.18-electron.0
OS: Linux x64 6.6.13-gentoo-dist

@nickdiego thanks a lot for taking the time to investigate and address this issue! I will test change in Electron and backport it to our release lines.

EDIT: verified the fix and backported at https://github.com/electron/electron/pull/44753

The fix has landed upstream chromium yesterday and started shipping in version 132.0.6826.0 (canary channel). Please test and report back, I didn’t test it on KDE, for example. Feel free to ping me over mail or matrix if needed. thanks!

After digging into it a bit more and considering that W3C dnd spec does not mandate drag data to be necessarily assigned by the application, I believe that’s something we must address at chromium level. It’s being tracked under https://issues.chromium.org/377760837. The wip fix is under review here and will hopefully land soon. thanks

the real funny part: it works for me too when i drag the view outside of vscode, move it over my desktop and then drop it to the right (or left). Screencast_20240314_131952.webm

For me with the official build, drag&drop works mostly fine, except for certain operations.

Drag & drop selection = OK Moving tabs around = OK Creating split views from drag&drop = OK Reordering sidebar tabs = fail Moving to secondary sidebar = fail

Tested on a Framework 13 laptop, NixOS with Plasma (wayland) desktop. I launched insiders with --enable-features=UseOzonePlatform --ozone-platform=wayland and was able to drag around tabs and see the animation.

OK, I’ve figured out the root issue: It seems no data/type is being set for those draggable items, as explained in [1], which leads to no mime types being offered and accepted at Wayland protocol level. As can be seen in this wayland debug log excerpt (collected upon drop event):

[...]
[1676869.941]  -> wl_data_offer#4278190082.set_actions(2, 2)
[1676886.644] wl_data_device#21.motion(4822119, 1276.84765625, 325.04687500)
[1676886.989]  -> wl_data_offer#4278190082.set_actions(2, 2)
[1676902.653] wl_data_device#21.motion(4822133, 1277.42187500, 325.04687500)
[1676902.896]  -> wl_data_offer#4278190082.set_actions(2, 2)
[1677506.020] wl_data_source#45.cancelled()
[1677507.245]  -> wl_data_source#45.destroy()
[1677507.264]  -> wl_data_offer#4278190082.destroy()
[...]

That leads to the dnd session to fail (cancelled) which is why the visual item does not get moved. Quoted below is what the Wayland protocol says about it:

For objects of version 3 or newer, this request determines the final result of the drag-and-drop operation. If the end result is that no mime types were accepted, the drag-and-drop operation will be cancelled and the corresponding drag source will receive wl_data_source.cancelled. Clients may still use this event in conjunction with wl_data_source.action for feedback.

Further context at https://wayland.app/protocols/wayland#wl_data_offer:request:accept

Thus, it must be fixed at app level (ie: vscode), by associating data and type to those draggable items.

[1] https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API#the_basics

the real funny part: it works for me too when i drag the view outside of vscode, move it over my desktop and then drop it to the right (or left). Screencast_20240314_131952.webm

I was hoping this would also work with sway but it does not; my current workaround is to launch vscode as an X11 application, making the panel drag & drop changes I want, closing vscode and re-opening it with the wayland flags re-enabled

Having the same Problem on Plasma 6.0

Version: 1.86.2 Commit: 903b1e9d8990623e3d7da1df3d33db3e42d80eda Date: 2024-02-13T19:41:37.860Z Electron: 27.2.3 ElectronBuildId: 26908389 Chromium: 118.0.5993.159 Node.js: 18.17.1 V8: 11.8.172.18-electron.0 OS: Linux x64 6.7.7

I can drag Stuff, but when releasing (for example having 2 files side by side) nothing happens.

disconfirming with both vscode 1.78 and insiders 1.79. I think I made a mistake earlier by not passing the right arguments to code-insiders, so I was testing the X11 version.

reordering sidebar tabs does not work, neither does secondary sidebar. both actions work fine when ozone platform is x11

FYI: Today i got updates for my system (Arch), now i have plasma 6.0.2 and also new vscode, and now drag/drop works with wayland

@ulrichSchreiner did you test dragging a panel from one side to the other? Because that still doesn’t work on my arch:

https://github.com/microsoft/vscode/assets/1282767/fed5ff18-aaa0-4d88-b3f4-e68b3afbf277

FYI: Today i got updates for my system (Arch), now i have plasma 6.0.2 and also new vscode, and now drag/drop works with wayland

I can confirm the same. KDE Plasma 6 on Wayland, Electron v27.3.5.

Revisited this today, I see dnd operation to work fine with latest insiders based on Electron 27 under Ubuntu 22.04 and Gnome 42.9. Can others confirm as well.

@deepak1556 I am pretty sure you opened vscode as xwayland client, rather than a native wayland client while testing and confirming that it works.

Yes, it works as an x11 client, but this issue is about drag/drop for the wayland client.

Please make sure your vscode is properly closed, and then open it using code --ozone-platform-hint=auto. Validate if you are indeed looking at a native wayland client by either running xprop or xwininfo and hovering your mouse over your vscode and clicking. If the cursor changes to a crosshair and clicking prints window intormation, it is still an x11 (xwayland) window. If it stays the default cursor and clicking it doesn’t print any output, then it is a proper wayland client.

And once you made sure it is a wayland client, re-test drag and dropping a panel from the left to the right side.

edit: I am saying this because I just had someone on gnome test this with a wayland client, and drag and drop does not work for them.

Same on Manjaro Gnome 45.2. 18 months and it’s still not fixed, a joke.

+1 I can confirm this bug exists on freshly installed Ubuntu 22.04 LTS

Why the issue was closed? As the author mentioned above: Reordering sidebar tabs = fail Moving to secondary sidebar = fail

For me those actions are bugged too. Maybe we should create a separate issue for them?

For what it’s worth, I can also reproduce this bug (on sway) but only when the title bar style setting is set to native. When using the custom title bar, drag-and-drop seems to work as expected.

I just wanted to report, that after switching from sway to niri, drag and drop seems to work flawlessly:

https://github.com/user-attachments/assets/cb7b9bf5-bd34-4fdc-9e9d-1dd9ba64e17f

So this might be related to sway.

@deepak1556 Just for completeness, under sway, drag and drop still doesn’t work for many things like re-ordering panels, it does for tabs though. But please do have a look at the issues under sway, the crashes and the drag/drop issues are almost unbearable.

edit: also for completeness, this doesn’t just affect sway, it affects all wlroots based compositors, and also all smithay based compositors (like the new popos one, which is gonna be a pretty big group as well). I’m taking your word for it that this doesn’t affect gnome, since I didn’t test it. But that’s just one of many compositors that are apparently not affected.

Im facing this issue, doesnt happen on Windows. I’m used to just drag files from Explorer/Nautilus into the editor, for some reason it fails the majority of the time but works sporadically. See video: Screencast from 2023-09-25 14-58-30.webm

Does not work for me either in insiders.

Some Elements I try to drag behave same as in older builds (e.g. can drag them but the do not change their location after dropping)

Other elements make the whole app crash when trying to drag them somewhere…

Closing as we will be shipping Electron 22 update with v1.78

~/verified~

think i made a mistake here

For what it’s worth, I can also reproduce this bug (on sway) but only when the title bar style setting is set to native. When using the custom title bar, drag-and-drop seems to work as expected.

Thank you very much this solved my problem!

I’m seeing the same (no drag&drop of any elements) on https://vscode.dev/ running in Chrome 103.0.5060.134 with Preferred Ozone platform set to wayland (same reason, need it for scaling).

Oh, ok. Thanks all for clarifying!

I can reproduce it even with https://vscode.dev using chrome’s wayland backend, which is rather not reproducible with the X11 backend (even through XWayland). That likely indicates an upstream chromium issue. I’ll look into it!

Currently, I’m using Arch Linux with Sway, and I’ve discovered that the bug only occurs when VSCode is running in native Wayland mode (rather than XWayland). I came up with a stupid but rather simplistic workaround:

  1. Preparation:

    • Locate the configuration file, usually found at ~/.config/code-flags.conf.
    • Back up the contents of this file in case you need to restore it later.
  2. Remove Startup Options:

    • Remove all startup options for VSCode (e.g., --ozone-platform-hint=auto) to force it to run under the X window system.
  3. Launch VSCode:

    • Start VSCode, and you will find that all functionalities work correctly (except for some flickering with the input method).
  4. Adjust the Layout:

    • Adjust VSCode to your desired layout.
  5. Close VSCode and Restore Startup Options:

    • Close VSCode.
    • Restore the previously backed-up startup options.
  6. Verify the Effect:

    • Since VSCode remembers the previous layout by default, the outline pane will appear in the auxiliary sidebar.
  7. Repeat the Steps:

    • If you need to modify the layout or adjust it again, you can repeat the above steps.

You can directly run the original VSCode executable instead of the wrapper script provided by Arch to run VSCode without arguments.

Currently, I’m using Arch Linux with Sway, and I’ve discovered that the bug only occurs when VSCode is running in native Wayland mode (rather than XWayland). I came up with a stupid but rather simplistic workaround:

  1. Preparation:

    • Locate the configuration file, usually found at ~/.config/code-flags.conf.
    • Back up the contents of this file in case you need to restore it later.
  2. Remove Startup Options:

    • Remove all startup options for VSCode (e.g., --ozone-platform-hint=auto) to force it to run under the X window system.
  3. Launch VSCode:

    • Start VSCode, and you will find that all functionalities work correctly (except for some flickering with the input method).
  4. Adjust the Layout:

    • Adjust VSCode to your desired layout.
  5. Close VSCode and Restore Startup Options:

    • Close VSCode.
    • Restore the previously backed-up startup options.
  6. Verify the Effect:

    • Since VSCode remembers the previous layout by default, the outline pane will appear in the auxiliary sidebar.
  7. Repeat the Steps:

    • If you need to modify the layout or adjust it again, you can repeat the above steps.

@phisch Thanks! Just confirmed too. niri definitely works, but GNOME, Sway, and Hyprland do not. Maybe there is some interaction with a wayland protocol extension or something…

FYI: Today i got updates for my system (Arch), now i have plasma 6.0.2 and also new vscode, and now drag/drop works with wayland

@ulrichSchreiner did you test dragging a panel from one side to the other? Because that still doesn’t work on my arch: 2024-03-14.11-27-45.mp4

I’ve just tried it on my system and it works fine. I’m KDE Plasma 6.0.2 and Code running as a Wayland (with --enable-features=UseOzonePlatform --ozone-platform=wayland)

Screencast_20240314_125634.webm

FYI: there is a issue in KDE’s bugzilla which i think is the same problem.

https://bugs.kde.org/show_bug.cgi?id=482142

so i think this is not really a VSCode problem (at least when using plasma6).

The same issue on KDE 6 Wayland. Setting --enable-features=WaylandWindowDecorations or changing "window.titleBarStyle" doesn’t help

@ouzdll I don’t know where Electron 22.5.5 comes from 😕. It doesn’t seem to be a formal release. However, Electron 22.3.12 on Arch fixes this, as noted here: https://bugs.archlinux.org/task/78753

@deepak1556 There may be several issues at play, since the insiders release does fix the problem for me on Sway/Arch Linux. Looking forward to the next release!

It also effects vscode.dev which runs in the browser rather than electron? So I guess it is an issue with newer versions of Chromium.