def __init__(self, config, displayName=None, fname=None, no_spawn=False, log=None, state=None): gobject.threads_init() self.log = log or init_log() if hasattr(config, "log_level"): self.log.setLevel(config.log_level) self.no_spawn = no_spawn if not displayName: displayName = os.environ.get("DISPLAY") if not displayName: raise QtileError("No DISPLAY set.") if not fname: # Dots might appear in the host part of the display name # during remote X sessions. Let's strip the host part first. displayNum = displayName.partition(":")[2] if not "." in displayNum: displayName = displayName + ".0" fname = command.find_sockfile(displayName) self.conn = xcbq.Connection(displayName) self.config = config self.fname = fname hook.init(self) self.keyMap = {} self.windowMap = {} self.widgetMap = {} self.groupMap = {} self.groups = [] self.keyMap = {} # Find the modifier mask for the numlock key, if there is one: nc = self.conn.keysym_to_keycode(xcbq.keysyms["Num_Lock"]) self.numlockMask = xcbq.ModMasks[self.conn.get_modifier(nc)] self.validMask = ~(self.numlockMask | xcbq.ModMasks["lock"]) # Because we only do Xinerama multi-screening, # we can assume that the first # screen's root is _the_ root. self.root = self.conn.default_screen.root self.root.set_attribute( eventmask=(EventMask.StructureNotify | EventMask.SubstructureNotify | EventMask.SubstructureRedirect | EventMask.EnterWindow | EventMask.LeaveWindow)) self.root.set_property( '_NET_SUPPORTED', [self.conn.atoms[x] for x in xcbq.SUPPORTED_ATOMS]) self.supporting_wm_check_window = self.conn.create_window(-1, -1, 1, 1) self.root.set_property('_NET_SUPPORTING_WM_CHECK', self.supporting_wm_check_window.wid) # TODO: maybe allow changing the name without external tools? self.supporting_wm_check_window.set_property('_NET_WM_NAME', "qtile") self.supporting_wm_check_window.set_property( '_NET_SUPPORTING_WM_CHECK', self.supporting_wm_check_window.wid) if config.main: config.main(self) if self.config.groups: key_binder = None if hasattr(self.config, 'dgroups_key_binder'): key_binder = self.config.dgroups_key_binder DGroups(self, self.config.groups, key_binder) if hasattr(config, "widget_defaults") and config.widget_defaults: _Widget.global_defaults = config.widget_defaults else: _Widget.global_defaults = {} for i in self.groups: self.groupMap[i.name] = i self.currentScreen = None self.screens = [] self._process_screens() self.currentScreen = self.screens[0] self._drag = None self.ignoreEvents = set([ xcb.xproto.KeyReleaseEvent, xcb.xproto.ReparentNotifyEvent, xcb.xproto.CreateNotifyEvent, # DWM handles this to help "broken focusing windows". xcb.xproto.MapNotifyEvent, xcb.xproto.LeaveNotifyEvent, xcb.xproto.FocusOutEvent, xcb.xproto.FocusInEvent, xcb.xproto.NoExposureEvent ]) self.conn.flush() self.conn.xsync() self._xpoll() self.server = command._Server(self.fname, self, config) # Map and Grab keys for key in self.config.keys: self.mapKey(key) # It fixes problems with focus when clicking windows of some specific clients like xterm def noop(qtile): pass self.config.mouse += (Click([], "Button1", command.lazy.function(noop), focus="after"), ) self.mouseMap = {} for i in self.config.mouse: if self.mouseMap.get(i.button_code) is None: self.mouseMap[i.button_code] = [] self.mouseMap[i.button_code].append(i) self.grabMouse() hook.fire("startup") self.scan() self.update_net_desktops() hook.subscribe.setgroup(self.update_net_desktops) if state: st = pickle.load(StringIO(state)) st.apply(self)
def __init__(self, config, displayName=None, fname=None, testing=False): self._testing = testing if not displayName: displayName = os.environ.get("DISPLAY") if not displayName: raise QtileError("No DISPLAY set.") if not fname: # Dots might appear in the host part of the display name # during remote X sessions. Let's strip the host part first. displayNum = displayName.partition(":")[2] if not "." in displayNum: displayName = displayName + ".0" fname = command.find_sockfile(displayName) self.conn = xcbq.Connection(displayName) self.config, self.fname = config, fname self.log = Log( self._logLength, sys.stderr if self.debug else None ) hook.init(self) self.windowMap = {} self.widgetMap = {} self.groupMap = {} self.groups = [] # Because we only do Xinerama multi-screening, we can assume that the first # screen's root is _the_ root. self.root = self.conn.default_screen.root self.root.set_attribute( eventmask = EventMask.StructureNotify |\ EventMask.SubstructureNotify |\ EventMask.SubstructureRedirect |\ EventMask.EnterWindow |\ EventMask.LeaveWindow ) if config.main: config.main(self) self.groups += self.config.groups[:] for i in self.groups: i._configure(config.layouts, config.floating_layout, self) self.groupMap[i.name] = i self.currentScreen = None self.screens = [] for i, s in enumerate(self.conn.pseudoscreens): if i+1 > len(config.screens): scr = Screen() else: scr = config.screens[i] if not self.currentScreen: self.currentScreen = scr scr._configure( self, i, s.x, s.y, s.width, s.height, self.groups[i], ) self.screens.append(scr) if not self.screens: if config.screens: s = config.screens[0] else: s = Screen() self.currentScreen = s s._configure( self, 0, 0, 0, self.conn.default_screen.width_in_pixels, self.conn.default_screen.height_in_pixels, self.groups[0], ) self.screens.append(s) self.currentScreen = self.screens[0] self.ignoreEvents = set([ xcb.xproto.KeyReleaseEvent, xcb.xproto.ReparentNotifyEvent, xcb.xproto.CreateNotifyEvent, # DWM handles this to help "broken focusing windows". xcb.xproto.MapNotifyEvent, xcb.xproto.LeaveNotifyEvent, xcb.xproto.FocusOutEvent, xcb.xproto.FocusInEvent, ]) self.conn.flush() self.conn.xsync() self._prev = None # for logging self._prev_count = 0 self.xpoll() if self._exit: print >> sys.stderr, "Access denied: Another window manager running?" sys.exit(1) self.server = command._Server(self.fname, self, config) # Find the modifier mask for the numlock key, if there is one: nc = self.conn.keysym_to_keycode(xcbq.keysyms["Num_Lock"]) self.numlockMask = xcbq.ModMasks[self.conn.get_modifier(nc)] self.validMask = ~(self.numlockMask | xcbq.ModMasks["lock"]) self.keyMap = {} for i in self.config.keys: self.keyMap[(i.keysym, i.modmask&self.validMask)] = i self.mouseMap = {} for i in self.config.mouse: self.mouseMap[(i.button_code, i.modmask&self.validMask)] = i self.grabKeys() self.grabMouse() self.scan()
def __init__(self, config, displayName=None, fname=None, testing=False): self._testing = testing if not displayName: displayName = os.environ.get("DISPLAY") if not displayName: raise QtileError("No DISPLAY set.") if not fname: if not "." in displayName: displayName = displayName + ".0" fname = os.path.join("~", command.SOCKBASE % displayName) fname = os.path.expanduser(fname) self.conn = xcbq.Connection(displayName) self.config, self.fname = config, fname self.log = Log(self._logLength, sys.stderr if self.debug else None) hook.init(self) self.windowMap = {} self.widgetMap = {} self.groupMap = {} self.groups = self.config.groups[:] for i in self.groups: i._configure(config.layouts, self) self.groupMap[i.name] = i self.currentScreen = None self.screens = [] extensions = self.conn.extensions() if "xinerama" in extensions: for i, s in enumerate(self.conn.xinerama.query_screens()): if i + 1 > len(config.screens): scr = Screen() else: scr = config.screens[i] if not self.currentScreen: self.currentScreen = scr scr._configure(self, i, s.x_org, s.y_org, s.width, s.height, self.groups[i]) self.screens.append(scr) if not self.screens: if config.screens: s = config.screens[0] else: s = Screen() self.currentScreen = s s._configure( self, 0, 0, 0, self.conn.default_screen.width_in_pixels, self.conn.default_screen.height_in_pixels, self.groups[0], ) self.screens.append(s) self.currentScreen = self.screens[0] self.ignoreEvents = set( [ xcb.xproto.KeyReleaseEvent, xcb.xproto.ReparentNotifyEvent, xcb.xproto.CreateNotifyEvent, # DWM handles this to help "broken focusing windows". xcb.xproto.MapNotifyEvent, xcb.xproto.LeaveNotifyEvent, xcb.xproto.FocusOutEvent, xcb.xproto.FocusInEvent, ] ) # Because we only do Xinerama multi-screening, we can assume that the first # screen's root is _the_ root. self.root = self.conn.default_screen.root self.root.set_attribute( eventmask=EventMask.StructureNotify | EventMask.SubstructureNotify | EventMask.SubstructureRedirect | EventMask.EnterWindow | EventMask.LeaveWindow ) self.conn.flush() self.conn.xsync() self.xpoll() if self._exit: print >> sys.stderr, "Access denied: Another window manager running?" sys.exit(1) self.server = command._Server(self.fname, self, config) # Find the modifier mask for the numlock key, if there is one: nc = self.conn.keysym_to_keycode(xcbq.keysyms["Num_Lock"]) self.numlockMask = xcbq.ModMasks[self.conn.get_modifier(nc)] self.validMask = ~(self.numlockMask | xcbq.ModMasks["lock"]) self.keyMap = {} for i in self.config.keys: self.keyMap[(i.keysym, i.modmask & self.validMask)] = i self.grabKeys() self.scan()
def __init__(self, config, displayName=None, fname=None): if not displayName: displayName = os.environ.get("DISPLAY") if not displayName: raise QtileError("No DISPLAY set.") if not fname: if not "." in displayName: displayName = displayName + ".0" fname = os.path.join("~", command.SOCKBASE%displayName) fname = os.path.expanduser(fname) self.display = Xlib.display.Display(displayName) self.config, self.fname = config, fname self.log = Log( self._logLength, sys.stderr if self.debug else None ) defaultScreen = self.display.screen( self.display.get_default_screen() ) self.root = defaultScreen.root hook.init(self) self.atoms = dict( internal = self.display.intern_atom("QTILE_INTERNAL"), python = self.display.intern_atom("QTILE_PYTHON") ) self.windowMap = {} self.internalMap = {} self.widgetMap = {} self.groupMap = {} if config.theme: self.theme = config.theme else: self.theme = Theme() self.groups = [] for i in self.config.groups: g = Group(i, self.config.layouts, self) self.groups.append(g) self.groupMap[g.name] = g self.currentScreen = None self.screens = [] if self.display.has_extension("XINERAMA"): for i, s in enumerate(self.display.xinerama_query_screens().screens): if i+1 > len(config.screens): scr = Screen() else: scr = config.screens[i] if not self.currentScreen: self.currentScreen = scr scr._configure( self, self.theme, i, s["x"], s["y"], s["width"], s["height"], self.groups[i], ) self.screens.append(scr) if not self.screens: if config.screens: s = config.screens[0] else: s = Screen() self.currentScreen = s s._configure( self, self.theme, 0, 0, 0, defaultScreen.width_in_pixels, defaultScreen.height_in_pixels, self.groups[0], ) self.screens.append(s) self.currentScreen = self.screens[0] self.display.set_error_handler(self.initialErrorHandler) self.root.change_attributes( event_mask = X.SubstructureNotifyMask |\ X.SubstructureRedirectMask |\ X.EnterWindowMask |\ X.LeaveWindowMask |\ X.StructureNotifyMask ) self.display.sync() if self._exit: print >> sys.stderr, "Access denied: Another window manager running?" sys.exit(1) # Now install the real error handler self.display.set_error_handler(self.errorHandler) self.server = command._Server(self.fname, self, config) self.ignoreEvents = set([ X.KeyRelease, X.ReparentNotify, X.CreateNotify, # DWM handles this to help "broken focusing windows". X.MapNotify, X.LeaveNotify, X.FocusOut, X.FocusIn, ]) # Find the modifier mask for the numlock key, if there is one: maskmap = { X.ControlMapIndex: X.ControlMask, X.LockMapIndex: X.LockMask, X.Mod1MapIndex: X.Mod1Mask, X.Mod2MapIndex: X.Mod2Mask, X.Mod3MapIndex: X.Mod3Mask, X.Mod4MapIndex: X.Mod4Mask, X.Mod5MapIndex: X.Mod5Mask, X.ShiftMapIndex: X.ShiftMask, } nc = self.display.keysym_to_keycode( XK.string_to_keysym("Num_Lock") ) self.numlockMask = None for i, l in enumerate(self.display.get_modifier_mapping()): for j in l: if j == nc: self.numlockMask = maskmap[i] self.validMask = ~(self.numlockMask | X.LockMask) self.keyMap = {} for i in self.config.keys: self.keyMap[(i.keysym, i.modmask&self.validMask)] = i self.grabKeys() self.scan()
def __init__(self, config, displayName=None, fname=None, no_spawn=False, log=None, state=None): gobject.threads_init() self.log = log or init_log() if hasattr(config, "log_level"): self.log.setLevel(config.log_level) self.no_spawn = no_spawn if not displayName: displayName = os.environ.get("DISPLAY") if not displayName: raise QtileError("No DISPLAY set.") if not fname: # Dots might appear in the host part of the display name # during remote X sessions. Let's strip the host part first. displayNum = displayName.partition(":")[2] if not "." in displayNum: displayName = displayName + ".0" fname = command.find_sockfile(displayName) self.conn = xcbq.Connection(displayName) self.config = config self.fname = fname hook.init(self) self.keyMap = {} self.windowMap = {} self.widgetMap = {} self.groupMap = {} self.groups = [] self.keyMap = {} # Find the modifier mask for the numlock key, if there is one: nc = self.conn.keysym_to_keycode(xcbq.keysyms["Num_Lock"]) self.numlockMask = xcbq.ModMasks[self.conn.get_modifier(nc)] self.validMask = ~(self.numlockMask | xcbq.ModMasks["lock"]) # Because we only do Xinerama multi-screening, # we can assume that the first # screen's root is _the_ root. self.root = self.conn.default_screen.root self.root.set_attribute( eventmask=( EventMask.StructureNotify | EventMask.SubstructureNotify | EventMask.SubstructureRedirect | EventMask.EnterWindow | EventMask.LeaveWindow ) ) self.root.set_property( '_NET_SUPPORTED', [self.conn.atoms[x] for x in xcbq.SUPPORTED_ATOMS] ) self.supporting_wm_check_window = self.conn.create_window(-1, -1, 1, 1) self.root.set_property( '_NET_SUPPORTING_WM_CHECK', self.supporting_wm_check_window.wid ) # TODO: maybe allow changing the name without external tools? self.supporting_wm_check_window.set_property('_NET_WM_NAME', "qtile") self.supporting_wm_check_window.set_property( '_NET_SUPPORTING_WM_CHECK', self.supporting_wm_check_window.wid ) if config.main: config.main(self) if self.config.groups: key_binder = None if hasattr(self.config, 'dgroups_key_binder'): key_binder = self.config.dgroups_key_binder DGroups(self, self.config.groups, key_binder) if hasattr(config, "widget_defaults") and config.widget_defaults: _Widget.global_defaults = config.widget_defaults else: _Widget.global_defaults = {} for i in self.groups: self.groupMap[i.name] = i self.currentScreen = None self.screens = [] self._process_screens() self.currentScreen = self.screens[0] self._drag = None self.ignoreEvents = set([ xcb.xproto.KeyReleaseEvent, xcb.xproto.ReparentNotifyEvent, xcb.xproto.CreateNotifyEvent, # DWM handles this to help "broken focusing windows". xcb.xproto.MapNotifyEvent, xcb.xproto.LeaveNotifyEvent, xcb.xproto.FocusOutEvent, xcb.xproto.FocusInEvent, xcb.xproto.NoExposureEvent ]) self.conn.flush() self.conn.xsync() self._xpoll() self.server = command._Server(self.fname, self, config) # Map and Grab keys for key in self.config.keys: self.mapKey(key) # It fixes problems with focus when clicking windows of some specific clients like xterm def noop(qtile): pass self.config.mouse += (Click([], "Button1", command.lazy.function(noop), focus="after"),) self.mouseMap = {} for i in self.config.mouse: if self.mouseMap.get(i.button_code) is None: self.mouseMap[i.button_code] = [] self.mouseMap[i.button_code].append(i) self.grabMouse() hook.fire("startup") self.scan() self.update_net_desktops() hook.subscribe.setgroup(self.update_net_desktops) if state: st = pickle.load(StringIO(state)) st.apply(self)