From c0459f2a91fafa13143b8b137115c8881d97c586 Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Thu, 5 Oct 2000 11:19:39 +0000 Subject: [PATCH] Fixed handling of X11 Xmb WM name atom. Non-latin1 window captions were not displayed correctly before. svn path=/trunk/kdebase/kwin/; revision=66444 --- client.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/client.cpp b/client.cpp index 9e12faf1aa..57f6bb5488 100644 --- a/client.cpp +++ b/client.cpp @@ -674,11 +674,19 @@ void Client::fetchName() if ( info->name() ) { s = QString::fromUtf8( info->name() ); } else { - char* c = 0; - if ( XFetchName( qt_xdisplay(), win, &c ) != 0 ) { - s = QString::fromLocal8Bit( c ); - XFree( c ); - } + XTextProperty tp; + char **text; + int count; + if ( XGetTextProperty( qt_xdisplay(), win, &tp, XA_WM_NAME) != 0 && tp.value != NULL ) { + if ( tp.encoding == XA_STRING ) + s = QString::fromLocal8Bit( (const char*) tp.value ); + else if ( XmbTextPropertyToTextList( qt_xdisplay(), &tp, &text, &count) == Success && + text != NULL && count > 0 ) { + s = QString::fromLocal8Bit( text[0] ); + XFreeStringList( text ); + } + XFree( tp.value ); + } } if ( s != caption() ) {