Hi and thank both of you for replying.
I can confirm that the same thing works fine on Mac OS X Lion.
Unfortunately, Mavericks is not going away any time soon, and it’s a little scary that we appear to be the only ones trying to show transparent icons on the latest Mac OS X.
I now managed to download and compile the sources for Tcl/Tk 8.6.1 and using printf:s around the code I managed to track down the problem:
- The way Tk composits photo images with alpha by creating an image of the background window and manually blending that image with the transparent image (see TkImgPhotoDisplay() in tkImgPhInstance.c).
- When it fails to create the image of the background image, it simply draws the image without alpha (see TkImgPhotoDisplay() @ “We failed to get the image so draw without blending alpha. It's the best we can do”).
- The problem is in case is that exactly that fails.
- The reason for the failure is inside XCopyArea() in tkMacOSXDraw.c. There we can find this code:
NSView *view = TkMacOSXDrawableView(srcDraw);
NSWindow *w = [view window];
NSInteger gs = [w windowNumber] > 0 ? [w gState] : 0;
… and gs becomes 0, which makes the method return prematurely.
When googling for NSWindow gState, I found this:
where it states:
Beginning in Mac OS X 10.9 -[NSView allocateGState] and -[NSView releaseGState] are no ops. These methods were seldom used. Additionally, methods that relied on the side effects of these methods, specifically -[NSView gState] and -[NSWindow gState] will now always return 0.
That would explain it, I think… But I don’t know what “gState” is and I don’t know how to solve it.
On 11/29/13, 3:58 AM, Wojciech Kocjan wrote:
- happens on OS X 10.9 only - does not happen on 10.8 and below (also,
transparency works fine on all other systems and all other OS X
versions, so I suspect this is a change in OS X 10.9 that broke it)
- happens with latest Tcl/Tk from fossil, latest ActiveTcl
- happens with both tkpng and Img
- I can also confirm it only happens with Cocoa, not Carbon
So this is definitely an issue with Tk.
I'm not certain where to start with this. I've seen reports in Apple's
dev forums about wonky color calibration in Mavericks (sRGB is no longer
accurately rendered in many contexts, which is causing headaches for
graphics shops), yet Linus reports that images created with the
tk::mac::IconBitmap command (which is just a thin wrapper around various
NSImage methods) work just fine. NSImage is itself an opaque wrapper
around many, many different things.
If the issues with alpha channel rendering are based in the system
changes in Mavericks, I am not optimistic about fixing them...it does
not seem like a good idea to try to special-case image code in the Img,
TkPNG, and 8.6 core, I would think. (Nor would I even know where to
Code by Kevin/Mobile Code by Kevin
Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
Tcl-mac mailing list