1

When resizing and moving with wmctrl, the outcome is both incorrect and depending on application.

Example: At the time of writing I have emacs, chromium, spotify and gnome-terminal running

ws=$(wmctrl -d | grep "*" | awk '{print $1}')
n=$(wmctrl -l | awk '{print $2 ";" $1}' | grep ^$ws | wc -l)
windows=$(wmctrl -l | awk '{print $2 ";" $1}' | grep ^$ws | cut -d ";" -f 2)

window1=$(echo $windows | cut -d " " -f 1)
window2=$(echo $windows | cut -d " " -f 2)
window3=$(echo $windows | cut -d " " -f 3)
window4=$(echo $windows | cut -d " " -f 4)

for i in ${windows[@]} ; do
    wmctrl -ir $i -b remove,maximized_horz,maximized_vert
done

wmctrl -ir $window1 -e 1,0,0,960,540
wmctrl -ir $window2 -e 1,0,540,960,540
wmctrl -ir $window3 -e 1,960,0,960,540
wmctrl -ir $window4 -e 1,960,540,960,540

Now, wmctrl -lG results in the following (irrelevant info removed):

width  height
952    540   emacs
960    540   chromium
954    529   gnome-terminal
960    540   Spotify

Running the exact same code for 4 terminal windows yield:

width  height
954    529   gnome-terminal
954    529   gnome-terminal
954    529   gnome-terminal
954    529   gnome-terminal

All sizes are incorrect, but also the different applications have different sizes whilst all windows of the same application has the same size.

Expected:

960    540   emacs
960    540   chromium
960    540   gnome-terminal
960    540   Spotify

I cannot seem to find any posts discussing this exact issue.

All help is much appreciated!

jkazan
  • 1,149
  • 12
  • 29
  • `${windows[@]}` windows is not an array, `windows` is a variable, so are `windows1`, `windows2`, `windows3` and `windows4`. – KamilCuk Aug 20 '18 at 08:18

1 Answers1

0

Each window has decorations (ie. border). Your gnome-terminal window has 6 pixels wide border on the left and 11 pixels high border on the top (probably title bar). When you move your window, it moves the position of the window excluding the border size, but the wmctrl -G output shows the geometry including the border sizes. See this topic. You can get the border size using xwininfo magic, like here.

KamilCuk
  • 120,984
  • 8
  • 59
  • 111
  • This sounds very promising, @Kamil! I have removed all borders and window decorations for my theme, however, it may still be encoded. I will try solving this with xwininfo and accept this answer if it works. Thank you, I truly appreciate your help! – jkazan Aug 20 '18 at 11:47
  • I just gave it a quick try and, unfortunately, it failed. I then tried to set some arbitrary size of a window (smaller than full screen) and then increased the height by 1 pixel at a time. It seems to demand some sort of minimum incremental step. It doesn't seem possible to set any pixel value. What is even more weird is that if I set the exact values of a window that is snapped to a corner, I cannot seem to get the same result as snapping. – jkazan Aug 20 '18 at 13:20