xpra icon
Bug tracker and wiki

This bug tracker and wiki are being discontinued
please use https://github.com/Xpra-org/xpra instead.


Ticket #210: forward-window-server-uuid.patch

File forward-window-server-uuid.patch, 8.1 KB (added by Antoine Martin, 9 years ago)

forwards the server uuid the window originally belongs to

  • wimpiggy/window.py

     
    232232                        "Window type",
    233233                        "NB, most preferred comes first, then fallbacks",
    234234                        gobject.PARAM_READABLE),
     235        "server-uuid": (gobject.TYPE_STRING,
     236                "The server this window originates from", "",
     237                "",
     238                gobject.PARAM_READABLE),
    235239        # NB "notify" signal never fires for the client-contents properties:
    236240        "client-contents": (gobject.TYPE_PYOBJECT,
    237241                            "gtk.gdk.Pixmap containing the window contents", "",
     
    351355            window_types = [gtk.gdk.atom_intern(window_type)]
    352356        self._internal_set_property("window-type", window_types)
    353357
     358        #this may be set if the window is itself an xpra client window
     359        server_uuid = self.prop_get("_XPRA_SERVER_UUID", "latin1", ignore_errors=True)
     360        self._internal_set_property("server-uuid", server_uuid)
     361        log.info("window initial properties: server-uuid=%s", server_uuid)
     362
    354363    def _guess_window_type(self, transient_for):
    355364        if transient_for is not None:
    356365            # EWMH says that even if it's transient-for, we MUST check to
     
    396405    def do_wimpiggy_unmap_event(self, event):
    397406        self.unmanage()
    398407
    399     def prop_get(self, key, ptype):
    400         return prop_get(self.client_window, key, ptype, ignore_errors=False)
     408    def prop_get(self, key, ptype, ignore_errors=False):
     409        return prop_get(self.client_window, key, ptype, ignore_errors)
    401410
    402411    def get_dimensions(self):
    403412        ww, wh = self._geometry[2:4]
  • xpra/client_window.py

     
    238238        except Exception, e:
    239239            log.error("failed to set workspace: %s", e)
    240240
     241    def set_server_uuid(self):
     242        log.info("set_server_uuid() is_mapped=%s", is_mapped(self))
     243        if is_mapped(self) and not sys.platform.startswith("win"):
     244            server_uuid = self._metadata.get("server-uuid", "")
     245            try:
     246                from wimpiggy.prop import prop_set
     247                log.info("setting window server-uuid to %s", server_uuid)
     248                prop_set(self.get_window(), "_XPRA_SERVER_UUID", "latin1", unicode(server_uuid))
     249            except Exception, e:
     250                log.error("failed to set server-uuid: %s", e)   
     251
    241252    def is_OR(self):
    242253        return self._override_redirect
    243254
     
    338349                    log("setting window type to %s - %s", window_type, hint)
    339350                    self.set_type_hint(hint)
    340351                    break
     352       
     353        if "server-uuid" in self._metadata:
     354            self.set_server_uuid()
    341355
    342356    def update_icon(self, width, height, coding, data):
    343357        if coding == "premult_argb32":
     
    415429        if self.group_leader:
    416430            self.window.set_group(self.group_leader)
    417431        self.set_workspace()
     432        self.set_server_uuid()
    418433        if not self._override_redirect:
    419434            x, y, w, h = get_window_geometry(self)
    420435            client_properties = {"workspace" : self.get_workspace()}
  • xpra/server.py

     
    335335
    336336    # These are the names of WindowModel properties that, when they change,
    337337    # trigger updates in the xpra window metadata:
    338     _all_metadata = ("title", "pid", "size-hints", "class-instance", "icon", "client-machine", "transient-for", "window-type", "modal")
    339     _OR_metadata = ("transient-for", "window-type")
     338    _all_metadata = ("server-uuid", "title", "pid", "size-hints", "class-instance", "icon", "client-machine", "transient-for", "window-type", "modal")
     339    _OR_metadata = ("server-uuid", "transient-for", "window-type")
    340340
    341341
    342342
  • xpra/server_base.py

     
    536536        #max packet size from client (the biggest we can get are clipboard packets)
    537537        proto.max_packet_size = 1024*1024  #1MB
    538538        proto.chunked_compression = capabilities.get("chunked_compression", False)
    539         ss = ServerSource(proto, self.get_transient_for,
    540                           self.supports_mmap,
    541                           self.supports_speaker, self.supports_microphone,
    542                           self.speaker_codecs, self.microphone_codecs,
    543                           self.default_quality)
     539        ss = self.new_ServerSource(proto)
    544540        ss.parse_hello(capabilities)
    545541        self._server_sources[proto] = ss
    546542        if self.randr:
     
    576572        # now we can set the modifiers to match the client
    577573        self.send_windows_and_cursors(ss)
    578574
     575    def new_ServerSource(self, proto):
     576        return ServerSource(proto, self.uuid, self.get_transient_for,
     577                          self.supports_mmap,
     578                          self.supports_speaker, self.supports_microphone,
     579                          self.speaker_codecs, self.microphone_codecs,
     580                          self.default_quality)
     581
    579582    def check_server_uuid(self, proto, server_uuid):
    580583        if server_uuid:
    581584            if server_uuid==self.uuid:
  • xpra/server_source.py

     
    401401    damage_packet_queue.
    402402    """
    403403
    404     def __init__(self, protocol, get_transient_for,
     404    def __init__(self, protocol, server_uuid, get_transient_for,
    405405                 supports_mmap,
    406406                 supports_speaker, supports_microphone,
    407407                 speaker_codecs, microphone_codecs,
    408408                 default_quality):
     409        self.server_uuid = server_uuid
    409410        self.closed = False
    410411        self.ordinary_packets = []
    411412        self.protocol = protocol
     
    433434
    434435        self.uuid = ""
    435436        self.hostname = ""
     437        self.client_server_uuid = ""                #this is the server uuid of where the client is running (if running within an xpra server)
    436438        # client capabilities/options:
    437439        self.client_type = None
    438440        self.client_version = None
     
    497499        #client uuid:
    498500        self.uuid = capabilities.get("uuid", "")
    499501        self.hostname = capabilities.get("hostname", "")
     502        self.client_server_uuid = capabilities.get("server_uuid", "")
    500503        self.client_type = capabilities.get("client_type", "PyGTK")
    501504        self.client_platform = capabilities.get("platform", "")
    502505        self.client_version = capabilities.get("version", None)
     
    638641            return {"modal" : window.get_property("modal")}
    639642        elif propname == "pid":
    640643            return {"pid" : window.get_property("pid") or -1}
     644        elif propname == "server-uuid":
     645            #pass the server-uuid set on the window if set, or our one
     646            return {"server-uuid" : window.get_property("server-uuid") or self.server_uuid}
    641647        elif propname == "size-hints":
    642648            hints_metadata = {}
    643649            hints = window.get_property("size-hints")
     
    951957            return  False
    952958        if window.is_tray() and not self.system_tray:
    953959            return  False
     960        try:
     961            server_uuid = window.prop_get("_XPRA_SERVER_UUID", "latin1", ignore_errors=True)
     962        except Exception, e:
     963            server_uuid = "FAILED: %s" % e
     964        log.warn("can_send_window(%s) window server-uuid=%s, our server-uuid=%s, client's server uuid=%s", window, server_uuid, self.server_uuid, self.client_server_uuid)
     965        if not server_uuid:
     966            server_uuid = self.server_uuid
     967        if self.client_server_uuid and server_uuid and server_uuid==self.client_server_uuid:
     968            log.warn("ignoring window %s because of server-uuid", window)
     969            return  False
    954970        return True
    955971
    956972    def new_tray(self, wid, window, w, h):