[PATCH weston v3 3/5] data-device: fix crash on systems with no pointer device

Stanislav Vorobiov s.vorobiov at samsung.com
Tue May 13 23:43:03 PDT 2014


---
 src/data-device.c |   19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/src/data-device.c b/src/data-device.c
index 6a81bc8..abab735 100644
--- a/src/data-device.c
+++ b/src/data-device.c
@@ -421,6 +421,7 @@ static void
 drag_grab_touch_down(struct weston_touch_grab *grab, uint32_t time,
 		int touch_id, wl_fixed_t sx, wl_fixed_t sy)
 {
+	wl_signal_emit(&grab->touch->motion_signal, grab->touch);
 }
 
 static void
@@ -476,6 +477,8 @@ drag_grab_touch_motion(struct weston_touch_grab *grab, uint32_t time,
 	wl_fixed_t view_x, view_y;
 	float fx, fy;
 
+	wl_signal_emit(&grab->touch->motion_signal, grab->touch);
+
 	if (touch_id != touch->grab_touch_id)
 		return;
 
@@ -650,11 +653,13 @@ data_device_start_drag(struct wl_client *client, struct wl_resource *resource,
 	struct weston_surface *icon = NULL;
 	int32_t ret = 0;
 
-	if ((seat->pointer->button_count == 0 ||
+	if ((!seat->pointer ||
+	    seat->pointer->button_count == 0 ||
 	    seat->pointer->grab_serial != serial ||
 	    !seat->pointer->focus ||
 	    seat->pointer->focus->surface != wl_resource_get_user_data(origin_resource)) &&
-		(seat->touch->grab_serial != serial ||
+		(!seat->touch ||
+		seat->touch->grab_serial != serial ||
 		!seat->touch->focus ||
 		seat->touch->focus->surface != wl_resource_get_user_data(origin_resource)))
 		return;
@@ -672,14 +677,16 @@ data_device_start_drag(struct wl_client *client, struct wl_resource *resource,
 		return;
 	}
 
-	if (seat->pointer->button_count == 1 &&
+	if (seat->pointer &&
+		seat->pointer->button_count == 1 &&
 		seat->pointer->grab_serial == serial &&
 		seat->pointer->focus &&
 		seat->pointer->focus->surface == wl_resource_get_user_data(origin_resource))
 		ret = weston_pointer_start_drag(seat->pointer, source, icon, client);
-	else if (seat->touch->grab_serial != serial ||
-		seat->touch->focus ||
-		seat->touch->focus->surface != wl_resource_get_user_data(origin_resource))
+	else if (seat->touch &&
+			(seat->touch->grab_serial != serial ||
+			seat->touch->focus ||
+			seat->touch->focus->surface != wl_resource_get_user_data(origin_resource)))
 		ret = weston_touch_start_drag(seat->touch, source, icon, client);
 
 	if (ret < 0)
-- 
1.7.9.5



More information about the wayland-devel mailing list