diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/internal.c | 16 | ||||
-rw-r--r-- | src/internal.h | 7 | ||||
-rw-r--r-- | src/mac.m | 13 | ||||
-rw-r--r-- | src/win.c | 12 | ||||
-rw-r--r-- | src/x11.c | 12 |
5 files changed, 34 insertions, 26 deletions
diff --git a/src/internal.c b/src/internal.c index 3c4d304..dfea0ca 100644 --- a/src/internal.c +++ b/src/internal.c @@ -68,6 +68,22 @@ puglSetString(char** dest, const char* string) } } +PuglStatus +puglStoreSizeHint(PuglView* const view, + const PuglSizeHint hint, + const unsigned width, + const unsigned height) +{ + if (width > INT16_MAX || height > INT16_MAX || + (unsigned)hint >= PUGL_NUM_SIZE_HINTS) { + return PUGL_BAD_PARAMETER; + } + + view->sizeHints[hint].width = (PuglSpan)width; + view->sizeHints[hint].height = (PuglSpan)height; + return PUGL_SUCCESS; +} + uint32_t puglDecodeUTF8(const uint8_t* buf) { diff --git a/src/internal.h b/src/internal.h index 3721c10..f978074 100644 --- a/src/internal.h +++ b/src/internal.h @@ -34,6 +34,13 @@ puglSetBlob(PuglBlob* dest, const void* data, size_t len); void puglSetString(char** dest, const char* string); +/// Store `width` and `height` as the current value of a size `hint` +PuglStatus +puglStoreSizeHint(PuglView* view, + PuglSizeHint hint, + unsigned width, + unsigned height); + /// Handle a changed string property PUGL_API PuglStatus @@ -1849,17 +1849,12 @@ puglSetSize(PuglView* const view, const unsigned width, const unsigned height) PuglStatus puglSetSizeHint(PuglView* const view, const PuglSizeHint hint, - const PuglSpan width, - const PuglSpan height) + const unsigned width, + const unsigned height) { - if ((unsigned)hint >= PUGL_NUM_SIZE_HINTS) { - return PUGL_BAD_PARAMETER; - } - - view->sizeHints[hint].width = width; - view->sizeHints[hint].height = height; + const PuglStatus st = puglStoreSizeHint(view, hint, width, height); - return view->impl->window ? updateSizeHint(view, hint) : PUGL_SUCCESS; + return (!st && view->impl->window) ? updateSizeHint(view, hint) : st; } PuglStatus @@ -1358,16 +1358,10 @@ puglSetSize(PuglView* const view, const unsigned width, const unsigned height) PuglStatus puglSetSizeHint(PuglView* const view, const PuglSizeHint hint, - const PuglSpan width, - const PuglSpan height) + const unsigned width, + const unsigned height) { - if ((unsigned)hint >= PUGL_NUM_SIZE_HINTS) { - return PUGL_BAD_PARAMETER; - } - - view->sizeHints[hint].width = width; - view->sizeHints[hint].height = height; - return PUGL_SUCCESS; + return puglStoreSizeHint(view, hint, width, height); } PuglStatus @@ -2038,16 +2038,12 @@ puglSetSize(PuglView* const view, const unsigned width, const unsigned height) PuglStatus puglSetSizeHint(PuglView* const view, const PuglSizeHint hint, - const PuglSpan width, - const PuglSpan height) + const unsigned width, + const unsigned height) { - if ((unsigned)hint >= PUGL_NUM_SIZE_HINTS) { - return PUGL_BAD_PARAMETER; - } + const PuglStatus st = puglStoreSizeHint(view, hint, width, height); - view->sizeHints[hint].width = width; - view->sizeHints[hint].height = height; - return updateSizeHints(view); + return st ? st : updateSizeHints(view); } PuglStatus |