wslg icon indicating copy to clipboard operation
wslg copied to clipboard

Ability to move windows when the title bar is off screen

Open shebiki opened this issue 4 years ago • 20 comments

Sometimes my WSLg apps appear with the title bar off screen. From what I can tell no keyboard shortcut exists to move back on screen.

Other tickets mention that window snapping, alt-dragging and windows+arrow keys don't work.

I'd love a workaround to enable using the application when this happens without having to restart it several times until it decides to position the window with the titlebar on screen again.

shebiki avatar Oct 21 '21 14:10 shebiki

Hi @shebiki,

Thanks for the feedback. Which application are you seeing this with? Only this application or many of them? Could you reproduce the problem then attach your /mnt/wslg/weston.log to this bug?

In theory Weston is supposed to be positioning a newly created window such that it fits properly within the display area. However, XWayland or the application itself can overwrite this and pick a location of their choice for the window on the desktop, including outside of the visible area. It would be useful to understand what's going on here.

spronovo avatar Oct 23 '21 18:10 spronovo

This happened when opening RubyMine but had previously bitten me a while ago (frequently at the time) with JetBrains Toolbox. I don't remember if this only happened when using multiple monitors or also happened on a single monitor. Will try and reproduce to get more specifics.

shebiki avatar Oct 25 '21 12:10 shebiki

A short script that will position all the windows top left. A crappy workaround, but it "works". You may need to install xdotool if it's not there already.

#!/usr/bin/bash
sx=30
sy=30
for window in $(xdotool search -name .)
do
   xdotool windowmove $window $sx $sy
   xdotool windowunmap $window
   xdotool windowmap $window
   sx=$(($sx + 40))
   sy=$(($sy + 40))
done

You could modify this to use "xwininfo", which asks you to click on a window (anywhere, not just the titlebar), and returns the id you would need to drive xdotool to move it. Like: xwininfo | grep -i 'window id' | awk '{print $4}' should extract just the window id you need.

Edit: Updated script to unmap/remap window because I'm seeing a new bug where windows get unmapped.

tyingq avatar Oct 28 '21 19:10 tyingq

@shebiki, when this happen, would you please check, using xwininfo, if the window position match to where it's on Windows desktop? (assuming you are only using single monitor with 100% DPI, since multiple monitor with non-100% DPI, coordinate translation between X space and Windows desktop space could be tricky). I would like to check if this is because the window is actually correctly positioned in X11 space, but not at expected position at Windows side, Thanks!

hideyukn88 avatar Oct 29 '21 21:10 hideyukn88

Here's an xwininfo dump for this; my WSL2 X11 Emacs window currently has its title bar completely off screen, and there's no way to bring it back. I'm using a standard 1920x1200 monitor at 100% (no HiDPI).

I'm running latest WSLg preview version from Microsoft store, with Ubuntu 20.04 distro.

% xwininfo
xwininfo: Window id: 0xa0001b "[*Messages*] - tower1 - Emacs 28.0.50 (WSL2)"

  Absolute upper-left X:  -28
  Absolute upper-left Y:  -47
  Relative upper-left X:  38
  Relative upper-left Y:  59
  Width: 1013
  Height: 943
  Depth: 24
  Visual: 0x1ae
  Visual Class: TrueColor
  Border width: 0
  Class: InputOutput
  Colormap: 0xa0001a (not 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:  +-28+-47  -2855+-47  -2855-305  +-28-305
  -geometry 108x50+-66+-106

And yes, that xwininfo position approximately looks like what I'm actually seeing. Windows is off the top left of the display screen.

garyo avatar Nov 18 '21 17:11 garyo

In my humble opinion, this should be marked as "Bug" rather than "Enhancement" since once a window opens with its task bar off screen, there is no way to get it back at all. It is a pretty serious bug for me. See also #332 which I think is the same bug.

garyo avatar Nov 18 '21 17:11 garyo

this is definitely a bug. i'm trying to use intellij and the configuration window opens up with the title bar off the screen. there's no way to drag or move the window, restarting the application does fix the positioning... so basically the application is unusable.

snapwich avatar Jan 27 '22 22:01 snapwich

I'm using PyCharm (so also a JetBrains IDE) and it happens to me as well, dual monitor setup. For me the application was completely off screen so I couldn't use xwinfo since it requires you to click on the window. I've managed to "fix" it by opening PowerShell and killing WSL with "wsl --shutdown" and then opening a new Linux terminal so that WSL starts again. After this the IDE appears on screen.

mvodanovic avatar Feb 08 '22 12:02 mvodanovic

I would like to use the wslg X11 server for openGL applications over ssh, to get the graphics acceleration. I typically open windows with matplotlib or Open3D. If I stay on one screen things work ok, but in a dual monitor setup when move a window between my screens the window will often pop out of view with no way to bring it back. This was so annoying for me so I moved back to VcXsrv instead of using the built in wslg.

Is there any update when this issue will be adressed for WSLg ?

IvanCobotic avatar Apr 12 '22 12:04 IvanCobotic

Same here. I'm using PyCharm and some windows are off-screen.

Luckily, I've found this solution: https://unix.stackexchange.com/a/324577.

Simply, install xdotool (sudo apt update && sudo apt install xdotool), then run:

xdotool selectwindow windowmove 50 50

Select the window that is off-screen and it will bring its top-left corner back 50 pixels from the left of the screen, and 50 pixels down from the top.

It's just a workaround but it's clean (just one short command).

devaminb avatar Jun 04 '22 23:06 devaminb

I would love to see a solution to this as well, using IntelliJ Ultimate I experience this often.

I can reproduce this when doing things such as resolving git conflicts, where a separate window is opened and half of it is not visible making it not able to be dragged back down. image

Using the provided tool above, I'm correctly able to have it snapped back into my screen. image

Owen1212055 avatar Jun 06 '22 03:06 Owen1212055

This issue is plaguing me always when using WSL 2, still no fix?

ROBYER1 avatar Aug 22 '22 09:08 ROBYER1

A quick solution I've found that seems to work without having to restart anything is enabling "Automatically hide the taskbar" in settings and then disabling it. At least for the applications I work with, this pops them back into view.

Jepson2k avatar Aug 22 '22 20:08 Jepson2k

thanks to @devaminb method, I wrote a script to automatically reset all the off-screen windows' location.


function resetwindow {
    for pid in $(xdotool search -name --onlyvisible --maxdepth 2 .); do
        read -r x y < <(xwininfo -id "$pid" | grep Absolute | awk '{print $4}' | xargs)
        if [[ "$x" -lt 1 ]] || [[ "$y" -lt 1 ]]; then
            xdotool windowmove "$pid" 150 150
        fi
    done
}

wuxu92 avatar Sep 13 '22 06:09 wuxu92

This might just be a corner case, but run into this issue again, after changing my setup

❯ weston-info

*** Please use wayland-info instead
*** weston-info is deprecated and will be removed in a future version

interface: 'wl_compositor', version: 4, name: 1
interface: 'wl_subcompositor', version: 1, name: 2
interface: 'wp_viewporter', version: 1, name: 3
interface: 'zxdg_output_manager_v1', version: 2, name: 4
        xdg_output_v1
                output: 22
                name: 'rdp-1'
                logical_x: 0, logical_y: 476
                logical_width: 1920, logical_height: 1080
        xdg_output_v1
                output: 12
                name: 'rdp-0'
                logical_x: 1920, logical_y: 0
                logical_width: 2560, logical_height: 1440
[...]
❯ xwininfo

xwininfo: Please select the window about which you
          would like information by clicking the
          mouse in that window.

xwininfo: Window id: 0x60004c "WindowTitle"

  Absolute upper-left X:  6
  Absolute upper-left Y:  27
  Relative upper-left X:  38
  Relative upper-left Y:  59

basically translates to something like this: image where blue is the desktop's surface, and red is the window's frame

a10cat avatar May 21 '24 15:05 a10cat

Should it be helpful, I have a setup where two monitors are at eye level. Monitor 3 shown in the screen cap is my "main" monitor. Monitor 1 is a laptop screen that sits physically lower on the desk so i arrange my monitors like this:

image

When a new window comes up, it is displayed "off the top of the screen" as though the Monitor 3 is being used for alignment, even though the window pops up on Monitor 1 and should be pushed "lower" on the virtual display

When the monitors are set to the same height this doesn't seem to be a problem for me: image

dovholuknf avatar Sep 27 '24 11:09 dovholuknf

Should it be helpful, I have a setup where two monitors are at eye level. Monitor 3 shown in the screen cap is my "main" monitor.

Thanks for that insight - in this scenario the xdotool solutions were not working, but this allows a simpler workaround for me.
Stretch the side of the window you can see across onto a higher screen (3 in your example), then the title-bar will be available.

Obvious upon reflection.

But still an issue since my screens are physically arranged at different levels - making them line up breaks the continuity of the desktop.

whitty avatar Mar 19 '25 05:03 whitty

Select the partially visible window and WinKey + Shift + Arrow. It should move it around from screen to screen, but it moves the window in the correct view. Because it doesn't handle that action well, click off on a regular Window of some sort, then click back to the X window you are wanting to control again. This should still be viewed as a "workaround" because the correct action would be to allow for an X action where I can set a keystroke to be able to move the windows,

hasues avatar Jun 01 '25 17:06 hasues

The workaround suggested by @hasues is the only one that worked in my case (application Sublime Merge). Thanks!

mericoda avatar Jul 02 '25 12:07 mericoda

You can try my modified system distribution by using Ctrl+left mouse button to move the window https://github.com/qq1038765585/wslg_title_bar_beautify/releases

Image

qq1038765585 avatar Jul 26 '25 03:07 qq1038765585