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
dev
Kristian Høgsberg 11 years ago
parent 97b747cdda
commit 70f2901989
  1. 9
      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)

Loading…
Cancel
Save