Efl: Add storage class Efl.Pointer.Event
authorJean-Philippe Andre <jp.andre@samsung.com>
Thu, 28 Apr 2016 08:31:46 +0000 (17:31 +0900)
committerJean-Philippe Andre <jp.andre@samsung.com>
Tue, 31 May 2016 10:03:04 +0000 (19:03 +0900)
This object is the data carried over in an event data pointer.

The private data should be accessible by Ecore and Evas, but
not externally. This means we should be able to easily extend
the feature set, adding more and more information, without
breaking API / ABI.

Also, this should allow applications to create fake input
events easily without exposing our internal structures, or
functions with more and more parameters (such as feed multi).

This is only a storage class, shouldn't contain any logic.
In the future, some logic may be added for gestures support
for instance, or input smoothing / resampling (eg. if input
frequency is 90Hz and screen refresh rate is 60Hz).

The aim is to replace:
- Evas_Event_Mouse_Xxx
- Evas_Event_Multi_Xxx
- Ecore_Event_Mouse_Xxx

We might want to also support Axis, Gestures, etc... with the
same model or even same storage class.

src/Makefile_Efl.am
src/lib/efl/Efl.h
src/lib/efl/interfaces/efl_common_internal.h
src/lib/efl/interfaces/efl_event.c [new file with mode: 0644]
src/lib/efl/interfaces/efl_event.eo [new file with mode: 0644]
src/lib/efl/interfaces/efl_pointer_event.c [new file with mode: 0644]
src/lib/efl/interfaces/efl_pointer_event.eo [new file with mode: 0644]

index 4388ef2..a770039 100644 (file)
@@ -39,6 +39,8 @@ efl_eolian_files = \
       lib/efl/interfaces/efl_vpath_file_core.eo \
       lib/efl/interfaces/efl_ui_spin.eo \
       lib/efl/interfaces/efl_ui_progress.eo \
+      lib/efl/interfaces/efl_event.eo \
+      lib/efl/interfaces/efl_pointer_event.eo \
       $(efl_eolian_legacy_files) \
       $(NULL)
 
@@ -81,6 +83,8 @@ lib/efl/interfaces/efl_vpath_manager.c \
 lib/efl/interfaces/efl_vpath_core.c \
 lib/efl/interfaces/efl_vpath_file_core.c \
 lib/efl/interfaces/efl_input_device.c \
+lib/efl/interfaces/efl_event.c \
+lib/efl/interfaces/efl_pointer_event.c \
 $(NULL)
 
 lib_efl_libefl_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl -I$(top_srcdir)/src/lib/efl @EFL_CFLAGS@ -DEFL_GFX_FILTER_BETA
index c834412..a71d17b 100644 (file)
@@ -128,8 +128,8 @@ static inline void efl_gfx_color16_type_set(Efl_Gfx_Color *color,
 /* Input events */
 #include "interfaces/efl_input_device.eo.h"
 //#include "interfaces/efl_input_state.eo.h"
-//#include "interfaces/efl_event.eo.h"
-//#include "interfaces/efl_pointer_event.eo.h"
+#include "interfaces/efl_event.eo.h"
+#include "interfaces/efl_pointer_event.eo.h"
 
 #else
 
index eb46814..aa95689 100644 (file)
@@ -23,34 +23,43 @@ typedef struct _Evas_Modifier Evas_Modifier;
 typedef struct _Evas_Lock Evas_Lock;
 #endif
 
-#if 0
 struct _Efl_Pointer_Event_Data
 {
    Eo             *eo;
-   const Eo_Event_Description *event;
-   unsigned int    timestamp;
+   unsigned int    timestamp; /* FIXME: store as double? */
    int             button;
    unsigned int    pressed_buttons;
    struct {
-      int          x, y;
-   } output;
+      struct {
+         int       x, y;
+      } output;
+      struct {
+         int       x, y;
+      } canvas;
+   } cur, prev;
    struct {
-      int          x, y;
-   } canvas;
-   Eo             *source; /* may be ecore or evas or evas object (?) */
-   Efl_Pointer_Action       action;
-   Efl_Pointer_Button_Flags button_flags;
-   Efl_Pointer_Event_Flags  event_flags;
-   void           *data;   /* evas data - whatever that is */
+      Efl_Orient   dir;
+      int          z;
+   } wheel;
+   Efl_Gfx                    *source; /* could it be ecore? */
+   Efl_Input_Device           *device;
+   Efl_Pointer_Action          action;
+   Efl_Pointer_Button_Flags    button_flags;
+   Efl_Pointer_Event_Flags     event_flags;
+   void                       *data; /* evas data - whatever that is */
+   const Eo_Event_Description *event_desc;
+   //Efl_Input_State            state;
 };
 
 struct _Efl_Input_State_Data
 {
    Eo             *eo;
+   /* FIXME / TODO  */
+#if 0
    Evas_Modifier  *modifiers;
    Evas_Lock      *locks;
-};
 #endif
+};
 
 struct _Efl_Input_Device_Data
 {
diff --git a/src/lib/efl/interfaces/efl_event.c b/src/lib/efl/interfaces/efl_event.c
new file mode 100644 (file)
index 0000000..1d75a1c
--- /dev/null
@@ -0,0 +1,10 @@
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <Efl.h>
+
+#define EFL_INTERNAL_UNSTABLE
+#include "efl_common_internal.h"
+
+#include "interfaces/efl_event.eo.c"
diff --git a/src/lib/efl/interfaces/efl_event.eo b/src/lib/efl/interfaces/efl_event.eo
new file mode 100644 (file)
index 0000000..076bc15
--- /dev/null
@@ -0,0 +1,38 @@
+type @extern Eo_Event_Description: __undefined_type;
+
+interface Efl.Event
+{
+   [[Represents a generic event data.
+
+     Note: Most Eo Events do not carry Eo objects, rather simple data
+           structures. This class is intended to carry more complex event
+           data, such as pointer events.
+
+     @since 1.18
+   ]]
+   legacy_prefix: null;
+   methods {
+      @property timestamp {
+         [[The time at which an event was generated.
+
+           If the event is generated by a server (eg. X.org or Wayland), then
+           the time may be set by the server. Usually this time will be based
+           on the monotonic clock, if available, but this class can not
+           guarantee it.
+         ]]
+         set { [[Call this when generating events manually.]] }
+         get {}
+         values {
+            ms: double; [[Time in milliseconds when the event happened.]]
+         }
+      }
+      @property event_type {
+         [[The type of this event, as an Eo Event type.]]
+         set {}
+         get {}
+         values {
+            type: const(Eo_Event_Description)*;
+         }
+      }
+   }
+}
diff --git a/src/lib/efl/interfaces/efl_pointer_event.c b/src/lib/efl/interfaces/efl_pointer_event.c
new file mode 100644 (file)
index 0000000..7e47902
--- /dev/null
@@ -0,0 +1,222 @@
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <Efl.h>
+
+#define EFL_INTERNAL_UNSTABLE
+#include "efl_common_internal.h"
+
+#define MY_CLASS EFL_POINTER_EVENT_CLASS
+
+
+/* Pointer Event
+ *
+ * This is a storage class only, should not require ANY knowledge about
+ * Ecore, Evas or anything else.
+ *
+ * This is intended to replace Ecore and Evas structs for mouse events.
+ *
+ * Do not add any logic here.
+ */
+
+EOLIAN static Eo_Base *
+_efl_pointer_event_eo_base_constructor(Eo *obj, Efl_Pointer_Event_Data *pd)
+{
+   eo_constructor(eo_super(obj, MY_CLASS));
+   pd->eo = obj;
+   return obj;
+}
+
+EOLIAN static void
+_efl_pointer_event_action_set(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd, Efl_Pointer_Action act)
+{
+   pd->action = act;
+}
+
+EOLIAN static Efl_Pointer_Action
+_efl_pointer_event_action_get(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd)
+{
+   return pd->action;
+}
+
+EOLIAN static void
+_efl_pointer_event_button_set(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd, int but)
+{
+   pd->button = but;
+}
+
+EOLIAN static int
+_efl_pointer_event_button_get(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd)
+{
+   return pd->button;
+}
+
+EOLIAN static void
+_efl_pointer_event_button_pressed_set(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd, int button, Eina_Bool pressed)
+{
+   if (button < 0) return;
+   if (button > 31) return;
+   if (pressed)
+     pd->button_flags |= (1 << button);
+   else
+     pd->button_flags &= ~(1 << button);
+}
+
+EOLIAN static Eina_Bool
+_efl_pointer_event_button_pressed_get(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd, int button)
+{
+   if (button < 0) return EINA_FALSE;
+   if (button > 31) return EINA_FALSE;
+   return (pd->button_flags & (1 << button)) != 0;
+}
+
+EOLIAN static void
+_efl_pointer_event_position_set(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd, int x, int y)
+{
+   pd->cur.canvas.x = x;
+   pd->cur.canvas.y = y;
+   /* FIXME: What is the difference??? */
+   pd->cur.output.x = x;
+   pd->cur.output.y = y;
+}
+
+EOLIAN static void
+_efl_pointer_event_position_get(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd, int *x, int *y)
+{
+   if (x) *x = pd->cur.canvas.x;
+   if (y) *y = pd->cur.canvas.y;
+}
+
+EOLIAN static void
+_efl_pointer_event_previous_position_set(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd, int x, int y)
+{
+   pd->prev.canvas.x = x;
+   pd->prev.canvas.y = y;
+   /* FIXME: What is the difference??? */
+   pd->prev.output.x = x;
+   pd->prev.output.y = y;
+}
+
+EOLIAN static void
+_efl_pointer_event_previous_position_get(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd, int *x, int *y)
+{
+   if (x) *x = pd->prev.canvas.x;
+   if (y) *y = pd->prev.canvas.y;
+}
+
+
+/* FIXME: implement input state with eo*/
+
+/*
+EOLIAN static void
+_efl_pointer_event_input_state_set(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd, Efl_Input_State *modifiers)
+{
+
+}
+EOLIAN static Efl_Input_State *
+_efl_pointer_event_input_state_get(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd)
+{
+
+}
+*/
+
+EOLIAN static void
+_efl_pointer_event_device_set(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd, Efl_Input_Device *dev)
+{
+   /* ref? */
+   pd->device = dev;
+}
+
+EOLIAN static Efl_Input_Device *
+_efl_pointer_event_device_get(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd)
+{
+   return pd->device;
+}
+
+EOLIAN static void
+_efl_pointer_event_source_set(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd, Efl_Gfx *src)
+{
+   /* ref? */
+   pd->source = src;
+}
+
+EOLIAN static Efl_Gfx *
+_efl_pointer_event_source_get(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd)
+{
+   return pd->source;
+}
+
+EOLIAN static void
+_efl_pointer_event_button_flags_set(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd, Efl_Pointer_Button_Flags flags)
+{
+   pd->button_flags = flags;
+}
+
+EOLIAN static Efl_Pointer_Button_Flags
+_efl_pointer_event_button_flags_get(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd)
+{
+   return pd->button_flags;
+}
+
+EOLIAN static void
+_efl_pointer_event_event_flags_set(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd, Efl_Pointer_Event_Flags flags)
+{
+   pd->event_flags = flags;
+}
+
+EOLIAN static Efl_Pointer_Event_Flags
+_efl_pointer_event_event_flags_get(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd)
+{
+   return pd->event_flags;
+}
+
+EOLIAN static void
+_efl_pointer_event_efl_event_timestamp_set(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd, double ms)
+{
+   pd->timestamp = (unsigned int) ms;
+}
+
+EOLIAN static double
+_efl_pointer_event_efl_event_timestamp_get(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd)
+{
+   return (double) pd->timestamp;
+}
+
+EOLIAN static void
+_efl_pointer_event_efl_event_event_type_set(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd, const Eo_Event_Description *type)
+{
+   pd->event_desc = type;
+}
+
+EOLIAN static const Eo_Event_Description *
+_efl_pointer_event_efl_event_event_type_get(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd)
+{
+   return pd->event_desc;
+}
+
+EOLIAN static void
+_efl_pointer_event_wheel_direction_set(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd, Efl_Orient dir)
+{
+   pd->wheel.dir = dir;
+}
+
+EOLIAN static Efl_Orient
+_efl_pointer_event_wheel_direction_get(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd)
+{
+   return pd->wheel.dir;
+}
+
+EOLIAN static void
+_efl_pointer_event_wheel_distance_set(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd, int dist)
+{
+   pd->wheel.z = dist;
+}
+
+EOLIAN static int
+_efl_pointer_event_wheel_distance_get(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd)
+{
+   return pd->wheel.z;
+}
+
+#include "interfaces/efl_pointer_event.eo.c"
diff --git a/src/lib/efl/interfaces/efl_pointer_event.eo b/src/lib/efl/interfaces/efl_pointer_event.eo
new file mode 100644 (file)
index 0000000..c845065
--- /dev/null
@@ -0,0 +1,138 @@
+import efl_orientation;
+
+/* FIXME: Do we need this? Or just use the Eo Event Description as a type? */
+enum Efl.Pointer.Action
+{
+   [[Pointer event type.
+
+     @since 1.18
+   ]]
+   none,        [[Not a valid event.]]
+   mouse_move,  [[Mouse or equivalent pointer moved.]]
+   mouse_down,  [[Mouse button pressed down.]]
+   mouse_up,    [[Mouse button released.]]
+   mouse_wheel, [[Mouse wheel scroll, horizontally or vertically.]]
+   touch_move,  [[Finger moved while touching surface.]]
+   touch_down,  [[Finger touch made contact.]]
+   touch_up,    [[Finger touch released.]]
+   hover,       [[A hovering movement over a distance-sensitive touch screen.]]
+}
+
+enum Efl.Pointer.Button_Flags
+{
+   /* Evas.Button_Flags */
+   none = 0,                [[No extra mouse button data]]
+   double_click = (1 << 0), [[This mouse button press was the 2nd press of a double click]]
+   triple_click = (1 << 1), [[This mouse button press was the 3rd press of a triple click]]
+}
+
+enum Efl.Pointer.Event_Flags
+{
+   /* Evas.Event_Flags */
+   none = 0,             [[No fancy flags set]]
+   on_hold = (1 << 0),   [[This event is being delivered but should be put "on hold" until the on hold flag is unset. The event should be used for informational purposes and maybe some indications visually, but not actually perform anything]]
+   on_scroll = (1 << 1), [[This event flag indicates the event occurs while scrolling; for example, DOWN event occurs during scrolling; the event should be used for informational purposes and maybe some indications visually, but not actually perform anything]]
+}
+
+class Efl.Pointer.Event (Eo.Base, Efl.Event)
+{
+   [[Event data carried over with any pointer event (mouse, touch, ...)
+
+     @since 1.18
+   ]]
+   legacy_prefix: null;
+   methods {
+      @property action {
+         [[The action represented by this event.]]
+         values {
+            act: Efl.Pointer.Action;
+         }
+      }
+      @property button {
+         [[The mouse button that triggered the event.]]
+         values {
+            but: int; [[1 to 32, 0 if not a button event.]]
+         }
+      }
+      @property button_pressed {
+         [[Whether a mouse button is pressed at the moment of the event.]]
+         keys {
+            button: int;
+         }
+         values {
+            pressed: bool;
+         }
+      }
+      /* FIXME: output vs. canvas position??? */
+      @property position {
+         [[Position where the event happened, relative to the window.]]
+         values {
+            x: int;
+            y: int;
+         }
+      }
+      @property previous_position {
+         [[Position of the previous event, valid for move events.
+
+           Relative to the window. May be equal to @.position.
+         ]]
+         values {
+            x: int;
+            y: int;
+         }
+      }
+      /*
+      @property input_state {
+         [[Carries information about keyboard modifiers and locks
+           at the moment of this event (eg. Ctrl, Alt or Caps Lock, Num Lock).]]
+         values {
+            modifiers: Efl.Input.State*; [[Can be $null (no info about state).]]
+         }
+      }
+      */
+      @property device {
+         [[Pointing device that originated this event.]]
+         values {
+            dev: Efl.Input.Device*;
+         }
+      }
+      @property source {
+         [[The object where this event first originated, in case of
+           propagation or repetition of the event.
+         ]]
+         values {
+            src: Efl.Gfx*;
+         }
+      }
+      /* FIXME: why not double_click() and triple_click() */
+      @property button_flags {
+         [[Double or triple click information.]]
+         values {
+            flags: Efl.Pointer.Button_Flags;
+         }
+      }
+      @property event_flags {
+         [[Extra flags for this event, may be changed by the user.]]
+         values {
+            flags: Efl.Pointer.Event_Flags;
+         }
+      }
+      @property wheel_direction {
+         values {
+            dir: Efl.Orient; [[Horizontal or Vertical only.]]
+         }
+      }
+      @property wheel_distance {
+         values {
+            dist: int;
+         }
+      }
+   }
+   implements {
+      Eo.Base.constructor;
+      Efl.Event.timestamp.set;
+      Efl.Event.timestamp.get;
+      Efl.Event.event_type.set;
+      Efl.Event.event_type.get;
+   }
+}