wslg: Context menu doesn't respect screen bounds

Note to contributors: I’m unsubscribing from this issue. If you implement a solution and want to ask a user to verify it, then please ping any of the rest of the users in this thread, thanks.

Environment

Windows build number: 10.0.22000.0 
Your Distribution version: Ubuntu 21.04
Your WSLg version: 1.0.26

Steps to reproduce

Open a GUI app which supports opening context menu and right click on it. (I’ve checked with Nautilus and Sublime Merge.)

Expected behavior

Context menu should appear inside the screen.

Actual behavior

Context menu are not trying to position themselves inside the screen and are always opened to the right of the cursor. Screenshots are of right edge of the screen:

image

Nautilus

image

Sublime Merge

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 5
  • Comments: 34 (1 by maintainers)

Commits related to this issue

Most upvoted comments

Here is a screenshot: image

I think the issue here is that the taskbar isn’t being respected. I believe that the bottom of the menu roughly aligns with the bottom of the screen. Indeed, setting the taskbar to autohide and then using a different monitor, I can see the bottom of the menu and it attaches to the bottom of the screen.

Still seeing the bug on versions below:

PS C:\Users\cseba> wsl --version
WSL version: 0.56.1.0
Kernel version: 5.10.93.2
WSLg version: 1.0.30
MSRDC version: 1.2.2924
Direct3D version: 1.601.0
Windows version: 10.0.22000.556

Can confirm that adding GDK_BACKEND=x11 fixes the context menu bug but makes the overall look uglier(big boxes around the windows, different cursor).

I’m not exporting it in bashrc, but I do manually export it when it’s unset. Regardless, manually vs automatically exporting something doesn’t change anything, it’s just an environment variable. Something about my bash installation is not allowing me to use wayland (probably systemd). I notice that when GDK_BACKEND is set to nothing in zsh (after a shell restart), wayland will be chosen, while if I do the same for bash, x11 will be chosen. In your case, wayland is chosen for both shells (replacing zsh with fish), meaning wayland isn’t recognized by my bash shell for some reason. Note that the DISPLAY variable it also set in my zsh shell.

My bash shell logs in via loginctl, this is not the case with zsh. This could very well be the reason. Regardless, my issue is not related to this one, so we shouldn’t talk about it here.

By choosing not to export DISPLAY variable, WSLg will no longer function, as every application will simply say “cannot open display:” (without the “:0” this time) (whether in x11 or wayland).

For me it also doesn’t show the updated versions in the settings app, but the updated versions do show up in WSL itself, by running cat /mnt/wslg/versions.txt and uname -a.

You are right, I can see the updated version there.

I’ll keep the issue open in case others also encounter this. Again, thanks for your help Peter!