wlt: theme: fix calculating window size regarding buttons
authorDavid Herrmann <dh.herrmann@googlemail.com>
Wed, 26 Sep 2012 17:12:16 +0000 (19:12 +0200)
committerDavid Herrmann <dh.herrmann@googlemail.com>
Wed, 26 Sep 2012 17:12:16 +0000 (19:12 +0200)
We need to avoid reducing window size beyond our minimal width used to
draw buttons.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
src/wlt_theme.c

index 96c1caa..c69d889 100644 (file)
@@ -239,7 +239,9 @@ static void widget_redraw(struct wlt_widget *widget, void *data)
        width = theme->buffer.width;
        height = theme->buffer.height;
        if (width < 2 ||
-           width < 2 * theme->frame_width) {
+           width < 2 * theme->frame_width ||
+           width < 2 * theme->button_margin + 2 * theme->button_padding +
+                   3 * theme->button_size) {
                widget_draw_fallback(theme);
        } else if (height < theme->control_height + 2 * theme->frame_width) {
                widget_draw_fallback(theme);
@@ -262,6 +264,14 @@ static void widget_prepare_resize(struct wlt_widget *widget,
                *width = minw;
        if (*height < minh)
                *height = minh;
+
+       minw = 2 * theme->button_margin + 2 * theme->button_padding +
+              3 * theme->button_size;
+       minh = theme->button_size + 2 * theme->button_padding;
+       if (*width < minw)
+               *width = minw;
+       if (*height < minh)
+               *height = minh;
 }
 
 static void widget_resize(struct wlt_widget *widget, struct wlt_rect *alloc,