From 8652f978876a41b7af37d44e95ebdd6936fb2067 Mon Sep 17 00:00:00 2001 From: Joshua Ashton Date: Sun, 17 Oct 2021 18:31:53 +0000 Subject: [PATCH] view: Add view_min_size helper function Signed-off-by: Joshua Ashton --- include/labwc.h | 1 + src/view.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/include/labwc.h b/include/labwc.h index 07e6cb91..1a575450 100644 --- a/include/labwc.h +++ b/include/labwc.h @@ -342,6 +342,7 @@ void view_update_title(struct view *view); void view_update_app_id(struct view *view); void view_impl_map(struct view *view); +void view_min_size(struct view *view, int *w, int *h); void foreign_toplevel_handle_create(struct view *view); diff --git a/src/view.c b/src/view.c index 011b69d6..938eeebf 100644 --- a/src/view.c +++ b/src/view.c @@ -29,6 +29,34 @@ view_move(struct view *view, double x, double y) view->impl->move(view, x, y); } +#define MIN_VIEW_WIDTH (100) +#define MIN_VIEW_HEIGHT (60) + +void +view_min_size(struct view *view, int *w, int *h) +{ + int min_width = MIN_VIEW_WIDTH; + int min_height = MIN_VIEW_HEIGHT; +#if HAVE_XWAYLAND + if (view->type == LAB_XWAYLAND_VIEW) { + if (view->xwayland_surface->size_hints) { + if (view->xwayland_surface->size_hints->min_width > 0 || + view->xwayland_surface->size_hints->min_height > 0) { + min_width = view->xwayland_surface->size_hints->min_width; + min_height = view->xwayland_surface->size_hints->min_height; + } + } + } +#endif + + if (w) { + *w = min_width; + } + if (h) { + *h = min_height; + } +} + void view_minimize(struct view *view, bool minimized) {