From: Sascha S. <sas...@si...> - 2011-07-02 12:18:45
|
In case Xlib doesn't support XUTF8StringStyle we fall back to the old, broken behaviour of using the encoding of the current locale. If there's really anyone still using such a beast _and_ caring about EWMH [1] they can enhance the code to do an explicit conversion (locale enconding to UTF-8) and set the type to the UTF8_STRING Atom manually. [1] http://freedesktop.org/wiki/Specifications/wm-spec Signed-off-by: Sascha Silbe <sas...@si...> --- With this fix wnck_screen_get_window_manager_name() (libwnck) will return "notion" instead of NULL, thus notion gets recognised as an active EWMH compliant window manager. ioncore/netwm.c | 4 ++++ ioncore/property.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ ioncore/property.h | 4 ++++ 3 files changed, 55 insertions(+), 0 deletions(-) diff --git a/ioncore/netwm.c b/ioncore/netwm.c index 06471c7..5e4b763 100644 --- a/ioncore/netwm.c +++ b/ioncore/netwm.c @@ -81,7 +81,11 @@ void netwm_init_rootwin(WRootWin *rw) 32, PropModeReplace, (uchar*)atoms, N_NETWM); p[0]=libtu_progbasename(); +#ifdef X_HAVE_UTF8_STRING + xwindow_set_utf8_property(rw->dummy_win, atom_net_wm_name, p, 1); +#else xwindow_set_text_property(rw->dummy_win, atom_net_wm_name, p, 1); +#endif } diff --git a/ioncore/property.c b/ioncore/property.c index 4ef66e3..8cc1937 100644 --- a/ioncore/property.c +++ b/ioncore/property.c @@ -230,6 +230,24 @@ void xwindow_set_text_property(Window win, Atom a, const char **ptr, int n) XFree(prop.value); } +#ifdef X_HAVE_UTF8_STRING +void xwindow_set_utf8_property(Window win, Atom a, const char **ptr, int n) +{ + XTextProperty prop; + bool ok; + + int st=XmbTextListToTextProperty(ioncore_g.dpy, (char **)ptr, n, + XUTF8StringStyle, &prop); + ok=(st>=0); + + if(!ok) + return; + + XSetTextProperty(ioncore_g.dpy, win, &prop, a); + XFree(prop.value); +} +#endif + /*}}}*/ @@ -437,6 +455,35 @@ void ioncore_x_set_text_property(int win, int atom, ExtlTab tab) } +#ifdef X_HAVE_UTF8_STRING +/*EXTL_DOC + * Set a UTF8_STRING property for a window. The fields of \var{tab} starting + * from 1 should be the different null-separated parts of the property. + * See the \code{XSetTextProperty}(3) manual page for more information. + */ +EXTL_EXPORT +void ioncore_x_set_utf8_property(int win, int atom, ExtlTab tab) +{ + char **list; + int i, n=extl_table_get_n(tab); + + list=ALLOC_N(char*, n); + + if(list==NULL) + return; + + for(i=0; i<n; i++){ + list[i]=NULL; + extl_table_geti_s(tab, i+1, &(list[i])); + } + + xwindow_set_utf8_property(win, atom, (const char **)list, n); + + XFreeStringList(list); +} +#endif + + /*}}}*/ diff --git a/ioncore/property.h b/ioncore/property.h index e1cd083..0e321c2 100644 --- a/ioncore/property.h +++ b/ioncore/property.h @@ -25,6 +25,10 @@ extern void xwindow_set_state_property(Window win, int state); extern char **xwindow_get_text_property(Window win, Atom a, int *nret); extern void xwindow_set_text_property(Window win, Atom a, const char **p, int n); +#ifdef X_HAVE_UTF8_STRING +extern void xwindow_set_utf8_property(Window win, Atom a, + const char **p, int n); +#endif extern bool xwindow_get_cardinal_property(Window win, Atom a, CARD32 *vret); #endif /* ION_IONCORE_PROPERTY_H */ -- 1.7.2.5 |