def get(self, key): if key in self._state: return self._state[key] elif Config.layout(self._tiler, key) is not None: self.set(key, Config.layout(self._tiler, key)) return Config.layout(self._tiler, key) return None
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 help_resize(self, window, x, y, width, height, margin=0, intMargin=None, intBorders={ 't': False, 'l': False, 'r': False, 'b': False }): if intMargin == None: intMargin = margin x += intMargin if intBorders['l'] else margin y += intMargin if intBorders['t'] else margin if intBorders['l']: width -= intMargin else: width -= margin if intBorders['r']: width -= intMargin else: width -= margin if intBorders['t']: height -= intMargin else: height -= margin if intBorders['b']: height -= intMargin else: height -= margin if window.static: window.remove_static_property() if Config.misc('decorations'): if not Config.misc('original_decor'): window.add_decorations() window.resize(int(x), int(y), int(width - window.d_left - window.d_right), int(height - window.d_top - window.d_bottom)) else: if Config.misc('original_decor'): window.remove_decorations() window.resize(int(x), int(y), int(width - 2), int(height - 2))
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 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 filtered(self): if self.winclass: for winfilter in Config.filter(): if self.winclass[0].lower().find(winfilter.lower()) != -1 or self.winclass[1].lower().find(winfilter.lower()) != -1: # or window.title.lower().find(winfilter.lower()) != -1: return True return False
def __init__(self, viewport, attrs): self.update_attributes(attrs) self._active = None self._tile = None self._tiled = False self._tiling = Config.misc('global_tiling') self.windows = {} self.viewport = viewport
def filtered(self): if self.winclass: for winfilter in Config.filter(): for i in {0, 1}: if self.winclass[i].lower().find(winfilter.lower()) != -1: return True return False
def _untile(self): # just resize all the windows back to their original x/y/width/height for window in self.storage.get_all(): if Config.misc('original_decor'): window.add_decorations() else: window.remove_decorations() window.resize(window.origx, window.origy, window.origwidth, window.origheight)
def filtered(self): if self.winclass: for winfilter in Config.filter(): if self.winclass[0].lower().find(winfilter.lower( )) != -1 or self.winclass[1].lower().find( winfilter.lower() ) != -1: # or window.title.lower().find(winfilter.lower()) != -1: return True return False
def cycle_tiler(self): for i in range(len(Config.misc('tilers'))): if Config.misc('tilers')[i] is self.__class__.__name__: if (i + 1) == len(Config.misc('tilers')): self.screen.set_tiler(Config.tilers(Config.misc('tilers')[0])) else: self.screen.set_tiler(Config.tilers(Config.misc('tilers')[i + 1])) self._reset()
def help_resize(self, window, x, y, width, height, margin = 0): if margin > 0: x += margin y += margin width -= (2 * margin) height -= (2 * margin) if window.static: window.remove_static_property() if Config.misc('decorations'): if not Config.misc('original_decor'): window.add_decorations() window.resize(int(x), int(y), int(width - window.d_left - window.d_right), int(height - window.d_top - window.d_bottom)) else: if Config.misc('original_decor'): window.remove_decorations() window.resize(int(x), int(y), int(width - 2), int(height - 2))
def get_workarea(self): # If we have one screen, look for a 'Screen 0' config # and use it if it exists... if len(self.viewport.screens) == 1: if 0 in Config.WORKAREA: x = self.x + Config.workarea(0, 'left') y = self.y + Config.workarea(0, 'top') height = self.height - Config.workarea( 0, 'bottom') + Config.workarea(0, 'top') width = self.width - Config.workarea( 0, 'right') + Config.workarea(0, 'left') else: if PROBE.is_compiz(): x = self.viewport.x y = self.viewport.y else: x = self.viewport.desktop.x y = self.viewport.desktop.y height = self.viewport.desktop.height width = self.viewport.desktop.width print(x, y, width, height) else: x = self.x y = self.y height = self.height width = self.width # Factor in manual docks... x += Config.workarea(self.id, 'left') y += Config.workarea(self.id, 'top') height -= Config.workarea(self.id, 'bottom') + Config.workarea( self.id, 'top') width -= Config.workarea(self.id, 'right') + Config.workarea( self.id, 'left') return (x, y, width, height)
def get_workarea(self): # If we have one screen, look for a "Screen 0" config # and use it if it exists... if len(self.viewport.screens) == 1: if 0 in Config.WORKAREA: x = self.x + Config.workarea(0, 'left') y = self.y + Config.workarea(0, 'top') height = self.height - Config.workarea(0, 'bottom') + Config.workarea(0, 'top') width = self.width - Config.workarea(0, 'right') + Config.workarea(0, 'left') else: if PROBE.is_compiz(): x = self.viewport.x y = self.viewport.y else: x = self.viewport.desktop.x y = self.viewport.desktop.y height = self.viewport.desktop.height width = self.viewport.desktop.width print x, y, width, height else: x = self.x y = self.y height = self.height width = self.width # Factor in manual docks... x += Config.workarea(self.id, 'left') y += Config.workarea(self.id, 'top') height -= Config.workarea(self.id, 'bottom') + Config.workarea(self.id, 'top') width -= Config.workarea(self.id, 'right') + Config.workarea(self.id, 'left') return (x, y, width, height)