ecore wayland: add selection type
authorThiep Ha <thiepha@gmail.com>
Tue, 3 May 2016 10:42:31 +0000 (10:42 +0000)
committerThiep Ha <thiepha@gmail.com>
Tue, 3 May 2016 17:13:47 +0000 (17:13 +0000)
We have copy & paste and drag & drop selection types, but we cannot
distinguish between these two types when requesters receive data
from data ready event.
This patch adds a new enum to help selection requesters distinguish
between two selection types and have suitable actions for each type.

src/lib/ecore_wl2/Ecore_Wl2.h
src/lib/ecore_wl2/ecore_wl2_dnd.c
src/lib/ecore_wl2/ecore_wl2_private.h

index 2308a9a..ff53140 100644 (file)
@@ -129,11 +129,18 @@ typedef struct _Ecore_Wl2_Event_Data_Source_Send
    int fd;
 } Ecore_Wl2_Event_Data_Source_Send;
 
+typedef enum
+{
+   ECORE_WL2_SELECTION_CNP,
+   ECORE_WL2_SELECTION_DND
+} Ecore_Wl2_Selection_Type;
+
 typedef struct _Ecore_Wl2_Event_Selection_Data_Ready
 {
    char *data;
    int len;
    Eina_Bool done;
+   Ecore_Wl2_Selection_Type sel_type;
 } Ecore_Wl2_Event_Selection_Data_Ready;
 
 typedef enum
index 2e4765c..e9feb12 100644 (file)
@@ -232,6 +232,7 @@ _selection_data_read(void *data, Ecore_Fd_Handler *fdh)
    event = calloc(1, sizeof(Ecore_Wl2_Event_Selection_Data_Ready));
    if (!event) return ECORE_CALLBACK_CANCEL;
 
+   event->sel_type = source->sel_type;
    if (len <= 0)
      {
         if (source->input->drag.source)
@@ -530,6 +531,7 @@ ecore_wl2_dnd_drag_get(Ecore_Wl2_Input *input, const char *type)
 
    if (!*t) return EINA_FALSE;
 
+   input->drag.source->sel_type = ECORE_WL2_SELECTION_DND;
    _selection_data_receive(input->drag.source, type);
 
    return EINA_TRUE;
@@ -639,6 +641,7 @@ ecore_wl2_dnd_selection_get(Ecore_Wl2_Input *input, const char *type)
 
    if (!*t) return EINA_FALSE;
 
+   input->selection.source->sel_type = ECORE_WL2_SELECTION_CNP;
    _selection_data_receive(input->selection.source, type);
 
    return EINA_TRUE;
index f1bd494..6913edc 100644 (file)
@@ -188,6 +188,7 @@ typedef struct _Ecore_Wl2_Dnd_Source
    struct wl_array types;
    uint32_t dnd_action;
    uint32_t source_actions;
+   Ecore_Wl2_Selection_Type sel_type;
 } Ecore_Wl2_Dnd_Source;