def __init__(self, qtile, wid, width, height): self.qtile = qtile self.wid, self.width, self.height = wid, width, height self.pixmap = self.qtile.conn.conn.generate_id() self.gc = self.qtile.conn.conn.generate_id() self.qtile.conn.conn.core.CreatePixmap( self.qtile.conn.default_screen.root_depth, self.pixmap, self.wid, self.width, self.height) self.qtile.conn.conn.core.CreateGC( self.gc, self.wid, xcffib.xproto.GC.Foreground | xcffib.xproto.GC.Background, [ self.qtile.conn.default_screen.black_pixel, self.qtile.conn.default_screen.white_pixel ]) self.surface = cairocffi.XCBSurface( qtile.conn.conn, self.pixmap, self.find_root_visual(), self.width, self.height, ) self.ctx = self.new_ctx() self.clear((0, 0, 1))
def __init__(self, wm, width, height): # self._surface = surface # self._ctx = cairocffi.Context(self._surface) # cairocffi.XCBSurface() self._wid = wm.get_root_win().get_wid() self._conn = wm.get_conn() screen = wm.get_screen() root_depth = screen.root_depth max_depth = [ depth for depth in screen.allowed_depths if depth.depth == screen.root_depth ][0] assert max_depth.depth == 24 self._gcid = self._conn.generate_id() self._conn.core.CreateGC(self._gcid, self._wid, GC.Foreground | GC.Background, [screen.white_pixel, screen.black_pixel], True).check() self._pixmap_id = self._conn.generate_id() self._conn.core.CreatePixmap(root_depth, self._pixmap_id, self._wid, width, height, True).check() self._surface = cairocffi.XCBSurface(self._conn, self._pixmap_id, max_depth.visuals[0], width, height) self._ctx = cairocffi.Context(self._surface) self.set_font('DejaVu Sans Mono', 12, True)
def _create_xcb_surface(self): surface = cairocffi.XCBSurface( self.qtile.core.conn.conn, self._pixmap, self._visual, self.width, self.height, ) return surface
def __init__(self, width, height): self.width = width self.height = height self.connection = xcb.connect() self.xsetup = self.connection.get_setup() self.window = self.connection.generate_id() self.pixmap = self.connection.generate_id() self.gc = self.connection.generate_id() events = [ self.xsetup.roots[0].white_pixel, EventMask.ButtonPress | EventMask.ButtonRelease | EventMask.EnterWindow | EventMask.LeaveWindow | EventMask.Exposure | EventMask.PointerMotion | EventMask.ButtonMotion | EventMask.KeyPress | EventMask.KeyRelease ] self.connection.core.CreateWindow( self.xsetup.roots[0].root_depth, self.window, # Parent is the root window self.xsetup.roots[0].root, 0, 0, self.width, self.height, 0, WindowClass.InputOutput, self.xsetup.roots[0].root_visual, CW.BackPixel | CW.EventMask, events) self.connection.core.CreatePixmap(self.xsetup.roots[0].root_depth, self.pixmap, self.xsetup.roots[0].root, self.width, self.height) self.connection.core.CreateGC(self.gc, self.xsetup.roots[0].root, GC.Foreground | GC.Background, [ self.xsetup.roots[0].black_pixel, self.xsetup.roots[0].white_pixel ]) self.surface = cairo.XCBSurface( self.connection, self.pixmap, self.xsetup.roots[0].allowed_depths[0].visuals[0], self.width, self.height) self.context = cairo.Context(self.surface) self.surfaces = {"screen": self.surface} self.contexts = {"screen": self.context} self.layers = OrderedDict() #Layer roots self.lastupdate = {} self.lastdrawn = {}