How to use the xcffib.xproto.CW function in xcffib

To help you get started, we’ve selected a few xcffib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github qtile / qtile / test / scripts / window.py View on Github external
except Exception as v:
        print("Error opening test window: ", type(v), v, file=sys.stderr)
        sys.exit(1)
    break
else:
    print("Could not open window on display %s" % (sys.argv[1]), file=sys.stderr)
    sys.exit(1)

screen = conn.get_setup().roots[conn.pref_screen]

window = conn.generate_id()
background = conn.core.AllocColor(screen.default_colormap, 0x2828, 0x8383, 0xCECE).reply().pixel  # Color "#2883ce"
conn.core.CreateWindow(xcffib.CopyFromParent, window, screen.root,
                       100, 100, 100, 100, 1,
                       xcffib.xproto.WindowClass.InputOutput, screen.root_visual,
                       xcffib.xproto.CW.BackPixel | xcffib.xproto.CW.EventMask,
                       [background, xcffib.xproto.EventMask.StructureNotify | xcffib.xproto.EventMask.Exposure])

conn.core.ChangeProperty(xcffib.xproto.PropMode.Replace,
                         window, xcffib.xproto.Atom.WM_NAME,
                         xcffib.xproto.Atom.STRING, 8, len(sys.argv[2]),
                         sys.argv[2])

wm_protocols = "WM_PROTOCOLS"
wm_protocols = conn.core.InternAtom(0, len(wm_protocols), wm_protocols).reply().atom

wm_delete_window = "WM_DELETE_WINDOW"
wm_delete_window = conn.core.InternAtom(0, len(wm_delete_window), wm_delete_window).reply().atom

conn.core.ChangeProperty(xcffib.xproto.PropMode.Replace,
                         window, wm_protocols,
                         xcffib.xproto.Atom.ATOM, 32, 1,
github Kozea / cairocffi / cairocffi / test_xcb.py View on Github external
def create_window(conn, width, height):
    """Creates a window of the given dimensions and returns the XID"""
    wid = conn.generate_id()
    default_screen = conn.setup.roots[conn.pref_screen]

    conn.core.CreateWindow(
        default_screen.root_depth,  # depth
        wid,                        # id
        default_screen.root,        # parent
        0, 0, width, height, 0,     # x, y, w, h, border width
        xcffib.xproto.WindowClass.InputOutput,  # window class
        default_screen.root_visual,             # visual
        CW.BackPixel | CW.EventMask,            # value mask
        [                                       # value list
            default_screen.black_pixel,
            EventMask.Exposure | EventMask.StructureNotify
        ]
    )

    return wid
github asrp / guitktk / xcb_doc.py View on Github external
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,
github mjkillough / set-wallpaper / set_wallpaper.py View on Github external
def set_background(self, pixmap):
        self._set_proprety_to_pixmap('_XROOTPMAP_ID', pixmap)
        self._set_proprety_to_pixmap('ESETROOT_PMAP_ID', pixmap)
        self.conn.core.ChangeWindowAttributes(self.root, xcffib.xproto.CW.BackPixmap, [pixmap])
        self.conn.core.ClearArea(0, self.root, 0, 0, self.width, self.height)
        self.conn.flush()
github qtile / qtile / libqtile / backend / x11 / xcbq.py View on Github external
mask = 0
        values = []
        for m, s in self.mmap:
            if s in kwargs:
                val = kwargs.get(s)
                if val is not None:
                    mask |= m
                    values.append(getattr(val, "_maskvalue", val))
                del kwargs[s]
        if kwargs:
            raise ValueError("Unknown mask names: %s" % list(kwargs.keys()))
        return mask, values


ConfigureMasks = MaskMap(xcffib.xproto.ConfigWindow)
AttributeMasks = MaskMap(CW)


class AtomCache:
    def __init__(self, conn):
        self.conn = conn
        self.atoms = {}
        self.reverse = {}

        # We can change the pre-loads not to wait for a return
        for name in WindowTypes.keys():
            self.insert(name=name)

        for i in dir(xcffib.xproto.Atom):
            if not i.startswith("_"):
                self.insert(name=i, atom=getattr(xcffib.xproto.Atom, i))
github qtile / qtile / libqtile / backend / x11 / xcbq.py View on Github external
def create_window(self, x, y, width, height):
        wid = self.conn.generate_id()
        self.conn.core.CreateWindow(
            self.default_screen.root_depth,
            wid,
            self.default_screen.root.wid,
            x, y, width, height, 0,
            WindowClass.InputOutput,
            self.default_screen.root_visual,
            CW.BackPixel | CW.EventMask,
            [
                self.default_screen.black_pixel,
                EventMask.StructureNotify | EventMask.Exposure
            ]
        )
        return Window(self, wid)