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

fix setsize and setposition

This commit is contained in:
Lea Anthony 2020-09-19 23:19:34 +10:00
parent a8bff7868b
commit eb68ba5120
No known key found for this signature in database
GPG Key ID: 33DAF7BB90A58405

View File

@ -336,13 +336,16 @@ void SetSize(struct Application *app, int width, int height) {
// Get the rect for the window // Get the rect for the window
CGRect frame = GET_FRAME(app->mainWindow); CGRect frame = GET_FRAME(app->mainWindow);
// Get the rect for the current screen // Get the rect for the current screen
CGRect visibleFrame = GET_FRAME(screen); // CGRect visibleFrame = GET_FRAME(screen);
// Credit: https://github.com/patr0nus/DeskGap/blob/73c0ac9f2c73f55b6e81f64f6673a7962b5719cd/lib/src/platform/mac/util/NSScreen%2BGeometry.m // Credit: https://github.com/patr0nus/DeskGap/blob/73c0ac9f2c73f55b6e81f64f6673a7962b5719cd/lib/src/platform/mac/util/NSScreen%2BGeometry.m
dumpFrame("visibleFrame", visibleFrame); // dumpFrame("visibleFrame", visibleFrame);
dumpFrame("frame", frame); dumpFrame("before", frame);
frame.origin.y = (frame.origin.y + frame.size.height) - (float)height;
frame.size.width = (float)width; frame.size.width = (float)width;
frame.size.height = (float)height; frame.size.height = (float)height;
dumpFrame("after", frame);
msg(app->mainWindow, s("setFrame:display:animate:"), frame, 1, 0); msg(app->mainWindow, s("setFrame:display:animate:"), frame, 1, 0);
) )
} }
@ -357,7 +360,7 @@ void SetPosition(struct Application *app, int x, int y) {
dumpFrame("screenFrame", screenFrame); dumpFrame("screenFrame", screenFrame);
dumpFrame("windowFrame before", windowFrame); dumpFrame("windowFrame before", windowFrame);
windowFrame.origin.x = screenFrame.origin.x + (float)x; windowFrame.origin.x = screenFrame.origin.x + (float)x;
windowFrame.origin.y = (screenFrame.origin.y + screenFrame.size.height) - (float)y; windowFrame.origin.y = (screenFrame.origin.y + screenFrame.size.height) - windowFrame.size.height - (float)y;
dumpFrame("windowFrame after", windowFrame); dumpFrame("windowFrame after", windowFrame);
msg(app->mainWindow, s("setFrame:display:animate:"), windowFrame, 1, 0); msg(app->mainWindow, s("setFrame:display:animate:"), windowFrame, 1, 0);
) )