diff options
author | David Robillard <d@drobilla.net> | 2022-12-27 20:43:57 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-12-27 20:43:57 -0500 |
commit | abe98d55c8775619f9392e16289c6d15c06b39b6 (patch) | |
tree | 162417ad2d418b555cbdcf27be2e50975a318af8 /src/mac.m | |
parent | ef19bb7e8f170db9fcd32b89b413c9b0a8f6d8c4 (diff) | |
download | pugl-abe98d55c8775619f9392e16289c6d15c06b39b6.tar.gz pugl-abe98d55c8775619f9392e16289c6d15c06b39b6.tar.bz2 pugl-abe98d55c8775619f9392e16289c6d15c06b39b6.zip |
Fix inconsistent initial window positioning across platforms
Diffstat (limited to 'src/mac.m')
-rw-r--r-- | src/mac.m | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -1058,17 +1058,21 @@ puglRealize(PuglView* view) CVDisplayLinkRelease(link); } - if (view->frame.width == 0.0 && view->frame.height == 0.0) { + // Set the size to the default if it has not already been set + if (view->frame.width <= 0.0 || view->frame.height <= 0.0) { const PuglViewSize defaultSize = view->sizeHints[PUGL_DEFAULT_SIZE]; if (!defaultSize.width || !defaultSize.height) { return PUGL_BAD_CONFIGURATION; } - const double screenWidthPx = [screen frame].size.width * scaleFactor; - const double screenHeightPx = [screen frame].size.height * scaleFactor; - view->frame.width = defaultSize.width; view->frame.height = defaultSize.height; + } + + // Center top-level windows if a position has not been set + if (!view->parent && !view->frame.x && !view->frame.y) { + const double screenWidthPx = [screen frame].size.width * scaleFactor; + const double screenHeightPx = [screen frame].size.height * scaleFactor; view->frame.x = (PuglCoord)((screenWidthPx - view->frame.width) / 2.0); view->frame.y = (PuglCoord)((screenHeightPx - view->frame.height) / 2.0); |