From 31e3a443281b97fa8b454356be941bd25f231288 Mon Sep 17 00:00:00 2001 From: Lukasz Wlazly Date: Thu, 16 May 2019 08:20:40 +0200 Subject: [PATCH] DispatchDragEvent improvement This patch modifies signature and implementation of DBus method "DispatchDragEvent" so gesture can be performed with multiple pointers Change-Id: Id91f5e4c20fd9c1477f78d6c9018668aef8b1c76 --- src/e_dispatch_gesture_event.c | 11 ++++++++--- src/e_dispatch_gesture_event.h | 2 +- src/e_mod_main.c | 7 ++++--- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/e_dispatch_gesture_event.c b/src/e_dispatch_gesture_event.c index e685d1f..d3d931d 100644 --- a/src/e_dispatch_gesture_event.c +++ b/src/e_dispatch_gesture_event.c @@ -174,18 +174,23 @@ _swap_points(Point *a, Point *b) } Eldbus_Message * -_e_dispatch_drag_event(DragInfo drag_info, Eldbus_Connection *conn, const Eldbus_Message *msg) +_e_dispatch_drag_event(DragInfo drag_info, int pointers_no, Eldbus_Connection *conn, const Eldbus_Message *msg) { Eldbus_Message *error_message = _check_and_correct_gesture_data(&drag_info, msg); if (error_message) return error_message; + if (pointers_no < 1) + return eldbus_message_error_new(msg, "org.freedesktop.DBus.Error.Failed", "Number of pointers is expected to be higher than 0."); + GestureCommand *cmd = (GestureCommand *)malloc(sizeof(GestureCommand)); if (!cmd) return eldbus_message_error_new(msg, "org.freedesktop.DBus.Error.Failed", "Malloc error."); - cmd->drag_info[0] = drag_info; - cmd->drag_info_size = 1; + for (int i = 0; i < pointers_no; ++i) + cmd->drag_info[i] = drag_info; + + cmd->drag_info_size = pointers_no; cmd->sequence_counter = 0; cmd->conn = conn; cmd->reply = eldbus_message_method_return_new(msg); diff --git a/src/e_dispatch_gesture_event.h b/src/e_dispatch_gesture_event.h index 402c89e..9cc4acb 100644 --- a/src/e_dispatch_gesture_event.h +++ b/src/e_dispatch_gesture_event.h @@ -19,7 +19,7 @@ typedef struct _PinchInfo { int steps; } PinchInfo; -Eldbus_Message * _e_dispatch_drag_event(DragInfo di, Eldbus_Connection *conn, const Eldbus_Message *msg); +Eldbus_Message * _e_dispatch_drag_event(DragInfo di, int pointers_no, Eldbus_Connection *conn, const Eldbus_Message *msg); Eldbus_Message * _e_dispatch_pinch_event(PinchInfo pinch_info, Eldbus_Connection *conn, const Eldbus_Message *msg); #endif /* E_DISPATCH_GESTURE_EVENT_H_ */ diff --git a/src/e_mod_main.c b/src/e_mod_main.c index 8cc2941..dcfb5d0 100644 --- a/src/e_mod_main.c +++ b/src/e_mod_main.c @@ -78,7 +78,7 @@ static const Eldbus_Method methods[] = { { "ObjectNeedsScrollGesture", ELDBUS_ARGS({"i", "int"}, {"i", "int"}), NULL, _object_needs_scroll_gesture }, - { "DispatchDragEvent", ELDBUS_ARGS({"i", "int"}, {"i", "int"}, {"i", "int"}, {"i", "int"}, {"i", "int"}, {"d", "double"}), NULL, + { "DispatchDragEvent", ELDBUS_ARGS({"i", "int"}, {"i", "int"}, {"i", "int"}, {"i", "int"}, {"i", "int"}, {"d", "double"}, {"i", "int"}), NULL, _dispatch_drag_event }, { "DispatchPinchEvent", ELDBUS_ARGS({"i", "int"}, {"i", "int"}, {"i", "int"}, {"i", "int"}), NULL, @@ -450,8 +450,9 @@ static Eldbus_Message * _dispatch_drag_event(const Eldbus_Service_Interface *iface, const Eldbus_Message *msg) { DragInfo drag_info; - if (eldbus_message_arguments_get(msg, "iiiiid", &drag_info.start.x, &drag_info.start.y, &drag_info.end.x, &drag_info.end.y, &drag_info.steps, &drag_info.hold_time)) - return _e_dispatch_drag_event(drag_info, conn, msg); + int pointers_no; + if (eldbus_message_arguments_get(msg, "iiiiidi", &drag_info.start.x, &drag_info.start.y, &drag_info.end.x, &drag_info.end.y, &drag_info.steps, &drag_info.hold_time, &pointers_no)) + return _e_dispatch_drag_event(drag_info, pointers_no, conn, msg); ERROR("eldbus_message_arguments_get() error\n"); return eldbus_message_error_new(msg, "org.freedesktop.DBus.Error.InvalidArgs", "Cannot get correct arguments"); -- 2.7.4