Author: greg.ercolano
Date: 2013-02-14 10:40:04 -0800 (Thu, 14 Feb 2013)
New Revision: 9824
Log:
Fixes STR#2930:
    Applying Chris's patch to fix d+d of text selections from 
Firefox/Thunderbird -> FLTK.
    Also applied Greg's fix for d+d of utf8 text in same use case.



Modified:
   branches/branch-1.3/src/Fl_x.cxx

Modified: branches/branch-1.3/src/Fl_x.cxx
===================================================================
--- branches/branch-1.3/src/Fl_x.cxx    2013-02-12 14:33:48 UTC (rev 9823)
+++ branches/branch-1.3/src/Fl_x.cxx    2013-02-14 18:40:04 UTC (rev 9824)
@@ -319,6 +319,7 @@
 //Atom fl_XdndProxy;
 Atom fl_XdndURIList;
 Atom fl_Xatextplainutf;
+Atom fl_Xatextplainutf2;               // STR#2930 
 Atom fl_Xatextplain;
 static Atom fl_XaText;
 Atom fl_XaCompoundText;
@@ -621,6 +622,7 @@
   fl_XdndEnter          = XInternAtom(d, "XdndEnter",           0);
   fl_XdndURIList        = XInternAtom(d, "text/uri-list",       0);
   fl_Xatextplainutf     = XInternAtom(d, "text/plain;charset=UTF-8",0);
+  fl_Xatextplainutf2    = XInternAtom(d, "text/plain;charset=utf-8",0);        
// Firefox/Thunderbird needs this - See STR#2930
   fl_Xatextplain        = XInternAtom(d, "text/plain",          0);
   fl_XaText             = XInternAtom(d, "TEXT",                0);
   fl_XaCompoundText     = XInternAtom(d, "COMPOUND_TEXT",       0);
@@ -1023,13 +1025,17 @@
        Atom type = XA_STRING;
        for (unsigned i = 0; i<count; i++) {
          Atom t = ((Atom*)portion)[i];
-           if (t == fl_Xatextplainutf ||
-                 t == fl_Xatextplain ||
-                 t == fl_XaUtf8String) {type = t; break;}
-           // rest are only used if no utf-8 available:
-           if (t == fl_XaText ||
-                 t == fl_XaTextUriList ||
-                 t == fl_XaCompoundText) type = t;
+         if (t == fl_Xatextplainutf ||
+             t == fl_Xatextplainutf2 ||
+             t == fl_Xatextplain ||
+             t == fl_XaUtf8String) {
+           type = t;
+           break;
+         }
+         // rest are only used if no utf-8 available:
+         if (t == fl_XaText ||
+             t == fl_XaTextUriList ||
+             t == fl_XaCompoundText) type = t;
        }
        XFree(portion);
        Atom property = xevent.xselection.property;
@@ -1096,7 +1102,8 @@
             e.target == fl_XaCompoundText ||
             e.target == fl_XaText ||
             e.target == fl_Xatextplain ||
-            e.target == fl_Xatextplainutf) {
+            e.target == fl_Xatextplainutf ||
+            e.target == fl_Xatextplainutf2) {
        // clobber the target type, this seems to make some applications
        // behave that insist on asking for XA_TEXT instead of UTF8_STRING
        // Does not change XA_STRING as that breaks xclipboard.
@@ -1186,24 +1193,25 @@
       }
 
       // Loop through the source types and pick the first text type...
-      int i;
-
-      for (i = 0; fl_dnd_source_types[i]; i ++)
-      {
-//        printf("fl_dnd_source_types[%d] = %ld (%s)\n", i,
-//             fl_dnd_source_types[i],
-//             XGetAtomName(fl_display, fl_dnd_source_types[i]));
-
-        if (!strncmp(XGetAtomName(fl_display, fl_dnd_source_types[i]),
-                     "text/", 5))
+      unsigned i;
+      Atom type = ((Atom*)fl_dnd_source_types)[0];
+      for (i = 0; fl_dnd_source_types[i]; i ++) {
+        Atom t = ((Atom*)fl_dnd_source_types)[i];
+        
//printf("fl_dnd_source_types[%d]=%ld(%s)\n",i,t,XGetAtomName(fl_display,t));
+        if (t == fl_Xatextplainutf ||          // "text/plain;charset=UTF-8"
+            t == fl_Xatextplainutf2 ||         // "text/plain;charset=utf-8" 
-- See STR#2930
+            t == fl_Xatextplain ||             // "text/plain"
+            t == fl_XaUtf8String) {            // "UTF8_STRING"
+          type = t;
           break;
+       }
+        // rest are only used if no utf-8 available:
+        if (t == fl_XaText ||                  // "TEXT"
+            t == fl_XaTextUriList ||           // "text/uri-list"
+            t == fl_XaCompoundText) type = t;  // "COMPOUND_TEXT"
       }
+      fl_dnd_type = type;
 
-      if (fl_dnd_source_types[i])
-        fl_dnd_type = fl_dnd_source_types[i];
-      else
-        fl_dnd_type = fl_dnd_source_types[0];
-
       event = FL_DND_ENTER;
       Fl::e_text = unknown;
       Fl::e_length = unknown_len;

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to