def monitor_rects(monitors): """ Takes a list of monitors returned by ``xinerama.get_monitors`` and returns a new list of rectangles, in the same order, of monitor areas that account for all struts set by all windows. Duplicate struts are ignored. :param monitors: A list of 4-tuples representing monitor rectangles. :return: A list of 4-tuples representing monitor rectangles after subtracting strut areas. :rtype: [(top_left_x, top_left_y, width, height)] """ mons = monitors # alias wa = mons[:] clients = ewmh.get_client_list().reply() log = [] # Identical struts should be ignored for c in clients: try: cx, cy, cw, ch = window.get_geometry(c) except xproto.BadWindow: continue for i, (x, y, w, h) in enumerate(wa): if rect_intersect_area((x, y, w, h), (cx, cy, cw, ch)) > 0: struts = ewmh.get_wm_strut_partial(c).reply() if not struts: struts = ewmh.get_wm_strut(c).reply() key = (cx, cy, cw, ch, struts) if key in log: continue log.append(key) if struts and not all([v == 0 for v in struts.values()]): if struts["left"] or struts["right"]: if struts["left"]: x += cw w -= cw if struts["top"] or struts["bottom"]: if struts["top"]: y += ch h -= ch elif struts: # x/y shouldn't be zero if cx > 0 and w == cx + cw: w -= cw elif cy > 0 and h == cy + ch: h -= ch elif cx > 0 and x == cx: x += cw w -= cw elif cy > 0 and y == cy: y += ch h -= ch wa[i] = (x, y, w, h) return wa
def do_output(visibles, currentdesk, names, deskcnt): out_visible = [] out_hidden = [] for visible in visibles: if visible == currentdesk: out_visible.append(markup['current'] % names[visible]) else: out_visible.append(markup['visible'] % names[visible]) clients = ewmh.get_client_list().reply() nonemptydesks = set() for client in clients: nonemptydesks.add(ewmh.get_wm_desktop(client).reply()) for d in xrange(deskcnt): if d not in visibles: if d in nonemptydesks: out_hidden.append(markup['hidden'] % names[d]) else: out_hidden.append(markup['hidden_empty'] % names[d]) print '[%s] %s' % (' '.join(out_visible), ' '.join(out_hidden)) sys.stdout.flush()
def monitor_rects(monitors): """ Takes a list of monitors returned by ``xinerama.get_monitors`` and returns a new list of rectangles, in the same order, of monitor areas that account for all struts set by all windows. Duplicate struts are ignored. :param monitors: A list of 4-tuples representing monitor rectangles. :return: A list of 4-tuples representing monitor rectangles after subtracting strut areas. :rtype: [(top_left_x, top_left_y, width, height)] """ mons = monitors # alias wa = mons[:] clients = ewmh.get_client_list().reply() log = [] # Identical struts should be ignored for c in clients: try: cx, cy, cw, ch = window.get_geometry(c) except xcb.xproto.BadWindow: continue for i, (x, y, w, h) in enumerate(wa): if rect_intersect_area((x, y, w, h), (cx, cy, cw, ch)) > 0: struts = ewmh.get_wm_strut_partial(c).reply() if not struts: struts = ewmh.get_wm_strut(c).reply() key = (cx, cy, cw, ch, struts) if key in log: continue log.append(key) if struts and not all([v == 0 for v in struts.itervalues()]): if struts['left'] or struts['right']: if struts['left']: x += cw w -= cw if struts['top'] or struts['bottom']: if struts['top']: y += ch h -= ch elif struts: # x/y shouldn't be zero if cx > 0 and w == cx + cw: w -= cw elif cy > 0 and h == cy + ch: h -= ch elif cx > 0 and x == cx: x += cw w -= cw elif cy > 0 and y == cy: y += ch h -= ch wa[i] = (x, y, w, h) return wa
def update_tracking_clients(): clist = ewmh.get_client_list().reply() for c in clist: if c not in state.clients: track_client(c) for c in state.clients.keys(): if c not in clist: untrack_client(c)
def cb_property_notify(e): global clients aname = util.get_atom_name(e.atom) if aname == '_NET_ACTIVE_WINDOW': update_window_opacity() elif aname == '_NET_CLIENT_LIST': clients = filter(client_is_normal, ewmh.get_client_list().reply())
def cb_property_notify(e): global clients aname = util.get_atom_name(e.atom) if aname == '_NET_ACTIVE_WINDOW': update_window_opacity(); elif aname == '_NET_CLIENT_LIST': clients = filter(client_is_normal, ewmh.get_client_list().reply())
def list_mapped_windows(workspace: Optional[int] = None) -> List[Window]: mapped_window_ids = get_client_list().reply() if mapped_window_ids is None: mapped_window_ids = list() mapped_windows = [Window(wid) for wid in mapped_window_ids if wid is not None] if workspace is not None: cookies = [get_wm_desktop(wid) for wid in mapped_window_ids] workspaces = [_try_unwrap(cookie) for cookie in cookies] mapped_windows = [win for win, ws in zip(mapped_windows, workspaces) if ws == workspace] return mapped_windows
def goto_window(win_name_or_id): wid = win_name_or_id if isinstance(wid, basestring): clients = ewmh.get_client_list().reply() for c in clients: if wid == ewmh.get_wm_name(c).reply(): wid = c break if isinstance(wid, int): wdesk = ewmh.get_wm_desktop(wid).reply() if wdesk not in ewmh.get_visible_desktops().reply(): ewmh.request_current_desktop_checked(wdesk).check() ewmh.request_active_window_checked(wid, source=2).check()
def remove_empty_current_desktop(): # This isn't as straight-forward as decrementing _NET_NUMBER_OF_DESKTOPS. # We need to make sure we remove the right name, too. # AND only do it if there are no clients on this desktop. clients = ewmh.get_client_list().reply() cur = ewmh.get_current_desktop().reply() for c in clients: if ewmh.get_wm_desktop(c).reply() == cur: return names = ewmh.get_desktop_names().reply() if cur < len(names): names.pop(cur) ewmh.set_desktop_names_checked(names).check() # Subtract one from every client's desktop above the current one for c in clients: cdesk = ewmh.get_wm_desktop(c).reply() if cdesk > cur and cdesk != 0xffffffff: ewmh.set_wm_desktop_checked(c, cdesk - 1).check() ndesks = ewmh.get_number_of_desktops().reply() ewmh.request_number_of_desktops_checked(ndesks - 1).check()
1 if client == activewin else opacity) xpybutil.conn.flush() def client_is_normal(client): wtype = ewmh.get_wm_window_type(client).reply() if not wtype or wtype[0] == util.get_atom('_NET_WM_WINDOW_TYPE_NORMAL'): return True return False def cb_property_notify(e): global clients aname = util.get_atom_name(e.atom) if aname == '_NET_ACTIVE_WINDOW': update_window_opacity() elif aname == '_NET_CLIENT_LIST': clients = filter(client_is_normal, ewmh.get_client_list().reply()) clients = filter(client_is_normal, ewmh.get_client_list().reply()) update_window_opacity() window.listen(xpybutil.root, 'PropertyChange') event.connect('PropertyNotify', xpybutil.root, cb_property_notify) event.main()
def get_all_window_ids(): return get_client_list().reply()
for client in clients: ewmh.set_wm_window_opacity(util.get_parent_window(client), 1 if client == activewin else opacity) xpybutil.conn.flush() def client_is_normal(client): wtype = ewmh.get_wm_window_type(client).reply() if not wtype or wtype[0] == util.get_atom('_NET_WM_WINDOW_TYPE_NORMAL'): return True return False def cb_property_notify(e): global clients aname = util.get_atom_name(e.atom) if aname == '_NET_ACTIVE_WINDOW': update_window_opacity(); elif aname == '_NET_CLIENT_LIST': clients = filter(client_is_normal, ewmh.get_client_list().reply()) clients = filter(client_is_normal, ewmh.get_client_list().reply()) update_window_opacity() window.listen(xpybutil.root, 'PropertyChange') event.connect('PropertyNotify', xpybutil.root, cb_property_notify) event.main()
def global_window_id_list(): return get_client_list().reply()