Signed-off-by: Derek Foreman <der...@osg.samsung.com> --- clients/simple-touch.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/clients/simple-touch.c b/clients/simple-touch.c index 446f2ca..383d802 100644 --- a/clients/simple-touch.c +++ b/clients/simple-touch.c @@ -56,6 +56,7 @@ struct touch { int has_argb; int width, height; void *data; + bool use_damage_buffer; }; static void @@ -148,7 +149,10 @@ touch_paint(struct touch *touch, int32_t x, int32_t y, int32_t id) p[2] = c; wl_surface_attach(touch->surface, touch->buffer, 0, 0); - wl_surface_damage(touch->surface, x - 2, y - 2, 5, 5); + if (touch->use_damage_buffer) + wl_surface_damage_buffer(touch->surface, x - 2, y - 2, 5, 5); + else + wl_surface_damage(touch->surface, x - 2, y - 2, 5, 5); /* todo: We could queue up more damage before committing, if there * are more input events to handle. */ @@ -269,9 +273,13 @@ handle_global(void *data, struct wl_registry *registry, struct touch *touch = data; if (strcmp(interface, "wl_compositor") == 0) { + int cv = MIN(WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION, version); + touch->compositor = wl_registry_bind(registry, name, - &wl_compositor_interface, 1); + &wl_compositor_interface, cv); + if (cv >= WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION) + touch->use_damage_buffer = true; } else if (strcmp(interface, "wl_shell") == 0) { touch->shell = wl_registry_bind(registry, name, @@ -308,6 +316,7 @@ touch_create(int width, int height) touch->display = wl_display_connect(NULL); assert(touch->display); + touch->use_damage_buffer = false; touch->has_argb = 0; touch->registry = wl_display_get_registry(touch->display); wl_registry_add_listener(touch->registry, ®istry_listener, touch); @@ -337,7 +346,10 @@ touch_create(int width, int height) memset(touch->data, 64, width * height * 4); wl_surface_attach(touch->surface, touch->buffer, 0, 0); - wl_surface_damage(touch->surface, 0, 0, width, height); + if (touch->use_damage_buffer) + wl_surface_damage_buffer(touch->surface, 0, 0, width, height); + else + wl_surface_damage(touch->surface, 0, 0, width, height); wl_surface_commit(touch->surface); return touch; -- 2.6.4 _______________________________________________ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel