Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* allow clients to provide ICC data using the XPRA_ICC_DATA env var
* hookup set_icc_profile and reset_icc_profile in server base class (noop implementation)
* implement support for ICC using X11 property _ICC_PROFILE

git-svn-id: https://xpra.org/svn/Xpra/trunk@13821 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Sep 22, 2016
1 parent 40ef1b8 commit 5e5d463
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/xpra/platform/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.

import os
import sys

_init_done = False
Expand Down Expand Up @@ -85,6 +86,13 @@ def get_display_icc_info():
def get_icc_info():
from xpra.log import Logger
log = Logger("platform")
ENV_ICC_DATA = os.environ.get("XPRA_ICC_DATA")
if ENV_ICC_DATA:
import binascii
return {
"name" : "environment-override",
"data" : binascii.unhexlify(ENV_ICC_DATA),
}
info = {}
try:
from PIL import ImageCms
Expand Down Expand Up @@ -279,7 +287,6 @@ def main():
x.enable_debug()

#naughty, but how else can I hook this up?
import os
if os.name=="posix":
try:
from xpra.x11.bindings import posix_display_source #@UnusedImport
Expand Down
10 changes: 10 additions & 0 deletions src/xpra/server/server_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -975,6 +975,7 @@ def last_client_exited(self):
except:
pass
self._focus(None, 0, [])
self.reset_icc_profile()


def get_all_protocols(self):
Expand Down Expand Up @@ -1206,6 +1207,7 @@ def do_parse_screen_info(self, ss):
w = min(w, maxw)
h = min(h, maxh)
self.set_desktop_geometry_attributes(w, h)
self.set_icc_profile()
return w, h

def set_screen_geometry_attributes(self, w, h):
Expand All @@ -1217,6 +1219,14 @@ def set_desktop_geometry_attributes(self, w, h):
self.calculate_workarea(w, h)
self.set_desktop_geometry(w, h)


def set_icc_profile(self):
pass

def reset_icc_profile(self):
pass


def parse_hello_ui_clipboard(self, ss, c):
#take the clipboard if no-one else has it yet:
if not ss.clipboard_enabled:
Expand Down
6 changes: 6 additions & 0 deletions src/xpra/server/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,9 @@ def __init__(self, protocol, disconnect_cb, idle_add, timeout_add, source_remove
self.av_sync_delay_total = 0
self.av_sync_delta = AV_SYNC_DELTA

self.icc = None
self.display_icc = {}

self.server_core_encodings = core_encodings
self.server_encodings = encodings
self.default_encoding = default_encoding
Expand Down Expand Up @@ -732,6 +735,9 @@ def parse_batch_int(value, varname):
self.set_screen_sizes(c.listget("screen_sizes"))
self.set_desktops(c.intget("desktops", 1), c.strlistget("desktop.names"))

self.icc = c.dictget("icc")
self.display_icc = c.dictget("display-icc")

#sound stuff:
self.pulseaudio_id = c.strget("sound.pulseaudio.id")
self.pulseaudio_server = c.strget("sound.pulseaudio.server")
Expand Down
7 changes: 7 additions & 0 deletions src/xpra/x11/shadow_x11_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,13 @@ def last_client_exited(self):
X11ServerBase.last_client_exited(self)


def set_icc_profile(self):
pass

def reset_icc_profile(self):
pass


def make_hello(self, source):
capabilities = X11ServerBase.make_hello(self, source)
capabilities.update(GTKShadowServerBase.make_hello(self, source))
Expand Down
30 changes: 30 additions & 0 deletions src/xpra/x11/x11_server_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,36 @@ def show_dpi():
return root_w, root_h


def set_icc_profile(self):
ui_clients = [s for s in self._server_sources.values() if s.ui_client]
if len(ui_clients)!=1:
screenlog("%i UI clients, not setting ICC profile")
self.reset_icc_profile()
return
icc = ui_clients[0].icc
data = None
for x in ("data", "icc-data", "icc-profile"):
if x in icc:
data = icc.get(x)
break
if not data:
screenlog("no icc data found in %s", icc)
self.reset_icc_profile()
return
import binascii
screenlog("set_icc_profile() icc data for %s: %s (%i bytes)", ui_clients[0], binascii.hexlify(data or ""), len(data or ""))
from xpra.x11.gtk_x11.prop import prop_set
#long byte data as CARDINAL and numbers as strings - wth?
prop_set(self.root_window, "_ICC_PROFILE", ["u32"], [ord(x) for x in data])
prop_set(self.root_window, "_ICC_PROFILE_IN_X_VERSION", "latin1", u"4") #0.4 -> 0*100+4*1

def reset_icc_profile(self):
screenlog("reset_icc_profile()")
from xpra.x11.gtk_x11.prop import prop_del
prop_del(self.root_window, "_ICC_PROFILE")
prop_del(self.root_window, "_ICC_PROFILE_IN_X_VERSION")


def do_cleanup(self, *args):
GTKServerBase.do_cleanup(self)
cleanup_fakeXinerama()
Expand Down

0 comments on commit 5e5d463

Please sign in to comment.