compositor: Add helper to damage surface below
authorKristian Høgsberg <krh@bitplanet.net>
Fri, 24 Jun 2011 01:00:04 +0000 (21:00 -0400)
committerKristian Høgsberg <krh@bitplanet.net>
Fri, 24 Jun 2011 01:00:04 +0000 (21:00 -0400)
compositor/compositor.c
compositor/compositor.h
compositor/shell.c

index 018be23..99b2946 100644 (file)
@@ -285,6 +285,23 @@ wlsc_surface_damage(struct wlsc_surface *surface)
                                      surface->width, surface->height);
 }
 
+WL_EXPORT void
+wlsc_surface_damage_below(struct wlsc_surface *surface)
+{
+       struct wlsc_surface *below;
+
+       if (surface->link.next == &surface->compositor->surface_list)
+               return;
+
+       below = container_of(surface->link.next, struct wlsc_surface, link);
+
+       pixman_region32_union_rect(&below->damage,
+                                  &below->damage,
+                                  surface->x, surface->y,
+                                  surface->width, surface->height);
+       wlsc_compositor_schedule_repaint(surface->compositor);
+}
+
 WL_EXPORT uint32_t
 wlsc_compositor_get_time(void)
 {
@@ -302,7 +319,7 @@ destroy_surface(struct wl_resource *resource, struct wl_client *client)
                container_of(resource, struct wlsc_surface, surface.resource);
        struct wlsc_compositor *compositor = surface->compositor;
 
-       wlsc_surface_damage(surface);
+       wlsc_surface_damage_below(surface);
 
        wl_list_remove(&surface->link);
        if (surface->saved_texture == 0)
@@ -951,7 +968,7 @@ surface_attach(struct wl_client *client,
         * surface.  Anything covered by the new surface will be
         * damaged by the client. */
        if (es->buffer)
-               wlsc_surface_damage(es);
+               wlsc_surface_damage_below(es);
 
        buffer->busy_count++;
        wlsc_buffer_post_release(es->buffer);
@@ -995,7 +1012,7 @@ static void
 wlsc_input_device_attach(struct wlsc_input_device *device,
                         int x, int y, int width, int height)
 {
-       wlsc_surface_damage(device->sprite);
+       wlsc_surface_damage_below(device->sprite);
 
        device->hotspot_x = x;
        device->hotspot_y = y;
@@ -1236,7 +1253,7 @@ notify_motion(struct wl_input_device *device, uint32_t time, int x, int y)
                                             time, x, y, sx, sy);
        }
 
-       wlsc_surface_damage(wd->sprite);
+       wlsc_surface_damage_below(wd->sprite);
 
        wd->sprite->x = device->x - wd->hotspot_x;
        wd->sprite->y = device->y - wd->hotspot_y;
index 643ca1d..e2cf9ef 100644 (file)
@@ -326,6 +326,9 @@ void
 wlsc_surface_damage(struct wlsc_surface *surface);
 
 void
+wlsc_surface_damage_below(struct wlsc_surface *surface);
+
+void
 wlsc_surface_damage_rectangle(struct wlsc_surface *surface,
                              int32_t x, int32_t y,
                              int32_t width, int32_t height);
index 388ccac..b1e780c 100644 (file)
@@ -46,7 +46,7 @@ move_grab_motion(struct wl_grab *grab,
        struct wlsc_move_grab *move = (struct wlsc_move_grab *) grab;
        struct wlsc_surface *es = move->surface;
 
-       wlsc_surface_damage(es);
+       wlsc_surface_damage_below(es);
        es->x = x + move->dx;
        es->y = y + move->dy;
        wlsc_surface_assign_output(es);