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) {