summaryrefslogtreecommitdiff
path: root/libdecor/demo
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2022-05-27 10:58:23 +0200
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2022-05-27 10:58:23 +0200
commit5afd0bb44aa3fff79fd7825e9ac97f991d3d1f39 (patch)
tree74c293e5e43e5422fe193b02d9766b1cf40bb570 /libdecor/demo
parentb78035624d5135f27b9742249652f124411f90a9 (diff)
libdecor: pull upstream changes (a382710b on 28 apr 2022).
Diffstat (limited to 'libdecor/demo')
-rw-r--r--libdecor/demo/demo.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/libdecor/demo/demo.c b/libdecor/demo/demo.c
index 85efcd739..ff285cc2f 100644
--- a/libdecor/demo/demo.c
+++ b/libdecor/demo/demo.c
@@ -166,6 +166,27 @@ static void
redraw(struct window *window);
static void
+constrain_content_size(const struct libdecor_frame *frame,
+ int *width,
+ int *height)
+{
+ int min_width, min_height, max_width, max_height;
+
+ libdecor_frame_get_min_content_size(frame, &min_width, &min_height);
+ libdecor_frame_get_max_content_size(frame, &max_width, &max_height);
+
+ if (min_width > 0)
+ *width = MAX(min_width, *width);
+ if (max_width > 0)
+ *width = MIN(*width, max_width);
+
+ if (min_height > 0)
+ *height = MAX(min_height, *height);
+ if (max_height > 0)
+ *height = MIN(*height, max_height);
+}
+
+static void
resize(struct window *window, int width, int height)
{
struct libdecor_state *state;
@@ -175,8 +196,10 @@ resize(struct window *window, int width, int height)
return;
}
+ constrain_content_size(window->frame, &width, &height);
+
/* commit changes to decorations */
- state = libdecor_state_new( width, height);
+ state = libdecor_state_new(width, height);
libdecor_frame_commit(window->frame, state, NULL);
libdecor_state_free(state);
/* force redraw of content and commit */