Fixed a crash in the core image effect. Using proper transparent bit in the CoreGraph...
authorKent Sutherland <ksuther@ithinksw.com>
Tue, 21 Feb 2006 20:06:07 +0000 (20:06 +0000)
committerKent Sutherland <ksuther@ithinksw.com>
Tue, 21 Feb 2006 20:06:07 +0000 (20:06 +0000)
ITCoreGraphicsHacks.h
ITCoreImageWindowEffect.m
ITIconAndTextStatusWindow.m
ITTransientStatusWindow.m

index c77185d..40c18d0 100644 (file)
@@ -31,6 +31,13 @@ enum {
        kCGSTrue = 1
 };
 
        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);
 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 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
 @interface NSApplication (ITCoreGraphicsHacks)
 - (CGSConnectionID)contextID;
 @end
\ No newline at end of file
index 9fd49aa..ea68c84 100644 (file)
@@ -14,6 +14,8 @@
 - (void)setupEffect;
 @end
 
 - (void)setupEffect;
 @end
 
+static BOOL _running = NO;
+
 @implementation ITCoreImageWindowEffect
 
 + (NSString *)effectName
 @implementation ITCoreImageWindowEffect
 
 + (NSString *)effectName
@@ -96,6 +98,7 @@
     [self setWindowVisibility:ITWindowVisibleState];
 
     __idle = YES;
     [self setWindowVisibility:ITWindowVisibleState];
 
     __idle = YES;
+       
     if ( __shouldReleaseWhenIdle ) {
         [self release];
     }
     if ( __shouldReleaseWhenIdle ) {
         [self release];
     }
 
 - (void)performVanish
 {
 
 - (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
 }
 
 - (void)performVanishFromProgress:(float)progress effectTime:(float)time
     [self setWindowVisibility:ITWindowHiddenState];
 
     __idle = YES;
     [self setWindowVisibility:ITWindowHiddenState];
 
     __idle = YES;
-    
+       
     if ( __shouldReleaseWhenIdle ) {
         [self release];
     }
     if ( __shouldReleaseWhenIdle ) {
         [self release];
     }
        NSRect rippleRect = [_window frame];
        NSRect screenRect = [[_window screen] frame];
        
        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);
        _ripple = YES;
        
     rippleRect.origin.y = - (NSMaxY(rippleRect) - screenRect.size.height);
        [[_effectWindow contentView] release];
     [_effectWindow release];
     [pool release];
        [[_effectWindow contentView] release];
     [_effectWindow release];
     [pool release];
+       
+       _running = NO;
 }
 
 @end
 }
 
 @end
index 5b03fab..69e81e6 100644 (file)
@@ -86,7 +86,7 @@
     float        maxHeight     = ( screenHeight - (SW_BORDER * 2) );
     float        excessWidth   = 0.0;
     float        excessHeight  = 0.0;
     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)) );
     ITImageView *imageView;
     BOOL         shouldAnimate = ( ! (([self visibilityState] == ITWindowAppearingState) ||
                                       ([self visibilityState] == ITWindowVanishingState)) );
index 44a0b90..029aa79 100644 (file)
@@ -120,14 +120,25 @@ static ITTransientStatusWindow *staticWindow = nil;
 
 - (void)setIgnoresMouseEvents:(BOOL)flag
 {
 
 - (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);
     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;
 }
 
     _reallyIgnoresEvents = flag;
 }