slitlist fixing up
This commit is contained in:
parent
bfcf8c4205
commit
8b5f039f10
4 changed files with 87 additions and 11 deletions
|
@ -1,5 +1,10 @@
|
||||||
(Format: Year/Month/Day)
|
(Format: Year/Month/Day)
|
||||||
Changes for 0.9.9:
|
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:
|
*04/01/23:
|
||||||
* Fix a few window frame issues when changing styles (Simon)
|
* Fix a few window frame issues when changing styles (Simon)
|
||||||
- particularly a "void" area of the window
|
- particularly a "void" area of the window
|
||||||
|
|
31
src/Slit.cc
31
src/Slit.cc
|
@ -22,7 +22,7 @@
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
// DEALINGS IN THE SOFTWARE.
|
// 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"
|
#include "Slit.hh"
|
||||||
|
|
||||||
|
@ -57,6 +57,7 @@
|
||||||
#include "SlitClient.hh"
|
#include "SlitClient.hh"
|
||||||
#include "Xutil.hh"
|
#include "Xutil.hh"
|
||||||
#include "FbAtoms.hh"
|
#include "FbAtoms.hh"
|
||||||
|
#include "FbTk/StringUtil.hh"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
@ -415,7 +416,7 @@ void Slit::addClient(Window w) {
|
||||||
// Look for slot in client list by name
|
// Look for slot in client list by name
|
||||||
SlitClient *client = 0;
|
SlitClient *client = 0;
|
||||||
std::string match_name;
|
std::string match_name;
|
||||||
match_name = Xutil::getWMName(w);
|
match_name = Xutil::getWMClassName(w);
|
||||||
SlitClients::iterator it = m_client_list.begin();
|
SlitClients::iterator it = m_client_list.begin();
|
||||||
SlitClients::iterator it_end = m_client_list.end();
|
SlitClients::iterator it_end = m_client_list.end();
|
||||||
bool found_match = false;
|
bool found_match = false;
|
||||||
|
@ -1123,22 +1124,34 @@ void Slit::toggleHidden() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Slit::loadClientList(const char *filename) {
|
void Slit::loadClientList(const char *filename) {
|
||||||
if (filename == 0)
|
if (filename == 0 || filename[0] == '\0')
|
||||||
return;
|
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;
|
struct stat buf;
|
||||||
if (!stat(filename, &buf)) {
|
if (stat(filename, &buf) != 0) {
|
||||||
std::ifstream file(filename);
|
std::ifstream file(filename);
|
||||||
std::string name;
|
std::string name;
|
||||||
while (! file.eof()) {
|
while (! file.eof()) {
|
||||||
name = "";
|
name = "";
|
||||||
std::getline(file, name); // get the entire line
|
std::getline(file, name); // get the entire line
|
||||||
if (name.size() > 0) { // don't add client unless we have a valid line
|
if (name.size() <= 0)
|
||||||
SlitClient *client = new SlitClient(name.c_str());
|
continue;
|
||||||
m_client_list.push_back(client);
|
|
||||||
}
|
// 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
56
src/Xutil.cc
56
src/Xutil.cc
|
@ -20,7 +20,7 @@
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
// DEALINGS IN THE SOFTWARE.
|
// 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"
|
#include "Xutil.hh"
|
||||||
|
|
||||||
|
@ -30,6 +30,8 @@
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
#include <X11/Xatom.h>
|
#include <X11/Xatom.h>
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
|
#include <iostream>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
namespace Xutil {
|
namespace Xutil {
|
||||||
|
|
||||||
|
@ -79,5 +81,57 @@ std::string getWMName(Window window) {
|
||||||
return name;
|
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
|
}; // end namespace Xutil
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
// DEALINGS IN THE SOFTWARE.
|
// 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
|
#ifndef XUTIL_HH
|
||||||
#define XUTIL_HH
|
#define XUTIL_HH
|
||||||
|
@ -33,6 +33,10 @@ namespace Xutil {
|
||||||
|
|
||||||
std::string getWMName(Window window);
|
std::string getWMName(Window window);
|
||||||
|
|
||||||
|
std::string getWMClassName(Window win);
|
||||||
|
std::string getWMClassClass(Window win);
|
||||||
|
|
||||||
|
|
||||||
}; // end namespace Xutil
|
}; // end namespace Xutil
|
||||||
|
|
||||||
#endif // XUTIL_HH
|
#endif // XUTIL_HH
|
||||||
|
|
Loading…
Reference in a new issue