aboutsummaryrefslogtreecommitdiffstats
path: root/pugl/detail/win.h
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-05-16 21:18:02 +0200
committerDavid Robillard <d@drobilla.net>2020-05-16 21:18:02 +0200
commitfe96ed3c451548278197e2da74d3d53b1d6a8dd9 (patch)
tree6c4e3e751ddd13cd4898fac0fae4f4aed7079f36 /pugl/detail/win.h
parent3200cda25e06887e809fc5b47780aaf950253172 (diff)
downloadpugl-fe96ed3c451548278197e2da74d3d53b1d6a8dd9.tar.gz
pugl-fe96ed3c451548278197e2da74d3d53b1d6a8dd9.tar.bz2
pugl-fe96ed3c451548278197e2da74d3d53b1d6a8dd9.zip
Add default and maximum size
Diffstat (limited to 'pugl/detail/win.h')
-rw-r--r--pugl/detail/win.h25
1 files changed, 21 insertions, 4 deletions
diff --git a/pugl/detail/win.h b/pugl/detail/win.h
index 8ebb7bf..087bbce 100644
--- a/pugl/detail/win.h
+++ b/pugl/detail/win.h
@@ -88,15 +88,32 @@ puglWinGetWindowExFlags(const PuglView* const view)
}
static inline PuglStatus
-puglWinCreateWindow(const PuglView* const view,
- const char* const title,
- HWND* const hwnd,
- HDC* const hdc)
+puglWinCreateWindow(PuglView* const view,
+ const char* const title,
+ HWND* const hwnd,
+ HDC* const hdc)
{
const char* className = (const char*)view->world->className;
const unsigned winFlags = puglWinGetWindowFlags(view);
const unsigned winExFlags = puglWinGetWindowExFlags(view);
+ if (view->frame.width == 0.0 && view->frame.height == 0.0) {
+ if (view->defaultWidth == 0.0 && view->defaultHeight == 0.0) {
+ return PUGL_BAD_CONFIGURATION;
+ }
+
+ RECT desktopRect;
+ GetClientRect(GetDesktopWindow(), &desktopRect);
+
+ const int screenWidth = desktopRect.right - desktopRect.left;
+ const int screenHeight = desktopRect.bottom - desktopRect.top;
+
+ view->frame.width = view->defaultWidth;
+ view->frame.height = view->defaultHeight;
+ view->frame.x = screenWidth / 2.0 - view->frame.width / 2.0;
+ view->frame.y = screenHeight / 2.0 - view->frame.height / 2.0;
+ }
+
// The meaning of "parent" depends on the window type (WS_CHILD)
PuglNativeView parent = view->parent ? view->parent : view->transientParent;