def activate(self): # we don't know where we are... if not self.screen: return PROBE.window_activate(self.xobj) State.reload_active(self)
def dispatch(tiler, action=None, keycode=None, masks=None): if not action and keycode and masks: if keycode not in State.get_dispatcher(): print >> sys.stderr, "Keycode %s is not bound" % keycode return # Now we need to determine which masks were used... if masks in State.get_dispatcher()[keycode]: action = State.get_dispatcher()[keycode][masks] else: print >> sys.stderr, "Keycode %s and keymask %d are not bound" % (keycode, masks) return if not tiler.screen.is_tiling() and action.find('tile.') == -1: return elif action: # We can only initiate tiling through keycodes... if not tiler.screen.is_tiling(): return # Turn the action into a method... if action.find('tile.') != -1: layout = action[(action.find('.') + 1):] if layout != 'default' and layout in Config.TILERS: tiler.screen.set_tiler(Config.tilers(layout)) tiler = tiler.screen.get_tiler() tiler._reset() action = Tile.tile else: action = eval('Tile.' + action) action(tiler)
def refresh_desktops(): for desk in PROBE.get_desktops().values(): if desk['id'] in State.get_desktops(): desktop = State.get_desktops()[desk['id']] desktop.update_attributes(desk) for viewport in desktop.viewports.values(): for screen in viewport.screens.values(): screen.needs_tiling()
def load_window(window_id): attrs = PROBE.get_window_by_id(window_id) if not attrs['popup'] and attrs['desktop'] in State.get_desktops(): for viewport in State.get_desktops()[attrs['desktop']].viewports.values(): if viewport.is_on_viewport(attrs['x'], attrs['y']): for screen in viewport.screens.values(): if screen.is_on_screen(attrs['x'], attrs['y']): win = Window(screen, attrs) if not win.filtered(): screen.add_window(win) screen.needs_tiling() if win.id == PROBE.get_active_window_id(): win.activate()
def load_window(window_id): attrs = PROBE.get_window_by_id(window_id) if not attrs['popup'] and attrs['desktop'] in State.get_desktops(): for viewport in State.get_desktops()[ attrs['desktop']].viewports.values(): if viewport.is_on_viewport(attrs['x'], attrs['y']): for screen in viewport.screens.values(): if screen.is_on_screen(attrs['x'], attrs['y']): win = Window(screen, attrs) if not win.filtered(): screen.add_window(win) screen.needs_tiling() if win.id == PROBE.get_active_window_id(): win.activate()
def refresh(self): oldscreen = self.screen oldviewport = oldscreen.viewport olddesk = oldviewport.desktop oldstate = self.hidden update = PROBE.get_window(self.xobj) # So this is a little bit weird- we're updating the window, but while # we care about it's new x,y (screen change?), we don't care about it's # new width and height. We're tiling, so we're in complete control of # width and height. (The key here is that x/y *completely* determines # which screen the window is on.) Therefore, we don't update them- but # why? It would seem harmless, except that some windows (like terminals, # text editors, etc) set width_inc/height_inc hints which standards # compliant window managers honor- like OpenBox. Therefore, the WM could # be resizing the width/height of a given window slightly differently than # what PyTyle thinks it's at. This causes the width/height to change slightly # on each window update, and has a cascading effect that mangles the # window's size. YUCK. (And these width_inc/height_inc hints seemingly # cannot be reset.) update['width'] = self.width update['height'] = self.height self.update_attributes(update) if olddesk.id != self.desktop or not oldviewport.is_on_viewport( update['x'], update['y']) or not oldscreen.is_on_screen( update['x'], update['y']): for viewport in State.get_desktops()[ self.desktop].viewports.values(): if viewport.is_on_viewport(update['x'], update['y']): for screen in viewport.screens.values(): if screen.is_on_screen(update['x'], update['y']): oldscreen.delete_window(self) screen.add_window(self) screen.needs_tiling() oldscreen.needs_tiling() self.screen = screen elif oldstate != self.hidden: self.screen.needs_tiling() # If it's the active window, then make sure PyTyle knows that. We don't # want to set input focus (well, it should already have it if X tells us # it's the active window) because it will generate another window change # event, and we end up in a positive feedback loop. Yuck. if self.id == PROBE.get_active_window_id(): State.reload_active()
def refresh(self): oldscreen = self.screen oldviewport = oldscreen.viewport olddesk = oldviewport.desktop oldstate = self.hidden update = PROBE.get_window(self.xobj) # So this is a little bit weird- we're updating the window, but while # we care about it's new x,y (screen change?), we don't care about it's # new width and height. We're tiling, so we're in complete control of # width and height. (The key here is that x/y *completely* determines # which screen the window is on.) Therefore, we don't update them- but # why? It would seem harmless, except that some windows (like terminals, # text editors, etc) set width_inc/height_inc hints which standards # compliant window managers honor- like OpenBox. Therefore, the WM could # be resizing the width/height of a given window slightly differently than # what PyTyle thinks it's at. This causes the width/height to change slightly # on each window update, and has a cascading effect that mangles the # window's size. YUCK. (And these width_inc/height_inc hints seemingly # cannot be reset.) update['width'] = self.width update['height'] = self.height self.update_attributes(update) if olddesk.id != self.desktop or not oldviewport.is_on_viewport(update['x'], update['y']) or not oldscreen.is_on_screen(update['x'], update['y']): for viewport in State.get_desktops()[self.desktop].viewports.values(): if viewport.is_on_viewport(update['x'], update['y']): for screen in viewport.screens.values(): if screen.is_on_screen(update['x'], update['y']): oldscreen.delete_window(self) screen.add_window(self) screen.needs_tiling() oldscreen.needs_tiling() self.screen = screen elif oldstate != self.hidden: self.screen.needs_tiling() # If it's the active window, then make sure PyTyle knows that. We don't # want to set input focus (well, it should already have it if X tells us # it's the active window) because it will generate another window change # event, and we end up in a positive feedback loop. Yuck. if self.id == PROBE.get_active_window_id(): State.reload_active()
def reload_desktops(): # initialize all desktops and their associated windows for desktop in State.get_desktops().values(): for viewport in desktop.viewports.values(): for screen in viewport.screens.values(): desk_or_view = desktop.id if PROBE.is_compiz(): desk_or_view = viewport.id screen.set_tiler(Config.tilers(Config.tiling(screen.id, desk_or_view))) screen.needs_tiling()
def reload_desktops(): # initialize all desktops and their associated windows for desktop in State.get_desktops().values(): for viewport in desktop.viewports.values(): for screen in viewport.screens.values(): desk_or_view = desktop.id if PROBE.is_compiz(): desk_or_view = viewport.id screen.set_tiler( Config.tilers(Config.tiling(screen.id, desk_or_view))) screen.needs_tiling()
def load_new_windows(): wins = State.scan_new_windows() for win in wins: Window.load_window(win)
def delete_window(self, window): State.delete_window(window) del self.windows[window.id] self.needs_tiling()
def _query(self): print(State.get_wm_name(), self.screen.viewport.desktop, self.storage)
def __init__(self, attrs): self.update_attributes(attrs) self._VIEWPORT = None self.viewports = {} State.add_desktop(self) self.load_viewports()
def needs_tiling(self): self._tiled = False State.queue_screen(self)
def delete(self): self.screen.delete_window(self) self.screen.needs_tiling() State.reload_active()
def add_window(self, window): State.add_window(window) self.windows[window.id] = window self.needs_tiling()
def _query(self): print State.get_wm_name() print self.screen.viewport.desktop print self.storage
def _reload(self): State.do_reload()