_NET_WM_NAME support patch
Ilya Konstantinov
wine-patches at future.shiny.co.il
Thu Sep 27 16:03:22 CDT 2001
Hi,
This patch adds a _NET_WM_NAME(UTF8_STRING) property to every window,
storing it's title in non-ambigous UTF8 encoding. This is a part of the
NET_WM standard. The UTF8 title feature is currently implemented only
by KWin (KDE's window manager), but is adopted by both GNOME and KDE
camps.
-------------- 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/27 19:26:06
@@ -17,6 +17,7 @@
#include "wingdi.h"
#include "winreg.h"
#include "winuser.h"
+#include "wine/unicode.h"
#include "debugtools.h"
#include "x11drv.h"
@@ -714,6 +715,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 );
@@ -746,12 +748,32 @@ BOOL X11DRV_SetWindowText( HWND hwnd, LP
return FALSE;
}
WideCharToMultiByte(text_cp, 0, text, -1, buffer, count, NULL, NULL);
+
+ count = utf8_wcstombs(text, strlenW(text), utf8_buffer, 0);
+ if (!(utf8_buffer = HeapAlloc( GetProcessHeap(), 0, count )))
+ {
+ ERR("Not enough memory for window text in UTF-8\n");
+ WIN_ReleaseWndPtr( wndPtr );
+ return FALSE;
+ }
+ utf8_wcstombs(text, strlenW(text), utf8_buffer, count);
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