WSL2/WSLg: How to bring back windows which open out of screen

In this post will fix the issue that windows open with their title bar out of screen

Many Windows users have WSL installed for their AWS development. With the advent of WSLg - the official support for running Linux GUI apps in Windows - it has become convenient to run the IDE in WSL as well.

Unfortunately WSLg still has some teething problems. One of the most annoying issues is that windows open with their title bar out of screen and the window therefor cannot be moved back onto the screen. This seems to be happening very frequently with Jetbrains IntelliJ based IDEs, where widgets often open with some portion of the UI invisible or out of the screen.

A quick and simple workaround1 to get your Linux windows back on screen is to make the window active with a left mouse click and then press the keyboard buttons

win + shift + left

This should bring back the whole window onto your screen.

Command line alternatives:

Install

1
sudo apt update && sudo apt install xdotool

Use

1
xdotool selectwindow windowmove 50 50

to position the active window back onto the screen.

Or you can run this short script that will position all the windows top left:2

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
#!/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