From 0e919b7d1ec9fad70e5f1245b8e5a83744562855 Mon Sep 17 00:00:00 2001 From: David Noblet Date: Fri, 2 Nov 2007 20:20:51 -0700 Subject: [PATCH] Leopard Updates darcs-hash:20071103032051-3181a-54aff581b06742e796fa37933fff56892aa34557.gz --- AXWindow.m | 18 ++++++++++---- CGDisplayConfiguration.h | 1 + CGDisplayConfiguration.m | 17 ++++++++++++++ DockRestorable.m | 2 +- FMN.m | 44 +++++++++++++++++++++++++++++------ FMN.xcodeproj/project.pbxproj | 5 ++++ FMNDisplayConfiguration.h | 1 + FMNRestorable.h | 2 +- FMNWindow.h | 6 ++--- FMNWindowOrientation.m | 6 ++--- X11Restorable.m | 2 +- 11 files changed, 82 insertions(+), 22 deletions(-) diff --git a/AXWindow.m b/AXWindow.m index b64df39..f18724d 100644 --- a/AXWindow.m +++ b/AXWindow.m @@ -98,8 +98,16 @@ - (NSSize) getWindowSize return size; } -- (void) setWindowPosition : (NSPoint) pos +- (void) setWindowPosition : (NSPoint) pos Context : (NSDictionary*) context { + NSNumber* off_x = + (NSNumber*) [context objectForKey:@"com.fmn.x-coordinate-offset"]; + NSNumber* off_y = + (NSNumber*) [context objectForKey:@"com.fmn.y-coordinate-offset"]; + + pos.x += [off_x floatValue]; + pos.y += [off_y floatValue]; + CFTypeRef value; value = AXValueCreate(kAXValueCGPointType,&pos); if(AXUIElementSetAttributeValue(windowElement,kAXPositionAttribute,value) @@ -119,7 +127,7 @@ - (void) setWindowPosition : (NSPoint) pos CFRelease(value); } -- (void) setWindowSize : (NSSize) size +- (void) setWindowSize : (NSSize) size Context : (NSDictionary*) context { CFTypeRef value; value = AXValueCreate(kAXValueCGSizeType,&size); @@ -140,10 +148,10 @@ - (void) setWindowSize : (NSSize) size CFRelease(value); } -- (void) setWindowSize : (NSSize) size Position : (NSPoint) pos +- (void) setWindowSize : (NSSize) size Position : (NSPoint) pos Context : (NSDictionary*) context { - [self setWindowPosition : pos]; - [self setWindowSize : size]; + [self setWindowPosition : pos Context : context]; + [self setWindowSize : size Context : context]; } - (void) dealloc diff --git a/CGDisplayConfiguration.h b/CGDisplayConfiguration.h index 47fc18c..2639363 100644 --- a/CGDisplayConfiguration.h +++ b/CGDisplayConfiguration.h @@ -13,6 +13,7 @@ @interface CGDisplayConfiguration : NSObject { @protected NSMutableArray* displays; + @protected FMNDisplayRef mainDisplay; } @end diff --git a/CGDisplayConfiguration.m b/CGDisplayConfiguration.m index ac81906..d89bc07 100644 --- a/CGDisplayConfiguration.m +++ b/CGDisplayConfiguration.m @@ -18,6 +18,7 @@ - (id) initWithCurrent if (![super init]) return nil; + mainDisplay = 0; displays = 0; int i; @@ -39,6 +40,9 @@ - (id) initWithCurrent { [displays addObject: [[[CGDisplay alloc] initWithDisplayID: screenList_p[i]] autorelease]]; + if(CGDisplayIsMain(screenList_p[i])) + mainDisplay = [[CGDisplay alloc] initWithDisplayID: + screenList_p[i]]; } [displays sortUsingSelector : @selector(compare:)]; @@ -60,6 +64,11 @@ - (FMNDisplayRef) getDisplay : (unsigned) i return [displays objectAtIndex : i]; } +- (FMNDisplayRef) getMainDisplay +{ + return mainDisplay; +} + - (BOOL) isEqual : (id) obj { //return [self hash] == [obj hash]; @@ -79,6 +88,9 @@ - (BOOL) isEqual : (id) obj int i; + if(![[self getMainDisplay] isEqual : [display getMainDisplay]]) + return NO; + for(i=0; i) configWithCurrent; - (unsigned) getDisplayCount; +- (FMNDisplayRef) getMainDisplay; - (FMNDisplayRef) getDisplay : (unsigned) i; - (NSString*) description; diff --git a/FMNRestorable.h b/FMNRestorable.h index 1a19847..6f1892a 100644 --- a/FMNRestorable.h +++ b/FMNRestorable.h @@ -20,7 +20,7 @@ enum */ @protocol FMNRestorable -- (void) restore; +- (void) restoreWithContext : (NSDictionary*) context; - (int) priority; @end diff --git a/FMNWindow.h b/FMNWindow.h index bf03a17..4580b59 100644 --- a/FMNWindow.h +++ b/FMNWindow.h @@ -15,9 +15,9 @@ - (NSPoint) getWindowPosition; - (NSSize) getWindowSize; -- (void) setWindowPosition : (NSPoint) pos; -- (void) setWindowSize : (NSSize) size; -- (void) setWindowSize : (NSSize) size Position : (NSPoint) pos; +- (void) setWindowPosition : (NSPoint) pos Context : (NSDictionary*) context; +- (void) setWindowSize : (NSSize) size Context : (NSDictionary*) context; +- (void) setWindowSize : (NSSize) size Position : (NSPoint) pos Context : (NSDictionary*) context; @end diff --git a/FMNWindowOrientation.m b/FMNWindowOrientation.m index 71e95dd..63f081f 100644 --- a/FMNWindowOrientation.m +++ b/FMNWindowOrientation.m @@ -35,11 +35,9 @@ - (id) initWithWindow : (FMNWindowRef) win return self; } -- (void) restore +- (void) restoreWithContext : (NSDictionary*) context { - /*[window setWindowPosition : position]; - [window setWindowSize : size];*/ - [window setWindowSize: size Position: position]; + [window setWindowSize: size Position: position Context: context]; NSLog(@"Restored %@", window); } diff --git a/X11Restorable.m b/X11Restorable.m index 6092bff..4b8fd3a 100644 --- a/X11Restorable.m +++ b/X11Restorable.m @@ -70,7 +70,7 @@ - (void) dealloc [super dealloc]; } -- (void) restore +- (void) restoreWithContext : (NSDictionary*) context { if ([mX11Bridge openDisplay]) { NSDate *startDate = [NSDate date];