1

I am writing a script that requires determining in what viewport a window is placed.

My desktop is 2x2 (4 viewports); it is usually thought as being 4 virtual desktops but on compiz/unity, it is actually a viewport and only one desktop, based on xdotool get_num_desktops.

Just to ease explaining, see these viewports (not sure if these would be actually their IDs, though):

0 1  
2 3  

Put your window at viewport 2, run xwininfo -all, and click on your window; you will get its ID and see the "upper-left" values are all small, like being at viewport 0, but these are actually relative to viewport 2.

Also, you find no info about at what viewport it is.

More information you can find with:
wmctrl -d that shows precise information about what viewport we are.
xdotool get_desktop_viewport will fail to be precise for viewports 2 and 3.

1 Answer 1

0

It is actually very simple, the window viewport position information is relative to the current viewport.

So, just type xwininfo and select a window.
Now, change the viewport and type xwininfo -id 0x... (0x... is the id you collected for the window), the position values will show as outside of the current viewport limits, with relative values based on current viewport like:

Absolute upper-left X:  -1270
Absolute upper-left Y:  62

Based on this is possible to determine where the window is.
In this case I was on viewport 1 and the window on viewport 0.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .