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
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.