summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@bitplanet.net>2014-01-09 15:43:17 -0800
committerKristian Høgsberg <krh@bitplanet.net>2014-01-09 15:43:17 -0800
commit70f290198937f76b7cf8de3ae9618d0aa5880e80 (patch)
treebb9b6e487d7a90f7d9a701de071e05a3d4d2bfa4
parent97b747cdda1ec32df3317a1df44d3c4a217f06d9 (diff)
shell: Make sure we still have touch or pointer focus when moving/resizing
It's possible to touch a surface to move it and let go before we get to common_surface_move(), in which case we don't have a touch focus when we get there. For pointers, we could click a surface, but have the surface go away before we get to common_surface_move(), in which case the button count is non-zero, but we don't have a surface. In either case we crash, so let's add a check to make sure we still have a focus surface before we try to move it. Closes: https://bugs.freedesktop.org/show_bug.cgi?id=73448
-rw-r--r--desktop-shell/shell.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index 00c7b019..c82c00f0 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -1469,6 +1469,7 @@ common_surface_move(struct wl_resource *resource,
struct weston_surface *surface;
if (seat->pointer &&
+ seat->pointer->focus &&
seat->pointer->button_count > 0 &&
seat->pointer->grab_serial == serial) {
surface = weston_surface_get_main_surface(seat->pointer->focus->surface);
@@ -1476,6 +1477,7 @@ common_surface_move(struct wl_resource *resource,
(surface_move(shsurf, seat) < 0))
wl_resource_post_no_memory(resource);
} else if (seat->touch &&
+ seat->touch->focus &&
seat->touch->grab_serial == serial) {
surface = weston_surface_get_main_surface(seat->touch->focus->surface);
if ((surface == shsurf->surface) &&
@@ -1656,10 +1658,13 @@ common_surface_resize(struct wl_resource *resource,
if (shsurf->state.fullscreen)
return;
- surface = weston_surface_get_main_surface(seat->pointer->focus->surface);
if (seat->pointer->button_count == 0 ||
seat->pointer->grab_serial != serial ||
- surface != shsurf->surface)
+ seat->pointer->focus == NULL)
+ return;
+
+ surface = weston_surface_get_main_surface(seat->pointer->focus->surface);
+ if (surface != shsurf->surface)
return;
if (surface_resize(shsurf, seat, edges) < 0)