Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* use CARDINAL for the version number just like everyone else (despite the spec)
* move X11 get_icc_info implementation to xposix: cleaner code, more re-usable

git-svn-id: https://xpra.org/svn/Xpra/trunk@14446 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Nov 18, 2016
1 parent cd20cfa commit 860d3ee
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 28 deletions.
26 changes: 0 additions & 26 deletions src/xpra/client/gtk_base/gtk_client_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,32 +301,6 @@ def get_image(self, icon_name, size=None):
return None


def get_icc_info(self):
try:
from xpra.x11.gtk_x11.prop import prop_get
except ImportError:
pass
else:
root = self.get_root_window()
data = prop_get(root, "_ICC_PROFILE", ["u32"], ignore_errors=True)
screenlog("_ICC_PROFILE=%s", data)
if data:
#repack the data as a binary string:
#(prop_get gives us an array of Integers..)
import struct
bin_data = "".join(struct.pack("=I", x) for x in data)
import binascii
v = prop_get(root, "_ICC_PROFILE_IN_X_VERSION", "latin1", ignore_errors=True)
screenlog("get_icc_info() found _ICC_PROFILE_IN_X_VERSION=%s, _ICC_PROFILE=%s", v, binascii.hexlify(bin_data))
return {
"source" : "_ICC_PROFILE",
"data" : bin_data,
}
return UIXpraClient.get_icc_info(self)
#def get_display_icc_info(self):
#TODO


def request_frame_extents(self, window):
from xpra.x11.gtk_x11.send_wm import send_wm_request_frame_extents
from xpra.gtk_common.error import xsync
Expand Down
42 changes: 42 additions & 0 deletions src/xpra/platform/xposix/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# later version. See the file COPYING for details.

import os
import sys
import struct
import binascii

Expand Down Expand Up @@ -93,6 +94,7 @@ def _get_X11_window_property(xid, name, req_type):
log("_get_X11_window_property(%#x, %s, %s): %s", xid, name, req_type, e)
except Exception as e:
log.warn("failed to get X11 window property %s on window %#x: %s", name, xid, e)
log("get_X11_window_property%s", (xid, name, req_type), exc_info=True)
return None
def _get_X11_root_property(name, req_type):
try:
Expand Down Expand Up @@ -226,6 +228,32 @@ def get_ydpi():
return _get_randr_dpi()[1]


def get_icc_info():
try:
data = _get_X11_root_property("_ICC_PROFILE", "CARDINAL")
if data:
screenlog("_ICC_PROFILE=%s (%s)", type(data), len(data))
#repack the data as a binary string of 8-bit data:
#(instead of a string made of CARD32 values containing just 8-bit)
assert len(data)%4==0, "_ICC_PROFILE CARD32 data length is not a multiple of 4!"
card32 = struct.unpack("=%iI" % (len(data)//4), data)
bin_data = b"".join(struct.pack("=B", x) for x in card32)
version = _get_X11_root_property("_ICC_PROFILE_IN_X_VERSION", "CARDINAL")
screenlog("get_icc_info() found _ICC_PROFILE_IN_X_VERSION=%s, _ICC_PROFILE=%s", version, binascii.hexlify(bin_data))
icc = {
"source" : "_ICC_PROFILE",
"data" : bin_data,
}
if version:
icc["version"] = version
return icc
except Exception as e:
screenlog.error("Error: cannot access _ICC_PROFILE X11 window property")
screenlog.error(" %s", e)
screenlog("get_icc_info()", exc_info=True)
return {}


def get_antialias_info():
info = {}
try:
Expand Down Expand Up @@ -630,3 +658,17 @@ def _handle_root_prop_changed(self, obj, prop):
self.client.desktops_changed("from %s event" % self._root_props_watcher)
else:
log.error("unknown property %s", prop)


def main():
try:
from xpra.x11.gtk2 import gdk_display_source
assert gdk_display_source
except:
pass
from xpra.platform.gui import main
main()


if __name__ == "__main__":
sys.exit(main())
4 changes: 2 additions & 2 deletions src/xpra/x11/x11_server_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,9 +560,9 @@ def set_icc_profile(self):
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?
#each CARD32 contains just one 8-bit value - don't ask me why
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
prop_set(self.root_window, "_ICC_PROFILE_IN_X_VERSION", "u32", 0*100+4) #0.4 -> 0*100+4*1

def reset_icc_profile(self):
screenlog("reset_icc_profile()")
Expand Down

0 comments on commit 860d3ee

Please sign in to comment.