summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrathnor <rathnor>2004-01-30 11:06:25 (GMT)
committerrathnor <rathnor>2004-01-30 11:06:25 (GMT)
commit8b5f039f10e51f972dbed0a4d75fc569bde4b9a8 (patch)
tree6807bde3faf8c4508c8050d5eab4a6c9665cc253 /src
parentbfcf8c42056dbdb5f0e38cf97c653ea6c62e8cda (diff)
downloadfluxbox_lack-8b5f039f10e51f972dbed0a4d75fc569bde4b9a8.zip
fluxbox_lack-8b5f039f10e51f972dbed0a4d75fc569bde4b9a8.tar.bz2
slitlist fixing up
Diffstat (limited to 'src')
-rw-r--r--src/Slit.cc31
-rw-r--r--src/Xutil.cc56
-rw-r--r--src/Xutil.hh6
3 files changed, 82 insertions, 11 deletions
diff --git a/src/Slit.cc b/src/Slit.cc
index 5d596ef..2c2574e 100644
--- a/src/Slit.cc
+++ b/src/Slit.cc
@@ -22,7 +22,7 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: Slit.cc,v 1.87 2004/01/10 02:58:21 fluxgen Exp $ 25// $Id: Slit.cc,v 1.88 2004/01/30 11:06:25 rathnor Exp $
26 26
27#include "Slit.hh" 27#include "Slit.hh"
28 28
@@ -57,6 +57,7 @@
57#include "SlitClient.hh" 57#include "SlitClient.hh"
58#include "Xutil.hh" 58#include "Xutil.hh"
59#include "FbAtoms.hh" 59#include "FbAtoms.hh"
60#include "FbTk/StringUtil.hh"
60 61
61#include <algorithm> 62#include <algorithm>
62#include <iostream> 63#include <iostream>
@@ -415,7 +416,7 @@ void Slit::addClient(Window w) {
415 // Look for slot in client list by name 416 // Look for slot in client list by name
416 SlitClient *client = 0; 417 SlitClient *client = 0;
417 std::string match_name; 418 std::string match_name;
418 match_name = Xutil::getWMName(w); 419 match_name = Xutil::getWMClassName(w);
419 SlitClients::iterator it = m_client_list.begin(); 420 SlitClients::iterator it = m_client_list.begin();
420 SlitClients::iterator it_end = m_client_list.end(); 421 SlitClients::iterator it_end = m_client_list.end();
421 bool found_match = false; 422 bool found_match = false;
@@ -1123,22 +1124,34 @@ void Slit::toggleHidden() {
1123} 1124}
1124 1125
1125void Slit::loadClientList(const char *filename) { 1126void Slit::loadClientList(const char *filename) {
1126 if (filename == 0) 1127 if (filename == 0 || filename[0] == '\0')
1127 return; 1128 return;
1128 1129
1129 m_filename = filename; // save filename so we can save client list later 1130 // save filename so we can save client list later
1131 m_filename = FbTk::StringUtil::expandFilename(filename);
1130 1132
1131 struct stat buf; 1133 struct stat buf;
1132 if (!stat(filename, &buf)) { 1134 if (stat(filename, &buf) != 0) {
1133 std::ifstream file(filename); 1135 std::ifstream file(filename);
1134 std::string name; 1136 std::string name;
1135 while (! file.eof()) { 1137 while (! file.eof()) {
1136 name = ""; 1138 name = "";
1137 std::getline(file, name); // get the entire line 1139 std::getline(file, name); // get the entire line
1138 if (name.size() > 0) { // don't add client unless we have a valid line 1140 if (name.size() <= 0)
1139 SlitClient *client = new SlitClient(name.c_str()); 1141 continue;
1140 m_client_list.push_back(client); 1142
1141 } 1143 // remove whitespaces from start and end
1144 FbTk::StringUtil::removeFirstWhitespace(name);
1145
1146 // the cleaned string could still be a comment, or blank
1147 if ( name.size() <= 0 || name[0] == '#' || name[0] == '!' )
1148 continue;
1149
1150 // trailing whitespace won't affect the above test
1151 FbTk::StringUtil::removeTrailingWhitespace(name);
1152
1153 SlitClient *client = new SlitClient(name.c_str());
1154 m_client_list.push_back(client);
1142 } 1155 }
1143 } 1156 }
1144} 1157}
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
diff --git a/src/Xutil.hh b/src/Xutil.hh
index cbb7f78..43796db 100644
--- a/src/Xutil.hh
+++ b/src/Xutil.hh
@@ -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.hh,v 1.2 2004/01/11 16:04:39 fluxgen Exp $ 23// $Id: Xutil.hh,v 1.3 2004/01/30 11:06:25 rathnor Exp $
24 24
25#ifndef XUTIL_HH 25#ifndef XUTIL_HH
26#define XUTIL_HH 26#define XUTIL_HH
@@ -33,6 +33,10 @@ namespace Xutil {
33 33
34std::string getWMName(Window window); 34std::string getWMName(Window window);
35 35
36std::string getWMClassName(Window win);
37std::string getWMClassClass(Window win);
38
39
36}; // end namespace Xutil 40}; // end namespace Xutil
37 41
38#endif // XUTIL_HH 42#endif // XUTIL_HH