_NET_WM_NAME patch (2)

Ilya Konstantinov wine-patches at future.shiny.co.il
Fri Sep 28 08:12:50 CDT 2001


Hi,

Here's a better patch, following Dmitry's suggestion to use native
Win32 calls.
-------------- next part --------------
Index: window.c
===================================================================
RCS file: /home/wine/wine/dlls/x11drv/window.c,v
retrieving revision 1.22
diff -u -3 -d -p -r1.22 window.c
--- window.c	2001/09/14 00:24:40	1.22
+++ window.c	2001/09/28 11:53:54
@@ -714,6 +714,7 @@ BOOL X11DRV_SetWindowText( HWND hwnd, LP
     Display *display = thread_display();
     UINT count;
     char *buffer;
+    char *utf8_buffer = NULL;
     static UINT text_cp = (UINT)-1;
     Window win;
     WND *wndPtr = WIN_FindWndPtr( hwnd );
@@ -747,11 +748,31 @@ BOOL X11DRV_SetWindowText( HWND hwnd, LP
         }
         WideCharToMultiByte(text_cp, 0, text, -1, buffer, count, NULL, NULL);
 
+        count = WideCharToMultiByte(CP_UTF8, 0, text, -1, NULL, 0, NULL, NULL);
+        if (!(utf8_buffer = HeapAlloc( GetProcessHeap(), 0, count )))
+        {
+            ERR("Not enough memory for window text in UTF-8\n");
+            WIN_ReleaseWndPtr( wndPtr );
+            return FALSE;
+        }
+        WideCharToMultiByte(CP_UTF8, 0, text, -1, utf8_buffer, count, NULL, NULL);
+
         wine_tsx11_lock();
         XStoreName( display, win, buffer );
         XSetIconName( display, win, buffer );
+        /*
+        Implements a NET_WM UTF-8 title. It should be without a trailing \0,
+        according to the standard
+        ( http://www.pps.jussieu.fr/~jch/software/UTF8_STRING/UTF8_STRING.text ).
+        */
+        XChangeProperty( display, win,
+            XInternAtom(display, "_NET_WM_NAME", False),
+            XInternAtom(display, "UTF8_STRING", False),
+            8, PropModeReplace, (unsigned char *) utf8_buffer,
+            count);
         wine_tsx11_unlock();
 
+        HeapFree( GetProcessHeap(), 0, utf8_buffer );
         HeapFree( GetProcessHeap(), 0, buffer );
     }
     WIN_ReleaseWndPtr( wndPtr );


More information about the wine-patches mailing list