Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/KDGui/platform/cocoa/cocoa_platform_window.mm
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,12 @@ - (void)windowDidResize:(NSNotification *)notification
const auto height = static_cast<uint32_t>(contentRect.size.height);
m_platformWindow->handleResize(width, height);
}

- (void)windowDidChangeBackingProperties:(NSNotification *)notification
{
// The window moved to a screen with a different pixel density
m_platformWindow->window()->scaleFactor = static_cast<float>([m_platformWindow->nativeWindow() backingScaleFactor]);
}
@end

@interface KDGuiView : NSView {
Expand Down Expand Up @@ -429,6 +435,10 @@ - (void)keyUp:(NSEvent *)event
[m_nativeWindow setAcceptsMouseMovedEvents:YES];
[m_nativeWindow setRestorable:NO];

// Window sizes are in points; scaleFactor gives the pixels per point.
// The window has no screen yet, so start from the main screen.
m_window->scaleFactor = static_cast<float>([[NSScreen mainScreen] backingScaleFactor]);

[NSApp activateIgnoringOtherApps:YES];
}

Expand Down Expand Up @@ -462,6 +472,7 @@ - (void)keyUp:(NSEvent *)event
@autoreleasepool {
[m_nativeWindow makeKeyAndOrderFront:nil];
}
m_window->scaleFactor = static_cast<float>([m_nativeWindow backingScaleFactor]);
}

void CocoaPlatformWindow::unmap()
Expand Down
Loading