If all Window Managers you're interested in running under support EWMH, the Extended Window Manager Hints standard, there are elegant ways to perform this (speaking to Xlib via ctypes, for example). The _NET_ACTIVE_WINDOW
property of the root window (see here) tells you which window is active (if any); the _NET_WM_STATE
property of the active window is then a list of atoms describing its state which will include _NET_WM_STATE_FULLSCREEN
if that window is fullscreen. (If you have multiple monitors of course a window could be fullscreen on one of them without being active; I believe other cases may exist in which a window may be fullscreen without being active -- I don't think there's any way to cover them all without essentially checking _NET_WM_STATE
for every window, though).