aboutsummaryrefslogtreecommitdiff
path: root/src/ClientPattern.cc
diff options
context:
space:
mode:
authormarkt <markt>2007-10-24 17:09:26 (GMT)
committermarkt <markt>2007-10-24 17:09:26 (GMT)
commitf3afe787c1209cf1357493924a4f7eb7864def54 (patch)
treed0c0c3eca154ab538fbc1fb3c62081e9250c05bd /src/ClientPattern.cc
parent74eb584a312aba21b21eccb6c49ade1571aa3740 (diff)
downloadfluxbox_pavel-f3afe787c1209cf1357493924a4f7eb7864def54.zip
fluxbox_pavel-f3afe787c1209cf1357493924a4f7eb7864def54.tar.bz2
introduced workspacename for ClientPattern, and some miscellaneous cleanup
Diffstat (limited to 'src/ClientPattern.cc')
-rw-r--r--src/ClientPattern.cc35
1 files changed, 19 insertions, 16 deletions
diff --git a/src/ClientPattern.cc b/src/ClientPattern.cc
index f8238dd..9ee1848 100644
--- a/src/ClientPattern.cc
+++ b/src/ClientPattern.cc
@@ -129,6 +129,8 @@ ClientPattern::ClientPattern(const char *str, bool default_no_transient):
129 prop = ICONHIDDEN; 129 prop = ICONHIDDEN;
130 } else if (strcasecmp(memstr.c_str(), "workspace") == 0) { 130 } else if (strcasecmp(memstr.c_str(), "workspace") == 0) {
131 prop = WORKSPACE; 131 prop = WORKSPACE;
132 } else if (strcasecmp(memstr.c_str(), "workspacename") == 0) {
133 prop = WORKSPACENAME;
132 } else if (strcasecmp(memstr.c_str(), "head") == 0) { 134 } else if (strcasecmp(memstr.c_str(), "head") == 0) {
133 prop = HEAD; 135 prop = HEAD;
134 } else if (strcasecmp(memstr.c_str(), "layer") == 0) { 136 } else if (strcasecmp(memstr.c_str(), "layer") == 0) {
@@ -236,6 +238,9 @@ string ClientPattern::toString() const {
236 case WORKSPACE: 238 case WORKSPACE:
237 pat.append("workspace="); 239 pat.append("workspace=");
238 break; 240 break;
241 case WORKSPACENAME:
242 pat.append("workspacename=");
243 break;
239 case HEAD: 244 case HEAD:
240 pat.append("head="); 245 pat.append("head=");
241 break; 246 break;
@@ -268,20 +273,11 @@ bool ClientPattern::match(const Focusable &win) const {
268 Terms::const_iterator it_end = m_terms.end(); 273 Terms::const_iterator it_end = m_terms.end();
269 for (; it != it_end; ++it) { 274 for (; it != it_end; ++it) {
270 if ((*it)->orig == "[current]") { 275 if ((*it)->orig == "[current]") {
271 // workspaces don't necessarily have unique names, so we want to 276 WinClient *focused = FocusControl::focusedWindow();
272 // compare numbers instead of strings 277 if (!focused || !((*it)->negate ^
273 if ((*it)->prop == WORKSPACE && (!win.fbwindow() || 278 (getProperty((*it)->prop, win) ==
274 !((*it)->negate ^ 279 getProperty((*it)->prop, *focused))))
275 (win.fbwindow()->workspaceNumber() ==
276 win.screen().currentWorkspaceID()))))
277 return false; 280 return false;
278 else {
279 WinClient *focused = FocusControl::focusedWindow();
280 if (!focused || !((*it)->negate ^
281 (getProperty((*it)->prop, win) ==
282 getProperty((*it)->prop, *focused))))
283 return false;
284 }
285 } else if ((*it)->prop == HEAD && 281 } else if ((*it)->prop == HEAD &&
286 (*it)->orig == "[mouse]") { 282 (*it)->orig == "[mouse]") {
287 int mouse_head = win.screen().getCurrHead(); 283 int mouse_head = win.screen().getCurrHead();
@@ -315,8 +311,7 @@ bool ClientPattern::addTerm(const string &str, WinProperty prop, bool negate) {
315 return true; 311 return true;
316} 312}
317 313
318string ClientPattern::getProperty(WinProperty prop, 314string ClientPattern::getProperty(WinProperty prop, const Focusable &client) {
319 const Focusable &client) const {
320 // we need this for some of the window properties 315 // we need this for some of the window properties
321 const FluxboxWindow *fbwin = client.fbwindow(); 316 const FluxboxWindow *fbwin = client.fbwindow();
322 317
@@ -357,6 +352,14 @@ string ClientPattern::getProperty(WinProperty prop,
357 case WORKSPACE: { 352 case WORKSPACE: {
358 if (!fbwin) 353 if (!fbwin)
359 return ""; 354 return "";
355 char tmpstr[128];
356 sprintf(tmpstr, "%d", fbwin->workspaceNumber());
357 return std::string(tmpstr);
358 break;
359 }
360 case WORKSPACENAME: {
361 if (!fbwin)
362 return "";
360 const Workspace *w = client.screen().getWorkspace(fbwin->workspaceNumber()); 363 const Workspace *w = client.screen().getWorkspace(fbwin->workspaceNumber());
361 return w ? w->name() : ""; 364 return w ? w->name() : "";
362 break; 365 break;
@@ -377,7 +380,7 @@ string ClientPattern::getProperty(WinProperty prop,
377 return client.getWMClassName(); 380 return client.getWMClassName();
378} 381}
379 382
380bool ClientPattern::equals(const ClientPattern &pat) const { 383bool ClientPattern::operator ==(const ClientPattern &pat) const {
381 // we require the terms to be identical (order too) 384 // we require the terms to be identical (order too)
382 Terms::const_iterator it = m_terms.begin(); 385 Terms::const_iterator it = m_terms.begin();
383 Terms::const_iterator it_end = m_terms.end(); 386 Terms::const_iterator it_end = m_terms.end();