Skip to content

Commit

Permalink
#885: some properties should not be sent back to the client (usually …
Browse files Browse the repository at this point in the history
…comes from there - or is not useful there) but we still want them exposed via xpra info, define "internal_property_names" for those, use it for "frame", "allowed-actions" and "state"

git-svn-id: https://xpra.org/svn/Xpra/trunk@9953 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Jul 17, 2015
1 parent 67839f7 commit 3460dbb
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 13 deletions.
4 changes: 3 additions & 1 deletion src/xpra/server/server_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
from xpra.scripts.config import python_platform, parse_bool_or_int
from xpra.scripts.main import sound_option
from xpra.codecs.loader import PREFERED_ENCODING_ORDER, PROBLEMATIC_ENCODINGS, load_codecs, codec_versions, has_codec, get_codec
from xpra.codecs.codec_constants import get_PIL_encodings
from xpra.codecs.video_helper import getVideoHelper, ALL_VIDEO_ENCODER_OPTIONS, ALL_CSC_MODULE_OPTIONS
if sys.version > '3':
unicode = str #@ReservedAssignment
Expand Down Expand Up @@ -1550,6 +1549,9 @@ def get_window_info(self, window):
continue
metadata = make_window_metadata(window, prop, get_transient_for=self.get_transient_for)
info.update(metadata)
for prop in window.get_internal_property_names():
metadata = make_window_metadata(window, prop)
info.update(metadata)
if "size-constraints" in info:
size_constraints = info["size-constraints"]
del info["size-constraints"]
Expand Down
4 changes: 4 additions & 0 deletions src/xpra/server/shadow_server_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def __init__(self, root_window):
self.window = root_window
self.property_names = ["title", "class-instance", "client-machine", "window-type", "size-hints", "icon"]
self.dynamic_property_names = []
self.internal_property_names = []

def is_managed(self):
return True
Expand Down Expand Up @@ -57,6 +58,9 @@ def get_property_names(self):
def get_dynamic_property_names(self):
return self.dynamic_property_names

def get_internal_property_names(self):
return self.internal_property_names

def get_generic_os_name(self):
for k,v in {"linux" : "linux",
"darwin" : "osx",
Expand Down
38 changes: 26 additions & 12 deletions src/xpra/server/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,37 +54,39 @@


def make_window_metadata(window, propname, get_transient_for=None, get_window_id=None):
def raw():
return window.get_property(propname)
if propname in ("title", "icon-title", "command"):
v = window.get_property(propname)
v = raw()
if v is None:
return {propname: ""}
return {propname: v.encode("utf-8")}
elif propname in ("pid", "workspace", "bypass-compositor"):
v = window.get_property(propname)
v = raw()
assert v is not None, "%s is None!" % propname
if v<0 or (v==WORKSPACE_UNSET and propname=="workspace"):
#meaningless
return {}
return {propname : v}
elif propname == "size-hints":
hints = window.get_property("size-hints")
hints = raw()
if not hints:
return {}
return {"size-constraints": hints}
elif propname == "strut":
strut = window.get_property("strut")
strut = raw()
if not strut:
strut = {}
else:
strut = strut.todict()
return {"strut": strut}
elif propname == "class-instance":
c_i = window.get_property("class-instance")
c_i = raw()
if c_i is None:
return {}
return {"class-instance": [x.encode("utf-8") for x in c_i]}
elif propname == "client-machine":
client_machine = window.get_property("client-machine")
client_machine = raw()
if client_machine is None:
import socket
client_machine = socket.gethostname()
Expand All @@ -100,25 +102,25 @@ def make_window_metadata(window, propname, get_transient_for=None, get_window_id
return {}
elif propname in ("window-type", "shape"):
#always send unchanged:
return {propname : window.get_property(propname)}
return {propname : raw()}
elif propname in ("iconic", "fullscreen", "maximized", "decorations", "above", "below", "shaded", "sticky", "skip-taskbar", "skip-pager", "modal", "focused"):
#always send these when requested
return {propname : bool(window.get_property(propname))}
return {propname : bool(raw())}
elif propname in ("has-alpha", "override-redirect", "tray"):
v = window.get_property(propname)
v = raw()
if v is False:
#save space: all these properties are assumed false if unspecified
return {}
return {propname : v}
elif propname in ("role", "opacity", "fullscreen-monitors"):
v = window.get_property(propname)
v = raw()
if v is None or v=="":
return {}
return {propname : v}
elif propname == "xid":
return {"xid" : hex(window.get_property("xid") or 0)}
return {"xid" : hex(raw() or 0)}
elif propname == "group-leader":
gl = window.get_property("group-leader")
gl = raw()
if not gl or not get_window_id:
return {}
xid, gdkwin = gl
Expand All @@ -130,6 +132,18 @@ def make_window_metadata(window, propname, get_transient_for=None, get_window_id
if glwid:
p["group-leader-wid"] = glwid
return p
#the properties below are not actually exported to the client (yet?)
#it was just easier to handle them here
#(convert to a type that can be encoded for xpra info):
elif propname == "state":
return {"state" : list(raw() or [])}
elif propname == "allowed-actions":
return {"allowed-actions" : list(raw())}
elif propname == "frame":
frame = raw()
if not frame:
return {}
return {"frame" : list(frame)}
raise Exception("unhandled property name: %s" % propname)


Expand Down
1 change: 1 addition & 0 deletions src/xpra/x11/gtk2/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ class BaseWindowModel(CoreX11WindowModel):
_dynamic_property_names = CoreX11WindowModel._dynamic_property_names + [
"attention-requested",
"fullscreen", "focused", "maximized", "above", "below", "shaded", "skip-taskbar", "skip-pager", "sticky"]
_internal_property_names = CoreX11WindowModel._internal_property_names+["state"]
_initial_x11_properties = CoreX11WindowModel._initial_x11_properties + [
"WM_TRANSIENT_FOR",
"_NET_WM_WINDOW_TYPE",
Expand Down
8 changes: 8 additions & 0 deletions src/xpra/x11/gtk2/models/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,12 @@ class CoreX11WindowModel(AutoPropGObjectMixin, gobject.GObject):
"xpra-focus-out-event" : one_arg_signal,
}

#things that we expose:
_property_names = ["xid", "has-alpha", "client-machine", "pid", "title", "role", "command", "class-instance", "shape"]
#exposed and changing (should be watched for notify signals):
_dynamic_property_names = ["title", "command", "shape"]
#should not be exported to the clients:
_internal_property_names = ["frame", "allowed-actions"]
_initial_x11_properties = ["_NET_WM_PID", "WM_CLIENT_MACHINE",
"WM_NAME", "_NET_WM_NAME", #_NET_WM_NAME is redundant, as it calls the same handler as "WM_NAME"
"WM_PROTOCOLS", "WM_CLASS", "WM_WINDOW_ROLE"]
Expand Down Expand Up @@ -444,6 +448,10 @@ def get_dynamic_property_names(self):
""" The properties that may change over time """
return self._dynamic_property_names

def get_internal_property_names(self):
""" The properties that should not be exposed to the client """
return self._internal_property_names

def _updateprop(self, name, value):
""" Updates the property and fires notify(),
but only if the value has changed
Expand Down

0 comments on commit 3460dbb

Please sign in to comment.