diff options
author | David Robillard <d@drobilla.net> | 2025-02-08 16:47:58 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2025-02-08 18:02:30 -0500 |
commit | 1004888ac9ace7cc2c1955c30ac449f8112f90f0 (patch) | |
tree | 3e251c41559add5e14e7c6a53f608c3dc233389a | |
parent | 1a35285eb9ca6f10a89f913fd2184c4544607e7d (diff) | |
download | pugl-1004888ac9ace7cc2c1955c30ac449f8112f90f0.tar.gz pugl-1004888ac9ace7cc2c1955c30ac449f8112f90f0.tar.bz2 pugl-1004888ac9ace7cc2c1955c30ac449f8112f90f0.zip |
MacOS: Avoid puglSetFrame() in puglRealize()
-rw-r--r-- | src/mac.m | 22 |
1 files changed, 15 insertions, 7 deletions
@@ -1216,13 +1216,12 @@ puglRealize(PuglView* view) CVDisplayLinkRelease(link); } - // Get the initial frame to use from the defaults or last configuration - const PuglArea size = puglGetInitialSize(view); - const PuglPoint pos = puglGetInitialPosition(view, size); - const PuglRect initialFrame = {pos.x, pos.y, size.width, size.height}; + // Get the initial size and position from the defaults or last configuration + const PuglArea size = puglGetInitialSize(view); + const PuglPoint pos = puglGetInitialPosition(view, size); // Convert frame to points - const NSRect framePx = rectToNsRect(initialFrame); + const NSRect framePx = NSMakeRect(pos.x, pos.y, size.width, size.height); const NSRect framePt = NSMakeRect(framePx.origin.x / scaleFactor, framePx.origin.y / scaleFactor, framePx.size.width / scaleFactor, @@ -1308,8 +1307,17 @@ puglRealize(PuglView* view) ((NSWindow*)window).delegate = [[PuglWindowDelegate alloc] initWithPuglWindow:window]; - // Set basic window hints and attributes - puglSetFrame(view, initialFrame); + // Set window frame + const NSRect screenPt = rectToScreen(screen, framePt); + const NSRect winFrame = [impl->window frameRectForContentRect:screenPt]; + [impl->window setFrame:winFrame display:NO]; + + // Resize views and move them to (0, 0) + const NSRect sizePx = {{0, 0}, {framePx.size.width, framePx.size.height}}; + const NSRect sizePt = [impl->drawView convertRectFromBacking:sizePx]; + [impl->wrapperView setFrame:sizePt]; + [impl->drawView setFrame:sizePt]; + puglSetTransientParent(view, view->transientParent); updateSizeHints(view); |