From: Kent Sutherland Date: Tue, 21 Feb 2006 20:06:07 +0000 (+0000) Subject: Fixed a crash in the core image effect. Using proper transparent bit in the CoreGraph... X-Git-Tag: MenuTunes-1.7~3 X-Git-Url: http://git.ithinksw.org/ITKit.git/commitdiff_plain/d89a0ca515b4db2cb0f4bbe6b7e4d709c5296eba Fixed a crash in the core image effect. Using proper transparent bit in the CoreGraphics hacks so that it doesn't throw that annoying console warning every launch. --- diff --git a/ITCoreGraphicsHacks.h b/ITCoreGraphicsHacks.h index c77185d..40c18d0 100644 --- a/ITCoreGraphicsHacks.h +++ b/ITCoreGraphicsHacks.h @@ -31,6 +31,13 @@ enum { kCGSTrue = 1 }; +typedef enum { + CGSTagExposeFade = 0x0002, // Fade out when Expose activates. + CGSTagNoShadow = 0x0008, // No window shadow. + CGSTagTransparent = 0x0200, // Transparent to mouse clicks. + CGSTagSticky = 0x0800, // Appears on all workspaces. +} CGSWindowTag; + extern void CGStyleRelease(CGStyleRef style); extern void CGSReleaseObj(void *obj); extern void CGContextSetStyle(CGContextRef c, CGStyleRef style); @@ -43,6 +50,10 @@ extern CGError CGSSetWindowProperty(const CGSConnectionID cid, CGSWindowID wid, extern CGError CGSSetWindowWarp(const CGSConnectionID cid, CGSWindowID wid, int w,int h, float *mesh); extern CGError CGSSetWindowTransform(const CGSConnectionID cid, CGSWindowID wid, CGAffineTransform transform); +extern OSStatus CGSGetWindowTags(const CGSConnectionID cid, const CGSWindowID wid, CGSWindowTag *tags, int thirtyTwo); +extern OSStatus CGSSetWindowTags(const CGSConnectionID cid, const CGSWindowID wid, CGSWindowTag *tags, int thirtyTwo); +extern OSStatus CGSClearWindowTags(const CGSConnectionID cid, const CGSWindowID wid, CGSWindowTag *tags, int thirtyTwo); + @interface NSApplication (ITCoreGraphicsHacks) - (CGSConnectionID)contextID; @end \ No newline at end of file diff --git a/ITCoreImageWindowEffect.m b/ITCoreImageWindowEffect.m index 9fd49aa..ea68c84 100644 --- a/ITCoreImageWindowEffect.m +++ b/ITCoreImageWindowEffect.m @@ -14,6 +14,8 @@ - (void)setupEffect; @end +static BOOL _running = NO; + @implementation ITCoreImageWindowEffect + (NSString *)effectName @@ -96,6 +98,7 @@ [self setWindowVisibility:ITWindowVisibleState]; __idle = YES; + if ( __shouldReleaseWhenIdle ) { [self release]; } @@ -119,10 +122,10 @@ - (void)performVanish { - __idle = NO; + __idle = NO; - [self setWindowVisibility:ITWindowVanishingState]; - [self performVanishFromProgress:1.0 effectTime:_effectTime]; + [self setWindowVisibility:ITWindowVanishingState]; + [self performVanishFromProgress:1.0 effectTime:_effectTime]; } - (void)performVanishFromProgress:(float)progress effectTime:(float)time @@ -166,7 +169,7 @@ [self setWindowVisibility:ITWindowHiddenState]; __idle = YES; - + if ( __shouldReleaseWhenIdle ) { [self release]; } @@ -192,6 +195,12 @@ NSRect rippleRect = [_window frame]; NSRect screenRect = [[_window screen] frame]; + if (_running) { + //Short-circuit to avoid layering effects and crashing + return; + } + + _running = YES; _ripple = YES; rippleRect.origin.y = - (NSMaxY(rippleRect) - screenRect.size.height); @@ -259,6 +268,8 @@ [[_effectWindow contentView] release]; [_effectWindow release]; [pool release]; + + _running = NO; } @end diff --git a/ITIconAndTextStatusWindow.m b/ITIconAndTextStatusWindow.m index 5b03fab..69e81e6 100644 --- a/ITIconAndTextStatusWindow.m +++ b/ITIconAndTextStatusWindow.m @@ -86,7 +86,7 @@ float maxHeight = ( screenHeight - (SW_BORDER * 2) ); float excessWidth = 0.0; float excessHeight = 0.0; - NSPoint windowOrigin; + NSPoint windowOrigin = NSZeroPoint; ITImageView *imageView; BOOL shouldAnimate = ( ! (([self visibilityState] == ITWindowAppearingState) || ([self visibilityState] == ITWindowVanishingState)) ); diff --git a/ITTransientStatusWindow.m b/ITTransientStatusWindow.m index 44a0b90..029aa79 100644 --- a/ITTransientStatusWindow.m +++ b/ITTransientStatusWindow.m @@ -120,14 +120,25 @@ static ITTransientStatusWindow *staticWindow = nil; - (void)setIgnoresMouseEvents:(BOOL)flag { - CGSValueObj key; - CGSValueObj ignore; + //CGSValueObj key; + //CGSValueObj ignore; + CGSWindowTag tags; - key = CGSCreateCString("IgnoreForEvents"); + /*key = CGSCreateCString("IgnoreForEvents"); ignore = CGSCreateBoolean( (flag ? kCGSTrue : kCGSFalse) ); CGSSetWindowProperty([NSApp contextID], (CGSWindowID)[self windowNumber], key, ignore); CGSReleaseObj(key); - CGSReleaseObj(ignore); + CGSReleaseObj(ignore);*/ + + CGSGetWindowTags([NSApp contextID], (CGSWindowID)[self windowNumber], &tags, 32); + + if (flag) { + tags = tags | CGSTagTransparent; + } else { + tags = tags & CGSTagTransparent; + } + + CGSSetWindowTags([NSApp contextID], (CGSWindowID)[self windowNumber], &tags, 32); _reallyIgnoresEvents = flag; }