How to use xcffib - 10 common examples

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 / libqtile / window.py View on Github external
is_java_dialog = 'sun-awt-X11-XDialogPeer' in cls
        is_java = is_java_main or is_java_dialog

        if not self.hidden:
            # Never send TAKE_FOCUS on java *dialogs*
            if not is_java_dialog and \
                    "WM_TAKE_FOCUS" in self.window.get_wm_protocols():
                data = [
                    self.qtile.conn.atoms["WM_TAKE_FOCUS"],
                    xcffib.xproto.Time.CurrentTime,
                    0,
                    0,
                    0
                ]

                u = xcffib.xproto.ClientMessageData.synthetic(data, "I" * 5)
                e = xcffib.xproto.ClientMessageEvent.synthetic(
                    format=32,
                    window=self.window.wid,
                    type=self.qtile.conn.atoms["WM_PROTOCOLS"],
                    data=u
                )

                self.window.send_event(e)

            # Never send FocusIn to java windows
            if not is_java and self.hints['input']:
                self.window.set_input_focus()
            try:
                if warp and self.qtile.config.cursor_warp:
                    self.window.warp_pointer(self.width // 2, self.height // 2)
            except AttributeError:
github qtile / qtile / libqtile / widget / systray.py View on Github external
self.offset + xoffset,
                self.bar.height // 2 - self.icon_size // 2,
                icon.width, self.icon_size,
                0,
                None
            )
            if icon.hidden:
                icon.unhide()
                data = [
                    self.qtile.conn.atoms["_XEMBED_EMBEDDED_NOTIFY"],
                    xcffib.xproto.Time.CurrentTime,
                    0,
                    self.bar.window.window.wid,
                    XEMBED_PROTOCOL_VERSION
                ]
                u = xcffib.xproto.ClientMessageData.synthetic(data, "I" * 5)
                event = xcffib.xproto.ClientMessageEvent.synthetic(
                    format=32,
                    window=icon.window.wid,
                    type=self.qtile.conn.atoms["_XEMBED"],
                    data=u
                )
                self.window.send_event(event)

            xoffset += icon.width + self.padding
github qtile / qtile / libqtile / window.py View on Github external
is_java = is_java_main or is_java_dialog

        if not self.hidden:
            # Never send TAKE_FOCUS on java *dialogs*
            if not is_java_dialog and \
                    "WM_TAKE_FOCUS" in self.window.get_wm_protocols():
                data = [
                    self.qtile.conn.atoms["WM_TAKE_FOCUS"],
                    xcffib.xproto.Time.CurrentTime,
                    0,
                    0,
                    0
                ]

                u = xcffib.xproto.ClientMessageData.synthetic(data, "I" * 5)
                e = xcffib.xproto.ClientMessageEvent.synthetic(
                    format=32,
                    window=self.window.wid,
                    type=self.qtile.conn.atoms["WM_PROTOCOLS"],
                    data=u
                )

                self.window.send_event(e)

            # Never send FocusIn to java windows
            if not is_java and self.hints['input']:
                self.window.set_input_focus()
            try:
                if warp and self.qtile.config.cursor_warp:
                    self.window.warp_pointer(self.width // 2, self.height // 2)
            except AttributeError:
                pass
github qtile / qtile / libqtile / widget / systray.py View on Github external
self.bar.height // 2 - self.icon_size // 2,
                icon.width, self.icon_size,
                0,
                None
            )
            if icon.hidden:
                icon.unhide()
                data = [
                    self.qtile.conn.atoms["_XEMBED_EMBEDDED_NOTIFY"],
                    xcffib.xproto.Time.CurrentTime,
                    0,
                    self.bar.window.window.wid,
                    XEMBED_PROTOCOL_VERSION
                ]
                u = xcffib.xproto.ClientMessageData.synthetic(data, "I" * 5)
                event = xcffib.xproto.ClientMessageEvent.synthetic(
                    format=32,
                    window=icon.window.wid,
                    type=self.qtile.conn.atoms["_XEMBED"],
                    data=u
                )
                self.window.send_event(event)

            xoffset += icon.width + self.padding
github qtile / qtile / test / scripts / window.py View on Github external
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,
                         [wm_delete_window])
github qtile / qtile / test / scripts / window.py View on Github external
import xcffib.xproto


def configure(window):
    window.configure(
        width=100,
        height=100,
        x=0,
        y=0,
        border_width=1,
    )


for i in range(20):
    try:
        conn = xcffib.connect(display=sys.argv[1])
    except xcffib.ConnectionException:
        time.sleep(0.1)
        continue
    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,
github qtile / qtile / test / scripts / window.py View on Github external
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,
                         [wm_delete_window])

conn.core.ConfigureWindow(window,
                          xcffib.xproto.ConfigWindow.X | xcffib.xproto.ConfigWindow.Y |
                          xcffib.xproto.ConfigWindow.Width | xcffib.xproto.ConfigWindow.Height |
                          xcffib.xproto.ConfigWindow.BorderWidth,
                          [0, 0, 100, 100, 1])
conn.core.MapWindow(window)
conn.flush()
conn.core.ConfigureWindow(window,
                          xcffib.xproto.ConfigWindow.X | xcffib.xproto.ConfigWindow.Y |
                          xcffib.xproto.ConfigWindow.Width | xcffib.xproto.ConfigWindow.Height |
                          xcffib.xproto.ConfigWindow.BorderWidth,
                          [0, 0, 100, 100, 1])

try:
    while 1:
        event = conn.wait_for_event()
        if event.__class__ == xcffib.xproto.ClientMessageEvent:
            if conn.core.GetAtomName(event.data.data32[0]).reply().name.to_string() == "WM_DELETE_WINDOW":
                sys.exit(1)
except xcffib.XcffibException:
    pass
github qtile / qtile / test / scripts / window.py View on Github external
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,
                         [wm_delete_window])

conn.core.ConfigureWindow(window,
                          xcffib.xproto.ConfigWindow.X | xcffib.xproto.ConfigWindow.Y |
                          xcffib.xproto.ConfigWindow.Width | xcffib.xproto.ConfigWindow.Height |
                          xcffib.xproto.ConfigWindow.BorderWidth,
                          [0, 0, 100, 100, 1])
conn.core.MapWindow(window)
conn.flush()
conn.core.ConfigureWindow(window,
                          xcffib.xproto.ConfigWindow.X | xcffib.xproto.ConfigWindow.Y |
                          xcffib.xproto.ConfigWindow.Width | xcffib.xproto.ConfigWindow.Height |
                          xcffib.xproto.ConfigWindow.BorderWidth,
                          [0, 0, 100, 100, 1])

try:
    while 1:
        event = conn.wait_for_event()
        if event.__class__ == xcffib.xproto.ClientMessageEvent:
            if conn.core.GetAtomName(event.data.data32[0]).reply().name.to_string() == "WM_DELETE_WINDOW":
                sys.exit(1)
github qtile / qtile / test / scripts / window.py View on Github external
conn.core.ChangeProperty(xcffib.xproto.PropMode.Replace,
                         window, wm_protocols,
                         xcffib.xproto.Atom.ATOM, 32, 1,
                         [wm_delete_window])

conn.core.ConfigureWindow(window,
                          xcffib.xproto.ConfigWindow.X | xcffib.xproto.ConfigWindow.Y |
                          xcffib.xproto.ConfigWindow.Width | xcffib.xproto.ConfigWindow.Height |
                          xcffib.xproto.ConfigWindow.BorderWidth,
                          [0, 0, 100, 100, 1])
conn.core.MapWindow(window)
conn.flush()
conn.core.ConfigureWindow(window,
                          xcffib.xproto.ConfigWindow.X | xcffib.xproto.ConfigWindow.Y |
                          xcffib.xproto.ConfigWindow.Width | xcffib.xproto.ConfigWindow.Height |
                          xcffib.xproto.ConfigWindow.BorderWidth,
                          [0, 0, 100, 100, 1])

try:
    while 1:
        event = conn.wait_for_event()
        if event.__class__ == xcffib.xproto.ClientMessageEvent:
            if conn.core.GetAtomName(event.data.data32[0]).reply().name.to_string() == "WM_DELETE_WINDOW":
                sys.exit(1)
except xcffib.XcffibException:
    pass
github qtile / qtile / test / scripts / window.py View on Github external
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,
                         [wm_delete_window])

conn.core.ConfigureWindow(window,
                          xcffib.xproto.ConfigWindow.X | xcffib.xproto.ConfigWindow.Y |
                          xcffib.xproto.ConfigWindow.Width | xcffib.xproto.ConfigWindow.Height |