Ejemplo n.º 1
0
    def _set_wm_state(self, *states):
        # Set property
        net_wm_state = xlib.XInternAtom(self._x_display, '_NET_WM_STATE', False)
        atoms = []
        for state in states:
            atoms.append(xlib.XInternAtom(self._x_display, state, False))
        atom_type = xlib.XInternAtom(self._x_display, 'ATOM', False)
        if len(atoms):
            atoms_ar = (xlib.Atom * len(atoms))(*atoms)
            xlib.XChangeProperty(self._x_display, self._window,
                net_wm_state, atom_type, 32, xlib.PropModePrepend,
                cast(pointer(atoms_ar), POINTER(c_ubyte)), len(atoms))
        else:
            xlib.XDeleteProperty(self._x_display, self._window, net_wm_state)

        # Nudge the WM
        e = xlib.XEvent()
        e.xclient.type = xlib.ClientMessage
        e.xclient.message_type = net_wm_state
        e.xclient.display = cast(self._x_display, POINTER(xlib.Display))
        e.xclient.window = self._window
        e.xclient.format = 32
        e.xclient.data.l[0] = xlib.PropModePrepend
        for i, atom in enumerate(atoms):
            e.xclient.data.l[i + 1] = atom
        xlib.XSendEvent(self._x_display, self._get_root(),
            False, xlib.SubstructureRedirectMask, byref(e))
Ejemplo n.º 2
0
 def _set_atoms_property(self, name, values, mode=xlib.PropModeReplace):
     name_atom = xlib.XInternAtom(self._x_display, asbytes(name), False)
     atoms = []
     for value in values:
         atoms.append(xlib.XInternAtom(self._x_display, asbytes(value), False))
     atom_type = xlib.XInternAtom(self._x_display, asbytes('ATOM'), False)
     if len(atoms):
         atoms_ar = (xlib.Atom * len(atoms))(*atoms)
         xlib.XChangeProperty(self._x_display, self._window,
             name_atom, atom_type, 32, mode,
             cast(pointer(atoms_ar), POINTER(c_ubyte)), len(atoms))
     else:
         xlib.XDeleteProperty(self._x_display, self._window, net_wm_state)