window.c: Do resize work from the repaint idle callback

This way we always make sure we handle any resizing before we start drawing.
Kristian Høgsberg 13 years ago
parent 7a011eac73
commit 42b4f80116
  1. 24
      clients/window.c

@ -125,8 +125,7 @@ struct window {
int redraw_scheduled; int redraw_scheduled;
int redraw_needed; int redraw_needed;
struct task redraw_task; struct task redraw_task;
int resize_scheduled; int resize_needed;
struct task resize_task;
int type; int type;
int transparent; int transparent;
struct input *keyboard_device; struct input *keyboard_device;
@ -888,8 +887,6 @@ window_destroy(struct window *window)
if (window->redraw_scheduled) if (window->redraw_scheduled)
wl_list_remove(&window->redraw_task.link); wl_list_remove(&window->redraw_task.link);
if (window->resize_scheduled)
wl_list_remove(&window->resize_task.link);
wl_list_for_each(input, &display->input_list, link) { wl_list_for_each(input, &display->input_list, link) {
if (input->pointer_focus == window) if (input->pointer_focus == window)
@ -2014,13 +2011,11 @@ window_move(struct window *window, struct input *input, uint32_t time)
} }
static void static void
idle_resize(struct task *task, uint32_t events) idle_resize(struct window *window)
{ {
struct window *window =
container_of(task, struct window, resize_task);
struct widget *widget; struct widget *widget;
window->resize_scheduled = 0; window->resize_needed = 0;
widget = window->widget; widget = window->widget;
widget_set_allocation(widget, widget_set_allocation(widget,
window->pending_allocation.x, window->pending_allocation.x,
@ -2059,11 +2054,8 @@ window_schedule_resize(struct window *window, int width, int height)
window->pending_allocation.width = width; window->pending_allocation.width = width;
window->pending_allocation.height = height; window->pending_allocation.height = height;
if (!window->resize_scheduled) { window->resize_needed = 1;
window->resize_task.run = idle_resize; window_schedule_redraw(window);
display_defer(window->display, &window->resize_task);
window->resize_scheduled = 1;
}
} }
void void
@ -2151,10 +2143,12 @@ static const struct wl_callback_listener listener = {
static void static void
idle_redraw(struct task *task, uint32_t events) idle_redraw(struct task *task, uint32_t events)
{ {
struct window *window = struct window *window = container_of(task, struct window, redraw_task);
container_of(task, struct window, redraw_task);
struct wl_callback *callback; struct wl_callback *callback;
if (window->resize_needed)
idle_resize(window);
window_create_surface(window); window_create_surface(window);
widget_redraw(window->widget); widget_redraw(window->widget);
window_flush(window); window_flush(window);

Loading…
Cancel
Save