summaryrefslogtreecommitdiff
path: root/src/Xutil.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/Xutil.cc')
-rw-r--r--src/Xutil.cc32
1 files changed, 19 insertions, 13 deletions
diff --git a/src/Xutil.cc b/src/Xutil.cc
index 87f5253..c138142 100644
--- a/src/Xutil.cc
+++ b/src/Xutil.cc
@@ -32,7 +32,13 @@
32#include <X11/Xatom.h> 32#include <X11/Xatom.h>
33#include <X11/Xlib.h> 33#include <X11/Xlib.h>
34#include <iostream> 34#include <iostream>
35using namespace std; 35
36using std::string;
37
38#ifdef DEBUG
39using std::cerr;
40using std::endl;
41#endif // DEBUG
36 42
37namespace Xutil { 43namespace Xutil {
38 44
@@ -48,14 +54,14 @@ FbTk::FbString getWMName(Window window) {
48 char **list; 54 char **list;
49 int num; 55 int num;
50 _FB_USES_NLS; 56 _FB_USES_NLS;
51 std::string name; 57 string name;
52 58
53 if (XGetWMName(display, window, &text_prop)) { 59 if (XGetWMName(display, window, &text_prop)) {
54 if (text_prop.value && text_prop.nitems > 0) { 60 if (text_prop.value && text_prop.nitems > 0) {
55 if (text_prop.encoding != XA_STRING) { 61 if (text_prop.encoding != XA_STRING) {
56 62
57 text_prop.nitems = strlen((char *) text_prop.value); 63 text_prop.nitems = strlen((char *) text_prop.value);
58 64
59 if ((XmbTextPropertyToTextList(display, &text_prop, 65 if ((XmbTextPropertyToTextList(display, &text_prop,
60 &list, &num) == Success) && 66 &list, &num) == Success) &&
61 (num > 0) && *list) { 67 (num > 0) && *list) {
@@ -63,7 +69,7 @@ FbTk::FbString getWMName(Window window) {
63 XFreeStringList(list); 69 XFreeStringList(list);
64 } else 70 } else
65 name = text_prop.value ? FbTk::FbStringUtil::XStrToFb((char *)text_prop.value) : ""; 71 name = text_prop.value ? FbTk::FbStringUtil::XStrToFb((char *)text_prop.value) : "";
66 72
67 } else 73 } else
68 name = text_prop.value ? FbTk::FbStringUtil::XStrToFb((char *)text_prop.value) : ""; 74 name = text_prop.value ? FbTk::FbStringUtil::XStrToFb((char *)text_prop.value) : "";
69 75
@@ -82,19 +88,19 @@ FbTk::FbString getWMName(Window window) {
82 88
83 89
84// The name of this particular instance 90// The name of this particular instance
85std::string getWMClassName(Window win) { 91string getWMClassName(Window win) {
86 XClassHint ch; 92 XClassHint ch;
87 std::string instance_name; 93 string instance_name;
88 94
89 if (XGetClassHint(FbTk::App::instance()->display(), win, &ch) == 0) { 95 if (XGetClassHint(FbTk::App::instance()->display(), win, &ch) == 0) {
90#ifdef DEBUG 96#ifdef DEBUG
91 cerr<<"Xutil: Failed to read class hint!"<<endl; 97 cerr<<"Xutil: Failed to read class hint!"<<endl;
92#endif //DEBUG 98#endif //DEBUG
93 instance_name = ""; 99 instance_name = "";
94 } else { 100 } else {
95 101
96 XFree(ch.res_class); 102 XFree(ch.res_class);
97 103
98 if (ch.res_class != 0) { 104 if (ch.res_class != 0) {
99 instance_name = const_cast<char *>(ch.res_name); 105 instance_name = const_cast<char *>(ch.res_name);
100 XFree(ch.res_name); 106 XFree(ch.res_name);
@@ -108,19 +114,19 @@ std::string getWMClassName(Window win) {
108} 114}
109 115
110// the name of the general class of the app 116// the name of the general class of the app
111std::string getWMClassClass(Window win) { 117string getWMClassClass(Window win) {
112 XClassHint ch; 118 XClassHint ch;
113 std::string class_name; 119 string class_name;
114 120
115 if (XGetClassHint(FbTk::App::instance()->display(), win, &ch) == 0) { 121 if (XGetClassHint(FbTk::App::instance()->display(), win, &ch) == 0) {
116#ifdef DEBUG 122#ifdef DEBUG
117 cerr<<"Xutil: Failed to read class hint!"<<endl; 123 cerr<<"Xutil: Failed to read class hint!"<<endl;
118#endif //DEBUG 124#endif //DEBUG
119 class_name = ""; 125 class_name = "";
120 } else { 126 } else {
121 127
122 XFree(ch.res_name); 128 XFree(ch.res_name);
123 129
124 if (ch.res_class != 0) { 130 if (ch.res_class != 0) {
125 class_name = const_cast<char *>(ch.res_class); 131 class_name = const_cast<char *>(ch.res_class);
126 XFree(ch.res_class); 132 XFree(ch.res_class);