Exemplo n.º 1
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.º 2
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.º 3
0
 def get_monitor_area(self):
     return rect.get_monitor_area(self.geom, state.monitors)
Exemplo n.º 4
0
def init():
    global _window, _box

    _window = gtk.Window(gtk.WINDOW_TOPLEVEL)

    _window.connect('delete_event', gtk.main_quit)

    if config.dock:
        _window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DOCK)
    else:
        _window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_NORMAL)

    if config.sticky:
        _window.stick()
    if config.above:
        _window.set_keep_above(True)

    _window.set_resizable(False)
    _window.set_decorated(False)
    _window.set_title('pager-multihead')
    _window.set_skip_pager_hint(True)
    _window.set_skip_taskbar_hint(True)
    _window.set_geometry_hints(None, min_width=config.width,
                               min_height=config.height, max_width=config.width,
                               max_height=config.height)
    _window.move(config.x, config.y)

    _window.modify_bg(gtk.STATE_NORMAL, 
                      gtk.gdk.color_parse(config.pager_bgcolor))

    if state.orient == 'H':
        _box = gtk.HBox(True, 0)
    else:
        _box = gtk.VBox(True, 0)
    _window.add(_box)

    for i in xrange(state.desk_num):
        d = Desktop(i)
        _box.pack_start(d.box, True, True, 0)
        desktops.append(d)

    update_desktop_order()
    _window.show_all()

    # If the user says to set struts, we *will* do it.
    # We are a little bit smart, though... We'll account for dead area.
    # This does not allow for between-monitor struts... For another day!
    if config.struts:
        wx, wy, ww, wh = config.x, config.y, config.width, config.height
        mx, my, mw, mh = rect.get_monitor_area((wx, wy, ww, wh), state.monitors)
        rw, rh = state.root_geom['width'], state.root_geom['height']

        struts = { nm: 0 for nm in
                            ['left', 'right', 'top', 'bottom',
                             'left_start_y', 'left_end_y',
                             'right_start_y', 'right_end_y',
                             'top_start_x', 'top_end_x',
                             'bottom_start_x', 'bottom_end_x'] }
        if state.orient == 'V':
            # left or right?
            if wx < rw / 2: # left
                struts['left'] = ww + mx + wx
                struts['left_start_y'] = wy
                struts['left_end_y'] = wy + wh
            else: # right
                struts['right'] = ww + rw - mw - mx
                struts['right_start_y'] = wy
                struts['right_end_y'] = wy + wh
        else:
            # top or bottom?
            if wy < rh / 2: # top
                struts['top'] = wh + my
                struts['top_start_x'] = wx
                struts['top_end_x'] = wx + ww
            else: #bottom
                struts['bottom'] = wh + rh - mh - my
                struts['bottom_start_x'] = wx
                struts['bottom_end_x'] = wx + ww

        ewmh.set_wm_strut_partial_checked(_window.window.xid, **struts).check()
Exemplo n.º 5
0
 def get_monitor_area(self):
     return rect.get_monitor_area(self.geom, state.monitors)
Exemplo n.º 6
0
def init():
    global _window, _box

    _window = gtk.Window(gtk.WINDOW_TOPLEVEL)

    _window.connect('delete_event', gtk.main_quit)

    if config.dock:
        _window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DOCK)
    else:
        _window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_NORMAL)

    if config.sticky:
        _window.stick()
    if config.above:
        _window.set_keep_above(True)

    _window.set_resizable(False)
    _window.set_decorated(False)
    _window.set_title('pager-multihead')
    _window.set_skip_pager_hint(True)
    _window.set_skip_taskbar_hint(True)
    _window.set_geometry_hints(None,
                               min_width=config.width,
                               min_height=config.height,
                               max_width=config.width,
                               max_height=config.height)
    _window.move(config.x, config.y)

    _window.modify_bg(gtk.STATE_NORMAL,
                      gtk.gdk.color_parse(config.pager_bgcolor))

    expand = config.desk_views(config)
    if state.orient == 'H':
        _box = gtk.HBox(expand, 0)
    else:
        _box = gtk.VBox(expand, 0)
    _window.add(_box)

    for i in xrange(state.desk_num):
        d = Desktop(i)
        _box.pack_start(d.box, expand, expand, 0)
        desktops.append(d)

    update_desktop_order()
    _window.show_all()

    # If the user says to set struts, we *will* do it.
    # We are a little bit smart, though... We'll account for dead area.
    # This does not allow for between-monitor struts... For another day!
    if config.struts:
        wx, wy, ww, wh = config.x, config.y, config.width, config.height
        mx, my, mw, mh = rect.get_monitor_area((wx, wy, ww, wh),
                                               state.monitors)
        rw, rh = state.root_geom['width'], state.root_geom['height']

        struts = {
            nm: 0
            for nm in [
                'left', 'right', 'top', 'bottom', 'left_start_y', 'left_end_y',
                'right_start_y', 'right_end_y', 'top_start_x', 'top_end_x',
                'bottom_start_x', 'bottom_end_x'
            ]
        }
        if state.orient == 'V':
            # left or right?
            if wx < rw / 2:  # left
                struts['left'] = ww + mx + wx
                struts['left_start_y'] = wy
                struts['left_end_y'] = wy + wh
            else:  # right
                struts['right'] = ww + rw - mw - mx
                struts['right_start_y'] = wy
                struts['right_end_y'] = wy + wh
        else:
            # top or bottom?
            if wy < rh / 2:  # top
                struts['top'] = wh + my
                struts['top_start_x'] = wx
                struts['top_end_x'] = wx + ww
            else:  #bottom
                struts['bottom'] = wh + rh - mh - my
                struts['bottom_start_x'] = wx
                struts['bottom_end_x'] = wx + ww

        ewmh.set_wm_strut_partial_checked(_window.window.xid, **struts).check()