diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2017-07-30 20:58:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-30 20:58:02 +0200 |
commit | db0680896488d9cceb72ab93115243f97265e18d (patch) | |
tree | 26cd72e8e91347f363023e38dfeb9b396e2a0a62 /platform | |
parent | f1fe2cd90e07fbfa8883b3129f27186a33608a4b (diff) | |
parent | d18922a56e6024a447051c8fb4378ced31c198be (diff) |
Merge pull request #9953 from bruvzg/3.0-hidpi-window-moving
Change display scale when moving the window from monitor to monitor [macOS]
Diffstat (limited to 'platform')
-rw-r--r-- | platform/osx/os_osx.mm | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index fce38b6a8b..09ddc0dd7e 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -162,6 +162,36 @@ static bool mouse_down_control = false; } #endif // MAC_OS_X_VERSION_MAX_ALLOWED +- (void)windowDidChangeBackingProperties:(NSNotification *)notification { + if (!OS_OSX::singleton) + return; + + NSWindow *window = (NSWindow *)[notification object]; + CGFloat newBackingScaleFactor = [window backingScaleFactor]; + CGFloat oldBackingScaleFactor = [[[notification userInfo] objectForKey:@"NSBackingPropertyOldScaleFactorKey"] doubleValue]; + + if (newBackingScaleFactor != oldBackingScaleFactor) { + //Set new display scale and window size + OS_OSX::singleton->display_scale = newBackingScaleFactor; + + const NSRect contentRect = [OS_OSX::singleton->window_view frame]; + const NSRect fbRect = contentRect; //convertRectToBacking(contentRect); + + OS_OSX::singleton->window_size.width = fbRect.size.width * OS_OSX::singleton->display_scale; + OS_OSX::singleton->window_size.height = fbRect.size.height * OS_OSX::singleton->display_scale; + + //Update context + if (OS_OSX::singleton->main_loop) { + [OS_OSX::singleton->context update]; + + //Force window resize ??? + NSRect frame = [OS_OSX::singleton->window_object frame]; + [OS_OSX::singleton->window_object setFrame:NSMakeRect(frame.origin.x, frame.origin.y, 1, 1) display:YES]; + [OS_OSX::singleton->window_object setFrame:frame display:YES]; + } + } +} + - (void)windowDidResize:(NSNotification *)notification { [OS_OSX::singleton->context update]; |