Reset touch focus in unmap

Otherwise, there will be race condition of visiting invalid surface data.
This commit is contained in:
Michael Fu
2013-07-23 15:51:06 +08:00
committed by Kristian Høgsberg
parent dce3dacc37
commit a2bb7919de
3 changed files with 9 additions and 4 deletions
+2
View File
@@ -988,6 +988,8 @@ weston_surface_unmap(struct weston_surface *surface)
NULL, NULL,
wl_fixed_from_int(0), wl_fixed_from_int(0),
wl_fixed_from_int(0)); wl_fixed_from_int(0));
if (seat->touch && seat->touch->focus == surface)
weston_touch_set_focus(seat, NULL);
} }
weston_surface_schedule_repaint(surface); weston_surface_schedule_repaint(surface);
+3
View File
@@ -371,6 +371,9 @@ weston_touch_create(void);
void void
weston_touch_destroy(struct weston_touch *touch); weston_touch_destroy(struct weston_touch *touch);
void void
weston_touch_set_focus(struct weston_seat *seat,
struct weston_surface *surface);
void
weston_touch_start_grab(struct weston_touch *device, weston_touch_start_grab(struct weston_touch *device,
struct weston_touch_grab *grab); struct weston_touch_grab *grab);
void void
+4 -4
View File
@@ -983,8 +983,8 @@ notify_keyboard_focus_out(struct weston_seat *seat)
weston_keyboard_end_grab(keyboard); weston_keyboard_end_grab(keyboard);
} }
static void WL_EXPORT void
touch_set_focus(struct weston_seat *seat, struct weston_surface *surface) weston_touch_set_focus(struct weston_seat *seat, struct weston_surface *surface)
{ {
struct wl_resource *resource; struct wl_resource *resource;
@@ -1045,7 +1045,7 @@ notify_touch(struct weston_seat *seat, uint32_t time, int touch_id,
* until all touch points are up again. */ * until all touch points are up again. */
if (seat->num_tp == 1) { if (seat->num_tp == 1) {
es = weston_compositor_pick_surface(ec, x, y, &sx, &sy); es = weston_compositor_pick_surface(ec, x, y, &sx, &sy);
touch_set_focus(seat, es); weston_touch_set_focus(seat, es);
} else if (touch->focus) { } else if (touch->focus) {
es = (struct weston_surface *) touch->focus; es = (struct weston_surface *) touch->focus;
weston_surface_from_global_fixed(es, x, y, &sx, &sy); weston_surface_from_global_fixed(es, x, y, &sx, &sy);
@@ -1074,7 +1074,7 @@ notify_touch(struct weston_seat *seat, uint32_t time, int touch_id,
grab->interface->up(grab, time, touch_id); grab->interface->up(grab, time, touch_id);
if (seat->num_tp == 0) if (seat->num_tp == 0)
touch_set_focus(seat, NULL); weston_touch_set_focus(seat, NULL);
break; break;
} }
} }