aboutsummaryrefslogtreecommitdiff
path: root/src/Ewmh.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/Ewmh.cc')
-rw-r--r--src/Ewmh.cc20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/Ewmh.cc b/src/Ewmh.cc
index 03a824f..e12a792 100644
--- a/src/Ewmh.cc
+++ b/src/Ewmh.cc
@@ -821,32 +821,38 @@ void Ewmh::updateWorkspaceNames(BScreen &screen) {
821 const BScreen::WorkspaceNames &workspacenames = screen.getWorkspaceNames(); 821 const BScreen::WorkspaceNames &workspacenames = screen.getWorkspaceNames();
822 const size_t number_of_desks = workspacenames.size(); 822 const size_t number_of_desks = workspacenames.size();
823 823
824 const char** names = new const char*[number_of_desks]; 824 /* the SPEC states "NULL-terminated strings". This implies, that also the
825 * last element actually gets proper NULL-termination after being treated
826 * by Xutf8TextListToTextProperty. Xutf8TextListToTextProperty removes
827 * the NULL from the last name and thus it is missing when reading the
828 * _NET_DESKTOP_NAMES property. This might confuse other WMs, pagers etc.
829 * thus, an artifical "empty" name is added at the end of the regular
830 * names list which is then properly encoded by Xutf8TextListToTextProperty
831 * and everyone is happy
832 */
833 const char* names[number_of_desks+1];
825 834
826 for (size_t i = 0; i < number_of_desks; i++) { 835 for (size_t i = 0; i < number_of_desks; i++) {
827 names[i] = workspacenames[i].c_str(); 836 names[i] = workspacenames[i].c_str();
828 } 837 }
838 names[number_of_desks] = NULL;
829 839
830#ifdef X_HAVE_UTF8_STRING 840#ifdef X_HAVE_UTF8_STRING
831 int code = Xutf8TextListToTextProperty(FbTk::App::instance()->display(), 841 int code = Xutf8TextListToTextProperty(FbTk::App::instance()->display(),
832 const_cast<char**>(names), number_of_desks, XUTF8StringStyle, &text); 842 const_cast<char**>(names), number_of_desks+1, XUTF8StringStyle, &text);
833 if (code != XNoMemory && code != XLocaleNotSupported) { 843 if (code != XNoMemory && code != XLocaleNotSupported) {
834 XSetTextProperty(FbTk::App::instance()->display(), 844 XSetTextProperty(FbTk::App::instance()->display(),
835 screen.rootWindow().window(), 845 screen.rootWindow().window(),
836 &text, m_net->desktop_names); 846 &text, m_net->desktop_names);
837
838 XFree(text.value); 847 XFree(text.value);
839 } 848 }
840
841#else 849#else
842 if (XStringListToTextProperty(names, number_of_desks, &text)) { 850 if (XStringListToTextProperty(names, number_of_desks+1, &text)) {
843 XSetTextProperty(FbTk::App::instance()->display(), screen.rootWindow().window(), 851 XSetTextProperty(FbTk::App::instance()->display(), screen.rootWindow().window(),
844 &text, m_net->desktop_names); 852 &text, m_net->desktop_names);
845 XFree(text.value); 853 XFree(text.value);
846 } 854 }
847#endif 855#endif
848
849 delete[] names;
850} 856}
851 857
852void Ewmh::updateCurrentWorkspace(BScreen &screen) { 858void Ewmh::updateCurrentWorkspace(BScreen &screen) {