window: Compute initial window size correctly
We didn't take decoration size into account before.
This commit is contained in:
parent
e828e904b5
commit
a1627927c7
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue