libweston/data-device: Don't crash when doing dnd operations w/o a keyboard

pointer/touch drag-n-drop operations could happen if there's no keyboard
hooked up or when it is unplugged.

Fixes: #235

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
dev
Marius Vlad 4 years ago committed by Daniel Stone
parent 10c072b3f5
commit 2ab08d8698
  1. 6
      libweston/data-device.c

@ -640,6 +640,7 @@ data_device_end_pointer_drag_grab(struct weston_pointer_drag *drag)
data_device_end_drag_grab(&drag->base, pointer->seat);
weston_pointer_end_grab(pointer);
if (keyboard)
weston_keyboard_end_grab(keyboard);
free(drag);
}
@ -740,6 +741,7 @@ data_device_end_touch_drag_grab(struct weston_touch_drag *drag)
data_device_end_drag_grab(&drag->base, touch->seat);
weston_touch_end_grab(touch);
if (keyboard)
weston_keyboard_end_grab(keyboard);
free(drag);
}
@ -954,9 +956,11 @@ weston_pointer_start_drag(struct weston_pointer *pointer,
}
weston_pointer_clear_focus(pointer);
if (keyboard)
weston_keyboard_set_focus(keyboard, NULL);
weston_pointer_start_grab(pointer, &drag->grab);
if (keyboard)
weston_keyboard_start_grab(keyboard, &drag->base.keyboard_grab);
return 0;
@ -1014,9 +1018,11 @@ weston_touch_start_drag(struct weston_touch *touch,
&drag->base.data_source_listener);
}
if (keyboard)
weston_keyboard_set_focus(keyboard, NULL);
weston_touch_start_grab(touch, &drag->grab);
if (keyboard)
weston_keyboard_start_grab(keyboard, &drag->base.keyboard_grab);
drag_grab_touch_focus(drag);

Loading…
Cancel
Save