window: Compute initial window size correctly
authorKristian Høgsberg <krh@bitplanet.net>
Wed, 20 Jun 2012 21:30:03 +0000 (17:30 -0400)
committerKristian Høgsberg <krh@bitplanet.net>
Wed, 20 Jun 2012 21:30:03 +0000 (17:30 -0400)
We didn't take decoration size into account before.

clients/dnd.c
clients/terminal.c
clients/window.c
clients/window.h

index f67bfb5..c38b94f 100644 (file)
@@ -590,7 +590,7 @@ dnd_create(struct display *display)
        width = 4 * (item_width + item_padding) + item_padding;
        height = 4 * (item_height + item_padding) + item_padding;
 
-       widget_schedule_resize(dnd->widget, width, height);
+       frame_set_child_size(dnd->widget, width, height);
 
        return dnd;
 }
index 409a148..d747a63 100644 (file)
@@ -804,7 +804,8 @@ terminal_resize(struct terminal *terminal, int columns, int rows)
        m = 2 * terminal->margin;
        width = columns * terminal->extents.max_x_advance + m;
        height = rows * terminal->extents.height + m;
-       widget_schedule_resize(terminal->widget, width, height);
+
+       frame_set_child_size(terminal->widget, width, height);
 }
 
 struct color_scheme DEFAULT_COLORS = {
@@ -2338,7 +2339,7 @@ terminal_create(struct display *display, int fullscreen)
        cairo_destroy(cr);
        cairo_surface_destroy(surface);
 
-       window_schedule_resize(terminal->window, 500, 400);
+       terminal_resize(terminal, 80, 25);
 
        return terminal;
 }
index 2d67acd..fffc231 100644 (file)
@@ -1692,6 +1692,29 @@ frame_create(struct window *window, void *data)
        return frame->child;
 }
 
+void
+frame_set_child_size(struct widget *widget, int child_width, int child_height)
+{
+       struct display *display = widget->window->display;
+       struct theme *t = display->theme;
+       int decoration_width, decoration_height;
+       int width, height;
+
+       if (widget->window->type != TYPE_FULLSCREEN) {
+               decoration_width = (t->width + t->margin) * 2;
+               decoration_height = t->width +
+                       t->titlebar_height + t->margin * 2;
+
+               width = child_width + decoration_width;
+               height = child_height + decoration_height;
+       } else {
+               width = child_width;
+               height = child_height;
+       }
+
+       window_schedule_resize(widget->window, width, height);
+}
+
 static void
 frame_destroy(struct frame *frame)
 {
index da3815b..92e52a9 100644 (file)
@@ -363,6 +363,8 @@ widget_schedule_redraw(struct widget *widget);
 
 struct widget *
 frame_create(struct window *window, void *data);
+void
+frame_set_child_size(struct widget *widget, int child_width, int child_height);
 
 void
 input_set_pointer_image(struct input *input, int pointer);