]> git.mdlowis.com Git - proto/labwc.git/commitdiff
view: use fixed default window width
authortokyo4j <hrak1529@gmail.com>
Mon, 1 Sep 2025 08:29:24 +0000 (17:29 +0900)
committerJohan Malm <johanmalm@users.noreply.github.com>
Mon, 1 Sep 2025 19:13:00 +0000 (20:13 +0100)
Now it's not very reasonable to determine the default window width based
on the titlebar geometry, as the titlebar can be shrunk to 1px.

Let's use the fixed value of 100px for simplification.

include/view.h
src/snap.c
src/view.c
src/xwayland.c

index f2dcb5c901aee722fc748efdd3fa8a4bf95872f5..9418101571f06a14524cd93589589f79cf1c4902 100644 (file)
 #include "config.h"
 #include "config/types.h"
 
+/*
+ * Default minimal window size. Clients can explicitly set smaller values via
+ * e.g. xdg_toplevel::set_min_size.
+ */
+#define LAB_MIN_VIEW_WIDTH 100
 #define LAB_MIN_VIEW_HEIGHT 60
 
 /*
@@ -573,7 +578,6 @@ const char *view_get_string_prop(struct view *view, const char *prop);
 void view_update_title(struct view *view);
 void view_update_app_id(struct view *view);
 void view_reload_ssd(struct view *view);
-int view_get_min_width(void);
 
 void view_set_shade(struct view *view, bool shaded);
 
index fcb8f335dd98bc3c5c6877dce0acb0c37f42a1bd..83087e26fc0797dc1cb4a68ad5f1ff1a25710da8 100644 (file)
@@ -221,7 +221,6 @@ snap_shrink_to_next_edge(struct view *view,
 
        *geo = view->pending;
        enum lab_edge resize_edges;
-       int min_width = view_get_min_width();
 
        /*
         * First shrink the view along the relevant edge. The maximum shrink
@@ -230,12 +229,12 @@ snap_shrink_to_next_edge(struct view *view,
         */
        switch (direction) {
        case LAB_EDGE_RIGHT:
-               geo->width = MAX(geo->width / 2, min_width);
+               geo->width = MAX(geo->width / 2, LAB_MIN_VIEW_WIDTH);
                geo->x = view->pending.x + view->pending.width - geo->width;
                resize_edges = LAB_EDGE_LEFT;
                break;
        case LAB_EDGE_LEFT:
-               geo->width = MAX(geo->width / 2, min_width);
+               geo->width = MAX(geo->width / 2, LAB_MIN_VIEW_WIDTH);
                resize_edges = LAB_EDGE_RIGHT;
                break;
        case LAB_EDGE_BOTTOM:
index 293d466c5e4d8c40ac7e81c53cb203ff82bf907d..4173f64320169d329c61f0aa364404aa2d8beb98 100644 (file)
@@ -744,7 +744,6 @@ view_adjust_size(struct view *view, int *w, int *h)
 {
        assert(view);
        struct view_size_hints hints = view_get_size_hints(view);
-       int min_width = view_get_min_width();
 
        /*
         * "If a base size is not provided, the minimum size is to be
@@ -764,7 +763,7 @@ view_adjust_size(struct view *view, int *w, int *h)
 
        /* If a minimum width/height was not set, then use default */
        if (hints.min_width < 1) {
-               hints.min_width = min_width;
+               hints.min_width = LAB_MIN_VIEW_WIDTH;
        }
        if (hints.min_height < 1) {
                hints.min_height = LAB_MIN_VIEW_HEIGHT;
@@ -2412,17 +2411,6 @@ view_reload_ssd(struct view *view)
        }
 }
 
-int
-view_get_min_width(void)
-{
-       int button_count_left = wl_list_length(&rc.title_buttons_left);
-       int button_count_right =  wl_list_length(&rc.title_buttons_right);
-       return (rc.theme->window_button_width * (button_count_left + button_count_right)) +
-               (rc.theme->window_button_spacing * MAX((button_count_right - 1), 0)) +
-               (rc.theme->window_button_spacing * MAX((button_count_left - 1), 0)) +
-               (2 * rc.theme->window_titlebar_padding_width);
-}
-
 void
 view_toggle_keybinds(struct view *view)
 {
index 9f311e865c311efb7cc8b8f7dd15f5357934976f..62c96831a7862e92dbabe07b820e9c547dfec6ba 100644 (file)
@@ -748,15 +748,13 @@ handle_map_request(struct wl_listener *listener, void *data)
 static void
 check_natural_geometry(struct view *view)
 {
-       int min_width = view_get_min_width();
-
        /*
         * Some applications (example: Thonny) don't set a reasonable
         * un-maximized size when started maximized. Try to detect this
         * and set a fallback size.
         */
        if (!view_is_floating(view)
-                       && (view->natural_geometry.width < min_width
+                       && (view->natural_geometry.width < LAB_MIN_VIEW_WIDTH
                        || view->natural_geometry.height < LAB_MIN_VIEW_HEIGHT)) {
                view_set_fallback_natural_geometry(view);
        }