Get window position and size in python with Xlib

You are probably using reparenting window manager, and because of this id window has zero x and y. Check coordinates of parent window (which is window manager frame)


Liss posted the following solution as a comment:

from ewmh import EWMH
ewmh = EWMH()

def frame(client):
    frame = client
    while frame.query_tree().parent != ewmh.root:
        frame = frame.query_tree().parent
    return frame

for client in ewmh.getClientList():
    print frame(client).get_geometry()

I'm copying it here because answers should contain the actual answer, and to prevent link rot.

Tags:

Python

Xlib