1

I have Ubuntu 22.04 in WSL 2, and I installed pycharm and xfce4-terminal (I also checked with Nautilus) inside it. For some reason I can't move any window to the right or left, neither with the mouse, by dragging the window to a corner, or with the keyboard shortcuts Win+/.

I tried to install gtile Gnome extension, but I found that it is irrelevant because there is no X server; WSL 2 is running with Wayland.

To recreate the problem, just install Nautilus (sudo apt install nautilus) and then run it (nautilus) and try Win+ or to drag it to one of the screen corners.

NotTheDr01ds
  • 28,025
Aking
  • 113
  • 5

1 Answers1

2

Quick update: The release notes for the WSL 2.0.0 pre-release report that this works now. I'll confirm and update the full answer soon.


Short Answer Workaround:

Not on WSLg, but you can install a third-party X server on Windows, and windows launched via it will observe "snap-to" behavior.

See this answer along with some additional detail in this answer for instructions.

More explanation:

A few things are going on here:

  • First, unfortunately, snap-to just isn't supported in WSLg. From the WSLg architecture overview:

    [WSLg] still uses server-side window movement and resizing, resulting in ... the inability to snap Linux windows on the edges of the monitors or to custom snap region. These annoy us too .

    That was from the "WSLg Preview", but it's still applicable today. Also refer to and track this Github issue.

    I can imagine this will be a bit challenging to implement. What really happens with any X/Wayland/RDP implementation in Windows is that the "canvas" on which the Linux GUI applications are running is a full-screen "rootless" window (no background). As the architecture overview states, you are dragging the Nautilus window around that rootless window rather than around the Windows desktop.

    The same problem exists when running a third-party X server in fullscreen mode. However, you can also run some third-party X servers in "multiple-windows" mode. For instance, I just tested VcXsrv on Windows 10 (it will also work on Windows 11 with the appropriate DISPLAY setting), and xterm, at least, will snap to the left and right edges when running in "multiple-windows" mode.

However, Nautilus still will not, even though it's running as an X (rather than Wayland) application.

I tried to install gtile gnome extension but I found that it is irrelevant because there is no X server, wsl-2 is running with wayland.

Well, there is an X server in WSLg, it's XWayland, running under Wayland. So xterm, as an X-only app, is running on XWayland, and Nautilus detects that Wayland is available and runs in that mode.

I think the problem with qtile will be that it is a Gnome extension, not an app. It depends on Gnome being the Desktop Manager.

Most every X-based "snap to" feature that I could find is dependent on the window/desktop manager, which means that they aren't going to work with WSLg's full-screen, rootless, Wayland/XWayland window.

NotTheDr01ds
  • 28,025