Example #1
0
def create_blank_window(wm_name=None, wm_class=None):
    """Create a blank Xorg window."""
    setup = xpybutil.conn.get_setup()
    window = xpybutil.conn.generate_id()
    xpybutil.conn.core.CreateWindow(
        setup.roots[0].root_depth,
        window,
        setup.roots[0].root,
        0,
        0,
        640,
        480,
        0,
        xcffib.xproto.WindowClass.InputOutput,
        setup.roots[0].root_visual,
        xcffib.xproto.CW.BackPixel | xcffib.xproto.CW.EventMask,
        [
            setup.roots[0].white_pixel,
            xcffib.xproto.EventMask.Exposure
            | xcffib.xproto.EventMask.KeyPress,
        ],
    )
    xpybutil.conn.core.MapWindow(window)
    xpybutil.conn.flush()
    cookies = []
    if wm_class:
        cookies.append(set_wm_class_checked(window, wm_class[0], wm_class[1]))
    if wm_name:
        cookies.append(set_wm_name_checked(window, wm_name))
    for cookie in cookies:
        cookie.check()
    return window
Example #2
0
    def __init__(self, xSetup, height=16, bottom=False, screenExtents=None, name=''):
        black = xSetup.screen.black_pixel

        width = xSetup.screen.width_in_pixels if screenExtents is None else screenExtents.width

        if bottom:
            outputHeight = xSetup.screen.height_in_pixels if screenExtents is None else screenExtents.height
            pos = 0 if screenExtents is None else screenExtents.x, outputHeight - height
        else:
            if screenExtents is not None:
                pos = screenExtents.x, screenExtents.y
            else:
                pos = 0, 0

        attributes = {
            CW.BackPixel: black,
            CW.BorderPixel: black,
        }

        super().__init__(xSetup, *pos, width, height, attributes=attributes)

        strutPartial = bottomStrut(width, height, screenExtents.x) if bottom \
            else topStrut(width, screenExtents.y + height, screenExtents.x)

        cookies = [
            icccm.set_wm_state_checked(self.id, icccm.State.Normal, 0),
            icccm.set_wm_name_checked(self.id, f'xcffibaer_{name}'),
            icccm.set_wm_class_checked(self.id, 'xcffibaer', 'xcffibär'),
            ewmh.set_wm_pid_checked(self.id, os.getpid()),
            ewmh.set_wm_strut_checked(self.id, *strutPartial[:4]),
            ewmh.set_wm_strut_partial_checked(self.id, *strutPartial),
            ewmh.set_wm_window_type_checked(self.id, [atoms['_NET_WM_WINDOW_TYPE_DOCK']]),
            ewmh.set_wm_state_checked(self.id, [atoms['_NET_WM_STATE_STICKY'], atoms['_NET_WM_STATE_ABOVE']]),
            #FIXME: This fails. Doing it manually with ChangeProperty works.
            #ewmh.set_wm_name_checked(self.id, 'xcffibär'),
            self.connection.core.ChangeProperty(
                PropMode.Replace, self.id,
                atoms['_NET_WM_NAME'], atoms['UTF8_STRING'], 8,
                *xStr('xcffibär'),
                is_checked=True
            ),
            self.connection.core.MapWindow(self.id, is_checked=True),
        ]

        self.chunks = Chunks([], [])
        self.chunkExtents = {}

        self.lastWidth = width
        self.lastHeight = height

        self.surface = XCBSurface(self.connection, self.id, self.visual, width, height)

        self.connection.flush()

        for cookie in cookies:
            cookie.check()
Example #3
0
 def set_name(self, name: str) -> None:
     set_wm_name_checked(self.id, name).check()
Example #4
0
 def stop(self) -> None:
     set_wm_name_checked(self.message_window.id, "KILL").check()
     self.keep_going = False
     self.join()
     self.message_window.destroy()
Example #5
0
 def stop(self):
     set_wm_name_checked(self.message_window, "KILL").check()
     super(XHandler, self).stop()
     destroy_window(self.message_window)