clients: Implement minimum size for toy toolkit clients
authorKristian Høgsberg <krh@bitplanet.net>
Fri, 20 Jul 2012 15:32:51 +0000 (11:32 -0400)
committerKristian Høgsberg <krh@bitplanet.net>
Fri, 20 Jul 2012 15:33:02 +0000 (11:33 -0400)
We default to setting the minimum size to the initial size.  To set a
different minimum size than the initial size, set the minimum size first
then then initial size.  Good enough for a toy toolkit.

https://bugs.freedesktop.org/show_bug.cgi?id=50263

clients/terminal.c
clients/window.c

index a726232..7e7a9fb 100644 (file)
@@ -695,10 +695,6 @@ terminal_resize_cells(struct terminal *terminal, int width, int height)
        struct rectangle allocation;
        struct winsize ws;
 
-       if (width < 1)
-               width = 1;
-       if (height < 1)
-               height = 1;
        if (terminal->width == width && terminal->height == height)
                return;
 
@@ -764,12 +760,6 @@ resize_handler(struct widget *widget,
        struct terminal *terminal = data;
        int32_t columns, rows, m;
 
-    if (width < 200)
-        width = 200;
-
-    if (height < 50)
-        height = 50;
-
        m = 2 * terminal->margin;
        columns = (width - m) / (int32_t) terminal->extents.max_x_advance;
        rows = (height - m) / (int32_t) terminal->extents.height;
@@ -2492,6 +2482,7 @@ terminal_create(struct display *display, int fullscreen)
        cairo_destroy(cr);
        cairo_surface_destroy(surface);
 
+       terminal_resize(terminal, 20, 5); /* Set minimum size first */
        terminal_resize(terminal, 80, 25);
 
        wl_list_insert(terminal_list.prev, &terminal->link);
index 93299e1..ddad36e 100644 (file)
@@ -135,6 +135,7 @@ struct window {
        struct wl_region *opaque_region;
        char *title;
        struct rectangle allocation, saved_allocation, server_allocation;
+       struct rectangle min_allocation;
        struct rectangle pending_allocation;
        int x, y;
        int resize_edges;
@@ -2614,6 +2615,13 @@ window_schedule_resize(struct window *window, int width, int height)
        window->pending_allocation.width = width;
        window->pending_allocation.height = height;
 
+       if (window->min_allocation.width == 0)
+               window->min_allocation = window->pending_allocation;
+       if (window->pending_allocation.width < window->min_allocation.width)
+               window->pending_allocation.width = window->min_allocation.width;
+       if (window->pending_allocation.height < window->min_allocation.height)
+               window->pending_allocation.height = window->min_allocation.height;
+
        window->resize_needed = 1;
        window_schedule_redraw(window);
 }