summaryrefslogtreecommitdiff
path: root/src/FbTk
diff options
context:
space:
mode:
authorsimonb <simonb>2006-05-07 10:08:25 (GMT)
committersimonb <simonb>2006-05-07 10:08:25 (GMT)
commitfaf043bef92338fe976e639e94d309764065b8b7 (patch)
tree6554ea89ff6064465bd605da8f640ee43212b356 /src/FbTk
parentac098b4d0f0640b2997ff674a5c1b3447b6ba09a (diff)
downloadfluxbox_lack-faf043bef92338fe976e639e94d309764065b8b7.zip
fluxbox_lack-faf043bef92338fe976e639e94d309764065b8b7.tar.bz2
more utf8 changes, notably window titles
Diffstat (limited to 'src/FbTk')
-rw-r--r--src/FbTk/FbString.cc8
-rw-r--r--src/FbTk/FbString.hh4
-rw-r--r--src/FbTk/FbWindow.cc30
3 files changed, 31 insertions, 11 deletions
diff --git a/src/FbTk/FbString.cc b/src/FbTk/FbString.cc
index a88b237..6c5ffbb 100644
--- a/src/FbTk/FbString.cc
+++ b/src/FbTk/FbString.cc
@@ -107,6 +107,14 @@ void shutdown() {
107 @param size number of BYTES to convert 107 @param size number of BYTES to convert
108 @return the recoded string, or 0 on failure 108 @return the recoded string, or 0 on failure
109*/ 109*/
110
111/**
112 --NOTE--
113 In the "C" locale, this will strip any high-bit characters
114 because C means 7-bit ASCII charset. If you don't want this
115 then you need to set your locale to something UTF-8, OR something
116 ISO8859-1.
117*/
110std::string recode(iconv_t cd, 118std::string recode(iconv_t cd,
111 const std::string &in) { 119 const std::string &in) {
112 120
diff --git a/src/FbTk/FbString.hh b/src/FbTk/FbString.hh
index 371d4e9..011d47a 100644
--- a/src/FbTk/FbString.hh
+++ b/src/FbTk/FbString.hh
@@ -49,10 +49,6 @@ std::string FbStrToX(const FbString &src);
49FbString LocaleStrToFb(const std::string &src); 49FbString LocaleStrToFb(const std::string &src);
50std::string FbStrToLocale(const FbString &src); 50std::string FbStrToLocale(const FbString &src);
51 51
52// essentially NO-OP
53inline FbString UTF8StrToFb(const std::string &src) { return src; }
54inline std::string FbStrToUTF8(const FbString &src) { return src; }
55
56bool haveUTF8(); 52bool haveUTF8();
57 53
58} // namespace FbStringUtil 54} // namespace FbStringUtil
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