From 5afd0bb44aa3fff79fd7825e9ac97f991d3d1f39 Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Fri, 27 May 2022 10:58:23 +0200 Subject: libdecor: pull upstream changes (a382710b on 28 apr 2022). --- libdecor/demo/demo.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'libdecor/demo') 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 @@ -165,6 +165,27 @@ static struct window *window; 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) { @@ -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 */ -- cgit v1.2.3