No need to push this to the toolkit users.
double sx, sy;
window_set_child_size(window, width, height);
- window_draw(window);
+ window_create_surface(window);
surface = window_get_surface(window);
cr = cairo_create(surface);
cairo_pattern_t *pat;
double cx, cy, r, f;
- window_draw(dialog->window);
-
surface = window_get_surface(dialog->window);
cr = cairo_create(surface);
window_get_child_allocation(dialog->window, &allocation);
cairo_paint(cr);
cairo_destroy(cr);
- window_flush(dialog->window);
cairo_surface_destroy(surface);
}
cairo_surface_t *surface;
int i;
- window_draw(dnd->window);
-
surface = window_get_surface(dnd->window);
cr = cairo_create(surface);
window_get_child_allocation(dnd->window, &allocation);
cairo_destroy(cr);
cairo_surface_destroy(surface);
- window_flush(dnd->window);
}
static void
cairo_t *cr;
struct rectangle rect;
- window_draw(e->window);
window_get_child_allocation(e->window, &rect);
surface = window_get_surface(e->window);
cairo_destroy(cr);
cairo_surface_destroy(surface);
- window_flush(e->window);
}
/**
}
/* Initial drawing of the window */
- eventdemo_draw(e);
+ window_schedule_redraw(e->window);
return e;
}
window_set_title(flower.window, "flower");
window_set_decoration(flower.window, 0);
- window_draw(flower.window);
+ window_create_surface(flower.window);
s = window_get_surface(flower.window);
if (s == NULL || cairo_surface_status (s) != CAIRO_STATUS_SUCCESS) {
fprintf(stderr, "failed to create cairo egl surface\n");
}
static void
-draw_gears(struct gears *gears)
+frame_callback(void *data, struct wl_callback *callback, uint32_t time)
+{
+ struct gears *gears = data;
+
+ gears->angle = (GLfloat) (time % 8192) * 360 / 8192.0;
+
+ window_schedule_redraw(gears->window);
+
+ if (callback)
+ wl_callback_destroy(callback);
+}
+
+static const struct wl_callback_listener listener = {
+ frame_callback
+};
+
+static void
+redraw_handler(struct window *window, void *data)
{
GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 0.0;
struct rectangle window_allocation;
struct rectangle allocation;
-
- window_draw(gears->window);
+ struct wl_callback *callback;
+ struct gears *gears = data;
window_get_child_allocation(gears->window, &allocation);
window_get_allocation(gears->window, &window_allocation);
glFlush();
display_release_window_surface(gears->d, gears->window);
- window_flush(gears->window);
+
+ callback = wl_surface_frame(window_get_wl_surface(gears->window));
+ wl_callback_add_listener(callback, &listener, gears);
}
static void
resize_handler(window, allocation.width, allocation.height, gears);
}
-static void
-frame_callback(void *data, struct wl_callback *callback, uint32_t time)
-{
- static const struct wl_callback_listener listener = {
- frame_callback
- };
- struct gears *gears = data;
-
- gears->angle = (GLfloat) (time % 8192) * 360 / 8192.0;
-
- draw_gears(gears);
-
- if (callback)
- wl_callback_destroy(callback);
-
- callback = wl_surface_frame(window_get_wl_surface(gears->window));
- wl_callback_add_listener(callback, &listener, gears);
-}
-
static struct gears *
gears_create(struct display *display)
{
window_set_user_data(gears->window, gears);
window_set_resize_handler(gears->window, resize_handler);
+ window_set_redraw_handler(gears->window, redraw_handler);
window_set_keyboard_focus_handler(gears->window, keyboard_focus_handler);
frame_callback(gears, NULL, 0);
cairo_t *cr;
cairo_surface_t *surface;
- window_draw(image->window);
-
window_get_child_allocation(image->window, &allocation);
pb = gdk_pixbuf_new_from_file_at_size(image->filename,
cairo_paint(cr);
cairo_destroy(cr);
- window_flush(image->window);
cairo_surface_destroy(surface);
}
window_set_keyboard_focus_handler(image->window,
keyboard_focus_handler);
- image_draw(image);
+ window_schedule_redraw(image->window);
return image;
}
cairo_t *cr;
struct rectangle allocation;
- window_draw(resizor->window);
-
window_get_child_allocation(resizor->window, &allocation);
surface = window_get_surface(resizor->window);
cairo_destroy(cr);
cairo_surface_destroy(surface);
-
- window_flush(resizor->window);
}
static void
window_set_child_size(resizor->window, resizor->width, height);
widget_set_button_handler(resizor->widget, button_handler);
- resizor_draw(resizor);
+ window_schedule_redraw(resizor->window);
return resizor;
}
const int rows = 4, columns = 5, icon_width = 128, icon_height = 128;
int x, y, i, width, height, vmargin, hmargin, vpadding, hpadding;
- window_draw(shell->homescreen);
+ window_create_surface(shell->homescreen);
window_get_child_allocation(shell->homescreen, &allocation);
surface = window_get_surface(shell->homescreen);
cr = cairo_create(surface);
cairo_t *cr;
int width, height;
- window_draw(shell->lockscreen);
+ window_create_surface(shell->lockscreen);
window_get_child_allocation(shell->lockscreen, &allocation);
surface = window_get_surface(shell->lockscreen);
cr = cairo_create(surface);
}
static void
-terminal_draw(struct terminal *terminal)
-{
- window_draw(terminal->window);
- terminal_draw_contents(terminal);
- window_flush(terminal->window);
-}
-
-static void
redraw_handler(struct window *window, void *data)
{
struct terminal *terminal = data;
- terminal_draw(terminal);
+ terminal_draw_contents(terminal);
}
static void
if (!terminal->fullscreen)
terminal_resize(terminal, 80, 24);
- terminal_draw(terminal);
+ window_schedule_redraw(terminal->window);
return 0;
}
cairo_surface_t *frame;
int width, height, shadow_dx = 3, shadow_dy = 3;
- window_create_surface(window);
-
width = window->allocation.width;
height = window->allocation.height;
window_schedule_redraw(widget->window);
}
-void
-window_draw(struct window *window)
-{
- if (!window->decoration)
- window_create_surface(window);
- else
- window_draw_decorations(window);
-}
-
cairo_surface_t *
window_get_surface(struct window *window)
{
struct window *window =
container_of(task, struct window, redraw_task);
+ window_create_surface(window);
+ if (window->decoration)
+ window_draw_decorations(window);
+
window->redraw_handler(window, window->user_data);
+
+ window_flush(window);
+
window->redraw_scheduled = 0;
+
}
void
struct menu *menu = data;
int32_t width, height, i;
- window_create_surface(window);
-
cr = cairo_create(window->cairo_surface);
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 0.0);
}
cairo_destroy(cr);
- window_flush(window);
}
struct window *
mi->swap_buffers = 0;
- window_draw(mi->window);
-
window_get_child_allocation(mi->window, &drawarea);
window_get_allocation(mi->window, &winarea);
fprintf(stderr, "%s: swapBuffers not called\n", progname);
display_release_window_surface(wscr->display, mi->window);
- window_flush(mi->window);
}
static void