Beispiel #1
0
 def call_setup(self):
     """
         Call this method to prepare the window:
         * makes sure it still exists
           (by querying its geometry which may raise an XError)
         * setup composite redirection
         * calls setup
         The difficulty comes from X11 errors and synchronization:
         we want to catch errors and undo what we've done.
         The mix of GTK and pure-X11 calls is not helping.
     """
     try:
         with xsync:
             geom = X11Window.geometry_with_border(self.xid)
             if geom is None:
                 raise Unmanageable("window %#x disappeared already" %
                                    self.xid)
             self._internal_set_property("geometry", geom[:4])
             self._read_initial_X11_properties()
     except XError as e:
         raise Unmanageable(e)
     add_event_receiver(self.client_window, self)
     # Keith Packard says that composite state is undefined following a
     # reparent, so I'm not sure doing this here in the superclass,
     # before we reparent, actually works... let's wait and see.
     try:
         self._composite = CompositeHelper(self.client_window)
         with xsync:
             self._composite.setup()
             if X11Window.displayHasXShape():
                 X11Window.XShapeSelectInput(self.xid)
     except Exception as e:
         remove_event_receiver(self.client_window, self)
         log("%s %#x does not support compositing: %s", self._MODELTYPE,
             self.xid, e)
         with xswallow:
             self._composite.destroy()
         self._composite = None
         if isinstance(e, Unmanageable):
             raise
         raise Unmanageable(e)
     #compositing is now enabled,
     #from now on we must call setup_failed to clean things up
     self._managed = True
     try:
         with xsync:
             self.setup()
     except XError as e:
         try:
             with xsync:
                 self.setup_failed(e)
         except Exception as ex:
             log.error("error in cleanup handler: %s", ex)
         raise Unmanageable(e)
     self._setup_done = True
Beispiel #2
0
    def setup(self):
        super(WindowModel, self).setup()

        x, y, w, h, _ = self.client_window.get_geometry()
        # We enable PROPERTY_CHANGE_MASK so that we can call
        # x11_get_server_time on this window.
        # clamp this window to the desktop size:
        x, y = self._clamp_to_desktop(x, y, w, h)
        self.corral_window = gdk.Window(self.parking_window,
                                        x=x, y=y, width=w, height=h,
                                        window_type=gdk.WINDOW_CHILD,
                                        wclass=gdk.INPUT_OUTPUT,
                                        event_mask=gdk.PROPERTY_CHANGE_MASK,
                                        title = "CorralWindow-%#x" % self.xid)
        log("setup() corral_window=%#x", self.corral_window.xid)
        prop_set(self.corral_window, "_NET_WM_NAME", "utf8", u"Xpra-CorralWindow-%#x" % self.xid)
        X11Window.substructureRedirect(self.corral_window.xid)
        add_event_receiver(self.corral_window, self)

        # The child might already be mapped, in case we inherited it from
        # a previous window manager.  If so, we unmap it now, and save the
        # serial number of the request -- this way, when we get an
        # UnmapNotify later, we'll know that it's just from us unmapping
        # the window, not from the client withdrawing the window.
        if X11Window.is_mapped(self.xid):
            log("hiding inherited window")
            self.last_unmap_serial = X11Window.Unmap(self.xid)

        log("setup() adding to save set")
        X11Window.XAddToSaveSet(self.xid)
        self.in_save_set = True

        log("setup() reparenting")
        X11Window.Reparent(self.xid, self.corral_window.xid, 0, 0)
        self.client_reparented = True

        geomlog("setup() geometry")
        geom = X11Window.geometry_with_border(self.xid)
        if geom is None:
            raise Unmanageable("window %#x disappeared already" % self.xid)
        w, h = geom[2:4]
        hints = self.get_property("size-hints")
        geomlog("setup() hints=%s size=%ix%i", hints, w, h)
        nw, nh = calc_constrained_size(w, h, hints)
        if nw>=MAX_WINDOW_SIZE or nh>=MAX_WINDOW_SIZE:
            #we can't handle windows that big!
            raise Unmanageable("window constrained size is too large: %sx%s (from client geometry: %s,%s with size hints=%s)" % (nw, nh, w, h, hints))
        self._updateprop("geometry", (x, y, nw, nh))
        geomlog("setup() resizing windows to %sx%s", nw, nh)
        self.corral_window.resize(nw, nh)
        self.client_window.resize(nw, nh)
        self.client_window.show_unraised()
        #this is here to trigger X11 errors if any are pending
        #or if the window is deleted already:
        self.client_window.get_geometry()
Beispiel #3
0
 def setup(self):
     super(OverrideRedirectWindowModel, self).setup()
     # So now if the window becomes unmapped in the future then we will
     # notice... but it might be unmapped already, and any event
     # already generated, and our request for that event is too late!
     # So double check now, *after* putting in our request:
     if not X11Window.is_mapped(self.xid):
         raise Unmanageable("window already unmapped")
     ch = self._composite.get_contents_handle()
     if ch is None:
         raise Unmanageable("failed to get damage handle")
Beispiel #4
0
 def setup(self):
     self.invalidate_pixmap()
     xid = self.client_window.xid
     geom = X11Window.geometry_with_border(xid)
     if geom is None:
         raise Unmanageable("window %#x disappeared already" % xid)
     self._border_width = geom[-1]
     self.create_damage_handle()
     add_event_receiver(self.client_window, self)