aboutsummaryrefslogtreecommitdiffstats
path: root/src/mac.m
diff options
context:
space:
mode:
Diffstat (limited to 'src/mac.m')
-rw-r--r--src/mac.m49
1 files changed, 24 insertions, 25 deletions
diff --git a/src/mac.m b/src/mac.m
index b6867a4..41d358a 100644
--- a/src/mac.m
+++ b/src/mac.m
@@ -1707,20 +1707,10 @@ puglGetScaleFactor(const PuglView* const view)
return [viewScreen(view) backingScaleFactor];
}
-PuglStatus
-puglSetPosition(PuglView* const view, const int x, const int y)
+static PuglStatus
+puglSetWindowPosition(PuglView* const view, const int x, const int y)
{
- if (!puglIsValidPosition(x, y)) {
- return PUGL_BAD_PARAMETER;
- }
-
PuglInternals* const impl = view->impl;
- if (!impl->wrapperView) {
- // Set defaults to be used when realized
- view->defaultX = x;
- view->defaultY = y;
- return PUGL_SUCCESS;
- }
const NSRect framePx =
NSMakeRect(x, y, view->lastConfigure.width, view->lastConfigure.height);
@@ -1741,20 +1731,12 @@ puglSetPosition(PuglView* const view, const int x, const int y)
return dispatchCurrentChildViewConfiguration(view);
}
-PuglStatus
-puglSetSize(PuglView* const view, const unsigned width, const unsigned height)
+static PuglStatus
+puglSetWindowSize(PuglView* const view,
+ const unsigned width,
+ const unsigned height)
{
- if (!puglIsValidSize(width, height)) {
- return PUGL_BAD_PARAMETER;
- }
-
PuglInternals* const impl = view->impl;
- if (!impl->wrapperView) {
- // Set defaults to be used when realized
- view->sizeHints[PUGL_DEFAULT_SIZE].width = (PuglSpan)width;
- view->sizeHints[PUGL_DEFAULT_SIZE].height = (PuglSpan)height;
- return PUGL_SUCCESS;
- }
// Set wrapper view size
const double scaleFactor = [viewScreen(view) backingScaleFactor];
@@ -1783,6 +1765,23 @@ puglSetSize(PuglView* const view, const unsigned width, const unsigned height)
}
PuglStatus
+puglSetPositionHint(PuglView* const view,
+ const PuglPositionHint hint,
+ const int x,
+ const int y)
+{
+ if (x <= INT16_MIN || x > INT16_MAX || y <= INT16_MIN || y > INT16_MAX) {
+ return PUGL_BAD_PARAMETER;
+ }
+
+ view->positionHints[hint].x = (PuglCoord)x;
+ view->positionHints[hint].y = (PuglCoord)y;
+
+ return (hint == PUGL_CURRENT_POSITION) ? puglSetWindowPosition(view, x, y)
+ : PUGL_SUCCESS;
+}
+
+PuglStatus
puglSetSizeHint(PuglView* const view,
const PuglSizeHint hint,
const unsigned width,
@@ -1791,7 +1790,7 @@ puglSetSizeHint(PuglView* const view,
const PuglStatus st = puglStoreSizeHint(view, hint, width, height);
return st ? st
- : (hint == PUGL_CURRENT_SIZE) ? puglSetSize(view, width, height)
+ : (hint == PUGL_CURRENT_SIZE) ? puglSetWindowSize(view, width, height)
: updateSizeHint(view, hint);
}