What causes the deviation in the wmctrl window move command
Solution 1:
What's happening is that wmctrl is returning the geometry of the window inside the decorations (i.e. not including the title bar and borders) but is using the larger window position for the move.
(Some command output lines removed : xdotool
might not be installed)
$ wmctrl -lG
0x04000040 0 702 23 900 950 KMatrix dave@KMatrix: test – Konsole
$ xdotool getwindowgeometry 0x04000040
Window 67108928
Position: 702,23 (screen: 0)
Geometry: 900x950
The next command prompts for the window of interest and returns the parent window which includes all the decorations and varies depending on the window theme in use.
$ xdotool selectwindow
25166060
$ xdotool getwindowgeometry 0x18000ec
Window 25166060
Position: 700,0 (screen: 0)
Geometry: 904x977
As you can see, it's a different window; the X position starts 2px to the left (702-2) and the total width is larger by 4px (900+2+2) because the right border is also 2px. Y is higher (above the top border, if any, and the title bar); height is larger because of all of that plus the bottom border.
wmctrl moves the parent window to the desired [X,Y] position of the child window; width and height are applied correctly to the child, as shown in the "before & after" below.
$ wmctrl -lG
0x04000040 0 702 23 900 950 KMatrix dave@KMatrix: test – Konsole
$ xdotool getwindowgeometry 0x18000ec # (PARENT)
Window 25166060
Position: 700,0 (screen: 0)
Geometry: 904x977
$ xdotool getwindowgeometry 0x04000040 # (CHILD)
Window 67108928
Position: 702,23 (screen: 0)
Geometry: 900x950
$ wmctrl -ir 0x04000040 -e 0,702,23,900,950 # <----- "MOVE/RESIZE" *****
$ wmctrl -lG
0x04000040 0 704 46 900 950 KMatrix dave@KMatrix: test – Konsole
$ xdotool getwindowgeometry 0x18000ec # (PARENT)
Window 25166060
Position: 702,23 (screen: 0) <----- Desired [X,Y] applied to parent
Geometry: 904x977
$ xdotool getwindowgeometry 0x04000040 # (CHILD)
Window 67108928
Position: 704,46 (screen: 0)
Geometry: 900x950 <----- Desired [W,H] applied to child
Edit: additional info.
Desktop geometry, Viewport & Workarea
$ wmctrl -d # (KDE)
0 * DG: 1680x1050 VP: 0,0 WA: 0,0 1680x1015 Desktop 1
$ xdotool -v
xdotool version 3.20140217.1
https://github.com/jordansissel/xdotool
Re: @Sneetsher tip in comments
$ xprop | grep FRAME
_KDE_NET_WM_FRAME_STRUT(CARDINAL) = 2, 2, 23, 4
_NET_FRAME_EXTENTS(CARDINAL) = 2, 2, 23, 4