window: Get rid of the window child allocation concept
This commit is contained in:
@@ -393,9 +393,7 @@ background_configure(void *data,
|
|||||||
struct background *background =
|
struct background *background =
|
||||||
(struct background *) window_get_user_data(window);
|
(struct background *) window_get_user_data(window);
|
||||||
|
|
||||||
window_set_child_size(background->window, width, height);
|
widget_schedule_resize(background->widget, width, height);
|
||||||
widget_set_allocation(background->widget, 0, 0, width, height);
|
|
||||||
window_schedule_redraw(background->window);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -410,7 +408,7 @@ unlock_dialog_redraw_handler(struct widget *widget, void *data)
|
|||||||
|
|
||||||
surface = window_get_surface(dialog->window);
|
surface = window_get_surface(dialog->window);
|
||||||
cr = cairo_create(surface);
|
cr = cairo_create(surface);
|
||||||
window_get_child_allocation(dialog->window, &allocation);
|
widget_get_allocation(dialog->widget, &allocation);
|
||||||
cairo_rectangle(cr, allocation.x, allocation.y,
|
cairo_rectangle(cr, allocation.x, allocation.y,
|
||||||
allocation.width, allocation.height);
|
allocation.width, allocation.height);
|
||||||
cairo_clip(cr);
|
cairo_clip(cr);
|
||||||
|
|||||||
+5
-6
@@ -170,7 +170,7 @@ dnd_redraw_handler(struct widget *widget, void *data)
|
|||||||
|
|
||||||
surface = window_get_surface(dnd->window);
|
surface = window_get_surface(dnd->window);
|
||||||
cr = cairo_create(surface);
|
cr = cairo_create(surface);
|
||||||
window_get_child_allocation(dnd->window, &allocation);
|
widget_get_allocation(dnd->widget, &allocation);
|
||||||
cairo_rectangle(cr, allocation.x, allocation.y,
|
cairo_rectangle(cr, allocation.x, allocation.y,
|
||||||
allocation.width, allocation.height);
|
allocation.width, allocation.height);
|
||||||
|
|
||||||
@@ -222,7 +222,7 @@ dnd_get_item(struct dnd *dnd, int32_t x, int32_t y)
|
|||||||
struct rectangle allocation;
|
struct rectangle allocation;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
window_get_child_allocation(dnd->window, &allocation);
|
widget_get_allocation(dnd->widget, &allocation);
|
||||||
|
|
||||||
x -= allocation.x;
|
x -= allocation.x;
|
||||||
y -= allocation.y;
|
y -= allocation.y;
|
||||||
@@ -363,7 +363,7 @@ dnd_button_handler(struct widget *widget,
|
|||||||
struct dnd_drag *dnd_drag;
|
struct dnd_drag *dnd_drag;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
window_get_child_allocation(dnd->window, &allocation);
|
widget_get_allocation(dnd->widget, &allocation);
|
||||||
input_get_position(input, &x, &y);
|
input_get_position(input, &x, &y);
|
||||||
item = dnd_get_item(dnd, x, y);
|
item = dnd_get_item(dnd, x, y);
|
||||||
x -= allocation.x;
|
x -= allocation.x;
|
||||||
@@ -468,7 +468,7 @@ dnd_receive_func(void *data, size_t len, int32_t x, int32_t y, void *user_data)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
window_get_child_allocation(dnd->window, &allocation);
|
widget_get_allocation(dnd->widget, &allocation);
|
||||||
item = item_create(dnd->display,
|
item = item_create(dnd->display,
|
||||||
x - message->x_offset - allocation.x,
|
x - message->x_offset - allocation.x,
|
||||||
y - message->y_offset - allocation.y,
|
y - message->y_offset - allocation.y,
|
||||||
@@ -535,9 +535,8 @@ dnd_create(struct display *display)
|
|||||||
|
|
||||||
width = 4 * (item_width + item_padding) + item_padding;
|
width = 4 * (item_width + item_padding) + item_padding;
|
||||||
height = 4 * (item_height + item_padding) + item_padding;
|
height = 4 * (item_height + item_padding) + item_padding;
|
||||||
window_set_child_size(dnd->window, width, height);
|
|
||||||
|
|
||||||
window_schedule_redraw(dnd->window);
|
widget_schedule_resize(dnd->widget, width, height);
|
||||||
|
|
||||||
return dnd;
|
return dnd;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-8
@@ -107,7 +107,7 @@ redraw_handler(struct widget *widget, void *data)
|
|||||||
if (log_redraw)
|
if (log_redraw)
|
||||||
printf("redraw\n");
|
printf("redraw\n");
|
||||||
|
|
||||||
window_get_child_allocation(e->window, &rect);
|
widget_get_allocation(e->widget, &rect);
|
||||||
surface = window_get_surface(e->window);
|
surface = window_get_surface(e->window);
|
||||||
|
|
||||||
cr = cairo_create(surface);
|
cr = cairo_create(surface);
|
||||||
@@ -150,7 +150,7 @@ resize_handler(struct widget *widget,
|
|||||||
height = height_max;
|
height = height_max;
|
||||||
|
|
||||||
/* set the new window dimensions */
|
/* set the new window dimensions */
|
||||||
window_set_child_size(e->window, width, height);
|
widget_set_size(e->widget, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -266,12 +266,6 @@ eventdemo_create(struct display *d)
|
|||||||
if(e == NULL)
|
if(e == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* Creates a new window with the given title, width and height.
|
|
||||||
* To set the size of the window for a given usable areas width
|
|
||||||
* and height in a window decoration agnostic way use:
|
|
||||||
* window_set_child_size(struct window *window,
|
|
||||||
* int32_t width, int32_t height);
|
|
||||||
*/
|
|
||||||
e->window = window_create(d, width, height);
|
e->window = window_create(d, width, height);
|
||||||
e->widget = window_add_widget(e->window, e);
|
e->widget = window_add_widget(e->window, e);
|
||||||
window_set_title(e->window, title);
|
window_set_title(e->window, title);
|
||||||
|
|||||||
+4
-4
@@ -221,7 +221,7 @@ redraw_handler(struct widget *widget, void *data)
|
|||||||
struct wl_callback *callback;
|
struct wl_callback *callback;
|
||||||
struct gears *gears = data;
|
struct gears *gears = data;
|
||||||
|
|
||||||
window_get_child_allocation(gears->window, &allocation);
|
widget_get_allocation(gears->widget, &allocation);
|
||||||
window_get_allocation(gears->window, &window_allocation);
|
window_get_allocation(gears->window, &window_allocation);
|
||||||
|
|
||||||
if (display_acquire_window_surface(gears->d,
|
if (display_acquire_window_surface(gears->d,
|
||||||
@@ -232,7 +232,7 @@ redraw_handler(struct widget *widget, void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
glViewport(allocation.x,
|
glViewport(allocation.x,
|
||||||
window_allocation.height - allocation.height - allocation.x,
|
window_allocation.height - allocation.height - allocation.y,
|
||||||
allocation.width, allocation.height);
|
allocation.width, allocation.height);
|
||||||
glScissor(allocation.x,
|
glScissor(allocation.x,
|
||||||
window_allocation.height - allocation.height - allocation.y,
|
window_allocation.height - allocation.height - allocation.y,
|
||||||
@@ -293,7 +293,7 @@ resize_handler(struct widget *widget,
|
|||||||
height = 300;
|
height = 300;
|
||||||
}
|
}
|
||||||
|
|
||||||
window_set_child_size(gears->window, width, height);
|
widget_set_size(gears->widget, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -361,7 +361,7 @@ gears_create(struct display *display)
|
|||||||
window_set_keyboard_focus_handler(gears->window,
|
window_set_keyboard_focus_handler(gears->window,
|
||||||
keyboard_focus_handler);
|
keyboard_focus_handler);
|
||||||
|
|
||||||
frame_callback(gears, NULL, 0);
|
window_schedule_resize(gears->window, width, height);
|
||||||
|
|
||||||
return gears;
|
return gears;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -142,7 +142,7 @@ redraw_handler(struct widget *widget, void *data)
|
|||||||
cairo_t *cr;
|
cairo_t *cr;
|
||||||
cairo_surface_t *surface;
|
cairo_surface_t *surface;
|
||||||
|
|
||||||
window_get_child_allocation(image->window, &allocation);
|
widget_get_allocation(image->widget, &allocation);
|
||||||
|
|
||||||
pb = gdk_pixbuf_new_from_file_at_size(image->filename,
|
pb = gdk_pixbuf_new_from_file_at_size(image->filename,
|
||||||
allocation.width,
|
allocation.width,
|
||||||
@@ -153,7 +153,7 @@ redraw_handler(struct widget *widget, void *data)
|
|||||||
|
|
||||||
surface = window_get_surface(image->window);
|
surface = window_get_surface(image->window);
|
||||||
cr = cairo_create(surface);
|
cr = cairo_create(surface);
|
||||||
window_get_child_allocation(image->window, &allocation);
|
widget_get_allocation(image->widget, &allocation);
|
||||||
cairo_rectangle(cr, allocation.x, allocation.y,
|
cairo_rectangle(cr, allocation.x, allocation.y,
|
||||||
allocation.width, allocation.height);
|
allocation.width, allocation.height);
|
||||||
cairo_clip(cr);
|
cairo_clip(cr);
|
||||||
@@ -215,7 +215,7 @@ image_create(struct display *display, const char *filename)
|
|||||||
window_set_keyboard_focus_handler(image->window,
|
window_set_keyboard_focus_handler(image->window,
|
||||||
keyboard_focus_handler);
|
keyboard_focus_handler);
|
||||||
|
|
||||||
window_schedule_redraw(image->window);
|
widget_schedule_resize(image->widget, 500, 400);
|
||||||
|
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-17
@@ -53,9 +53,6 @@ struct resizor {
|
|||||||
static void
|
static void
|
||||||
frame_callback(void *data, struct wl_callback *callback, uint32_t time)
|
frame_callback(void *data, struct wl_callback *callback, uint32_t time)
|
||||||
{
|
{
|
||||||
static const struct wl_callback_listener listener = {
|
|
||||||
frame_callback
|
|
||||||
};
|
|
||||||
struct resizor *resizor = data;
|
struct resizor *resizor = data;
|
||||||
double force, height;
|
double force, height;
|
||||||
|
|
||||||
@@ -79,23 +76,17 @@ frame_callback(void *data, struct wl_callback *callback, uint32_t time)
|
|||||||
resizor->height.previous = 200;
|
resizor->height.previous = 200;
|
||||||
}
|
}
|
||||||
|
|
||||||
window_set_child_size(resizor->window, resizor->width, height + 0.5);
|
widget_schedule_resize(resizor->widget, resizor->width, height + 0.5);
|
||||||
|
|
||||||
window_schedule_redraw(resizor->window);
|
|
||||||
|
|
||||||
if (resizor->frame_callback) {
|
if (resizor->frame_callback) {
|
||||||
wl_callback_destroy(resizor->frame_callback);
|
wl_callback_destroy(resizor->frame_callback);
|
||||||
resizor->frame_callback = NULL;
|
resizor->frame_callback = NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (fabs(resizor->height.previous - resizor->height.target) > 0.1) {
|
static const struct wl_callback_listener listener = {
|
||||||
resizor->frame_callback =
|
frame_callback
|
||||||
wl_surface_frame(
|
};
|
||||||
window_get_wl_surface(resizor->window));
|
|
||||||
wl_callback_add_listener(resizor->frame_callback, &listener,
|
|
||||||
resizor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
redraw_handler(struct widget *widget, void *data)
|
redraw_handler(struct widget *widget, void *data)
|
||||||
@@ -105,7 +96,7 @@ redraw_handler(struct widget *widget, void *data)
|
|||||||
cairo_t *cr;
|
cairo_t *cr;
|
||||||
struct rectangle allocation;
|
struct rectangle allocation;
|
||||||
|
|
||||||
window_get_child_allocation(resizor->window, &allocation);
|
widget_get_allocation(resizor->widget, &allocation);
|
||||||
|
|
||||||
surface = window_get_surface(resizor->window);
|
surface = window_get_surface(resizor->window);
|
||||||
|
|
||||||
@@ -121,6 +112,15 @@ redraw_handler(struct widget *widget, void *data)
|
|||||||
cairo_destroy(cr);
|
cairo_destroy(cr);
|
||||||
|
|
||||||
cairo_surface_destroy(surface);
|
cairo_surface_destroy(surface);
|
||||||
|
|
||||||
|
if (fabs(resizor->height.previous - resizor->height.target) > 0.1) {
|
||||||
|
resizor->frame_callback =
|
||||||
|
wl_surface_frame(
|
||||||
|
window_get_wl_surface(resizor->window));
|
||||||
|
wl_callback_add_listener(resizor->frame_callback, &listener,
|
||||||
|
resizor);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -222,10 +222,9 @@ resizor_create(struct display *display)
|
|||||||
resizor->height.target = resizor->height.current;
|
resizor->height.target = resizor->height.current;
|
||||||
height = resizor->height.current + 0.5;
|
height = resizor->height.current + 0.5;
|
||||||
|
|
||||||
window_set_child_size(resizor->window, resizor->width, height);
|
|
||||||
widget_set_button_handler(resizor->widget, button_handler);
|
widget_set_button_handler(resizor->widget, button_handler);
|
||||||
|
|
||||||
window_schedule_redraw(resizor->window);
|
widget_schedule_resize(resizor->widget, resizor->width, height);
|
||||||
|
|
||||||
return resizor;
|
return resizor;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ homescreen_draw(struct tablet_shell *shell)
|
|||||||
int x, y, i, width, height, vmargin, hmargin, vpadding, hpadding;
|
int x, y, i, width, height, vmargin, hmargin, vpadding, hpadding;
|
||||||
|
|
||||||
window_create_surface(shell->homescreen);
|
window_create_surface(shell->homescreen);
|
||||||
window_get_child_allocation(shell->homescreen, &allocation);
|
window_get_allocation(shell->homescreen, &allocation);
|
||||||
surface = window_get_surface(shell->homescreen);
|
surface = window_get_surface(shell->homescreen);
|
||||||
cr = cairo_create(surface);
|
cr = cairo_create(surface);
|
||||||
|
|
||||||
@@ -176,7 +176,7 @@ lockscreen_draw(struct tablet_shell *shell)
|
|||||||
int width, height;
|
int width, height;
|
||||||
|
|
||||||
window_create_surface(shell->lockscreen);
|
window_create_surface(shell->lockscreen);
|
||||||
window_get_child_allocation(shell->lockscreen, &allocation);
|
window_get_allocation(shell->lockscreen, &allocation);
|
||||||
surface = window_get_surface(shell->lockscreen);
|
surface = window_get_surface(shell->lockscreen);
|
||||||
cr = cairo_create(surface);
|
cr = cairo_create(surface);
|
||||||
|
|
||||||
|
|||||||
+41
-40
@@ -499,7 +499,7 @@ terminal_compare_position(struct terminal *terminal,
|
|||||||
struct rectangle allocation;
|
struct rectangle allocation;
|
||||||
int top_margin, side_margin, col, row, ref_x;
|
int top_margin, side_margin, col, row, ref_x;
|
||||||
|
|
||||||
window_get_child_allocation(terminal->window, &allocation);
|
widget_get_allocation(terminal->widget, &allocation);
|
||||||
side_margin = allocation.x + (allocation.width - terminal->width * terminal->extents.max_x_advance) / 2;
|
side_margin = allocation.x + (allocation.width - terminal->width * terminal->extents.max_x_advance) / 2;
|
||||||
top_margin = allocation.y + (allocation.height - terminal->height * terminal->extents.height) / 2;
|
top_margin = allocation.y + (allocation.height - terminal->height * terminal->extents.height) / 2;
|
||||||
|
|
||||||
@@ -694,7 +694,7 @@ terminal_shift_line(struct terminal *terminal, int d)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
terminal_resize(struct terminal *terminal, int width, int height)
|
terminal_resize_cells(struct terminal *terminal, int width, int height)
|
||||||
{
|
{
|
||||||
size_t size;
|
size_t size;
|
||||||
union utf8_char *data;
|
union utf8_char *data;
|
||||||
@@ -704,7 +704,6 @@ terminal_resize(struct terminal *terminal, int width, int height)
|
|||||||
int i, l, total_rows;
|
int i, l, total_rows;
|
||||||
struct rectangle allocation;
|
struct rectangle allocation;
|
||||||
struct winsize ws;
|
struct winsize ws;
|
||||||
int32_t pixel_width, pixel_height;
|
|
||||||
|
|
||||||
if (width < 1)
|
if (width < 1)
|
||||||
width = 1;
|
width = 1;
|
||||||
@@ -713,15 +712,6 @@ terminal_resize(struct terminal *terminal, int width, int height)
|
|||||||
if (terminal->width == width && terminal->height == height)
|
if (terminal->width == width && terminal->height == height)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!terminal->fullscreen) {
|
|
||||||
pixel_width = width *
|
|
||||||
terminal->extents.max_x_advance + 2 * terminal->margin;
|
|
||||||
pixel_height = height *
|
|
||||||
terminal->extents.height + 2 * terminal->margin;
|
|
||||||
window_set_child_size(terminal->window,
|
|
||||||
pixel_width, pixel_height);
|
|
||||||
}
|
|
||||||
|
|
||||||
data_pitch = width * sizeof(union utf8_char);
|
data_pitch = width * sizeof(union utf8_char);
|
||||||
size = data_pitch * height;
|
size = data_pitch * height;
|
||||||
data = malloc(size);
|
data = malloc(size);
|
||||||
@@ -771,12 +761,46 @@ terminal_resize(struct terminal *terminal, int width, int height)
|
|||||||
/* Update the window size */
|
/* Update the window size */
|
||||||
ws.ws_row = terminal->height;
|
ws.ws_row = terminal->height;
|
||||||
ws.ws_col = terminal->width;
|
ws.ws_col = terminal->width;
|
||||||
window_get_child_allocation(terminal->window, &allocation);
|
widget_get_allocation(terminal->widget, &allocation);
|
||||||
ws.ws_xpixel = allocation.width;
|
ws.ws_xpixel = allocation.width;
|
||||||
ws.ws_ypixel = allocation.height;
|
ws.ws_ypixel = allocation.height;
|
||||||
ioctl(terminal->master, TIOCSWINSZ, &ws);
|
ioctl(terminal->master, TIOCSWINSZ, &ws);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
resize_handler(struct widget *widget,
|
||||||
|
int32_t width, int32_t height, void *data)
|
||||||
|
{
|
||||||
|
struct terminal *terminal = data;
|
||||||
|
int32_t columns, rows, m;
|
||||||
|
|
||||||
|
m = 2 * terminal->margin;
|
||||||
|
columns = (width - m) / (int32_t) terminal->extents.max_x_advance;
|
||||||
|
rows = (height - m) / (int32_t) terminal->extents.height;
|
||||||
|
|
||||||
|
if (!terminal->fullscreen) {
|
||||||
|
width = columns * terminal->extents.max_x_advance + m;
|
||||||
|
height = rows * terminal->extents.height + m;
|
||||||
|
widget_set_size(terminal->widget, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
terminal_resize_cells(terminal, columns, rows);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
terminal_resize(struct terminal *terminal, int columns, int rows)
|
||||||
|
{
|
||||||
|
int32_t width, height, m;
|
||||||
|
|
||||||
|
if (terminal->fullscreen)
|
||||||
|
return;
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
struct color_scheme DEFAULT_COLORS = {
|
struct color_scheme DEFAULT_COLORS = {
|
||||||
{
|
{
|
||||||
{0, 0, 0, 1}, /* black */
|
{0, 0, 0, 1}, /* black */
|
||||||
@@ -915,7 +939,7 @@ redraw_handler(struct widget *widget, void *data)
|
|||||||
cairo_font_extents_t extents;
|
cairo_font_extents_t extents;
|
||||||
|
|
||||||
surface = window_get_surface(terminal->window);
|
surface = window_get_surface(terminal->window);
|
||||||
window_get_child_allocation(terminal->window, &allocation);
|
widget_get_allocation(terminal->widget, &allocation);
|
||||||
cr = cairo_create(surface);
|
cr = cairo_create(surface);
|
||||||
cairo_rectangle(cr, allocation.x, allocation.y,
|
cairo_rectangle(cr, allocation.x, allocation.y,
|
||||||
allocation.width, allocation.height);
|
allocation.width, allocation.height);
|
||||||
@@ -1010,25 +1034,6 @@ terminal_write(struct terminal *terminal, const char *data, size_t length)
|
|||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
resize_handler(struct widget *widget,
|
|
||||||
int32_t pixel_width, int32_t pixel_height, void *data)
|
|
||||||
{
|
|
||||||
struct terminal *terminal = data;
|
|
||||||
int32_t width, height;
|
|
||||||
|
|
||||||
width = (pixel_width - 2 * terminal->margin) /
|
|
||||||
(int32_t) terminal->extents.max_x_advance;
|
|
||||||
height = (pixel_height - 2 * terminal->margin) /
|
|
||||||
(int32_t) terminal->extents.height;
|
|
||||||
|
|
||||||
if (terminal->fullscreen)
|
|
||||||
window_set_child_size(terminal->window,
|
|
||||||
pixel_width, pixel_height);
|
|
||||||
|
|
||||||
terminal_resize(terminal, width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
terminal_data(struct terminal *terminal, const char *data, size_t length);
|
terminal_data(struct terminal *terminal, const char *data, size_t length);
|
||||||
|
|
||||||
@@ -1488,10 +1493,8 @@ handle_escape(struct terminal *terminal)
|
|||||||
switch (args[0]) {
|
switch (args[0]) {
|
||||||
case 4: /* resize px */
|
case 4: /* resize px */
|
||||||
if (set[1] && set[2]) {
|
if (set[1] && set[2]) {
|
||||||
window_set_child_size(terminal->window,
|
widget_schedule_resize(terminal->widget,
|
||||||
args[2], args[1]);
|
args[2], args[1]);
|
||||||
resize_handler(terminal->widget,
|
|
||||||
args[2], args[1], terminal);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 8: /* resize ch */
|
case 8: /* resize ch */
|
||||||
@@ -1500,13 +1503,13 @@ handle_escape(struct terminal *terminal)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 13: /* report position */
|
case 13: /* report position */
|
||||||
window_get_child_allocation(terminal->window, &allocation);
|
widget_get_allocation(terminal->widget, &allocation);
|
||||||
snprintf(response, MAX_RESPONSE, "\e[3;%d;%dt",
|
snprintf(response, MAX_RESPONSE, "\e[3;%d;%dt",
|
||||||
allocation.x, allocation.y);
|
allocation.x, allocation.y);
|
||||||
terminal_write(terminal, response, strlen(response));
|
terminal_write(terminal, response, strlen(response));
|
||||||
break;
|
break;
|
||||||
case 14: /* report px */
|
case 14: /* report px */
|
||||||
window_get_child_allocation(terminal->window, &allocation);
|
widget_get_allocation(terminal->widget, &allocation);
|
||||||
snprintf(response, MAX_RESPONSE, "\e[4;%d;%dt",
|
snprintf(response, MAX_RESPONSE, "\e[4;%d;%dt",
|
||||||
allocation.height, allocation.width);
|
allocation.height, allocation.width);
|
||||||
terminal_write(terminal, response, strlen(response));
|
terminal_write(terminal, response, strlen(response));
|
||||||
@@ -2354,8 +2357,6 @@ terminal_run(struct terminal *terminal, const char *path)
|
|||||||
if (!terminal->fullscreen)
|
if (!terminal->fullscreen)
|
||||||
terminal_resize(terminal, 80, 24);
|
terminal_resize(terminal, 80, 24);
|
||||||
|
|
||||||
window_schedule_redraw(terminal->window);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-3
@@ -66,7 +66,7 @@ view_draw(struct view *view)
|
|||||||
|
|
||||||
window_draw(view->window);
|
window_draw(view->window);
|
||||||
|
|
||||||
window_get_child_allocation(view->window, &allocation);
|
widget_get_allocation(view->widget, &allocation);
|
||||||
|
|
||||||
surface = window_get_surface(view->window);
|
surface = window_get_surface(view->window);
|
||||||
|
|
||||||
@@ -124,8 +124,7 @@ resize_handler(struct widget *widget,
|
|||||||
{
|
{
|
||||||
struct view *view = data;
|
struct view *view = data;
|
||||||
|
|
||||||
window_set_child_size(view->window, width, height);
|
widget_set_size(view->widget, width, height);
|
||||||
window_schedule_redraw(window);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
+60
-43
@@ -1111,6 +1111,26 @@ widget_get_allocation(struct widget *widget, struct rectangle *allocation)
|
|||||||
*allocation = widget->allocation;
|
*allocation = widget->allocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
widget_set_size(struct widget *widget, int32_t width, int32_t height)
|
||||||
|
{
|
||||||
|
struct window *window = widget->window;
|
||||||
|
|
||||||
|
widget->allocation.width = width;
|
||||||
|
widget->allocation.height = height;
|
||||||
|
|
||||||
|
window->allocation.x = 0;
|
||||||
|
window->allocation.y = 0;
|
||||||
|
if (widget->window->decoration) {
|
||||||
|
window->allocation.width = width + 20 + widget->window->margin;
|
||||||
|
window->allocation.height =
|
||||||
|
height + 60 + widget->window->margin;
|
||||||
|
} else {
|
||||||
|
window->allocation.width = width;
|
||||||
|
window->allocation.height = height;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
widget_set_allocation(struct widget *widget,
|
widget_set_allocation(struct widget *widget,
|
||||||
int32_t x, int32_t y, int32_t width, int32_t height)
|
int32_t x, int32_t y, int32_t width, int32_t height)
|
||||||
@@ -1911,12 +1931,17 @@ static void
|
|||||||
window_resize(struct window *window, int32_t width, int32_t height)
|
window_resize(struct window *window, int32_t width, int32_t height)
|
||||||
{
|
{
|
||||||
struct rectangle allocation;
|
struct rectangle allocation;
|
||||||
|
struct widget *widget;
|
||||||
|
int decoration_width, decoration_height;
|
||||||
|
|
||||||
|
decoration_width = 20 + window->margin * 2;
|
||||||
|
decoration_height = 60 + window->margin * 2;
|
||||||
|
|
||||||
if (window->decoration) {
|
if (window->decoration) {
|
||||||
allocation.x = 20;
|
allocation.x = 10 + window->margin;
|
||||||
allocation.y = 60;
|
allocation.y = 50 + window->margin;
|
||||||
allocation.width = width - 20 - window->margin * 2;
|
allocation.width = width - decoration_width;
|
||||||
allocation.height = height - 60 - window->margin * 2;
|
allocation.height = height - decoration_height;
|
||||||
} else {
|
} else {
|
||||||
allocation.x = 0;
|
allocation.x = 0;
|
||||||
allocation.y = 0;
|
allocation.y = 0;
|
||||||
@@ -1924,17 +1949,26 @@ window_resize(struct window *window, int32_t width, int32_t height)
|
|||||||
allocation.height = height;
|
allocation.height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
window->allocation.width = width;
|
widget = window->widget;
|
||||||
window->allocation.height = height;
|
widget_set_allocation(widget, allocation.x, allocation.y,
|
||||||
|
|
||||||
widget_set_allocation(window->widget, allocation.x, allocation.y,
|
|
||||||
allocation.width, allocation.height);
|
allocation.width, allocation.height);
|
||||||
|
|
||||||
if (window->widget->resize_handler)
|
if (widget->resize_handler)
|
||||||
window->widget->resize_handler(window->widget,
|
widget->resize_handler(widget,
|
||||||
allocation.width,
|
allocation.width,
|
||||||
allocation.height,
|
allocation.height,
|
||||||
window->widget->user_data);
|
widget->user_data);
|
||||||
|
|
||||||
|
if (window->decoration) {
|
||||||
|
window->allocation.x = 0;
|
||||||
|
window->allocation.y = 0;
|
||||||
|
window->allocation.width =
|
||||||
|
widget->allocation.width + decoration_width;
|
||||||
|
window->allocation.height =
|
||||||
|
widget->allocation.height + decoration_height;
|
||||||
|
} else {
|
||||||
|
window->allocation = widget->allocation;
|
||||||
|
}
|
||||||
|
|
||||||
window_schedule_redraw(window);
|
window_schedule_redraw(window);
|
||||||
}
|
}
|
||||||
@@ -1962,6 +1996,21 @@ window_schedule_resize(struct window *window, int width, int height)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
widget_schedule_resize(struct widget *widget, int32_t width, int32_t height)
|
||||||
|
{
|
||||||
|
struct window *window = widget->window;
|
||||||
|
|
||||||
|
if (widget->window->decoration) {
|
||||||
|
window_schedule_resize(window,
|
||||||
|
width + 20 + 2 * window->margin,
|
||||||
|
height + 60 + 2 * window->margin);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
window_schedule_resize(window, width, height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
handle_configure(void *data, struct wl_shell_surface *shell_surface,
|
handle_configure(void *data, struct wl_shell_surface *shell_surface,
|
||||||
uint32_t time, uint32_t edges,
|
uint32_t time, uint32_t edges,
|
||||||
@@ -2001,38 +2050,6 @@ window_get_allocation(struct window *window,
|
|||||||
*allocation = window->allocation;
|
*allocation = window->allocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
window_get_child_allocation(struct window *window,
|
|
||||||
struct rectangle *allocation)
|
|
||||||
{
|
|
||||||
if (!window->decoration) {
|
|
||||||
*allocation = window->allocation;
|
|
||||||
} else {
|
|
||||||
allocation->x = window->margin + 10;
|
|
||||||
allocation->y = window->margin + 50;
|
|
||||||
allocation->width =
|
|
||||||
window->allocation.width - 20 - window->margin * 2;
|
|
||||||
allocation->height =
|
|
||||||
window->allocation.height - 60 - window->margin * 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
window_set_child_size(struct window *window, int32_t width, int32_t height)
|
|
||||||
{
|
|
||||||
if (window->decoration) {
|
|
||||||
window->allocation.x = 20 + window->margin;
|
|
||||||
window->allocation.y = 60 + window->margin;
|
|
||||||
window->allocation.width = width + 20 + window->margin * 2;
|
|
||||||
window->allocation.height = height + 60 + window->margin * 2;
|
|
||||||
} else {
|
|
||||||
window->allocation.x = 0;
|
|
||||||
window->allocation.y = 0;
|
|
||||||
window->allocation.width = width;
|
|
||||||
window->allocation.height = height;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
widget_redraw(struct widget *widget)
|
widget_redraw(struct widget *widget)
|
||||||
{
|
{
|
||||||
|
|||||||
+5
-16
@@ -222,28 +222,13 @@ struct widget *
|
|||||||
window_get_focus_widget(struct window *window);
|
window_get_focus_widget(struct window *window);
|
||||||
struct display *
|
struct display *
|
||||||
window_get_display(struct window *window);
|
window_get_display(struct window *window);
|
||||||
struct widget *
|
|
||||||
window_get_widget(struct window *window);
|
|
||||||
|
|
||||||
void
|
void
|
||||||
window_move(struct window *window, struct input *input, uint32_t time);
|
window_move(struct window *window, struct input *input, uint32_t time);
|
||||||
|
|
||||||
void
|
void
|
||||||
window_draw(struct window *window);
|
window_get_allocation(struct window *window, struct rectangle *allocation);
|
||||||
|
|
||||||
void
|
|
||||||
window_get_allocation(struct window *window,
|
|
||||||
struct rectangle *allocation);
|
|
||||||
|
|
||||||
void
|
|
||||||
window_get_child_allocation(struct window *window,
|
|
||||||
struct rectangle *allocation);
|
|
||||||
|
|
||||||
void
|
void
|
||||||
window_set_transparent(struct window *window, int transparent);
|
window_set_transparent(struct window *window, int transparent);
|
||||||
void
|
void
|
||||||
window_set_child_size(struct window *window, int32_t width, int32_t height);
|
|
||||||
void
|
|
||||||
window_schedule_redraw(struct window *window);
|
window_schedule_redraw(struct window *window);
|
||||||
void
|
void
|
||||||
window_schedule_resize(struct window *window, int width, int height);
|
window_schedule_resize(struct window *window, int width, int height);
|
||||||
@@ -334,6 +319,10 @@ widget_get_allocation(struct widget *widget, struct rectangle *allocation);
|
|||||||
void
|
void
|
||||||
widget_set_allocation(struct widget *widget,
|
widget_set_allocation(struct widget *widget,
|
||||||
int32_t x, int32_t y, int32_t width, int32_t height);
|
int32_t x, int32_t y, int32_t width, int32_t height);
|
||||||
|
void
|
||||||
|
widget_set_size(struct widget *widget, int32_t width, int32_t height);
|
||||||
|
void
|
||||||
|
widget_schedule_resize(struct widget *widget, int32_t width, int32_t height);
|
||||||
|
|
||||||
void *
|
void *
|
||||||
widget_get_user_data(struct widget *widget);
|
widget_get_user_data(struct widget *widget);
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ redraw_handler(struct widget *widget, void *data)
|
|||||||
|
|
||||||
mi->swap_buffers = 0;
|
mi->swap_buffers = 0;
|
||||||
|
|
||||||
window_get_child_allocation(mi->window, &drawarea);
|
widget_get_allocation(mi->widget, &drawarea);
|
||||||
window_get_allocation(mi->window, &winarea);
|
window_get_allocation(mi->window, &winarea);
|
||||||
|
|
||||||
if (display_acquire_window_surface(wscr->display,
|
if (display_acquire_window_surface(wscr->display,
|
||||||
@@ -182,7 +182,7 @@ create_modeinfo(struct wscreensaver *wscr, struct window *window)
|
|||||||
if (!mi)
|
if (!mi)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
window_get_child_allocation(window, &drawarea);
|
window_get_allocation(window, &drawarea);
|
||||||
|
|
||||||
mi->priv = wscr;
|
mi->priv = wscr;
|
||||||
mi->eglctx = EGL_NO_CONTEXT;
|
mi->eglctx = EGL_NO_CONTEXT;
|
||||||
|
|||||||
Reference in New Issue
Block a user