all repos — fluxbox @ 8b5f039f10e51f972dbed0a4d75fc569bde4b9a8

custom fork of the fluxbox windowmanager

slitlist fixing up
rathnor rathnor
commit

8b5f039f10e51f972dbed0a4d75fc569bde4b9a8

parent

bfcf8c42056dbdb5f0e38cf97c653ea6c62e8cda

4 files changed, 87 insertions(+), 11 deletions(-)

jump to
M ChangeLogChangeLog

@@ -1,5 +1,10 @@

(Format: Year/Month/Day) Changes for 0.9.9: +*04/01/30: + * Tidy up a few slitlist things (Simon) + - expand ~, trim spaces, allow comments, use WM_CLASS instead of NAME + - should make it use regexp like remember sometime + Slit.cc Xutil.hh/cc *04/01/23: * Fix a few window frame issues when changing styles (Simon) - particularly a "void" area of the window
M src/Slit.ccsrc/Slit.cc

@@ -22,7 +22,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Slit.cc,v 1.87 2004/01/10 02:58:21 fluxgen Exp $ +// $Id: Slit.cc,v 1.88 2004/01/30 11:06:25 rathnor Exp $ #include "Slit.hh"

@@ -57,6 +57,7 @@ #include "SlitTheme.hh"

#include "SlitClient.hh" #include "Xutil.hh" #include "FbAtoms.hh" +#include "FbTk/StringUtil.hh" #include <algorithm> #include <iostream>

@@ -415,7 +416,7 @@

// Look for slot in client list by name SlitClient *client = 0; std::string match_name; - match_name = Xutil::getWMName(w); + match_name = Xutil::getWMClassName(w); SlitClients::iterator it = m_client_list.begin(); SlitClients::iterator it_end = m_client_list.end(); bool found_match = false;

@@ -1123,22 +1124,34 @@ frame.window.move(frame.x, frame.y);

} void Slit::loadClientList(const char *filename) { - if (filename == 0) + if (filename == 0 || filename[0] == '\0') return; - m_filename = filename; // save filename so we can save client list later + // save filename so we can save client list later + m_filename = FbTk::StringUtil::expandFilename(filename); struct stat buf; - if (!stat(filename, &buf)) { + if (stat(filename, &buf) != 0) { std::ifstream file(filename); std::string name; while (! file.eof()) { name = ""; std::getline(file, name); // get the entire line - if (name.size() > 0) { // don't add client unless we have a valid line - SlitClient *client = new SlitClient(name.c_str()); - m_client_list.push_back(client); - } + if (name.size() <= 0) + continue; + + // remove whitespaces from start and end + FbTk::StringUtil::removeFirstWhitespace(name); + + // the cleaned string could still be a comment, or blank + if ( name.size() <= 0 || name[0] == '#' || name[0] == '!' ) + continue; + + // trailing whitespace won't affect the above test + FbTk::StringUtil::removeTrailingWhitespace(name); + + SlitClient *client = new SlitClient(name.c_str()); + m_client_list.push_back(client); } } }
M src/Xutil.ccsrc/Xutil.cc

@@ -20,7 +20,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Xutil.cc,v 1.3 2004/01/11 16:04:39 fluxgen Exp $ +// $Id: Xutil.cc,v 1.4 2004/01/30 11:06:25 rathnor Exp $ #include "Xutil.hh"

@@ -30,6 +30,8 @@

#include <X11/Xutil.h> #include <X11/Xatom.h> #include <X11/Xlib.h> +#include <iostream> +using namespace std; namespace Xutil {

@@ -77,6 +79,58 @@ "Unnamed");

} return name; +} + + +// The name of this particular instance +std::string getWMClassName(Window win) { + XClassHint ch; + std::string instance_name; + + if (XGetClassHint(FbTk::App::instance()->display(), win, &ch) == 0) { +#ifdef DEBUG + cerr<<"Xutil: Failed to read class hint!"<<endl; +#endif //DEBUG + instance_name = ""; + } else { + + XFree(ch.res_class); + + if (ch.res_class != 0) { + instance_name = const_cast<char *>(ch.res_name); + XFree(ch.res_name); + ch.res_name = 0; + } else + instance_name = ""; + } + + return instance_name; + +} + +// the name of the general class of the app +std::string getWMClassClass(Window win) { + XClassHint ch; + std::string class_name; + + if (XGetClassHint(FbTk::App::instance()->display(), win, &ch) == 0) { +#ifdef DEBUG + cerr<<"Xutil: Failed to read class hint!"<<endl; +#endif //DEBUG + class_name = ""; + } else { + + XFree(ch.res_name); + + if (ch.res_class != 0) { + class_name = const_cast<char *>(ch.res_class); + XFree(ch.res_class); + ch.res_class = 0; + } else + class_name = ""; + } + + return class_name; } }; // end namespace Xutil
M src/Xutil.hhsrc/Xutil.hh

@@ -20,7 +20,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Xutil.hh,v 1.2 2004/01/11 16:04:39 fluxgen Exp $ +// $Id: Xutil.hh,v 1.3 2004/01/30 11:06:25 rathnor Exp $ #ifndef XUTIL_HH #define XUTIL_HH

@@ -32,6 +32,10 @@

namespace Xutil { std::string getWMName(Window window); + +std::string getWMClassName(Window win); +std::string getWMClassClass(Window win); + }; // end namespace Xutil