From a1627927c756d91c85448ff96ab437d0903e141f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kristian=20H=C3=B8gsberg?= Date: Wed, 20 Jun 2012 17:30:03 -0400 Subject: [PATCH] window: Compute initial window size correctly We didn't take decoration size into account before. --- clients/dnd.c | 2 +- clients/terminal.c | 5 +++-- clients/window.c | 23 +++++++++++++++++++++++ clients/window.h | 2 ++ 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/clients/dnd.c b/clients/dnd.c index f67bfb5..c38b94f 100644 --- a/clients/dnd.c +++ b/clients/dnd.c @@ -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; } diff --git a/clients/terminal.c b/clients/terminal.c index 409a148..d747a63 100644 --- a/clients/terminal.c +++ b/clients/terminal.c @@ -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; } diff --git a/clients/window.c b/clients/window.c index 2d67acd..fffc231 100644 --- a/clients/window.c +++ b/clients/window.c @@ -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) { diff --git a/clients/window.h b/clients/window.h index da3815b..92e52a9 100644 --- a/clients/window.h +++ b/clients/window.h @@ -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); -- 2.7.4