microsoft / wslg

Enabling the Windows Subsystem for Linux to include support for Wayland and X server related scenarios
MIT License
10.24k stars 307 forks source link

Windows open out of screen and no way to bring them back #332

Open CComparon opened 3 years ago

CComparon commented 3 years ago

Environment

Windows build number: Microsoft Windows NT 10.0.21390.0
Your Distribution version: Ubuntu 20.10
Your WSLg version: Windows Subsystem for Linux WSLg preview 1.0.24

Steps to reproduce

Many possible examples E.g with gitk:

  1. Choose any git repo on your workstation
  2. Edit .git/config
  3. Add a section like
    [gui]
        wmstate = normal
        geometry = 2162x935+4572+220 475 399
  4. in this repo, run gitk
  5. The gitk GUI window will most certainly appear somewhere outside of the screen, and there is no way to bring it back since neither WIN+LEFT, WIN+RIGHT, ALT+SPACE currently work with wslg.

WSL logs:

N/A

Expected behavior

Ideally WSLg would detect that windows are open outside of visible screen area and move them inside it if needed. Or at least one of WIN+LEFT, WIN+RIGHT, ALT+SPACE should work to allow to bring such windows back on screen. VcXsrv has a "Gather windows" emergency action that brings all X windows into Windows's primary monitor.

Actual behavior

Such windows are lost forever until process killed.

hideyukn88 commented 3 years ago

@CComparon , thanks for reporting the issue.

Currently, with WSLg, if X11 application replace its own window after map, the window location won't be restricted within desktop area, so I guess that's what's happening here. But like xterm/xclock, when they are given some position of out of desktop area like below, it gets relocated to within visible desktop area as position is specified prior to map.

xclock -geometry +36000+36000

Would you please let us know what do you see with VcXsrv? Does it also place a window out of desktop area? (but it does allow to gather windows, so there is a work around?) Or VcXsrv ignores such out-of-range position and place window at visible area?

VcXsrv has a "Gather windows" emergency action that brings all X windows into Windows's primary monitor.

Thanks!

CComparon commented 3 years ago

Thank you @hideyukn88 for your reply. I tried running xclock -geometry +36000+36000 and vcxsrv actually moves it spontaneously to the closest visible screen portion. Still not ideal as they are ignoring Windows taskbar so I still need to use the "gather windows" action to push it a bit from being obscured by the taskbar though. image

lelabo-m commented 3 years ago

Still no solution for this problem ? I am running into it very frequently.

At random, some apps decide to open at new positions, outside the window...

hideyukn88 commented 3 years ago

@lelabo-marc, would you please double check with xwininfo to check if the window is actually placed outside of the screen ? thanks!

lelabo-m commented 3 years ago

Sorry, I was away.

I am using Intellij Idea 2021.2 but I have seen this bug from the start of WSLg availability with other version of Intellij. I opened the Project Structure window using File -> Project Structure.

I used xwininfo like you asked and got the following:

xwininfo: Window id: 0x400282 "Project Structure"

  Absolute upper-left X:  235
  Absolute upper-left Y:  -12
  Relative upper-left X:  38
  Relative upper-left Y:  59
  Width: 1173
  Height: 910
  Depth: 24
  Visual: 0x25
  Visual Class: TrueColor
  Border width: 0
  Class: InputOutput
  Colormap: 0x24 (installed)
  Bit Gravity State: NorthWestGravity
  Window Gravity State: NorthWestGravity
  Backing Store State: NotUseful
  Save Under State: no
  Map State: IsViewable
  Override Redirect State: no
  Corners:  +235+-12  -521+-12  -521-1382  +235-1382
  -geometry 1173x910+197+-71
tyingq commented 3 years ago

A script that's roughly like the "gather windows" action, as a workaround: https://github.com/microsoft/wslg/issues/529#issuecomment-954120973

hideyukn88 commented 3 years ago

@lelabo-m, sorry for late response, so based on the information from your xwininfo output, I would like to clarify that the partial window is actually visible on Windows desktop, but because of Y coordinate being negative, window can't be grabbed/moved by title bar. Is my understand correct?

Absolute upper-left X: 235 Absolute upper-left Y: -12

The reason I would like to ask this to rule out these cases, 1) window is actually correctly positioned, but due to other error (like https://github.com/microsoft/wslg/issues/179), window is not visible, or 2) window is actually correctly position in X11 space, but it positioned wrongly at Windows's desktop side.

Thanks!

Wintereise commented 2 years ago

@lelabo-m, sorry for late response, so based on the information from your xwininfo output, I would like to clarify that the partial window is actually visible on Windows desktop, but because of Y coordinate being negative, window can't be grabbed/moved by title bar. Is my understand correct?

Absolute upper-left X: 235 Absolute upper-left Y: -12

The reason I would like to ask this to rule out these cases, 1) window is actually correctly positioned, but due to other error (like #179), window is not visible, or 2) window is actually correctly position in X11 space, but it positioned wrongly at Windows's desktop side.

Thanks!

I'm not sure if you're still waiting for a confirmation on this, but that is exactly it.

Seems to be a very frequent problem for Intellij based IDEs, half these widgets open with some portion of the UI invisible / out of monitor.

hideyukn88 commented 2 years ago

@Wintereise, thanks for your input!

piotrd commented 2 years ago

There's even easier way, a one-liner posted here https://github.com/microsoft/wslg/issues/529#issuecomment-1146700216:

xdotool selectwindow windowmove 50 50
wiewiurdp commented 2 years ago

I just found out quite simple workaround. Clicking win + shift + left bringing on screen the whole window. At least once I have more then one screen

IlyaZha commented 2 years ago

I just found out quite simple workaround. Clicking win + shift + left bringing on screen the whole window. At least once I have more then one screen

It doesn't work if window is child of other application. UPD: win + up worked

SingletC commented 2 years ago

The situation can be way worse if you have dual-monitor. Some windows will not be clickable till switching to one monitor mode.

hideyukn88 commented 2 years ago

@SingletC, would you please describe the problem a bit more, like what window from which application exhibits the issue? and also please run grep rdpMonitor /mnt/wslg/weston.log, this will give me the information how you arrange the monitors. And also please make sure you are on the latest version of WSL by installing from aka.ms/wslstorepage, or by wsl --update on Windows command prompt, wsl --version should show 0.70.0 or greater, thanks!