From d3a1965a3d1e8b40356c2c6fe5f7a40da315b5ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Fri, 20 Jul 2012 11:32:51 -0400 Subject: [PATCH] clients: Implement minimum size for toy toolkit clients 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 | 11 +---------- clients/window.c | 8 ++++++++ 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/clients/terminal.c b/clients/terminal.c index a726232b..7e7a9fb0 100644 --- a/clients/terminal.c +++ b/clients/terminal.c @@ -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); diff --git a/clients/window.c b/clients/window.c index 93299e17..ddad36ee 100644 --- a/clients/window.c +++ b/clients/window.c @@ -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); }