adium 2898:692bec0202ad: Quiet a warning about a possible missin...

commits at adium.im commits at adium.im
Mon Nov 9 17:31:07 UTC 2009


details:	http://hg.adium.im/adium/rev/692bec0202ad
revision:	2898:692bec0202ad
author:		Peter Hosey <hg at boredzo.org>
date:		Sun Nov 08 03:43:53 2009 -0800

Quiet a warning about a possible missing -dealloc by naming our method slightly differently. We still swizzle it with NSToolbar's -dealloc, so the effect remains the same.
Subject: adium 2899:4e56ddef1aad: Restore Exposé ignoring, using the new public API (a collection behavior bit) introduced for it in Snow Leopard. Obviously, this won't work on Leopard—but it won't hurt anything, either.

details:	http://hg.adium.im/adium/rev/4e56ddef1aad
revision:	2899:4e56ddef1aad
author:		Peter Hosey <hg at boredzo.org>
date:		Mon Nov 09 09:30:24 2009 -0800

Restore Exposé ignoring, using the new public API (a collection behavior bit) introduced for it in Snow Leopard. Obviously, this won't work on Leopard—but it won't hurt anything, either.
Subject: adium 2900:55168c0ae329: Burninate the old Quartz-Window-Services-based implementation of Exposé-ignoring.

details:	http://hg.adium.im/adium/rev/55168c0ae329
revision:	2900:55168c0ae329
author:		Peter Hosey <hg at boredzo.org>
date:		Mon Nov 09 09:30:26 2009 -0800

Burninate the old Quartz-Window-Services-based implementation of Exposé-ignoring.
Subject: adium 2901:ba9a84282496: When running on Snow Leopard, use the new public -isOnActiveSpace method in AppKit, rather than our own implementation based on private Quartz Window Services APIs.

details:	http://hg.adium.im/adium/rev/ba9a84282496
revision:	2901:ba9a84282496
author:		Peter Hosey <hg at boredzo.org>
date:		Mon Nov 09 09:30:27 2009 -0800

When running on Snow Leopard, use the new public -isOnActiveSpace method in AppKit, rather than our own implementation based on private Quartz Window Services APIs.

When we abandon Leopard, we can get rid of all of this code entirely, and switch all call sites over to call the AppKit method directly.

diffs (381 lines):

diff -r 7a11109d7198 -r ba9a84282496 Frameworks/AIUtilities Framework/Source/AILeopardCompatibility.h
--- a/Frameworks/AIUtilities Framework/Source/AILeopardCompatibility.h	Sun Nov 08 12:33:35 2009 -0500
+++ b/Frameworks/AIUtilities Framework/Source/AILeopardCompatibility.h	Mon Nov 09 09:30:27 2009 -0800
@@ -44,8 +44,15 @@
 @interface NSOperationQueue(NSOperationQueueLeopardMethods)
 - (void)setName:(NSString *)newName;
 @end
+
+ at interface NSWindow(NSWindowLeopardMethods)
+- (BOOL)isOnActiveSpace;
+ at end
+
 #endif
 
+enum { NSWindowCollectionBehaviorStationary = 1 << 4 };
+
 #else //Not compiling for 10.6
 
 #endif //MAC_OS_X_VERSION_10_6
diff -r 7a11109d7198 -r ba9a84282496 Frameworks/AIUtilities Framework/Source/AISmoothTooltipTracker.m
--- a/Frameworks/AIUtilities Framework/Source/AISmoothTooltipTracker.m	Sun Nov 08 12:33:35 2009 -0500
+++ b/Frameworks/AIUtilities Framework/Source/AISmoothTooltipTracker.m	Mon Nov 09 09:30:27 2009 -0800
@@ -10,6 +10,7 @@
 
 #import "AISmoothTooltipTracker.h"
 #import "AIDockingWindow.h"
+#import "AILeopardCompatibility.h"
 
 #define TOOL_TIP_CHECK_INTERVAL	45.0	//Check for mouse X times a second
 #define TOOL_TIP_DELAY			35.0	//Number of check intervals of no movement before a tip is displayed
@@ -323,6 +324,9 @@
 
 - (BOOL)isOnCurrentWorkspace
 {
+	if ([self respondsToSelector:@selector(isOnActiveSpace)])
+		return [self isOnActiveSpace];
+
 	OSStatus err;
 	int currentWorkspace, windowWorkspace;
 
diff -r 7a11109d7198 -r ba9a84282496 Frameworks/AIUtilities Framework/Source/AIWindowAdditions.h
--- a/Frameworks/AIUtilities Framework/Source/AIWindowAdditions.h	Sun Nov 08 12:33:35 2009 -0500
+++ b/Frameworks/AIUtilities Framework/Source/AIWindowAdditions.h	Mon Nov 09 09:30:27 2009 -0800
@@ -15,7 +15,6 @@
 
 @interface NSWindow (AIWindowAdditions)
 - (void)setContentSize:(NSSize)aSize display:(BOOL)displayFlag animate:(BOOL)animateFlag;
-- (void)setIgnoresExpose:(BOOL)flag;
 @property (readonly, nonatomic) BOOL isBorderless;
 - (void)betterCenter;
 @property (readonly, nonatomic) float toolbarHeight;
@@ -23,153 +22,3 @@
 - (NSResponder *)earliestResponderWhichRespondsToSelector:(SEL)selector andIsNotOfClass:(Class)classToAvoid;
 - (NSResponder *)earliestResponderOfClass:(Class)targetClass;
 @end
-
-// The following code is Copyright (C) 2003, 2004 Richard J Wareham <richwareham at users.sourceforge.net>,
-// distributed under the GNU General Public License (see above).
-
-/* These functions all return a status code. Typical CoreGraphics replies are:
-kCGErrorSuccess = 0,
-kCGErrorFirst = 1000,
-kCGErrorFailure = kCGErrorFirst,
-kCGErrorIllegalArgument = 1001,
-kCGErrorInvalidConnection = 1002,
-*/
-
-// Internal CoreGraphics typedefs
-
-typedef UInt32	WindowTags;
-typedef void	*CGSWindowID;
-typedef void	*CGSConnectionID;
-typedef int		CGSValue;
-
- at class CICGSFilter;
-
-//// CONSTANTS ////
-
-/* Window ordering mode. */
-typedef enum _CGSWindowIDOrderingMode {
-    kCGSOrderAbove                =  1, // Window is ordered above target.
-    kCGSOrderBelow                = -1, // Window is ordered below target.
-    kCGSOrderOut                  =  0  // Window is removed from the on-screen window list.
-} CGSWindowIDOrderingMode;
-
-// Internal CoreGraphics functions.
-
-/* Retrieve the workspace number associated with the workspace currently
-* being shown.
-*
-* cid -- Current connection.
-* workspace -- Pointer to int value to be set to workspace number.
-*/
-extern OSStatus CGSGetWorkspace(const CGSConnectionID cid, int *workspace);
-
-/* Retrieve workspace number associated with the workspace a particular window
-* resides on.
-*
-* cid -- Current connection.
-* wid -- Window number of window to examine.
-* workspace -- Pointer to int value to be set to workspace number.
-*/
-extern OSStatus CGSGetWindowWorkspace(const CGSConnectionID cid, const CGSWindowID wid, int *workspace);
-
-/* Show workspace associated with a workspace number.
-*
-* cid -- Current connection.
-* workspace -- Workspace number.
-*/
-extern OSStatus CGSSetWorkspace(const CGSConnectionID cid, int workspace);
-
-extern OSStatus CGSSetWindowTransform(const CGSConnectionID cid, CGSWindowID wid, CGAffineTransform transform);
-extern OSStatus CGSGetWindowTransform(const CGSConnectionID cid, CGSWindowID wid, CGAffineTransform *outTransform);
-
-
-typedef enum {
-    CGSNone = 0,	// No transition effect.
-    CGSFade,		// Cross-fade.
-    CGSZoom,		// Zoom/fade towards us.
-    CGSReveal,		// Reveal new desktop under old.
-    CGSSlide,		// Slide old out and new in.
-    CGSWarpFade,	// Warp old and fade out revealing new.
-    CGSSwap,		// Swap desktops over graphically.
-    CGSCube,		// The well-known cube effect.
-    CGSWarpSwitch   // Warp old, switch and un-warp.
-} CGSTransitionType;
-
-typedef enum {
-    CGSDown,				// Old desktop moves down.
-    CGSLeft,				// Old desktop moves left.
-    CGSRight,				// Old desktop moves right.
-    CGSInRight,				// CGSSwap: Old desktop moves into screen, 
-							//			new comes from right.
-    CGSBottomLeft = 5,		// CGSSwap: Old desktop moves to bl,
-							//			new comes from tr.
-    CGSBottomRight,			// Old desktop to br, New from tl.
-    CGSDownTopRight,		// CGSSwap: Old desktop moves down, new from tr.
-    CGSUp,					// Old desktop moves up.
-    CGSTopLeft,				// Old desktop moves tl.
-    
-    CGSTopRight,			// CGSSwap: old to tr. new from bl.
-    CGSUpBottomRight,		// CGSSwap: old desktop up, new from br.
-    CGSInBottom,			// CGSSwap: old in, new from bottom.
-    CGSLeftBottomRight,		// CGSSwap: old one moves left, new from br.
-    CGSRightBottomLeft,		// CGSSwap: old one moves right, new from bl.
-    CGSInBottomRight,		// CGSSwap: onl one in, new from br.
-    CGSInOut				// CGSSwap: old in, new out.
-} CGSTransitionOption;
-
-extern OSStatus CGSSetWorkspaceWithTransition(const CGSConnectionID cid,
-					      int workspaceNumber, CGSTransitionType transition, CGSTransitionOption subtype, 
-					      float time);
-
-/* Get the default connection for the current process. */
-extern CGSConnectionID _CGSDefaultConnection(void);
-
-// thirtyTwo must = 32 for some reason. tags is pointer to 
-//array ot ints (size 2?). First entry holds window tags.
-// 0x0800 is sticky bit.
-OSStatus      CGSSetWindowTags(  CGSConnectionID cgsID, CGSWindowID theWindow, SInt32 *theTags, SInt32 tagSize);
-OSStatus      CGSGetWindowTags(  CGSConnectionID cgsID, CGSWindowID theWindow, SInt32 *theTags, SInt32 tagSize);
-OSStatus      CGSClearWindowTags(CGSConnectionID cgsID, CGSWindowID theWindow, SInt32 *theTags, SInt32 tagSize);
-
-// Get on-screen window counts and lists.
-extern OSStatus CGSGetOnScreenWindowCount(const CGSConnectionID cid, CGSConnectionID targetCID, int* outCount); 
-extern OSStatus CGSGetOnScreenWindowList(const CGSConnectionID cid, CGSConnectionID targetCID, 
-					 int count, int* list, int* outCount);
-
-// Per-workspace window counts and lists.
-extern OSStatus CGSGetWorkspaceWindowCount(const CGSConnectionID cid, int workspaceNumber, int *outCount);
-extern OSStatus CGSGetWorkspaceWindowList(const CGSConnectionID cid, int workspaceNumber, int count, 
-					  int* list, int* outCount);
-
-// Gets the level of a window
-extern OSStatus CGSGetWindowLevel(const CGSConnectionID cid, CGSWindowID wid, 
-				  int *level);
-
-// Window ordering
-extern OSStatus CGSOrderWindow(const CGSConnectionID cid, const CGSWindowID wid, 
-			       CGSWindowIDOrderingMode place, CGSWindowID relativeToWindowID /* can be NULL */);	
-
-// Gets the screen rect for a window.
-extern OSStatus CGSGetScreenRectForWindow(const CGSConnectionID cid, CGSWindowID wid, 
-					  CGRect *outRect);
-
-// Window appearance/position
-extern OSStatus CGSSetWindowAlpha(const CGSConnectionID cid, const CGSWindowID wid, float alpha);
-extern OSStatus CGSMoveWindow(const CGSConnectionID cid, const CGSWindowID wid, CGPoint *point);
-
-// extern OSStatus CGSConnectionIDGetPID(const CGSConnectionID cid, pid_t *pid, CGSConnectionID b);
-
-extern OSStatus CGSGetWindowProperty(const CGSConnectionID cid, CGSWindowID wid, CGSValue key,
-				     CGSValue *outValue);
-
-//extern OSStatus CGSWindowIDAddRectToDirtyShape(const CGSConnectionID cid, const CGSWindowID wid, CGRect *rect);
-extern OSStatus CGSUncoverWindow(const CGSConnectionID cid, const CGSWindowID wid);
-extern OSStatus CGSFlushWindow(const CGSConnectionID cid, const CGSWindowID wid, int unknown /* 0 works */ );
-
-extern OSStatus CGSGetWindowOwner(const CGSConnectionID cid, const CGSWindowID wid, CGSConnectionID *ownerCid);
-extern OSStatus CGSConnectionIDGetPID(const CGSConnectionID cid, pid_t *pid, const CGSConnectionID ownerCid);
-
-// Values
-extern CGSValue CGSCreateCStringNoCopy(const char *str);
-extern char* CGSCStringValue(CGSValue string);
-
diff -r 7a11109d7198 -r ba9a84282496 Frameworks/AIUtilities Framework/Source/AIWindowAdditions.m
--- a/Frameworks/AIUtilities Framework/Source/AIWindowAdditions.m	Sun Nov 08 12:33:35 2009 -0500
+++ b/Frameworks/AIUtilities Framework/Source/AIWindowAdditions.m	Mon Nov 09 09:30:27 2009 -0800
@@ -114,89 +114,4 @@
 	return responder;	
 }
 
-#pragma mark Expose ignoring
-
-//This code appears to break Spaces interaction in 10.5. It remains in hopes that someone will fix it :)
-enum {
-    kWindowNoTags            = 0,
-    kWindowExposeWillMoveTag = (1 <<  0),
-    kWindowExposeWillHideTag = (1 <<  1),
-    kWindowExposeIsStickyTag = (1 << 11)
-};
-
-CGSWindowID     GetNativeWindowFromWindowRef(WindowRef window);
-CGSConnectionID CGSGetDefaultConnection(void);
-
-
-OSStatus GetWindowTags(WindowRef theWindow, WindowTags *theTags)
-{   CGSConnectionID   cgConnection;
-    SInt32          sysVersion;
-    CGSWindowID       cgWindow;
-    OSStatus        theErr;
-
-    // Check the system
-    theErr = Gestalt(gestaltSystemVersion, &sysVersion);
-    if (theErr != noErr || sysVersion < 0x00001013)
-	{
-        *theTags = kWindowNoTags;
-        return(noErr);
-	}
-
-    // Get the window
-    cgWindow = GetNativeWindowFromWindowRef(theWindow);
-    if (cgWindow == NULL)
-        return(unimpErr);
-
-    cgConnection = _CGSDefaultConnection();
-    if (cgConnection == NULL)
-        return(unimpErr);
-
-    // Get the tags
-    theErr = CGSGetWindowTags(cgConnection, cgWindow, (SInt32 *) &theTags, 32);
-
-    return(theErr);
-}
-
-
-OSStatus ChangeWindowTags(WindowRef theWindow, WindowTags setThese, WindowTags clearThese)
-{   CGSConnectionID   cgConnection;
-    SInt32          sysVersion;
-    CGSWindowID       cgWindow;
-    OSStatus        theErr;
-
-    // Check the system
-    theErr = Gestalt(gestaltSystemVersion, &sysVersion);
-    if (theErr != noErr || sysVersion < 0x00001013)
-        return(unimpErr);
-
-    // Get the window
-    cgWindow = GetNativeWindowFromWindowRef(theWindow);
-    if (cgWindow == NULL)
-        return(unimpErr);
-
-    cgConnection = _CGSDefaultConnection();
-    if (cgConnection == NULL)
-        return(unimpErr);
-
-    // Update the tags
-    theErr = noErr;
-
-    if (setThese != kWindowNoTags)
-        theErr |= CGSSetWindowTags(  cgConnection, cgWindow, (SInt32 *)   &setThese, 32);
-
-    if (clearThese != kWindowNoTags)
-        theErr |= CGSClearWindowTags(cgConnection, cgWindow, (SInt32 *) &clearThese, 32);
-
-    return(theErr);
-}
-
-- (void)setIgnoresExpose:(BOOL)flag
-{
-	NSLog(@"%s called! You should not use this method until this warning is removed.", __PRETTY_FUNCTION__);
-
-	ChangeWindowTags([self windowRef],
-					 (flag ? kWindowExposeIsStickyTag : kWindowNoTags),
-					 (!flag ? kWindowExposeIsStickyTag : kWindowNoTags)); 
-}
-
 @end
diff -r 7a11109d7198 -r ba9a84282496 Frameworks/Adium Framework/Source/AIToolbar.m
--- a/Frameworks/Adium Framework/Source/AIToolbar.m	Sun Nov 08 12:33:35 2009 -0500
+++ b/Frameworks/Adium Framework/Source/AIToolbar.m	Mon Nov 09 09:30:27 2009 -0800
@@ -42,13 +42,13 @@
 + (void)load
 {
 	//Anything you can do, I can do better...
-	method_exchangeImplementations(class_getInstanceMethod([NSToolbar class], @selector(dealloc)), class_getInstanceMethod(self, @selector(dealloc)));
+	method_exchangeImplementations(class_getInstanceMethod([NSToolbar class], @selector(dealloc)), class_getInstanceMethod(self, @selector(deallocWithNotifications)));
 }
 
 /*!
  * @brief Called before the toolbar deallocs
  */
-- (void)dealloc
+- (void)deallocWithNotifications
 {
 	NSNotificationCenter	*defaultCenter = [NSNotificationCenter defaultCenter];
 
@@ -65,7 +65,7 @@
 	}
 
 	//call the unswizzled implementation now that we're done with our additions
-	method_invoke(self, class_getInstanceMethod([AIToolbar class], @selector(dealloc)));
+	method_invoke(self, class_getInstanceMethod([AIToolbar class], @selector(deallocWithNotifications)));
 }
 
 @end
diff -r 7a11109d7198 -r ba9a84282496 Source/AIListWindowController.m
--- a/Source/AIListWindowController.m	Sun Nov 08 12:33:35 2009 -0500
+++ b/Source/AIListWindowController.m	Mon Nov 09 09:30:27 2009 -0800
@@ -36,6 +36,7 @@
 #import <Adium/AIUserIcons.h>
 #import <AIUtilities/AIDockingWindow.h>
 #import <AIUtilities/AIEventAdditions.h>
+#import <AIUtilities/AILeopardCompatibility.h>
 #import <Adium/AIContactList.h>
 #import <Adium/AIContactHidingController.h>
 
@@ -291,6 +292,21 @@
 	[[self window] setLevel:level];
 }
 
+//A ÒstationaryÓ window stays pinned to the desktop during ExposŽ. A supported API for this was introduced in Snow Leopard.
+- (void)setCollectionBehaviorOfWindow:(NSWindow *)window
+					  showOnAllSpaces:(BOOL)allSpaces
+						 isStationary:(BOOL)stationary
+{
+	NSWindowCollectionBehavior behavior = NSWindowCollectionBehaviorDefault;
+
+	if (allSpaces)
+		behavior |= NSWindowCollectionBehaviorCanJoinAllSpaces;
+	if (stationary && [NSApp isOnSnowLeopardOrBetter])
+		behavior |= NSWindowCollectionBehaviorStationary;
+
+	[window setCollectionBehavior:behavior];
+}
+
 //Preferences have changed
 - (void)preferencesChangedForGroup:(NSString *)group 
 							   key:(NSString *)key
@@ -317,7 +333,9 @@
 		[[self window] setHidesOnDeactivate:(windowHidingStyle == AIContactListWindowHidingStyleBackground)];
 		
 	    showOnAllSpaces = [[prefDict objectForKey:KEY_CL_ALL_SPACES] boolValue];
-		[[self window] setCollectionBehavior:showOnAllSpaces ? NSWindowCollectionBehaviorCanJoinAllSpaces : NSWindowCollectionBehaviorDefault];
+		[self setCollectionBehaviorOfWindow:[self window]
+							showOnAllSpaces:showOnAllSpaces
+							   isStationary:YES];
 		
 		if (windowHidingStyle == AIContactListWindowHidingStyleSliding) {
 			if (!slideWindowIfNeededTimer) {
@@ -722,7 +740,9 @@
 	//If we're hiding the window (generally) but now sliding it on screen, make sure it's on top
 	if (windowHidingStyle == AIContactListWindowHidingStyleSliding) {
 		[self setWindowLevel:NSFloatingWindowLevel];
-		[[self window] setCollectionBehavior:NSWindowCollectionBehaviorCanJoinAllSpaces];
+		[self setCollectionBehaviorOfWindow:[self window]
+							showOnAllSpaces:YES
+							   isStationary:YES];
 		
 		overrodeWindowLevel = YES;
 	}




More information about the commits mailing list