]> git.mdlowis.com Git - proto/labwc.git/commitdiff
view: Add view_min_size helper function
authorJoshua Ashton <joshua@froggi.es>
Sun, 17 Oct 2021 18:31:53 +0000 (18:31 +0000)
committerJohan Malm <johanmalm@users.noreply.github.com>
Sun, 17 Oct 2021 18:49:05 +0000 (19:49 +0100)
Signed-off-by: Joshua Ashton <joshua@froggi.es>
include/labwc.h
src/view.c

index 07e6cb91db94f29f974924c9322a08971681f4f3..1a575450167ce891d76cbd4cca1fcdd7448355cc 100644 (file)
@@ -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);
 
index 011b69d614f55ff57cb99a59cc066ee2ca47ac28..938eeebf1a452b273e14697d7e0e31d42f50fa07 100644 (file)
@@ -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)
 {