aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/FbWindow.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/FbTk/FbWindow.cc')
-rw-r--r--src/FbTk/FbWindow.cc30
1 files changed, 23 insertions, 7 deletions
diff --git a/src/FbTk/FbWindow.cc b/src/FbTk/FbWindow.cc
index 8f204b1..2c34fa1 100644
--- a/src/FbTk/FbWindow.cc
+++ b/src/FbTk/FbWindow.cc
@@ -23,6 +23,7 @@
23 23
24#include "FbWindow.hh" 24#include "FbWindow.hh"
25#include "FbPixmap.hh" 25#include "FbPixmap.hh"
26#include "FbString.hh"
26 27
27#include "EventManager.hh" 28#include "EventManager.hh"
28#include "Color.hh" 29#include "Color.hh"
@@ -450,28 +451,43 @@ void FbWindow::reparent(const FbWindow &parent, int x, int y, bool continuing) {
450 451
451std::string FbWindow::textProperty(Atom property) const { 452std::string FbWindow::textProperty(Atom property) const {
452 XTextProperty text_prop; 453 XTextProperty text_prop;
453 char ** stringlist; 454 char ** stringlist = 0;
454 int count; 455 int count;
455 std::string ret; 456 std::string ret;
456 457
458 static Atom m_utf8string = XInternAtom(display(), "UTF8_STRING", False);
459
457 if (XGetTextProperty(display(), window(), &text_prop, property) == 0) 460 if (XGetTextProperty(display(), window(), &text_prop, property) == 0)
458 return ""; 461 return "";
459 462
460 if (text_prop.value == 0 || text_prop.nitems == 0) 463 if (text_prop.value == 0 || text_prop.nitems == 0)
461 return ""; 464 return "";
462 465
463 if (text_prop.encoding != XA_STRING) { 466 if (text_prop.encoding == XA_STRING) {
464 // still returns a "StringList" despite the different name 467 if (XTextPropertyToStringList(&text_prop, &stringlist, &count) == 0 || count == 0)
465 if (XmbTextPropertyToTextList(display(), &text_prop, &stringlist, &count) == 0 || count == 0)
466 return ""; 468 return "";
467 } else { 469 ret = FbStringUtil::XStrToFb(stringlist[0]);
470 } else if (text_prop.encoding == m_utf8string && text_prop.format == 8) {
471#ifdef X_HAVE_UTF8_STRING
472 Xutf8TextPropertyToTextList(display(), &text_prop, &stringlist, &count);
473 if (count == 0)
474 return "";
475#else
468 if (XTextPropertyToStringList(&text_prop, &stringlist, &count) == 0 || count == 0) 476 if (XTextPropertyToStringList(&text_prop, &stringlist, &count) == 0 || count == 0)
469 return ""; 477 return "";
478#endif
479 ret = stringlist[0];
480 } else {
481 // still returns a "StringList" despite the different name
482 if (XmbTextPropertyToTextList(display(), &text_prop, &stringlist, &count) == 0 || count == 0)
483 return "";
470 484
485 ret = FbStringUtil::LocaleStrToFb(stringlist[0]);
471 } 486 }
472 487
473 ret = stringlist[0]; 488 // they all use stringlist
474 XFreeStringList(stringlist); 489 if (stringlist)
490 XFreeStringList(stringlist);
475 return ret; 491 return ret;
476} 492}
477 493