Exemplo n.º 1
0
 def add(self, c, above=None):
     if c.floating:
         if getattr(config, 'remove_decorations', False):
             motif.set_hints_checked(
                 c.wid, 2, decoration=1).check()  # add decorations
         if getattr(config, 'tiles_below', False):
             ewmh.request_wm_state_checked(
                 c.wid, 0, util.get_atom('_NET_WM_STATE_BELOW')).check()
         self.floats.append(c)
     else:
         #restore window if maximized
         #ewmh.request_wm_state_checked(c.wid,0,util.get_atom('_NET_WM_STATE_MAXIMIZED_VERT')).check()
         #ewmh.request_wm_state_checked(c.wid,0,util.get_atom('_NET_WM_STATE_MAXIMIZED_HORZ')).check()
         if getattr(config, 'remove_decorations', False):
             motif.set_hints_checked(
                 c.wid, 2, decoration=2).check()  #remove decorations
         if getattr(config, 'tiles_below', False):
             ewmh.request_wm_state_checked(
                 c.wid, 1, util.get_atom('_NET_WM_STATE_BELOW')).check()
         if len(self.masters) < self.mcnt:
             if c in self.slaves:
                 self.slaves.remove(c)
             self.masters.append(c)
         elif c not in self.slaves:
             self.slaves.append(c)
Exemplo n.º 2
0
	def is_maximized(self):
		vatom = util.get_atom('_NET_WM_STATE_MAXIMIZED_VERT')
		hatom = util.get_atom('_NET_WM_STATE_MAXIMIZED_HORZ')
		
		states = ewmh.get_wm_state(self.wid).reply()
		
		return vatom in states and hatom in states
Exemplo n.º 3
0
    def update_state(self):
        self.hidden = False

        hatom = util.get_atom('_NET_WM_STATE_HIDDEN')
        states = ewmh.get_wm_state(self.wid).reply()
        if states is not None and hatom in states:
            self.hidden = True
Exemplo n.º 4
0
 def update_state(self):
     self.hidden = False
     
     hatom = util.get_atom('_NET_WM_STATE_HIDDEN')
     states = ewmh.get_wm_state(self.wid).reply()
     if states is not None and hatom in states:
         self.hidden = True
Exemplo n.º 5
0
    def restore(self):
        debug('Restoring %s' % self)
        if getattr(config, 'remove_decorations', False):
            motif.set_hints_checked(self.wid, 2, decoration=1).check()
        if getattr(config, 'tiles_below', False):
            ewmh.request_wm_state_checked(
                self.wid, 0, util.get_atom('_NET_WM_STATE_BELOW')).check()
        if self.saved_state:
            fullymaxed = False
            vatom = util.get_atom('_NET_WM_STATE_MAXIMIZED_VERT')
            hatom = util.get_atom('_NET_WM_STATE_MAXIMIZED_HORZ')

            if vatom in self.saved_state and hatom in self.saved_state:
                fullymaxed = True
                ewmh.request_wm_state_checked(self.wid, 1, vatom,
                                              hatom).check()
            elif vatom in self.saved_state:
                ewmh.request_wm_state_checked(self.wid, 1, vatom).check()
            elif hatom in self.saved_state:
                ewmh.request_wm_state_checked(self.wid, 1, hatom).check()

            # No need to continue if we've fully maximized the window
            if fullymaxed:
                return

        mnow = rect.get_monitor_area(window.get_geometry(self.wid),
                                     state.monitors)
        mold = rect.get_monitor_area(self.saved_geom, state.monitors)

        x, y, w, h = self.saved_geom

        # What if the client is on a monitor different than what it was before?
        # Use the same algorithm in Openbox to convert one monitor's
        # coordinates to another.
        if mnow != mold:
            nowx, nowy, noww, nowh = mnow
            oldx, oldy, oldw, oldh = mold

            xrat, yrat = float(noww) / float(oldw), float(nowh) / float(oldh)

            x = nowx + (x - oldx) * xrat
            y = nowy + (y - oldy) * yrat
            w *= xrat
            h *= yrat

        window.moveresize(self.wid, x, y, w, h)
Exemplo n.º 6
0
 def add(self, c, above=None):
     if c.floating:
         if config.remove_decorations:
             motif.set_hints_checked(c.wid,2,decoration=1).check() # add decorations
         if config.tiles_below:
             ewmh.request_wm_state_checked(c.wid,0,util.get_atom('_NET_WM_STATE_BELOW')).check()
         self.floats.append(c)
     else:
         if config.remove_decorations:
             motif.set_hints_checked(c.wid,2,decoration=2).check() #remove decorations
         if config.tiles_below:
             ewmh.request_wm_state_checked(c.wid,1,util.get_atom('_NET_WM_STATE_BELOW')).check()
         if len(self.masters) < self.mcnt:
             if c in self.slaves:
                 self.slaves.remove(c)
             self.masters.append(c)
         elif c not in self.slaves:
             self.slaves.append(c)
Exemplo n.º 7
0
 def add(self, c, above=None):
     if c.floating:
         if getattr(config, 'remove_decorations', False):
             motif.set_hints_checked(c.wid,2,decoration=1).check() # add decorations
         if getattr(config, 'tiles_below', False):
             ewmh.request_wm_state_checked(c.wid,0,util.get_atom('_NET_WM_STATE_BELOW')).check()
         self.floats.append(c)
     else:
         if getattr(config, 'remove_decorations', False):
             motif.set_hints_checked(c.wid,2,decoration=2).check() #remove decorations
         if getattr(config, 'tiles_below', False):
             ewmh.request_wm_state_checked(c.wid,1,util.get_atom('_NET_WM_STATE_BELOW')).check()
         if len(self.masters) < self.mcnt:
             if c in self.slaves:
                 self.slaves.remove(c)
             self.masters.append(c)
         elif c not in self.slaves:
             self.slaves.append(c)
Exemplo n.º 8
0
 def remove(self):
     if config.tiles_below and not self.floating:
         ewmh.request_wm_state_checked(self.wid, 0, util.get_atom("_NET_WM_STATE_BELOW")).check()
     tile.update_client_removal(self)
     debug("Disconnecting from %s" % self)
     event.disconnect("ConfigureNotify", self.parentid)
     event.disconnect("PropertyNotify", self.wid)
     event.disconnect("FocusIn", self.wid)
     event.disconnect("FocusOut", self.wid)
Exemplo n.º 9
0
    def restore(self):
        debug('Restoring %s' % self)
        if config.remove_decorations:
            motif.set_hints_checked(self.wid,2,decoration=1).check()
        if config.tiles_below:
            ewmh.request_wm_state_checked(self.wid,0,util.get_atom('_NET_WM_STATE_BELOW')).check()
        if self.saved_state:
            fullymaxed = False
            vatom = util.get_atom('_NET_WM_STATE_MAXIMIZED_VERT')
            hatom = util.get_atom('_NET_WM_STATE_MAXIMIZED_HORZ')

            if vatom in self.saved_state and hatom in self.saved_state:
                fullymaxed = True
                ewmh.request_wm_state_checked(self.wid, 1, vatom, hatom).check()
            elif vatom in self.saved_state:
                ewmh.request_wm_state_checked(self.wid, 1, vatom).check()
            elif hatom in self.saved_state:
                ewmh.request_wm_state_checked(self.wid, 1, hatom).check()

            # No need to continue if we've fully maximized the window
            if fullymaxed:
                return
            
        mnow = rect.get_monitor_area(window.get_geometry(self.wid),
                                     state.monitors)
        mold = rect.get_monitor_area(self.saved_geom, state.monitors)

        x, y, w, h = self.saved_geom

        # What if the client is on a monitor different than what it was before?
        # Use the same algorithm in Openbox to convert one monitor's 
        # coordinates to another.
        if mnow != mold:
            nowx, nowy, noww, nowh = mnow
            oldx, oldy, oldw, oldh = mold

            xrat, yrat = float(noww) / float(oldw), float(nowh) / float(oldh)

            x = nowx + (x - oldx) * xrat
            y = nowy + (y - oldy) * yrat
            w *= xrat
            h *= yrat

        window.moveresize(self.wid, x, y, w, h)
Exemplo n.º 10
0
 def remove(self):
     if config.tiles_below and not self.floating:
         ewmh.request_wm_state_checked(
             self.wid, 0, util.get_atom('_NET_WM_STATE_BELOW')).check()
     tile.update_client_removal(self)
     debug('Disconnecting from %s' % self)
     event.disconnect('ConfigureNotify', self.parentid)
     event.disconnect('PropertyNotify', self.wid)
     event.disconnect('FocusIn', self.wid)
     event.disconnect('FocusOut', self.wid)
Exemplo n.º 11
0
 def remove(self, c):
     if c in self.floats:
         self.floats.remove(c)
     else:
         if config.tiles_below:
             ewmh.request_wm_state_checked(c.wid,0,util.get_atom('_NET_WM_STATE_BELOW')).check()
         if c in self.masters:
             self.masters.remove(c)
             if len(self.masters) < self.mcnt and self.slaves:
                 self.masters.append(self.slaves.pop(0))
         elif c in self.slaves:
             self.slaves.remove(c)
Exemplo n.º 12
0
 def add(self, c, above=None):
     if c.floating:
         self.floats.append(c)
     else:
         if config.tiles_below:
             ewmh.request_wm_state_checked(c.wid,1,util.get_atom('_NET_WM_STATE_BELOW')).check()
         if len(self.masters) < self.mcnt:
             if c in self.slaves:
                 self.slaves.remove(c)
             self.masters.append(c)
         elif c not in self.slaves:
             self.slaves.append(c)
Exemplo n.º 13
0
 def add(self, c, above=None):
     if c.floating:
         self.floats.append(c)
     else:
         if config.tiles_below:
             ewmh.request_wm_state_checked(
                 c.wid, 1, util.get_atom('_NET_WM_STATE_BELOW')).check()
         if len(self.masters) < self.mcnt:
             if c in self.slaves:
                 self.slaves.remove(c)
             self.masters.append(c)
         elif c not in self.slaves:
             self.slaves.append(c)
Exemplo n.º 14
0
def pack_client_message(window, message_type, *data):
    assert len(data) <= 5

    if isinstance(message_type, basestring):
        message_type = util.get_atom(message_type)

    data = list(data)
    data += [0] * (5 - len(data))

    # Taken from
    # http://xcb.freedesktop.org/manual/structxcb__client__message__event__t.html
    return struct.pack('BBH7I', Event.ClientMessageEvent, 32, 0, window,
                       message_type, *data)
Exemplo n.º 15
0
 def remove(self, c):
     if c in self.floats:
         self.floats.remove(c)
     else:
         if config.tiles_below:
             ewmh.request_wm_state_checked(
                 c.wid, 0, util.get_atom('_NET_WM_STATE_BELOW')).check()
         if c in self.masters:
             self.masters.remove(c)
             if len(self.masters) < self.mcnt and self.slaves:
                 self.masters.append(self.slaves.pop(0))
         elif c in self.slaves:
             self.slaves.remove(c)
Exemplo n.º 16
0
def pack_client_message(window, message_type, *data):
    assert len(data) <= 5

    if isinstance(message_type, stringtype):
        message_type = util.get_atom(message_type)

    data = list(data)
    data += [0] * (5 - len(data))

    # Taken from
    # http://xcb.freedesktop.org/manual/structxcb__client__message__event__t.html
    return struct.pack('BBH7I', Event.ClientMessageEvent, 32, 0, window,
                       message_type, *data)
Exemplo n.º 17
0
def unset_fullscreen(window: Window) -> None:
    request_wm_state_checked(
        window.id, action=0,
        first=get_atom("_NET_WM_STATE_FULLSCREEN")).check()
def client_is_normal(client):
    wtype = ewmh.get_wm_window_type(client).reply()
    if not wtype or wtype[0] == util.get_atom('_NET_WM_WINDOW_TYPE_NORMAL'):
        return True
    return False
Exemplo n.º 19
0
def client_is_normal(client):
    wtype = ewmh.get_wm_window_type(client).reply()
    if not wtype or wtype[0] == util.get_atom('_NET_WM_WINDOW_TYPE_NORMAL'):
        return True
    return False
Exemplo n.º 20
0
def add_atom(atom_str):
    global atom_cache
    module = sys.modules[__name__]
    atom  =  util.get_atom(atom_str)
    setattr(module, atom_str, atom)
    atom_cache.append(getattr(module, atom_str))
Exemplo n.º 21
0
	def minimize(self):
		atom = util.get_atom('_NET_WM_STATE_HIDDEN')
		ewmh.request_wm_state_checked(self.wid, State.Add, atom).check()
Exemplo n.º 22
0
 def unmaximize(self):
     vatom = util.get_atom('_NET_WM_STATE_MAXIMIZED_VERT')
     hatom = util.get_atom('_NET_WM_STATE_MAXIMIZED_HORZ')
     ewmh.request_wm_state_checked(self.wid, 0, vatom, hatom).check()