src/video/cocoa/SDL_cocoawindow.m
changeset 9643 413b222c4b64
parent 9628 065e4ddc8753
child 9679 7fc4a8be47a8
     1.1 --- a/src/video/cocoa/SDL_cocoawindow.m	Tue May 26 20:49:27 2015 -0400
     1.2 +++ b/src/video/cocoa/SDL_cocoawindow.m	Tue May 26 21:51:47 2015 -0300
     1.3 @@ -255,6 +255,7 @@
     1.4          [center addObserver:self selector:@selector(windowDidDeminiaturize:) name:NSWindowDidDeminiaturizeNotification object:window];
     1.5          [center addObserver:self selector:@selector(windowDidBecomeKey:) name:NSWindowDidBecomeKeyNotification object:window];
     1.6          [center addObserver:self selector:@selector(windowDidResignKey:) name:NSWindowDidResignKeyNotification object:window];
     1.7 +        [center addObserver:self selector:@selector(windowDidChangeBackingProperties:) name:NSWindowDidChangeBackingPropertiesNotification object:window];
     1.8          [center addObserver:self selector:@selector(windowWillEnterFullScreen:) name:NSWindowWillEnterFullScreenNotification object:window];
     1.9          [center addObserver:self selector:@selector(windowDidEnterFullScreen:) name:NSWindowDidEnterFullScreenNotification object:window];
    1.10          [center addObserver:self selector:@selector(windowWillExitFullScreen:) name:NSWindowWillExitFullScreenNotification object:window];
    1.11 @@ -385,6 +386,7 @@
    1.12          [center removeObserver:self name:NSWindowDidDeminiaturizeNotification object:window];
    1.13          [center removeObserver:self name:NSWindowDidBecomeKeyNotification object:window];
    1.14          [center removeObserver:self name:NSWindowDidResignKeyNotification object:window];
    1.15 +        [center removeObserver:self name:NSWindowDidChangeBackingPropertiesNotification object:window];
    1.16          [center removeObserver:self name:NSWindowWillEnterFullScreenNotification object:window];
    1.17          [center removeObserver:self name:NSWindowDidEnterFullScreenNotification object:window];
    1.18          [center removeObserver:self name:NSWindowWillExitFullScreenNotification object:window];
    1.19 @@ -584,6 +586,22 @@
    1.20      }
    1.21  }
    1.22  
    1.23 +- (void)windowDidChangeBackingProperties:(NSNotification *)aNotification
    1.24 +{
    1.25 +    NSNumber *oldscale = [[aNotification userInfo] objectForKey:NSBackingPropertyOldScaleFactorKey];
    1.26 +
    1.27 +    if (inFullscreenTransition) {
    1.28 +        return;
    1.29 +    }
    1.30 +
    1.31 +    if ([oldscale doubleValue] != [_data->nswindow backingScaleFactor]) {
    1.32 +        /* Force a resize event when the backing scale factor changes. */
    1.33 +        _data->window->w = 0;
    1.34 +        _data->window->h = 0;
    1.35 +        [self windowDidResize:aNotification];
    1.36 +    }
    1.37 +}
    1.38 +
    1.39  - (void)windowWillEnterFullScreen:(NSNotification *)aNotification
    1.40  {
    1.41      SDL_Window *window = _data->window;