def get_current_window(dpy):
"""
Returns active window or root window if there is no active.
"""
# Try using WM-provided info first
trash, prop = get_window_prop(dpy,
get_default_root_window(dpy), "_NET_ACTIVE_WINDOW")
if prop is not None:
rv = cast(prop, POINTER(Atom)).contents.value
free(prop)
return rv
# Fall-back to something what probably can't work anyway
win, revert_to = XID(), c_int()
get_input_focus(dpy, byref(win), byref(revert_to))
if win == 0:
return get_default_root_window(dpy)
return win
评论列表
文章目录