Skip to content

Commit

Permalink
#1155: expose icc info from osx
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@12284 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Mar 30, 2016
1 parent 81a0b5e commit 3ca8c9d
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
39 changes: 39 additions & 0 deletions src/xpra/platform/darwin/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,45 @@ def get_window_frame_size(x, y, w, h):
}


def get_icc_info():
from AppKit import NSScreen #@UnresolvedImport
ms = NSScreen.mainScreen()
info = do_get_screen_icc_info(ms)
screens = NSScreen.screens()
for i, screen in enumerate(screens):
si = do_get_screen_icc_info(screen)
if si:
info[i] = si
return info

def do_get_screen_icc_info(nsscreen):
info = {}
try:
from AppKit import NSUnknownColorSpaceModel, NSGrayColorSpaceModel, NSRGBColorSpaceModel, NSCMYKColorSpaceModel, NSLABColorSpaceModel, NSDeviceNColorSpaceModel, NSIndexedColorSpaceModel, NSPatternColorSpaceModel #@UnresolvedImport
COLORSPACE_STR = {
NSUnknownColorSpaceModel : "unknown",
NSGrayColorSpaceModel : "gray",
NSRGBColorSpaceModel : "RGB",
NSCMYKColorSpaceModel : "CMYK",
NSLABColorSpaceModel : "LAB",
NSDeviceNColorSpaceModel : "DeviceN",
NSIndexedColorSpaceModel : "Indexed",
NSPatternColorSpaceModel : "Pattern",
}
mscs = nsscreen.colorSpace()
log("%s.colorSpace=%s", nsscreen, mscs)
info.update({
"colorspace" : COLORSPACE_STR.get(mscs.colorSpaceModel(), "unknown"),
"data" : str(mscs.ICCProfileData() or ""),
"name" : str(mscs.localizedName()),
"components" : mscs.numberOfColorComponents(),
})
except Exception as e:
log.warn("Warning: cannot query ICC profiles:")
log.warn(" %s", e)
return info


#global menu handling:
window_menus = {}

Expand Down
5 changes: 3 additions & 2 deletions src/xpra/platform/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def get_icc_info():
INTENT_ABSOLUTE_COLORIMETRIC : "absolute-colorimetric",
}
def getDefaultIntentStr(_p):
return INTENT_STR.get(getDefaultIntent(_p))
return INTENT_STR.get(getDefaultIntent(_p), "unknown")
p = get_display_profile()
if p:
for (k, fn) in {
Expand All @@ -115,6 +115,7 @@ def getDefaultIntentStr(_p):
log.warn(" %s", e)
return info


#global workarea for all screens
def get_workarea():
return None
Expand Down Expand Up @@ -267,7 +268,7 @@ def main():
except:
pass #maybe running on OSX? hope for the best..
i = get_info()
print_nested_dict(i, vformat=str)
print_nested_dict(i)


if __name__ == "__main__":
Expand Down
2 changes: 2 additions & 0 deletions src/xpra/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,8 @@ def vf(k, v):
try:
if k.find("version")>=0 or k.find("revision")>=0:
return nonl(pver(v)).lstrip("v")
elif k=="data":
return binascii.hexlify(v)
except:
pass
return nonl(pver(v, ", ", ", "))
Expand Down

0 comments on commit 3ca8c9d

Please sign in to comment.