From 2eb319fbef4c611387f421afab0f8ccefbc298cf Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 2 Jan 2023 17:04:04 -0500 Subject: Factor out common realize checks and initialization --- src/win.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) (limited to 'src/win.c') 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; -- cgit v1.2.1