summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2003-06-22 12:35:03 (GMT)
committerfluxgen <fluxgen>2003-06-22 12:35:03 (GMT)
commit95193fd598968fc0ad5ea113410c6fd6e6042629 (patch)
treeef56dc5e04fe0cced90bf4d7fec29cb0ec149d51 /src
parent01a3274e357279c3644b39a5838e48690f7c8746 (diff)
downloadfluxbox_lack-95193fd598968fc0ad5ea113410c6fd6e6042629.zip
fluxbox_lack-95193fd598968fc0ad5ea113410c6fd6e6042629.tar.bz2
moved getWMName to Xutil
Diffstat (limited to 'src')
-rw-r--r--src/SlitClient.cc53
-rw-r--r--src/WinClient.cc44
2 files changed, 10 insertions, 87 deletions
diff --git a/src/SlitClient.cc b/src/SlitClient.cc
index 74a10a4..fe2567f 100644
--- a/src/SlitClient.cc
+++ b/src/SlitClient.cc
@@ -19,64 +19,17 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22// $Id: SlitClient.cc,v 1.1 2003/06/20 01:25:26 fluxgen Exp $ 22// $Id: SlitClient.cc,v 1.2 2003/06/22 12:30:59 fluxgen Exp $
23 23
24#include "SlitClient.hh" 24#include "SlitClient.hh"
25 25
26#include "I18n.hh"
27#include "Screen.hh" 26#include "Screen.hh"
28#include "App.hh" 27#include "App.hh"
28#include "Xutil.hh"
29 29
30#include <X11/Xutil.h> 30#include <X11/Xutil.h>
31#include <X11/Xatom.h> 31#include <X11/Xatom.h>
32 32
33namespace {
34
35void getWMName(BScreen *screen, Window window, std::string& name) {
36 name = "";
37
38 if (screen == 0 || window == None)
39 return;
40
41 Display *display = FbTk::App::instance()->display();
42
43 XTextProperty text_prop;
44 char **list;
45 int num;
46 I18n *i18n = I18n::instance();
47
48 if (XGetWMName(display, window, &text_prop)) {
49 if (text_prop.value && text_prop.nitems > 0) {
50 if (text_prop.encoding != XA_STRING) {
51
52 text_prop.nitems = strlen((char *) text_prop.value);
53
54 if ((XmbTextPropertyToTextList(display, &text_prop,
55 &list, &num) == Success) &&
56 (num > 0) && *list) {
57 name = static_cast<char *>(*list);
58 XFreeStringList(list);
59 } else
60 name = (char *)text_prop.value;
61
62 } else
63 name = (char *)text_prop.value;
64 } else { // default name
65 name = i18n->getMessage(
66 FBNLS::WindowSet, FBNLS::WindowUnnamed,
67 "Unnamed");
68 }
69 } else {
70 // default name
71 name = i18n->getMessage(
72 FBNLS::WindowSet, FBNLS::WindowUnnamed,
73 "Unnamed");
74 }
75
76}
77
78}; // end anonymous namespace
79
80SlitClient::SlitClient(BScreen *screen, Window win) { 33SlitClient::SlitClient(BScreen *screen, Window win) {
81 initialize(screen, win); 34 initialize(screen, win);
82} 35}
@@ -100,7 +53,7 @@ void SlitClient::initialize(BScreen *screen, Window win) {
100 resize(0, 0); 53 resize(0, 0);
101 54
102 if (matchName().empty()) 55 if (matchName().empty())
103 getWMName(screen, clientWindow(), m_match_name); 56 m_match_name = Xutil::getWMName(clientWindow());
104 m_visible = true; 57 m_visible = true;
105} 58}
106 59
diff --git a/src/WinClient.cc b/src/WinClient.cc
index ea29bc2..88be980 100644
--- a/src/WinClient.cc
+++ b/src/WinClient.cc
@@ -19,7 +19,7 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22// $Id: WinClient.cc,v 1.12 2003/06/15 18:36:16 fluxgen Exp $ 22// $Id: WinClient.cc,v 1.13 2003/06/22 12:35:03 fluxgen Exp $
23 23
24#include "WinClient.hh" 24#include "WinClient.hh"
25 25
@@ -29,6 +29,7 @@
29#include "I18n.hh" 29#include "I18n.hh"
30#include "FbAtoms.hh" 30#include "FbAtoms.hh"
31#include "EventManager.hh" 31#include "EventManager.hh"
32#include "Xutil.hh"
32 33
33#include <iostream> 34#include <iostream>
34#include <algorithm> 35#include <algorithm>
@@ -256,39 +257,7 @@ void WinClient::updateTransientInfo() {
256 257
257 258
258void WinClient::updateTitle() { 259void WinClient::updateTitle() {
259 XTextProperty text_prop; 260 m_title = Xutil::getWMName(window());
260 char **list = 0;
261 int num = 0;
262 I18n *i18n = I18n::instance();
263
264 if (getWMName(text_prop)) {
265 if (text_prop.value && text_prop.nitems > 0) {
266 if (text_prop.encoding != XA_STRING) {
267
268 text_prop.nitems = strlen((char *) text_prop.value);
269
270 if (XmbTextPropertyToTextList(FbTk::App::instance()->display(), &text_prop,
271 &list, &num) == Success &&
272 num > 0 && *list) {
273 m_title = static_cast<char *>(*list);
274 XFreeStringList(list);
275 } else
276 m_title = (char *)text_prop.value;
277
278 } else
279 m_title = (char *)text_prop.value;
280 XFree((char *) text_prop.value);
281 } else { // ok, we don't have a name, set default name
282 m_title = i18n->getMessage(
283 FBNLS::WindowSet, FBNLS::WindowUnnamed,
284 "Unnamed");
285 }
286 } else {
287 m_title = i18n->getMessage(
288 FBNLS::WindowSet, FBNLS::WindowUnnamed,
289 "Unnamed");
290 }
291
292} 261}
293 262
294void WinClient::updateIconTitle() { 263void WinClient::updateIconTitle() {
@@ -307,11 +276,12 @@ void WinClient::updateIconTitle() {
307 m_icon_title = (char *)*list; 276 m_icon_title = (char *)*list;
308 XFreeStringList(list); 277 XFreeStringList(list);
309 } else 278 } else
310 m_icon_title = (char *)text_prop.value; 279 m_icon_title = text_prop.value ? (char *)text_prop.value : "";
311 } else 280 } else
312 m_icon_title = (char *)text_prop.value; 281 m_icon_title = text_prop.value ? (char *)text_prop.value : "";
313 282
314 XFree((char *) text_prop.value); 283 if (text_prop.value)
284 XFree((char *) text_prop.value);
315 } else 285 } else
316 m_icon_title = title(); 286 m_icon_title = title();
317 } else 287 } else