window: create Cairo surfaces on demand for redraw
This introduces the function widget_cairo_create().
Instead of directly referencing surface->cairo_surface, use the function
widget_cairo_create(), which will create the cairo_surface as necessary,
and just returns a Cairo drawing context. Also fix window_get_surface()
similarly.
Now we can go through idle_redraw() without always creating Cairo
surfaces and committing them. This will be useful with sub-surfaces,
where repainting one sub-surface does not need to force the repaint of
all surfaces of a window.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
diff --git a/clients/window.h b/clients/window.h
index 792b309..646b3dd 100644
--- a/clients/window.h
+++ b/clients/window.h
@@ -382,6 +382,9 @@
void *
widget_get_user_data(struct widget *widget);
+cairo_t *
+widget_cairo_create(struct widget *widget);
+
void
widget_set_redraw_handler(struct widget *widget,
widget_redraw_handler_t handler);
@@ -409,6 +412,7 @@
struct widget *
frame_create(struct window *window, void *data);
+
void
frame_set_child_size(struct widget *widget, int child_width, int child_height);