aboutsummaryrefslogtreecommitdiffstats
path: root/src/mac.m
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/mac.m
parente1eaf1583025ed182b9a7226f3eb17e08e81bd34 (diff)
downloadpugl-2eb319fbef4c611387f421afab0f8ccefbc298cf.tar.gz
pugl-2eb319fbef4c611387f421afab0f8ccefbc298cf.tar.bz2
pugl-2eb319fbef4c611387f421afab0f8ccefbc298cf.zip
Factor out common realize checks and initialization
Diffstat (limited to 'src/mac.m')
-rw-r--r--src/mac.m19
1 files changed, 5 insertions, 14 deletions
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;