bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug #4658] Broken gpbs when doing pb operations between GS and X


From: Kazunobu Kuriyama
Subject: Re: [bug #4658] Broken gpbs when doing pb operations between GS and X
Date: Sat, 09 Aug 2003 01:49:45 +0900
User-agent: Mozilla/5.0 (X11; U; Linux i686; ja-JP; rv:1.4) Gecko/20030624 Netscape/7.1


2. It is not possible to copy from X and paste in GNUstep strings longer than 1024 character

The patch attached fixes the problem, though it is not fully tested.

(Since I cannot get any email from bug-gnustep now,  I'm afraid I cannot
reply to any email from you promptly. Be patient, please. )
--- xpbs.m      2003-07-30 12:39:18.000000000 +0900
+++ xpbs.m.rev  2003-07-30 12:39:29.000000000 +0900
@@ -30,6 +30,12 @@
 #include <X11/Xutil.h>
 #include <x11/xdnd.h>
 
+#ifdef X_HAVE_UTF8_STRING
+#warning "XFree86 UTF8 extension used"
+#else
+#warning "XFRee86 UTF8 extension not used: gpbs supports ISO Latin 1 
characters only"
+#endif
+
 static Atom    osTypeToX(NSString *t);
 static NSString        *xTypeToOs(Atom t);
 
@@ -51,7 +57,10 @@
   "USER",
   "TEXT",
   "NULL",
-  "FILE_NAME"
+  "FILE_NAME",
+#ifdef X_HAVE_UTF8_STRING
+  "UTF8_STRING"
+#endif
 };
 static Atom atoms[sizeof(atom_names)/sizeof(char*)];
 
@@ -74,6 +83,9 @@
 #define XG_TEXT                 atoms[12]
 #define XG_NULL                 atoms[13]
 #define XG_FILE_NAME           atoms[14]
+#ifdef X_HAVE_UTF8_STRING
+#define XG_UTF8_STRING         atoms[15]
+#endif
 
 
 
@@ -81,7 +93,11 @@
 osTypeToX(NSString *t)
 {
   if ([t isEqualToString: NSStringPboardType] == YES)
+#ifdef X_HAVE_UTF8_STRING
+    return XG_UTF8_STRING;
+#else
     return XA_STRING;
+#endif
   else if ([t isEqualToString: NSColorPboardType] == YES)
     return XG_NULL;
   else if ([t isEqualToString: NSFileContentsPboardType] == YES)
@@ -113,7 +129,11 @@
 static NSString*
 xTypeToOs(Atom t)
 {
+#ifdef X_HAVE_UTF8_STRING
+  if (t == XG_UTF8_STRING)
+#else
   if (t == XA_STRING)
+#endif
     return NSStringPboardType;
   else if (t == XG_TEXT)
     return NSStringPboardType;
@@ -160,6 +180,7 @@
   return True;
 }
 
+#ifdef USE_xConvertSelection 
 // This never gets called! 
 static unsigned char*
 xConvertSelection(Display* display,
@@ -245,6 +266,7 @@
 
   return data;
 }
+#endif // USE_xConvertSelection  defined
 
 @interface     XPbOwner : NSObject
 {
@@ -673,8 +695,13 @@
           * Ask the X system to provide the pasteboard data in the
           * appropriate property of our application root window.
           */
+#ifdef X_HAVE_UTF8_STRING
+         XConvertSelection(xDisplay, [self xPb], XG_UTF8_STRING,
+           [self xPb], xAppWin, whenRequested);
+#else // X_HAVE_UTF8_STRING not defined
          XConvertSelection(xDisplay, [self xPb], XA_STRING,
            [self xPb], xAppWin, whenRequested);
+#endif // X_HAVE_UTF8_STRING not defined
          XFlush(xDisplay);
 
          /*
@@ -766,7 +793,11 @@
   int          status;
   unsigned char        *data;
   Atom         actual_target;
+#ifdef X_HAVE_UTF8_STRING
+  Atom         new_target = XG_UTF8_STRING;
+#else // X_HAVE_UTF8_STRING not defined
   Atom         new_target = XA_STRING;
+#endif // X_HAVE_UTF8_STRING
   int          actual_format;
   unsigned long        bytes_remaining;
   unsigned long        number_items;
@@ -799,6 +830,22 @@
 // Convert data to text string.
 // string = PropertyToString(xDisplay,new_target,number_items,(char*)data);
 
+#ifdef X_HAVE_UTF8_STRING
+      if (actual_target == XG_UTF8_STRING)
+       {
+         NSData        *d;
+         NSString      *s;
+
+         d = [[NSData alloc] initWithBytes: (void *)data
+                                    length: number_items];
+         s = [[NSString alloc] initWithData: d
+                                   encoding: NSUTF8StringEncoding];
+         RELEASE(d);
+         d = [NSSerializer serializePropertyList: s];
+         RELEASE(s);
+         [self setData: d];
+       }
+#else // X_HAVE_UTF8_STRING not defined
       if (new_target == XA_STRING)
        {
          NSData        *d;
@@ -813,6 +860,7 @@
          RELEASE(s);
          [self setData: d];
        }
+#endif // X_HAVE_UTF8_STRING not defined
       else
        {
          NSLog(@"Unsupported data type from X selection.");
@@ -964,7 +1012,11 @@
          if ([osType isEqualToString: NSStringPboardType])
            {
              NSString  *s = [_pb stringForType: NSStringPboardType];
+#ifdef X_HAVE_UTF8_STRING
+             NSData *d = [s dataUsingEncoding: NSUTF8StringEncoding];
+#else // X_HAVE_UTF8_STRING not defined
              NSData *d = [s dataUsingEncoding: NSISOLatin1StringEncoding];
+#endif // X_HAVE_UTF8_STRING not defined
 
              format = 8;
              if (d != nil)
@@ -1056,7 +1108,11 @@
        * The property doesn't exist - so we will be creating a new (empty)
        * property.
        */
+#ifdef X_HAVE_UTF8_STRING
+      actualType = XG_UTF8_STRING;
+#else // X_HAVE_UTF8_STRING not defined
       actualType = XA_STRING;
+#endif // X_HAVE_UTF8_STRING not defined
       actualFormat = 8;
     }
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]