aboutsummaryrefslogtreecommitdiff
path: root/src
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
parentac098b4d0f0640b2997ff674a5c1b3447b6ba09a (diff)
downloadfluxbox-faf043bef92338fe976e639e94d309764065b8b7.zip
fluxbox-faf043bef92338fe976e639e94d309764065b8b7.tar.bz2
more utf8 changes, notably window titles
Diffstat (limited to 'src')
-rw-r--r--src/Ewmh.cc37
-rw-r--r--src/Ewmh.hh6
-rw-r--r--src/FbTk/FbString.cc8
-rw-r--r--src/FbTk/FbString.hh4
-rw-r--r--src/FbTk/FbWindow.cc30
-rw-r--r--src/Screen.cc3
-rw-r--r--src/WinClient.cc18
-rw-r--r--src/WinClient.hh7
-rw-r--r--src/WinClientUtil.cc8
-rw-r--r--src/Workspace.cc3
-rw-r--r--src/WorkspaceNameTool.cc4
-rw-r--r--src/fluxbox.cc2
12 files changed, 105 insertions, 25 deletions
diff --git a/src/Ewmh.cc b/src/Ewmh.cc
index 6bcd3e6..ea23a22 100644
--- a/src/Ewmh.cc
+++ b/src/Ewmh.cc
@@ -189,6 +189,15 @@ void Ewmh::initForScreen(BScreen &screen) {
189 189
190void Ewmh::setupClient(WinClient &winclient) { 190void Ewmh::setupClient(WinClient &winclient) {
191 updateStrut(winclient); 191 updateStrut(winclient);
192
193 FbTk::FbString newtitle = winclient.textProperty(m_net_wm_name);
194 if (!newtitle.empty()) {
195 winclient.setTitle(newtitle);
196 }
197 newtitle = winclient.textProperty(m_net_wm_icon_name);
198 if (!newtitle.empty()) {
199 winclient.setIconTitle(newtitle);
200 }
192} 201}
193 202
194void Ewmh::setupFrame(FluxboxWindow &win) { 203void Ewmh::setupFrame(FluxboxWindow &win) {
@@ -268,7 +277,7 @@ void Ewmh::setupFrame(FluxboxWindow &win) {
268 &ret_type, &fmt, &nitems, &bytes_after, 277 &ret_type, &fmt, &nitems, &bytes_after,
269 (unsigned char **) &data) && data) { 278 (unsigned char **) &data) && data) {
270 unsigned int desktop = static_cast<long>(*data); 279 unsigned int desktop = static_cast<long>(*data);
271 if (desktop == -1 && !win.isStuck()) 280 if (desktop == (unsigned int)(-1) && !win.isStuck())
272 win.stick(); 281 win.stick();
273 else 282 else
274 win.setWorkspace(desktop); 283 win.setWorkspace(desktop);
@@ -433,11 +442,21 @@ void Ewmh::updateWorkspaceNames(BScreen &screen) {
433 strcpy(names[i], workspacenames[i].c_str()); 442 strcpy(names[i], workspacenames[i].c_str());
434 } 443 }
435 444
445#ifdef X_HAVE_UTF8_STRING
446 Xutf8TextListToTextProperty(FbTk::App::instance()->display(),
447 names, number_of_desks, XUTF8StringStyle, &text);
448 XSetTextProperty(FbTk::App::instance()->display(), screen.rootWindow().window(),
449 &text, m_net_desktop_names);
450
451 XFree(text.value);
452
453#else
436 if (XStringListToTextProperty(names, number_of_desks, &text)) { 454 if (XStringListToTextProperty(names, number_of_desks, &text)) {
437 XSetTextProperty(FbTk::App::instance()->display(), screen.rootWindow().window(), 455 XSetTextProperty(FbTk::App::instance()->display(), screen.rootWindow().window(),
438 &text, m_net_desktop_names); 456 &text, m_net_desktop_names);
439 XFree(text.value); 457 XFree(text.value);
440 } 458 }
459#endif
441 460
442 for (size_t i = 0; i < number_of_desks; i++) 461 for (size_t i = 0; i < number_of_desks; i++)
443 delete [] names[i]; 462 delete [] names[i];
@@ -810,7 +829,17 @@ bool Ewmh::propertyNotify(WinClient &winclient, Atom the_property) {
810 if (the_property == m_net_wm_strut) { 829 if (the_property == m_net_wm_strut) {
811 updateStrut(winclient); 830 updateStrut(winclient);
812 return true; 831 return true;
813 } 832 } else if (the_property == m_net_wm_name) {
833 FbTk::FbString newtitle = winclient.textProperty(the_property);
834 if (!newtitle.empty())
835 winclient.setTitle(newtitle);
836 return true;
837 } else if (the_property == m_net_wm_icon_name) {
838 FbTk::FbString newtitle = winclient.textProperty(the_property);
839 if (!newtitle.empty())
840 winclient.setIconTitle(newtitle);
841 return true;
842 }
814 843
815 return false; 844 return false;
816} 845}
@@ -841,6 +870,7 @@ void Ewmh::createAtoms() {
841 870
842 m_net_properties = XInternAtom(disp, "_NET_PROPERTIES", False); 871 m_net_properties = XInternAtom(disp, "_NET_PROPERTIES", False);
843 m_net_wm_name = XInternAtom(disp, "_NET_WM_NAME", False); 872 m_net_wm_name = XInternAtom(disp, "_NET_WM_NAME", False);
873 m_net_wm_icon_name = XInternAtom(disp, "_NET_WM_ICON_NAME", False);
844 m_net_wm_desktop = XInternAtom(disp, "_NET_WM_DESKTOP", False); 874 m_net_wm_desktop = XInternAtom(disp, "_NET_WM_DESKTOP", False);
845 875
846 // type atoms 876 // type atoms
@@ -1017,6 +1047,8 @@ void Ewmh::updateStrut(WinClient &winclient) {
1017 } 1047 }
1018} 1048}
1019 1049
1050
1051
1020void Ewmh::updateActions(FluxboxWindow &win) { 1052void Ewmh::updateActions(FluxboxWindow &win) {
1021 1053
1022 /* From Extended Window Manager Hints, draft 1.3: 1054 /* From Extended Window Manager Hints, draft 1.3:
@@ -1151,3 +1183,4 @@ void Ewmh::clearState(FluxboxWindow &win) {
1151void Ewmh::saveState(FluxboxWindow &win, WindowState *state) { 1183void Ewmh::saveState(FluxboxWindow &win, WindowState *state) {
1152 m_savedstate[&win] = state; 1184 m_savedstate[&win] = state;
1153} 1185}
1186
diff --git a/src/Ewmh.hh b/src/Ewmh.hh
index 497665a..5c336e5 100644
--- a/src/Ewmh.hh
+++ b/src/Ewmh.hh
@@ -22,6 +22,7 @@
22// $Id$ 22// $Id$
23 23
24#include "AtomHandler.hh" 24#include "AtomHandler.hh"
25#include "FbTk/FbString.hh"
25 26
26#include <X11/Xatom.h> 27#include <X11/Xatom.h>
27#include <vector> 28#include <vector>
@@ -101,7 +102,8 @@ private:
101 Atom m_net_close_window, m_net_wm_moveresize; 102 Atom m_net_close_window, m_net_wm_moveresize;
102 103
103 // application window properties 104 // application window properties
104 Atom m_net_properties, m_net_wm_name, m_net_wm_desktop, 105 Atom m_net_properties, m_net_wm_name, m_net_wm_icon_name,
106 m_net_wm_desktop,
105 // types 107 // types
106 m_net_wm_window_type, 108 m_net_wm_window_type,
107 m_net_wm_window_type_dock, 109 m_net_wm_window_type_dock,
@@ -147,4 +149,6 @@ private:
147 void clearState(FluxboxWindow &win); 149 void clearState(FluxboxWindow &win);
148 void saveState(FluxboxWindow &win, WindowState *state); 150 void saveState(FluxboxWindow &win, WindowState *state);
149 151
152 FbTk::FbString getUTF8Property(Atom property);
153
150}; 154};
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
diff --git a/src/Screen.cc b/src/Screen.cc
index 0609cd4..626b296 100644
--- a/src/Screen.cc
+++ b/src/Screen.cc
@@ -75,6 +75,7 @@
75#include "FbTk/Transparent.hh" 75#include "FbTk/Transparent.hh"
76#include "FbTk/Select2nd.hh" 76#include "FbTk/Select2nd.hh"
77#include "FbTk/Compose.hh" 77#include "FbTk/Compose.hh"
78#include "FbTk/FbString.hh"
78 79
79//use GNU extensions 80//use GNU extensions
80#ifndef _GNU_SOURCE 81#ifndef _GNU_SOURCE
@@ -1459,7 +1460,7 @@ void BScreen::updateAvailableWorkspaceArea() {
1459} 1460}
1460 1461
1461void BScreen::addWorkspaceName(const char *name) { 1462void BScreen::addWorkspaceName(const char *name) {
1462 m_workspace_names.push_back(name); 1463 m_workspace_names.push_back(FbTk::FbStringUtil::LocaleStrToFb(name));
1463} 1464}
1464 1465
1465 1466
diff --git a/src/WinClient.cc b/src/WinClient.cc
index 056013a..891dc26 100644
--- a/src/WinClient.cc
+++ b/src/WinClient.cc
@@ -69,6 +69,8 @@ WinClient::WinClient(Window win, BScreen &screen, FluxboxWindow *fbwin):FbTk::Fb
69 m_win_gravity(0), 69 m_win_gravity(0),
70 m_title(""), m_icon_title(""), 70 m_title(""), m_icon_title(""),
71 m_class_name(""), m_instance_name(""), 71 m_class_name(""), m_instance_name(""),
72 m_title_override(false),
73 m_icon_title_override(false),
72 m_blackbox_hint(0), 74 m_blackbox_hint(0),
73 m_mwm_hint(0), 75 m_mwm_hint(0),
74 m_focus_mode(F_PASSIVE), 76 m_focus_mode(F_PASSIVE),
@@ -342,10 +344,26 @@ void WinClient::updateTitle() {
342 // also influenced 344 // also influenced
343 // 345 //
344 // the limitation to 512 chars only avoids running in that trap 346 // the limitation to 512 chars only avoids running in that trap
347 if (m_title_override)
348 return;
349
345 m_title = string(Xutil::getWMName(window()), 0, 512); 350 m_title = string(Xutil::getWMName(window()), 0, 512);
346} 351}
347 352
353void WinClient::setTitle(FbTk::FbString &title) {
354 m_title = title;
355 m_title_override = true;
356}
357
358void WinClient::setIconTitle(FbTk::FbString &icon_title) {
359 m_icon_title = icon_title;
360 m_icon_title_override = true;
361}
362
348void WinClient::updateIconTitle() { 363void WinClient::updateIconTitle() {
364 if (m_icon_title_override)
365 return;
366
349 XTextProperty text_prop; 367 XTextProperty text_prop;
350 char **list = 0; 368 char **list = 0;
351 int num = 0; 369 int num = 0;
diff --git a/src/WinClient.hh b/src/WinClient.hh
index aaaf111..870de6a 100644
--- a/src/WinClient.hh
+++ b/src/WinClient.hh
@@ -27,9 +27,9 @@
27#include "Window.hh" 27#include "Window.hh"
28#include "Subject.hh" 28#include "Subject.hh"
29#include "FbWindow.hh" 29#include "FbWindow.hh"
30#include "FbTk/FbString.hh"
30 31
31#include <X11/Xutil.h> 32#include <X11/Xutil.h>
32#include <string>
33 33
34class BScreen; 34class BScreen;
35class Strut; 35class Strut;
@@ -64,7 +64,9 @@ public:
64 void updateWMClassHint(); 64 void updateWMClassHint();
65 void updateWMProtocols(); 65 void updateWMProtocols();
66 66
67 67 // override the title with this
68 void setTitle(FbTk::FbString &title);
69 void setIconTitle(FbTk::FbString &icon_title);
68 void updateTitle(); 70 void updateTitle();
69 void updateIconTitle(); 71 void updateIconTitle();
70 /// updates transient window information 72 /// updates transient window information
@@ -198,6 +200,7 @@ private:
198 200
199 std::string m_title, m_icon_title; 201 std::string m_title, m_icon_title;
200 std::string m_class_name, m_instance_name; 202 std::string m_class_name, m_instance_name;
203 bool m_title_override, m_icon_title_override;
201 204
202 FbTk::FbPixmap m_icon_pixmap; 205 FbTk::FbPixmap m_icon_pixmap;
203 FbTk::FbPixmap m_icon_mask; 206 FbTk::FbPixmap m_icon_mask;
diff --git a/src/WinClientUtil.cc b/src/WinClientUtil.cc
index 112360d..a6460a2 100644
--- a/src/WinClientUtil.cc
+++ b/src/WinClientUtil.cc
@@ -9,8 +9,8 @@ void maxSize(const FluxboxWindow::ClientList &clients,
9 unsigned int &max_width, unsigned int &max_height) { 9 unsigned int &max_width, unsigned int &max_height) {
10 FluxboxWindow::ClientList::const_iterator it = clients.begin(); 10 FluxboxWindow::ClientList::const_iterator it = clients.begin();
11 FluxboxWindow::ClientList::const_iterator it_end = clients.end(); 11 FluxboxWindow::ClientList::const_iterator it_end = clients.end();
12 max_width = ~0; // unlimited 12 max_width = (unsigned int) ~0; // unlimited
13 max_height = ~0; // unlimited 13 max_height = (unsigned int) ~0; // unlimited
14 for (; it != it_end; ++it) { 14 for (; it != it_end; ++it) {
15 // special case for max height/width == 0 15 // special case for max height/width == 0
16 // 0 indicates unlimited size, so we skip them 16 // 0 indicates unlimited size, so we skip them
@@ -21,9 +21,9 @@ void maxSize(const FluxboxWindow::ClientList &clients,
21 max_width = std::min( (*it)->maxWidth(), max_width ); 21 max_width = std::min( (*it)->maxWidth(), max_width );
22 } 22 }
23 23
24 if (max_width == ~0) 24 if (max_width == (unsigned int) ~0)
25 max_width = 0; 25 max_width = 0;
26 if (max_height == ~0) 26 if (max_height == (unsigned int) ~0)
27 max_height = 0; 27 max_height = 0;
28} 28}
29 29
diff --git a/src/Workspace.cc b/src/Workspace.cc
index 343772a..c8650ca 100644
--- a/src/Workspace.cc
+++ b/src/Workspace.cc
@@ -38,6 +38,7 @@
38#include "FbTk/I18n.hh" 38#include "FbTk/I18n.hh"
39#include "FbTk/MenuItem.hh" 39#include "FbTk/MenuItem.hh"
40#include "FbTk/StringUtil.hh" 40#include "FbTk/StringUtil.hh"
41#include "FbTk/FbString.hh"
41 42
42// use GNU extensions 43// use GNU extensions
43#ifndef _GNU_SOURCE 44#ifndef _GNU_SOURCE
@@ -376,7 +377,7 @@ void Workspace::setName(const std::string &name) {
376 _FBTEXT(Workspace, DefaultNameFormat, 377 _FBTEXT(Workspace, DefaultNameFormat,
377 "Workspace %d", "Default workspace names, with a %d for the workspace number"), 378 "Workspace %d", "Default workspace names, with a %d for the workspace number"),
378 m_id + 1); //m_id starts at 0 379 m_id + 1); //m_id starts at 0
379 m_name = tname; 380 m_name = FbTk::FbStringUtil::LocaleStrToFb(tname);
380 } 381 }
381 382
382 screen().updateWorkspaceNamesAtom(); 383 screen().updateWorkspaceNamesAtom();
diff --git a/src/WorkspaceNameTool.cc b/src/WorkspaceNameTool.cc
index 99d6854..3f66298 100644
--- a/src/WorkspaceNameTool.cc
+++ b/src/WorkspaceNameTool.cc
@@ -90,7 +90,7 @@ unsigned int WorkspaceNameTool::width() const {
90 BScreen::Workspaces::const_iterator it; 90 BScreen::Workspaces::const_iterator it;
91 for (it = workspaces.begin(); it != workspaces.end(); it++) { 91 for (it = workspaces.begin(); it != workspaces.end(); it++) {
92 const std::string &name = (*it)->name(); 92 const std::string &name = (*it)->name();
93 max_size = std::max(m_theme.font().textWidth(name.c_str(), name.size()), 93 max_size = std::max(m_theme.font().textWidth(name, name.size()),
94 max_size); 94 max_size);
95 } 95 }
96 // so align text dont cut the last character 96 // so align text dont cut the last character
@@ -108,7 +108,7 @@ unsigned int WorkspaceNameTool::height() const {
108 BScreen::Workspaces::const_iterator it; 108 BScreen::Workspaces::const_iterator it;
109 for (it = workspaces.begin(); it != workspaces.end(); it++) { 109 for (it = workspaces.begin(); it != workspaces.end(); it++) {
110 const std::string &name = (*it)->name(); 110 const std::string &name = (*it)->name();
111 max_size = std::max(m_theme.font().textWidth(name.c_str(), name.size()), 111 max_size = std::max(m_theme.font().textWidth(name, name.size()),
112 max_size); 112 max_size);
113 } 113 }
114 // so align text dont cut the last character 114 // so align text dont cut the last character
diff --git a/src/fluxbox.cc b/src/fluxbox.cc
index 48b67bf..fd50392 100644
--- a/src/fluxbox.cc
+++ b/src/fluxbox.cc
@@ -1479,7 +1479,7 @@ void Fluxbox::save_rc() {
1479 1479
1480 for (unsigned int workspace=0; workspace < screen->numberOfWorkspaces(); workspace++) { 1480 for (unsigned int workspace=0; workspace < screen->numberOfWorkspaces(); workspace++) {
1481 if (screen->getWorkspace(workspace)->name().size()!=0) 1481 if (screen->getWorkspace(workspace)->name().size()!=0)
1482 workspaces_string.append(screen->getWorkspace(workspace)->name()); 1482 workspaces_string.append(FbTk::FbStringUtil::FbStrToLocale(screen->getWorkspace(workspace)->name()));
1483 else 1483 else
1484 workspaces_string.append("Null"); 1484 workspaces_string.append("Null");
1485 workspaces_string.append(","); 1485 workspaces_string.append(",");