Sample Header Ad - 728x90

Discrepancy in coordinates reported by wmctrl when managing window positions

2 votes
0 answers
28 views
I'm developing a script using wmctrl to restore window positions across different monitors and workspaces. However, I’ve encountered an issue where wmctrl reports different coordinates than the ones it was instructed to set. ### Example: Gnome Maps Here is an example using Gnome Maps (gnome-maps): boris@E5440-DELL:~$ wmctrl -lG | grep Maps 0x01400004 0 240 420 1800 900 E5440-DELL Maps boris@E5440-DELL:~$ wmctrl -ir 0x01400004 -e 0,35,80,1900,500 boris@E5440-DELL:~$ wmctrl -lG | grep Maps 0x01400004 0 70 160 1900 542 E5440-DELL Maps boris@E5440-DELL:~$ wmctrl -ir 0x01400004 -e 0,120,210,1800,900 boris@E5440-DELL:~$ wmctrl -lG | grep Maps 0x01400004 0 240 420 1800 900 E5440-DELL Maps When setting the window to (x=120, y=210), wmctrl reports (x=240, y=420). However, xwininfo confirms the coordinates were correctly set: boris@E5440-DELL:~$ xwininfo xwininfo: Please select the window about which you would like information by clicking the mouse in that window. xwininfo: Window id: 0x1400004 "Maps" Absolute upper-left X: 120 Absolute upper-left Y: 210 Relative upper-left X: 120 Relative upper-left Y: 210 Width: 1800 Height: 900 Depth: 32 Visual: 0xad Visual Class: TrueColor Border width: 0 Class: InputOutput Colormap: 0x1400001 (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: +120+210 -0+210 -0--30 +120--30 -geometry 1800x900-0--30 ### Example: Discord Here’s another example with Discord (com.discordapp.Discord): boris@E5440-DELL:~$ wmctrl -lG | grep Discord 0x02c00005 1 364 199 1200 800 E5440-DELL Friends - Discord boris@E5440-DELL:~$ wmctrl -ir 0x02c00005 -e 0,55,80,1200,800 boris@E5440-DELL:~$ wmctrl -lG | grep Discord 0x02c00005 1 69 129 1200 800 E5440-DELL Friends - Discord boris@E5440-DELL:~$ wmctrl -ir 0x02c00005 -e 0,350,150,1200,800 boris@E5440-DELL:~$ wmctrl -lG | grep Discord 0x02c00005 1 364 199 1200 800 E5440-DELL Friends - Discord Again, the set coordinates (x=350, y=150) are confirmed by xwininfo but wmctrl reports (x=364, y=199). boris@E5440-DELL:~$ xwininfo xwininfo: Please select the window about which you would like information by clicking the mouse in that window. xwininfo: Window id: 0x2c00005 "Friends - Discord" Absolute upper-left X: 350 Absolute upper-left Y: 150 Relative upper-left X: 14 Relative upper-left Y: 49 Width: 1200 Height: 800 Depth: 24 Visual: 0x21 Visual Class: TrueColor Border width: 0 Class: InputOutput Colormap: 0x20 (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: +350+150 -370+150 -370-130 +350-130 -geometry 1200x800+350+150 ### Conclusion In most cases, the reported window coordinates are off by a factor of 2. For example, when a window is set to (x=20, y=10), wmctrl reports (x=40, y=20). However, some applications, such as Discord (com.discordapp.Discord) and GlobalProtect (yuezk/GlobalProtect-openconnect), exhibit unpredictable behavior where the discrepancy doesn’t follow the factor-of-2 pattern. If it were simply a factor-of-2 scaling issue, the discrepancy could be resolved mathematically. However, the unpredictable behavior in certain applications complicates things. At first wmctrl seemed like a suitable tool for this purpose, but these discrepancies make it unreliable for my use case. Any insights would be greatly appreciated! Is this behavior expected in wmctrl, or could it be a bug? Has anyone experienced similar issues with wmctrl reporting incorrect window coordinates?
Asked by Boris L. (121 rep)
Jan 16, 2025, 06:17 PM