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
Kristian Høgsberg 12 years ago
parent 905d7cedf5
commit d3a1965a3d
  1. 11
      clients/terminal.c
  2. 8
      clients/window.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);

@ -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);
}

Loading…
Cancel
Save