Exemplo n.º 1
0
    def set_below(self, below):
        self._send_client_event(
            Atom.get_atom('_NET_WM_STATE'),
            [
                1 if below else 0,
                Atom.get_atom('_NET_WM_STATE_BELOW'),
            ]
        )

        connection.push()
Exemplo n.º 2
0
    def restore(self):
        self._send_client_event(
            Atom.get_atom('_NET_WM_STATE'),
            [
                0, # _NET_WM_STATE_REMOVE = 0, _NET_WM_STATE_ADD = 1, _NET_WM_STATE_TOGGLE = 2
                Atom.get_atom('_NET_WM_STATE_MAXIMIZED_VERT'),
                Atom.get_atom('_NET_WM_STATE_MAXIMIZED_HORZ')
            ]
        )

        connection.push()
Exemplo n.º 3
0
    def remove_decorations(self):
        if XROOT.wm() == 'openbox':
            self._send_client_event(
                Atom.get_atom('_NET_WM_STATE'),
                [
                    1,
                    Atom.get_atom('_OB_WM_STATE_UNDECORATED')
                ]
            )
        else:
            self._set_property('_MOTIF_WM_HINTS', [2, 0, 0, 0, 0])

        connection.push()
Exemplo n.º 4
0
    def _get_property(self, atom_name):
        try:
            if not Atom.get_type_name(atom_name):
                return ''

            rsp = connection.get_core().GetProperty(
                False,
                self.wid,
                Atom.get_atom(atom_name),
                Atom.get_atom_type(atom_name),
                0,
                (2 ** 32) - 1
            ).reply()

            if Atom.get_type_name(atom_name) in ('UTF8_STRING', 'STRING'):
                if atom_name == 'WM_CLASS':
                    return Atom.null_terminated_to_strarray(rsp.value)
                else:
                    return Atom.ords_to_str(rsp.value)
            elif Atom.get_type_name(atom_name) in ('UTF8_STRING[]', 'STRING[]'):
                return Atom.null_terminated_to_strarray(rsp.value)
            else:
                return list(struct.unpack('I' * (len(rsp.value) / 4), rsp.value.buf()))
        except:
            pass
Exemplo n.º 5
0
 def set_desktop(self, desk):
     self._send_client_event(
         Atom.get_atom('_NET_WM_DESKTOP'),
         [
             desk,
             2
         ]
     )
Exemplo n.º 6
0
 def restack(self, below=False):
     self._send_client_event(
         Atom.get_atom('_NET_RESTACK_WINDOW'),
         [
             2 if not below else 1,
             self.wid,
             0
         ]
     )
Exemplo n.º 7
0
 def activate(self):
     self._send_client_event(
         Atom.get_atom('_NET_ACTIVE_WINDOW'),
         [
             2,
             xcb.xcb.CurrentTime,
             self.wid
         ]
     )
     self.stack(True)
Exemplo n.º 8
0
 def close(self):
     self._send_client_event(
         Atom.get_atom('_NET_CLOSE_WINDOW'),
         [
             xcb.xproto.Time.CurrentTime,
             2,
             0,
             0,
             0
         ]
     )
Exemplo n.º 9
0
    def __init__(self, wsid, x, y, width, height, color=0x000000):
        self._root_depth = connection.setup.roots[0].root_depth
        self._root_visual = connection.setup.roots[0].root_visual
        self._pixel = color

        self.wid  = connection.conn.generate_id()

        connection.get_core().CreateWindow(
            self._root_depth,
            self.wid,
            XROOT.wid,
            x,
            y,
            width,
            height,
            0,
            xcb.xproto.WindowClass.InputOutput,
            self._root_visual,
            xcb.xproto.CW.BackPixel,
            [self._pixel]
        )

        self._set_property('_NET_WM_NAME', 'Place holder')
        self.set_desktop(wsid)
        self._set_property('WM_NAME', 'pytyle-internal-window')
        self._set_property('WM_PROTOCOLS', [Atom.get_atom('WM_DELETE_WINDOW')])
        self._set_property(
            '_PYTYLE_TYPE',
            [
                Atom.get_atom('_PYTYLE_TYPE_PLACE_HOLDER')
            ]
        )

        #self.set_override_redirect(True)
        connection.get_core().MapWindow(self.wid)
        connection.push()
        self._moveresize(x, y, width, height)
        connection.push()
        #self.set_override_redirect(False)
        connection.push()
Exemplo n.º 10
0
    def _moveresize(self, x, y, width, height):
        #print self.get_wmname(), x, y, width, height
        self._send_client_event(
            Atom.get_atom('_NET_MOVERESIZE_WINDOW'),
            [
                xcb.xproto.Gravity.NorthWest
                | 1 << 8 | 1 << 9 | 1 << 10 | 1 << 11 | 1 << 13,
                x,
                y,
                width,
                height
            ],
            32,
            xcb.xproto.EventMask.StructureNotify
        )

        connection.push()
Exemplo n.º 11
0
    def _set_property(self, atom_name, value):
        try:
            if isinstance(value, list):
                data = struct.pack(len(value) * 'I', *value)
                data_len = len(value)
            else:
                value = str(value)
                data_len = len(value)
                data = value

            connection.get_core().ChangeProperty(
                xcb.xproto.PropMode.Replace,
                self.wid,
                Atom.get_atom(atom_name),
                Atom.get_atom_type(atom_name),
                Atom.get_atom_length(atom_name),
                data_len,
                data
            )
        except:
            print traceback.format_exc()