aboutsummaryrefslogtreecommitdiffstats
path: root/src/win.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2022-12-27 20:43:57 -0500
committerDavid Robillard <d@drobilla.net>2022-12-27 20:43:57 -0500
commitabe98d55c8775619f9392e16289c6d15c06b39b6 (patch)
tree162417ad2d418b555cbdcf27be2e50975a318af8 /src/win.c
parentef19bb7e8f170db9fcd32b89b413c9b0a8f6d8c4 (diff)
downloadpugl-abe98d55c8775619f9392e16289c6d15c06b39b6.tar.gz
pugl-abe98d55c8775619f9392e16289c6d15c06b39b6.tar.bz2
pugl-abe98d55c8775619f9392e16289c6d15c06b39b6.zip
Fix inconsistent initial window positioning across platforms
Diffstat (limited to 'src/win.c')
-rw-r--r--src/win.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/win.c b/src/win.c
index 34ad4c3..c83c91d 100644
--- a/src/win.c
+++ b/src/win.c
@@ -1372,21 +1372,25 @@ puglWinCreateWindow(PuglView* const view,
const unsigned winFlags = puglWinGetWindowFlags(view);
const unsigned winExFlags = puglWinGetWindowExFlags(view);
- 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;
}
+ 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) {
RECT desktopRect;
GetClientRect(GetDesktopWindow(), &desktopRect);
const int screenWidth = desktopRect.right - desktopRect.left;
const int screenHeight = desktopRect.bottom - desktopRect.top;
- view->frame.width = defaultSize.width;
- view->frame.height = defaultSize.height;
-
view->frame.x = (PuglCoord)((screenWidth - view->frame.width) / 2);
view->frame.y = (PuglCoord)((screenHeight - view->frame.height) / 2);
}