support COMPOUNDTEXT and TEXT target

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

 



This patch add support for selection request with COMPOUND_TEXT or TEXT
target.
--- wine-20030508.orig/dlls/x11drv/event.c	2003-05-04 11:27:20.000000000 +0900
+++ wine-20030508/dlls/x11drv/event.c	2003-06-13 08:21:24.000000000 +0900
@@ -664,6 +664,110 @@
 
 
 /***********************************************************************
+ *           EVENT_SelectionRequest_COMPOUND_TEXT
+ *  Service a COMPOUND_TEXT or TEXT selection request event
+ */
+static Atom EVENT_SelectionRequest_COMPOUND_TEXT( Display *display,
+						  Window requestor,
+						  Atom target, Atom rprop )
+{
+    static UINT text_cp = (UINT)-1;
+    HANDLE hUnicodeText;
+    LPWSTR uni_text;
+    LPSTR  text;
+    int    size,i,j;
+    char* lpstr = 0;
+    char *itemFmtName;
+    XTextProperty prop;
+    XICCEncodingStyle style;
+
+    if(text_cp == (UINT)-1)
+    {
+	HKEY hkey;
+	/* default value */
+	text_cp = CP_ACP;
+	if(!RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\x11drv", &hkey))
+	{
+	    char buf[20];
+	    DWORD type, count = sizeof(buf);
+	    if(!RegQueryValueExA(hkey, "TextCP", 0, &type, buf, &count))
+		text_cp = atoi(buf);
+	    RegCloseKey(hkey);
+	  }
+    }
+
+    /*
+     * Map the requested X selection property type atom name to a
+     * windows clipboard format ID.
+     */
+    itemFmtName = TSXGetAtomName(display, target);
+    TRACE("Request for %s (wFormat=%x %s)\n",
+	itemFmtName, CF_UNICODETEXT, CLIPBOARD_GetFormatName(CF_UNICODETEXT, NULL, 0));
+    if (strcmp(itemFmtName, "COMPOUND_TEXT") == 0)
+    {
+	style = XCompoundTextStyle;
+    }
+    else
+    {
+	style = XStdICCTextStyle;
+    }
+    TSXFree(itemFmtName);
+
+    hUnicodeText = GetClipboardData(CF_UNICODETEXT);
+    if(!hUnicodeText)
+       return None;
+    uni_text = GlobalLock(hUnicodeText);
+    if(!uni_text)
+       return None;
+
+    size = WideCharToMultiByte(text_cp, 0, uni_text, -1, NULL, 0, NULL, NULL);
+    text = HeapAlloc(GetProcessHeap(), 0, size);
+    if (!text)
+       return None;
+    WideCharToMultiByte(text_cp, 0, uni_text, -1, text, size, NULL, NULL);
+
+    /* remove carriage returns */
+
+    lpstr = (char*)HeapAlloc( GetProcessHeap(), 0, size-- );
+    if(lpstr == NULL) return None;
+    for(i=0,j=0; i < size && text[i]; i++ )
+    {
+        if( text[i] == '\r' &&
+            (text[i+1] == '\n' || text[i+1] == '\0') ) continue;
+        lpstr[j++] = text[i];
+    }
+    lpstr[j]='\0';
+
+    /* Update the X property */
+    wine_tsx11_lock();
+    if (XmbTextListToTextProperty(display, &lpstr, 1, style, &prop) == Success)
+    {
+	if (WINE_TRACE_ON(event))
+	{
+	    char *property_name;
+
+	    property_name = XGetAtomName(display, rprop);
+	    TRACE("\tUpdating property %s...\n", property_name);
+	    XFree(property_name);
+	}
+	XSetTextProperty(display, requestor, &prop, rprop);
+	XFree(prop.value);
+    }
+    else
+    {
+	rprop = None;
+    }
+    wine_tsx11_unlock();
+
+    GlobalUnlock(hUnicodeText);
+    HeapFree(GetProcessHeap(), 0, text);
+    HeapFree( GetProcessHeap(), 0, lpstr );
+
+    return rprop;
+}
+
+
+/***********************************************************************
  *           EVENT_SelectionRequest_STRING
  *  Service a STRING selection request event
  */
@@ -1017,6 +1121,8 @@
   Atom            xaClipboard = TSXInternAtom(display, "CLIPBOARD", False);
   Atom            xaTargets = TSXInternAtom(display, "TARGETS", False);
   Atom            xaMultiple = TSXInternAtom(display, "MULTIPLE", False);
+  Atom            xaCompoundText = TSXInternAtom(display, "COMPOUND_TEXT", False);
+  Atom            xaText = TSXInternAtom(display, "TEXT", False);
 
   /*
    * We can only handle the selection request if :
@@ -1048,6 +1154,11 @@
       /* MULTIPLE selection request */
       rprop = EVENT_SelectionRequest_MULTIPLE( hWnd, event );
   }
+  else if(event->target == xaCompoundText || event->target == xaText)
+  {
+      /* COMPOUND_TEXT or TEXT selection request */
+      rprop = EVENT_SelectionRequest_COMPOUND_TEXT( display, request, event->target, rprop );
+  }
   else if(event->target == XA_STRING)  /* treat CF_TEXT as Unix text */
   {
       /* XA_STRING selection request */

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux