commit 13e0a59

Michael Forney  ·  2013-09-12 23:59:54 +0000 UTC
parent 98a2f5d
surface: Fix input region
3 files changed,  +16, -13
+7, -5
 1@@ -204,7 +204,7 @@ static void handle_focus(struct swc_pointer * pointer)
 2     struct swc_seat * seat;
 3     struct swc_compositor * compositor;
 4     struct swc_surface * surface;
 5-    int32_t surface_x, surface_y;
 6+    int32_t x, y;
 7 
 8     seat = swc_container_of(pointer, typeof(*seat), pointer);
 9     compositor = swc_container_of(seat, typeof(*compositor), seat);
10@@ -217,11 +217,13 @@ static void handle_focus(struct swc_pointer * pointer)
11             (&region, surface->geometry.x, surface->geometry.y,
12              surface->geometry.width, surface->geometry.height);
13 
14-        surface_x = wl_fixed_to_int(pointer->x) - surface->geometry.x;
15-        surface_y = wl_fixed_to_int(pointer->y) - surface->geometry.y;
16+        x = wl_fixed_to_int(pointer->x);
17+        y = wl_fixed_to_int(pointer->y);
18 
19-        if (pixman_region32_contains_point(&surface->state.input,
20-                                           surface_x, surface_y, NULL))
21+        if (swc_rectangle_contains_point(&surface->geometry, x, y)
22+            && pixman_region32_contains_point(&surface->state.input,
23+                                              x - surface->geometry.x,
24+                                              y - surface->geometry.y, NULL))
25         {
26             swc_pointer_set_focus(pointer, surface);
27             return;
+2, -8
 1@@ -270,10 +270,8 @@ static void commit(struct wl_client * client, struct wl_resource * resource)
 2     /* Input */
 3     if (surface->pending.commit & SWC_SURFACE_COMMIT_INPUT)
 4     {
 5-        pixman_region32_intersect_rect(&surface->state.input,
 6-                                       &surface->pending.state.input, 0, 0,
 7-                                       surface->geometry.width,
 8-                                       surface->geometry.height);
 9+        pixman_region32_copy(&surface->state.input,
10+                             &surface->pending.state.input);
11     }
12 
13     /* Frame */
14@@ -362,10 +360,6 @@ struct swc_surface * swc_surface_new(struct wl_client * client, uint32_t id)
15     state_initialize(&surface->state);
16     state_initialize(&surface->pending.state);
17 
18-    /* The input region should be intersected with the surface's geometry,
19-     * which at this point is empty. */
20-    pixman_region32_clear(&surface->state.input);
21-
22     wl_signal_init(&surface->event_signal);
23 
24     /* Add the surface to the client. */
+7, -0
 1@@ -17,6 +17,13 @@
 2 
 3 void swc_remove_resource(struct wl_resource * resource);
 4 
 5+static inline bool swc_rectangle_contains_point
 6+    (pixman_rectangle32_t * rectangle, int32_t x, int32_t y)
 7+{
 8+    return x > rectangle->x && x < rectangle->x + rectangle->width
 9+        && y > rectangle->y && y < rectangle->y + rectangle->height;
10+}
11+
12 static inline bool swc_rectangle_overlap
13     (pixman_rectangle32_t * r1, pixman_rectangle32_t * r2)
14 {