aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/internal.c9
-rw-r--r--src/internal.h4
-rw-r--r--src/mac.m2
-rw-r--r--src/win.c2
-rw-r--r--src/x11.c2
5 files changed, 14 insertions, 5 deletions
diff --git a/src/internal.c b/src/internal.c
index 3799e97..31345f3 100644
--- a/src/internal.c
+++ b/src/internal.c
@@ -19,6 +19,12 @@ puglIsValidPosition(const int x, const int y)
}
bool
+puglIsValidSize(const unsigned width, const unsigned height)
+{
+ return width && height && width <= INT16_MAX && height <= INT16_MAX;
+}
+
+bool
puglIsValidArea(const PuglArea size)
{
return size.width && size.height;
@@ -80,8 +86,7 @@ puglStoreSizeHint(PuglView* const view,
const unsigned width,
const unsigned height)
{
- if (width > INT16_MAX || height > INT16_MAX ||
- (unsigned)hint >= PUGL_NUM_SIZE_HINTS) {
+ if (!puglIsValidSize(width, height)) {
return PUGL_BAD_PARAMETER;
}
diff --git a/src/internal.h b/src/internal.h
index 3a2663b..8497c50 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -22,6 +22,10 @@ PUGL_BEGIN_DECLS
bool
puglIsValidPosition(int x, int y);
+/// Return true if `width`,`height` is a valid position
+bool
+puglIsValidSize(unsigned x, unsigned y);
+
/// Return true if `size` is a valid view size
bool
puglIsValidArea(PuglArea size);
diff --git a/src/mac.m b/src/mac.m
index 180db83..b5b617b 100644
--- a/src/mac.m
+++ b/src/mac.m
@@ -1812,7 +1812,7 @@ puglSetPosition(PuglView* const view, const int x, const int y)
PuglStatus
puglSetSize(PuglView* const view, const unsigned width, const unsigned height)
{
- if (width > INT16_MAX || height > INT16_MAX) {
+ if (!puglIsValidSize(width, height)) {
return PUGL_BAD_PARAMETER;
}
diff --git a/src/win.c b/src/win.c
index ed18a39..1efc9a2 100644
--- a/src/win.c
+++ b/src/win.c
@@ -1326,7 +1326,7 @@ puglSetPosition(PuglView* const view, const int x, const int y)
PuglStatus
puglSetSize(PuglView* const view, const unsigned width, const unsigned height)
{
- if (width > INT16_MAX || height > INT16_MAX) {
+ if (!puglIsValidSize(width, height)) {
return PUGL_BAD_PARAMETER;
}
diff --git a/src/x11.c b/src/x11.c
index b7401f1..6e9d6c0 100644
--- a/src/x11.c
+++ b/src/x11.c
@@ -2021,7 +2021,7 @@ puglSetSize(PuglView* const view, const unsigned width, const unsigned height)
{
Display* const display = view->world->impl->display;
- if (width > INT16_MAX || height > INT16_MAX) {
+ if (!puglIsValidSize(width, height)) {
return PUGL_BAD_PARAMETER;
}