5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-03 18:13:20 +08:00

[mac] setPosition - adjust based on scale factor

This commit is contained in:
Lea Anthony 2024-12-20 18:12:54 +11:00
parent 01899adef9
commit 454d170dfb
No known key found for this signature in database
GPG Key ID: 33DAF7BB90A58405

View File

@ -578,10 +578,14 @@ void windowSetPosition(void* nsWindow, int x, int y) {
if (screen == NULL) {
screen = [NSScreen mainScreen];
}
// Get the scale of the screen
CGFloat scale = [screen backingScaleFactor];
NSRect frame = [window frame];
frame.origin.x = x;
frame.origin.y = (screen.frame.size.height - frame.size.height) - y;
[window setFrame:frame display:YES];
// Scale the position
frame.origin.x = x / scale;
frame.origin.y = (screen.frame.size.height - frame.size.height) - (y / scale);
// Set the frame
[window setFrame:frame display:YES];
}