aboutsummaryrefslogtreecommitdiffstats
path: root/src/win.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2023-01-02 17:04:04 -0500
committerDavid Robillard <d@drobilla.net>2023-01-02 17:04:04 -0500
commit2eb319fbef4c611387f421afab0f8ccefbc298cf (patch)
treed377a73acd4bc84c6321b044829a143be0aa0961 /src/win.c
parente1eaf1583025ed182b9a7226f3eb17e08e81bd34 (diff)
downloadpugl-2eb319fbef4c611387f421afab0f8ccefbc298cf.tar.gz
pugl-2eb319fbef4c611387f421afab0f8ccefbc298cf.tar.bz2
pugl-2eb319fbef4c611387f421afab0f8ccefbc298cf.zip
Factor out common realize checks and initialization
Diffstat (limited to 'src/win.c')
-rw-r--r--src/win.c24
1 files changed, 8 insertions, 16 deletions
diff --git a/src/win.c b/src/win.c
index c83c91d..e41222b 100644
--- a/src/win.c
+++ b/src/win.c
@@ -213,10 +213,18 @@ PuglStatus
puglRealize(PuglView* view)
{
PuglInternals* impl = view->impl;
+ PuglStatus st = PUGL_SUCCESS;
+
+ // Ensure that we're unrealized
if (impl->hwnd) {
return PUGL_FAILURE;
}
+ // Check that the basic required configuration has been done
+ if ((st = puglPreRealize(view))) {
+ return st;
+ }
+
// Getting depth from the display mode seems tedious, just set usual values
if (view->hints[PUGL_RED_BITS] == PUGL_DONT_CARE) {
view->hints[PUGL_RED_BITS] = 8;
@@ -242,11 +250,6 @@ puglRealize(PuglView* view)
return PUGL_REGISTRATION_FAILED;
}
- if (!view->backend || !view->backend->configure) {
- return PUGL_BAD_BACKEND;
- }
-
- PuglStatus st = PUGL_SUCCESS;
if ((st = view->backend->configure(view)) ||
(st = view->backend->create(view))) {
return st;
@@ -1372,17 +1375,6 @@ puglWinCreateWindow(PuglView* const view,
const unsigned winFlags = puglWinGetWindowFlags(view);
const unsigned winExFlags = puglWinGetWindowExFlags(view);
- // 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;