Implementation of dispatch rotation event functionality. 05/163505/4
authorPawel Kurowski <p.kurowski2@samsung.com>
Tue, 12 Dec 2017 12:09:46 +0000 (13:09 +0100)
committerPawel Kurowski <p.kurowski2@samsung.com>
Tue, 12 Dec 2017 12:35:36 +0000 (13:35 +0100)
Change-Id: I8a306ec61faa15a7443b9f517b04742d7c380b59

src/Makefile.am
src/e_dispatch_rotation_event.c [new file with mode: 0644]
src/e_dispatch_rotation_event.h [new file with mode: 0644]
src/e_mod_main.c

index c2cdbd3..02b0558 100644 (file)
@@ -10,6 +10,7 @@ module_la_SOURCES      = \
        e_screen_reader_config.c \
        e_screen_reader_gestures.c \
        e_dispatch_gesture_event.c \
+       e_dispatch_rotation_event.c \
        e_universal_switch.c
 
 module_la_LIBADD       =
diff --git a/src/e_dispatch_rotation_event.c b/src/e_dispatch_rotation_event.c
new file mode 100644 (file)
index 0000000..a52354d
--- /dev/null
@@ -0,0 +1,39 @@
+#include "e.h"
+#include "e_screen_reader_private.h"
+#include "e_dispatch_rotation_event.h"
+
+static void
+_e_zone_event_rotation_change_begin_free(void *data, void *ev)
+{
+   E_Event_Zone_Rotation_Change_Begin *e = ev;
+   e_object_unref(E_OBJECT(e->zone));
+   E_FREE(e);
+}
+
+void _e_dispatch_rotation_event(int angle)
+{
+   if (angle % 90 != 0 || angle < 0 || angle > 270)
+     {
+       ERROR("Wrong angle");
+       return;
+     }
+
+   E_Zone *zone = e_zone_current_get();
+   if (!zone)
+     {
+       ERROR("Fail to find zone");
+       return;
+     }
+
+   zone->rot.prev = zone->rot.act;
+   zone->rot.curr = angle;
+   zone->rot.wait_for_done = EINA_TRUE;
+
+   E_Event_Zone_Rotation_Change_Begin *ev = E_NEW(E_Event_Zone_Rotation_Change_Begin, 1);
+   if (ev)
+     {
+       ev->zone = zone;
+       e_object_ref(E_OBJECT(ev->zone));
+       ecore_event_add(E_EVENT_ZONE_ROTATION_CHANGE_BEGIN, ev, _e_zone_event_rotation_change_begin_free, NULL);
+     }
+}
\ No newline at end of file
diff --git a/src/e_dispatch_rotation_event.h b/src/e_dispatch_rotation_event.h
new file mode 100644 (file)
index 0000000..56acac5
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef E_DISPATCH_ROTATION_EVENT_H_
+#define E_DISPATCH_ROTATION_EVENT_H_
+
+void _e_dispatch_rotation_event(int angle);
+
+#endif /* E_DISPATCH_ROTATION_EVENT_H_ */
\ No newline at end of file
index 11d97e2..f3e4522 100644 (file)
@@ -5,6 +5,7 @@
 #include <e_screen_reader_private.h>
 #include <vconf.h>
 #include <e_dispatch_gesture_event.h>
+#include <e_dispatch_rotation_event.h>
 #include "e_universal_switch.h"
 
 #define E_A11Y_SERVICE_BUS_NAME "org.enlightenment.wm-screen-reader"
@@ -44,6 +45,7 @@ static Eldbus_Message *_is_selection_mode(const Eldbus_Service_Interface *iface,
 static Eldbus_Message *_object_needs_scroll_gesture(const Eldbus_Service_Interface *iface, const Eldbus_Message *msg);
 static Eldbus_Message *_dispatch_gesture_event(const Eldbus_Service_Interface *iface, const Eldbus_Message *msg);
 static Eldbus_Message *_dispatch_drag_event(const Eldbus_Service_Interface *iface, const Eldbus_Message *msg);
+static Eldbus_Message *_dispatch_rotation_event(const Eldbus_Service_Interface *iface, const Eldbus_Message *msg);
 
 static const Eldbus_Method methods[] = {
       { "ScreenReaderEnabled", ELDBUS_ARGS({"b", "bool"}), ELDBUS_ARGS({"b", "bool"}),
@@ -79,6 +81,9 @@ static const Eldbus_Method methods[] = {
       { "DispatchDragEvent", ELDBUS_ARGS({"i", "int"}, {"i", "int"}, {"i", "int"}, {"i", "int"}, {"i", "int"}, {"d", "double"}), NULL,
         _dispatch_drag_event
       },
+      { "DispatchRotationEvent", ELDBUS_ARGS({"i", "int"}), NULL,
+        _dispatch_rotation_event
+      },
       { }
 };
 
@@ -442,6 +447,20 @@ _dispatch_drag_event(const Eldbus_Service_Interface *iface, const Eldbus_Message
    return eldbus_message_method_return_new(msg);
 }
 
+static Eldbus_Message *
+_dispatch_rotation_event(const Eldbus_Service_Interface *iface, const Eldbus_Message *msg)
+{
+   int angle;
+   if (eldbus_message_arguments_get(msg, "i", &angle))
+     {
+        _e_dispatch_rotation_event(angle);
+     }
+   else
+     ERROR("eldbus_message_arguments_get() error\n");
+
+   return eldbus_message_method_return_new(msg);
+}
+
 static int
 _fetch_a11y_bus_address(void)
 {