예제 #1
0
 def __init__(self, screen_number=0):
     selection = "_XSETTINGS_S%i" % screen_number
     self._manager = ManagerSelection(selection)
     # Technically I suppose ICCCM says we should use FORCE, but it's not
     # like a window manager where you have to wait for the old wm to clean
     # things up before you can do anything... as soon as the selection is
     # gone, the settings are gone. (Also, if we're stealing from
     # ourselves, we probably don't clean up the window properly.)
     self._manager.acquire(self._manager.FORCE_AND_RETURN)
     self._window = self._manager.window()
예제 #2
0
파일: wm.py 프로젝트: DiGuoZhiMeng/Xpra
    def __init__(self, replace_other_wm, wm_name, display=None):
        gobject.GObject.__init__(self)

        if display is None:
            display = display_get_default()
        self._display = display
        self._root = self._display.get_default_screen().get_root_window()
        self._wm_name = wm_name
        self._ewmh_window = None

        self._windows = {}
        # EWMH says we have to know the order of our windows oldest to
        # youngest...
        self._windows_in_order = []

        # Become the Official Window Manager of this year's display:
        self._wm_selection = ManagerSelection(self._display, "WM_S0")
        self._cm_wm_selection = ManagerSelection(self._display,
                                                 "_NET_WM_CM_S0")
        self._wm_selection.connect("selection-lost", self._lost_wm_selection)
        self._cm_wm_selection.connect("selection-lost",
                                      self._lost_wm_selection)
        # May throw AlreadyOwned:
        if replace_other_wm:
            mode = self._wm_selection.FORCE
        else:
            mode = self._wm_selection.IF_UNOWNED
        self._wm_selection.acquire(mode)
        self._cm_wm_selection.acquire(mode)

        # Set up the necessary EWMH properties on the root window.
        self._setup_ewmh_window()
        # Start with just one desktop:
        self.set_desktop_list((u"Main", ))
        self.set_current_desktop(0)
        # Start with the full display as workarea:
        root_w, root_h = get_default_root_window().get_geometry()[2:4]
        self.root_set("_NET_SUPPORTED", ["atom"], NET_SUPPORTED)
        self.set_workarea(0, 0, root_w, root_h)
        self.set_desktop_geometry(root_w, root_h)
        self.root_set("_NET_DESKTOP_VIEWPORT", ["u32"], [0, 0])

        self.size_constraints = DEFAULT_SIZE_CONSTRAINTS

        # Load up our full-screen widget
        self._world_window = None
        if not is_gtk3():
            self._world_window = WorldWindow(
                self._display.get_default_screen())
            self.notify("toplevel")
            self._world_window.show_all()

        # Okay, ready to select for SubstructureRedirect and then load in all
        # the existing clients.
        add_event_receiver(self._root, self)
        add_fallback_receiver("xpra-client-message-event", self)
        #when reparenting, the events may get sent
        #to a window that is already destroyed
        #and we don't want to miss those events, so:
        add_fallback_receiver("child-map-request-event", self)
        rxid = get_xwindow(self._root)
        X11Window.substructureRedirect(rxid)

        for w in get_children(self._root):
            # Checking for FOREIGN here filters out anything that we've
            # created ourselves (like, say, the world window), and checking
            # for mapped filters out any withdrawn windows.
            xid = get_xwindow(w)
            if (w.get_window_type() == GDKWINDOW_FOREIGN
                    and not X11Window.is_override_redirect(xid)
                    and X11Window.is_mapped(xid)):
                log("Wm managing pre-existing child window %#x", xid)
                self._manage_client(w)

        # Also watch for focus change events on the root window
        X11Window.selectFocusChange(rxid)
        X11Keyboard.selectBellNotification(True)