Enlightenment CVS committal

Author  : raster
Project : e17
Module  : libs/ecore

Dir     : e17/libs/ecore/src/lib/ecore_x


Modified Files:
        Ecore_X.h ecore_x_dnd.c 


Log Message:


lok's xdnd work.

===================================================================
RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_x/Ecore_X.h,v
retrieving revision 1.187
retrieving revision 1.188
diff -u -3 -r1.187 -r1.188
--- Ecore_X.h   13 Apr 2007 17:12:09 -0000      1.187
+++ Ecore_X.h   18 Aug 2007 10:35:47 -0000      1.188
@@ -1041,6 +1041,7 @@
 EAPI int              ecore_x_dnd_type_isset(Ecore_X_Window win, const char 
*type);
 EAPI void             ecore_x_dnd_type_set(Ecore_X_Window win, const char 
*type, int on);
 EAPI void             ecore_x_dnd_types_set(Ecore_X_Window win, char **types, 
unsigned int num_types);
+EAPI void             ecore_x_dnd_actions_set(Ecore_X_Window win, Ecore_X_Atom 
*actions, unsigned int num_actions);
 EAPI void             ecore_x_dnd_begin_prefetch(Ecore_X_Window source);
 EAPI void             ecore_x_dnd_begin_fetch(void);
 EAPI int              ecore_x_dnd_begin(Ecore_X_Window source, unsigned char 
*data, int size);
===================================================================
RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_x/ecore_x_dnd.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -3 -r1.30 -r1.31
--- ecore_x_dnd.c       5 Nov 2006 15:14:49 -0000       1.30
+++ ecore_x_dnd.c       18 Aug 2007 10:35:47 -0000      1.31
@@ -66,7 +66,7 @@
        ECORE_X_EVENT_XDND_DROP               = ecore_event_type_new();
        ECORE_X_EVENT_XDND_FINISHED           = ecore_event_type_new();
 
-       ECORE_X_ATOM_SELECTION_PROP_XDND      = XInternAtom(_ecore_x_disp, 
"JXSelectionWindowProperty", False);
+       ECORE_X_ATOM_SELECTION_PROP_XDND      = XInternAtom(_ecore_x_disp, 
"XSelectionWindowProperty", False);
        ECORE_X_ATOM_SELECTION_XDND           = XInternAtom(_ecore_x_disp, 
"XdndSelection", False);
        ECORE_X_ATOM_XDND_AWARE               = XInternAtom(_ecore_x_disp, 
"XdndAware", False);
        ECORE_X_ATOM_XDND_TYPE_LIST           = XInternAtom(_ecore_x_disp, 
"XdndTypeList", False);
@@ -114,6 +114,36 @@
    _ecore_x_dnd_init_count = 0;
 }
 
+static int
+_ecore_x_dnd_converter_copy(char *target, void *data, int size, void 
**data_ret, int *size_ret)
+{
+   XTextProperty text_prop;
+   char *mystr;
+   XICCEncodingStyle style = XTextStyle;
+
+   if (!data || !size)
+     return 0;
+
+   if (!(mystr = strdup(data)))
+     return 0;
+
+   if (XmbTextListToTextProperty(_ecore_x_disp, &mystr, 1, style, &text_prop) 
== Success)
+     {
+       int bufsize = strlen(text_prop.value) + 1;
+       *data_ret = malloc(bufsize);
+       memcpy(*data_ret, text_prop.value, bufsize);
+       *size_ret = bufsize;
+       XFree(text_prop.value);
+       free(mystr);
+       return 1;
+     }
+   else
+     {
+       free(mystr);
+       return 0;
+     }
+}
+
 EAPI void
 ecore_x_dnd_aware_set(Ecore_X_Window win, int on)
 {
@@ -245,13 +275,38 @@
        if (!newset) return;
        data = (unsigned char *)newset;
        for (i = 0; i < num_types; i++)
-         newset[i] = ecore_x_atom_get(types[i]);
+         {
+            newset[i] = ecore_x_atom_get(types[i]);
+            ecore_x_selection_converter_atom_add(newset[i], 
_ecore_x_dnd_converter_copy);
+         }
        ecore_x_window_prop_property_set(win, ECORE_X_ATOM_XDND_TYPE_LIST,
                                         XA_ATOM, 32, data, num_types);
        free(newset);
      }
 }
 
+EAPI void
+ecore_x_dnd_actions_set(Ecore_X_Window win, Ecore_X_Atom *actions, unsigned 
int num_actions)
+{
+   unsigned int      i;
+   unsigned char     *data = NULL;
+
+   if (!num_actions)
+     {
+       ecore_x_window_prop_property_del(win, ECORE_X_ATOM_XDND_ACTION_LIST);
+     }
+   else
+     {
+       data = (unsigned char *)actions;
+       for (i = 0; i < num_actions; i++)
+         {
+            ecore_x_selection_converter_atom_add(actions[i], 
_ecore_x_dnd_converter_copy);
+         }
+       ecore_x_window_prop_property_set(win, ECORE_X_ATOM_XDND_ACTION_LIST,
+                                        XA_ATOM, 32, data, num_actions);
+     }
+}
+
 Ecore_X_DND_Source *
 _ecore_x_dnd_source_get(void)
 {
@@ -280,9 +335,11 @@
    _source->state = ECORE_X_DND_SOURCE_DRAGGING;
    _source->time = _ecore_x_event_last_time;
 
-   /* Default Accepted Action: ask */
-   _source->action = ECORE_X_ATOM_XDND_ACTION_COPY;
+   /* Default Accepted Action: move */
+   _source->action = ECORE_X_ATOM_XDND_ACTION_MOVE;
    _source->accepted_action = None;
+   _source->dest = None;
+
    return 1;
 }
 
@@ -326,9 +383,6 @@
      }
    ecore_x_window_ignore_set(_source->win, 0);
 
-   _source->dest = None; 
-
-
    return status;
 }
 
@@ -503,4 +557,3 @@
 
    _source->dest = win;
 }
-



-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to