src/video/cocoa/SDL_cocoawindow.m
changeset 5374 dacb4f5e0dd3
parent 5371 fc3d3d580777
child 5375 16877f74123c
     1.1 --- a/src/video/cocoa/SDL_cocoawindow.m	Mon Feb 21 15:08:36 2011 -0800
     1.2 +++ b/src/video/cocoa/SDL_cocoawindow.m	Mon Feb 21 15:25:49 2011 -0800
     1.3 @@ -48,13 +48,17 @@
     1.4  
     1.5      center = [NSNotificationCenter defaultCenter];
     1.6  
     1.7 -    [center addObserver:self selector:@selector(windowDisExpose:) name:NSWindowDidExposeNotification object:window];
     1.8 -    [center addObserver:self selector:@selector(windowDidMove:) name:NSWindowDidMoveNotification object:window];
     1.9 -    [center addObserver:self selector:@selector(windowDidResize:) name:NSWindowDidResizeNotification object:window];
    1.10 -    [center addObserver:self selector:@selector(windowDidMiniaturize:) name:NSWindowDidMiniaturizeNotification object:window];
    1.11 -    [center addObserver:self selector:@selector(windowDidDeminiaturize:) name:NSWindowDidDeminiaturizeNotification object:window];
    1.12 -    [center addObserver:self selector:@selector(windowDidBecomeKey:) name:NSWindowDidBecomeKeyNotification object:window];
    1.13 -    [center addObserver:self selector:@selector(windowDidResignKey:) name:NSWindowDidResignKeyNotification object:window];
    1.14 +    if ([window delegate] != nil) {
    1.15 +        [center addObserver:self selector:@selector(windowDidExpose:) name:NSWindowDidExposeNotification object:window];
    1.16 +        [center addObserver:self selector:@selector(windowDidMove:) name:NSWindowDidMoveNotification object:window];
    1.17 +        [center addObserver:self selector:@selector(windowDidResize:) name:NSWindowDidResizeNotification object:window];
    1.18 +        [center addObserver:self selector:@selector(windowDidMiniaturize:) name:NSWindowDidMiniaturizeNotification object:window];
    1.19 +        [center addObserver:self selector:@selector(windowDidDeminiaturize:) name:NSWindowDidDeminiaturizeNotification object:window];
    1.20 +        [center addObserver:self selector:@selector(windowDidBecomeKey:) name:NSWindowDidBecomeKeyNotification object:window];
    1.21 +        [center addObserver:self selector:@selector(windowDidResignKey:) name:NSWindowDidResignKeyNotification object:window];
    1.22 +    } else {
    1.23 +        [window setDelegate:self];
    1.24 +    }
    1.25      [center addObserver:self selector:@selector(windowDidHide:) name:NSApplicationDidHideNotification object:NSApp];
    1.26      [center addObserver:self selector:@selector(windowDidUnhide:) name:NSApplicationDidUnhideNotification object:NSApp];
    1.27  
    1.28 @@ -76,18 +80,26 @@
    1.29  
    1.30      center = [NSNotificationCenter defaultCenter];
    1.31  
    1.32 -    [center removeObserver:self name:NSWindowDidExposeNotification object:window];
    1.33 -    [center removeObserver:self name:NSWindowDidMoveNotification object:window];
    1.34 -    [center removeObserver:self name:NSWindowDidResizeNotification object:window];
    1.35 -    [center removeObserver:self name:NSWindowDidMiniaturizeNotification object:window];
    1.36 -    [center removeObserver:self name:NSWindowDidDeminiaturizeNotification object:window];
    1.37 -    [center removeObserver:self name:NSWindowDidBecomeKeyNotification object:window];
    1.38 -    [center removeObserver:self name:NSWindowDidResignKeyNotification object:window];
    1.39 +    if ([window delegate] != self) {
    1.40 +        [center removeObserver:self name:NSWindowDidExposeNotification object:window];
    1.41 +        [center removeObserver:self name:NSWindowDidMoveNotification object:window];
    1.42 +        [center removeObserver:self name:NSWindowDidResizeNotification object:window];
    1.43 +        [center removeObserver:self name:NSWindowDidMiniaturizeNotification object:window];
    1.44 +        [center removeObserver:self name:NSWindowDidDeminiaturizeNotification object:window];
    1.45 +        [center removeObserver:self name:NSWindowDidBecomeKeyNotification object:window];
    1.46 +        [center removeObserver:self name:NSWindowDidResignKeyNotification object:window];
    1.47 +    } else {
    1.48 +        [window setDelegate:nil];
    1.49 +    }
    1.50      [center removeObserver:self name:NSApplicationDidHideNotification object:NSApp];
    1.51      [center removeObserver:self name:NSApplicationDidUnhideNotification object:NSApp];
    1.52  
    1.53 -    [window setNextResponder:nil];
    1.54 -    [view setNextResponder:nil];
    1.55 +    if ([window nextResponder] == self) {
    1.56 +        [window setNextResponder:nil];
    1.57 +    }
    1.58 +    if ([view nextResponder] == self) {
    1.59 +        [view setNextResponder:nil];
    1.60 +    }
    1.61  }
    1.62  
    1.63  - (BOOL)windowShouldClose:(id)sender