GdkWindow *transient_for;
GdkWindowTypeHint hint;
+ /* The surface which is being "drawn to" to */
cairo_surface_t *cairo_surface;
+
+ /* The surface that was the last surface the Wayland buffer from which was attached
+ * to the Wayland surface. It will be the same as cairo_surface after a call
+ * to gdk_wayland_window_attach_image. But after a call to
+ * gdk_wayland_window_update_size and then
+ * gdk_wayland_window_ref_cairo_surface the above pointer will be different.
+ */
cairo_surface_t *server_surface;
+
GLuint texture;
uint32_t resize_edges;
if (GDK_WINDOW_DESTROYED (window))
return;
+ /* The "drawn to" Cairo surface is the same as the Cairo surface from which
+ * we are driving the buffer for the Wayland surface. Therefore we don't
+ * need to do anything here
+ */
if (impl->server_surface == impl->cairo_surface)
return;
+ /* The wayland surface is attached to a buffer that is from the old "drawn
+ * to" surface. Unref the surface and restore the state.
+ */
if (impl->server_surface)
{
data = cairo_surface_get_user_data (impl->server_surface,
&gdk_wayland_cairo_key);
+
+ /* Save the old dimensions used for the surface */
server_width = data->width;
server_height = data->height;
+
cairo_surface_destroy (impl->server_surface);
}
else
server_height = 0;
}
+ /* Save the current "drawn to" surface for future calls into here */
impl->server_surface = cairo_surface_reference (impl->cairo_surface);
+
+ /* Get a Wayland buffer from this new surface */
data = cairo_surface_get_user_data (impl->cairo_surface,
&gdk_wayland_cairo_key);
if (!data->buffer)
else
dy = 0;
+ /* Attach this new buffer to the surface */
wl_surface_attach (impl->surface, data->buffer, dx, dy);
}
return surface;
}
+/* On this first call this creates a double reference - the first reference
+ * is held by the GdkWindowImplWayland struct - since unlike other backends
+ * the Cairo surface is not just a cheap wrapper around some other backing.
+ * It is the buffer itself.
+ */
static cairo_surface_t *
gdk_wayland_window_ref_cairo_surface (GdkWindow *window)
{