kmscon_pty_resize(term->pty, term->cols, term->rows);
}
+static void widget_prepare_resize(struct wlt_widget *widget,
+ unsigned int width, unsigned int height,
+ unsigned int *new_width,
+ unsigned int *new_height,
+ void *data)
+{
+ struct wlt_terminal *term = data;
+
+ if (*new_width < width)
+ *new_width = width;
+ if (*new_height < height)
+ *new_height = height;
+}
+
static void widget_key(struct wlt_widget *widget, unsigned int mask,
uint32_t sym, uint32_t state, void *data)
{
wlt_widget_set_destroy_cb(term->widget, widget_destroy);
wlt_widget_set_redraw_cb(term->widget, widget_redraw);
- wlt_widget_set_resize_cb(term->widget, NULL, widget_resize);
+ wlt_widget_set_resize_cb(term->widget, widget_prepare_resize,
+ widget_resize);
wlt_widget_set_keyboard_cb(term->widget, widget_key);
*out = term;
return 0;
}
static void widget_prepare_resize(struct wlt_widget *widget,
- unsigned int *width, unsigned int *height,
+ unsigned int width, unsigned int height,
+ unsigned int *new_width,
+ unsigned int *new_height,
void *data)
{
struct wlt_theme *theme = data;
- unsigned int minw, minh;
+ unsigned int minw, minh, tw, th;
minw = theme->frame_width * 2;
minh = theme->control_height + theme->frame_width * 2;
- if (*width < minw)
- *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;
+
+ tw = 2 * theme->button_margin + 2 * theme->button_padding +
+ 3 * theme->button_size;
+ th = theme->button_size + 2 * theme->button_padding;
+
+ if (minw < tw)
+ minw = tw;
+ if (minh < th)
+ minh = th;
+
+ *new_width += minw;
+ *new_height += minh;
}
static void widget_resize(struct wlt_widget *widget, struct wlt_rect *alloc,
struct wlt_pool *old_pool = NULL;
size_t nsize;
int ret;
- unsigned int oldw, oldh;
+ unsigned int oldw, oldh, neww, newh;
if (!wnd || !width || !height)
return -EINVAL;
+ neww = 0;
+ newh = 0;
shl_dlist_for_each(iter, &wnd->widget_list) {
widget = shl_dlist_entry(iter, struct wlt_widget, list);
if (widget->prepare_resize_cb)
- widget->prepare_resize_cb(widget, &width, &height,
+ widget->prepare_resize_cb(widget, width, height,
+ &neww, &newh,
widget->data);
}
+ if (neww)
+ width = neww;
+ if (newh)
+ height = newh;
+
if (width == wnd->buffer.width &&
height == wnd->buffer.height)
return 0;
typedef void (*wlt_widget_destroy_cb) (struct wlt_widget *widget,
void *data);
typedef void (*wlt_widget_prepare_resize_cb) (struct wlt_widget *widget,
- unsigned int *width,
- unsigned int *height,
+ unsigned int width,
+ unsigned int height,
+ unsigned int *new_width,
+ unsigned int *new_height,
void *data);
typedef void (*wlt_widget_resize_cb) (struct wlt_widget *widget,
struct wlt_rect *allocation,