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/mac.m | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) (limited to 'src/mac.m') diff --git a/src/mac.m b/src/mac.m index 152874a..0ba95ca 100644 --- a/src/mac.m +++ b/src/mac.m @@ -1007,13 +1007,16 @@ PuglStatus puglRealize(PuglView* view) { PuglInternals* impl = view->impl; + PuglStatus st = PUGL_SUCCESS; + // Ensure that we're unrealized if (impl->wrapperView) { return PUGL_FAILURE; } - if (!view->backend || !view->backend->configure) { - return PUGL_BAD_BACKEND; + // Check that the basic required configuration has been done + if ((st = puglPreRealize(view))) { + return st; } const NSScreen* const screen = [NSScreen mainScreen]; @@ -1053,17 +1056,6 @@ puglRealize(PuglView* view) CVDisplayLinkRelease(link); } - // 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) { const double screenWidthPx = [screen frame].size.width * scaleFactor; @@ -1115,7 +1107,6 @@ puglRealize(PuglView* view) } // Create draw view to be rendered to - PuglStatus st = PUGL_SUCCESS; if ((st = view->backend->configure(view)) || (st = view->backend->create(view))) { return st; -- cgit v1.2.1