aboutsummaryrefslogtreecommitdiff
path: root/src/Xutil.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/Xutil.cc')
-rw-r--r--src/Xutil.cc56
1 files changed, 55 insertions, 1 deletions
diff --git a/src/Xutil.cc b/src/Xutil.cc
index a5a6c59..e36080a 100644
--- a/src/Xutil.cc
+++ b/src/Xutil.cc
@@ -20,7 +20,7 @@
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21// DEALINGS IN THE SOFTWARE. 21// DEALINGS IN THE SOFTWARE.
22 22
23// $Id: Xutil.cc,v 1.3 2004/01/11 16:04:39 fluxgen Exp $ 23// $Id: Xutil.cc,v 1.4 2004/01/30 11:06:25 rathnor Exp $
24 24
25#include "Xutil.hh" 25#include "Xutil.hh"
26 26
@@ -30,6 +30,8 @@
30#include <X11/Xutil.h> 30#include <X11/Xutil.h>
31#include <X11/Xatom.h> 31#include <X11/Xatom.h>
32#include <X11/Xlib.h> 32#include <X11/Xlib.h>
33#include <iostream>
34using namespace std;
33 35
34namespace Xutil { 36namespace Xutil {
35 37
@@ -79,5 +81,57 @@ std::string getWMName(Window window) {
79 return name; 81 return name;
80} 82}
81 83
84
85// The name of this particular instance
86std::string getWMClassName(Window win) {
87 XClassHint ch;
88 std::string instance_name;
89
90 if (XGetClassHint(FbTk::App::instance()->display(), win, &ch) == 0) {
91#ifdef DEBUG
92 cerr<<"Xutil: Failed to read class hint!"<<endl;
93#endif //DEBUG
94 instance_name = "";
95 } else {
96
97 XFree(ch.res_class);
98
99 if (ch.res_class != 0) {
100 instance_name = const_cast<char *>(ch.res_name);
101 XFree(ch.res_name);
102 ch.res_name = 0;
103 } else
104 instance_name = "";
105 }
106
107 return instance_name;
108
109}
110
111// the name of the general class of the app
112std::string getWMClassClass(Window win) {
113 XClassHint ch;
114 std::string class_name;
115
116 if (XGetClassHint(FbTk::App::instance()->display(), win, &ch) == 0) {
117#ifdef DEBUG
118 cerr<<"Xutil: Failed to read class hint!"<<endl;
119#endif //DEBUG
120 class_name = "";
121 } else {
122
123 XFree(ch.res_name);
124
125 if (ch.res_class != 0) {
126 class_name = const_cast<char *>(ch.res_class);
127 XFree(ch.res_class);
128 ch.res_class = 0;
129 } else
130 class_name = "";
131 }
132
133 return class_name;
134}
135
82}; // end namespace Xutil 136}; // end namespace Xutil
83 137