summaryrefslogtreecommitdiff
path: root/src/ClientPattern.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/ClientPattern.cc')
-rw-r--r--src/ClientPattern.cc78
1 files changed, 40 insertions, 38 deletions
diff --git a/src/ClientPattern.cc b/src/ClientPattern.cc
index 6a19f2f..41080fa 100644
--- a/src/ClientPattern.cc
+++ b/src/ClientPattern.cc
@@ -102,38 +102,43 @@ ClientPattern::ClientPattern(const char *str):
102 negate = true; 102 negate = true;
103 memstr.assign(memstr, 0, memstr.length()-1); 103 memstr.assign(memstr, 0, memstr.length()-1);
104 } 104 }
105 if (strcasecmp(memstr.c_str(), "name") == 0) { 105
106 memstr = FbTk::StringUtil::toLower(memstr);
107
108 if (memstr == "name") {
106 prop = NAME; 109 prop = NAME;
107 } else if (strcasecmp(memstr.c_str(), "class") == 0) { 110 } else if (memstr == "class") {
108 prop = CLASS; 111 prop = CLASS;
109 } else if (strcasecmp(memstr.c_str(), "title") == 0) { 112 } else if (memstr == "title") {
110 prop = TITLE; 113 prop = TITLE;
111 } else if (strcasecmp(memstr.c_str(), "role") == 0) { 114 } else if (memstr == "role") {
112 prop = ROLE; 115 prop = ROLE;
113 } else if (strcasecmp(memstr.c_str(), "transient") == 0) { 116 } else if (memstr == "transient") {
114 prop = TRANSIENT; 117 prop = TRANSIENT;
115 } else if (strcasecmp(memstr.c_str(), "maximized") == 0) { 118 } else if (memstr == "maximized") {
116 prop = MAXIMIZED; 119 prop = MAXIMIZED;
117 } else if (strcasecmp(memstr.c_str(), "minimized") == 0) { 120 } else if (memstr == "minimized") {
118 prop = MINIMIZED; 121 prop = MINIMIZED;
119 } else if (strcasecmp(memstr.c_str(), "shaded") == 0) { 122 } else if (memstr == "shaded") {
120 prop = SHADED; 123 prop = SHADED;
121 } else if (strcasecmp(memstr.c_str(), "stuck") == 0) { 124 } else if (memstr == "stuck") {
122 prop = STUCK; 125 prop = STUCK;
123 } else if (strcasecmp(memstr.c_str(), "focushidden") == 0) { 126 } else if (memstr == "focushidden") {
124 prop = FOCUSHIDDEN; 127 prop = FOCUSHIDDEN;
125 } else if (strcasecmp(memstr.c_str(), "iconhidden") == 0) { 128 } else if (memstr == "iconhidden") {
126 prop = ICONHIDDEN; 129 prop = ICONHIDDEN;
127 } else if (strcasecmp(memstr.c_str(), "workspace") == 0) { 130 } else if (memstr == "workspace") {
128 prop = WORKSPACE; 131 prop = WORKSPACE;
129 } else if (strcasecmp(memstr.c_str(), "workspacename") == 0) { 132 } else if (memstr == "workspacename") {
130 prop = WORKSPACENAME; 133 prop = WORKSPACENAME;
131 } else if (strcasecmp(memstr.c_str(), "head") == 0) { 134 } else if (memstr == "head") {
132 prop = HEAD; 135 prop = HEAD;
133 } else if (strcasecmp(memstr.c_str(), "layer") == 0) { 136 } else if (memstr == "layer") {
134 prop = LAYER; 137 prop = LAYER;
135 } else if (strcasecmp(memstr.c_str(), "urgent") == 0) { 138 } else if (memstr == "urgent") {
136 prop = URGENT; 139 prop = URGENT;
140 } else if (memstr == "screen") {
141 prop = SCREEN;
137 } else { 142 } else {
138 prop = NAME; 143 prop = NAME;
139 expr = match; 144 expr = match;
@@ -245,6 +250,10 @@ string ClientPattern::toString() const {
245 break; 250 break;
246 case URGENT: 251 case URGENT:
247 pat.append("urgent="); 252 pat.append("urgent=");
253 break;
254 case SCREEN:
255 pat.append("screen=");
256 break;
248 } 257 }
249 258
250 pat.append((*it)->orig); 259 pat.append((*it)->orig);
@@ -273,9 +282,7 @@ bool ClientPattern::match(const Focusable &win) const {
273 if ((*it)->orig == "[current]") { 282 if ((*it)->orig == "[current]") {
274 WinClient *focused = FocusControl::focusedWindow(); 283 WinClient *focused = FocusControl::focusedWindow();
275 if ((*it)->prop == WORKSPACE) { 284 if ((*it)->prop == WORKSPACE) {
276 char tmpstr[128]; 285 if (!(*it)->negate ^ (getProperty((*it)->prop, win) == FbTk::StringUtil::number2String(win.screen().currentWorkspaceID())))
277 sprintf(tmpstr, "%d", win.screen().currentWorkspaceID());
278 if (!(*it)->negate ^ (getProperty((*it)->prop, win) == tmpstr))
279 return false; 286 return false;
280 } else if ((*it)->prop == WORKSPACENAME) { 287 } else if ((*it)->prop == WORKSPACENAME) {
281 const Workspace *w = win.screen().currentWorkspace(); 288 const Workspace *w = win.screen().currentWorkspace();
@@ -286,16 +293,11 @@ bool ClientPattern::match(const Focusable &win) const {
286 (getProperty((*it)->prop, win) == 293 (getProperty((*it)->prop, win) ==
287 getProperty((*it)->prop, *focused)))) 294 getProperty((*it)->prop, *focused))))
288 return false; 295 return false;
289 } else if ((*it)->prop == HEAD && 296 } else if ((*it)->prop == HEAD && (*it)->orig == "[mouse]") {
290 (*it)->orig == "[mouse]") { 297 if (!(*it)->negate ^ (getProperty((*it)->prop, win) == FbTk::StringUtil::number2String(win.screen().getCurrHead())))
291 int mouse_head = win.screen().getCurrHead();
292 char num[32];
293 sprintf(num, "%d", mouse_head);
294 if (!(*it)->negate ^ (getProperty((*it)->prop, win) == num))
295 return false; 298 return false;
296 299
297 } else if (!(*it)->negate ^ 300 } else if (!(*it)->negate ^ (*it)->regexp.match(getProperty((*it)->prop, win)))
298 (*it)->regexp.match(getProperty((*it)->prop, win)))
299 return false; 301 return false;
300 } 302 }
301 return true; 303 return true;
@@ -378,17 +380,14 @@ string ClientPattern::getProperty(WinProperty prop, const Focusable &client) {
378 return (fbwin && fbwin->isIconHidden()) ? "yes" : "no"; 380 return (fbwin && fbwin->isIconHidden()) ? "yes" : "no";
379 break; 381 break;
380 case WORKSPACE: { 382 case WORKSPACE: {
381 if (!fbwin) 383 unsigned int wsnum = (fbwin ? fbwin->workspaceNumber() : client.screen().currentWorkspaceID());
382 return ""; 384 return FbTk::StringUtil::number2String(wsnum);
383 char tmpstr[128];
384 sprintf(tmpstr, "%d", fbwin->workspaceNumber());
385 return std::string(tmpstr);
386 break; 385 break;
387 } 386 }
388 case WORKSPACENAME: { 387 case WORKSPACENAME: {
389 if (!fbwin) 388 const Workspace *w = (fbwin ?
390 return ""; 389 client.screen().getWorkspace(fbwin->workspaceNumber()) :
391 const Workspace *w = client.screen().getWorkspace(fbwin->workspaceNumber()); 390 client.screen().currentWorkspace());
392 return w ? w->name() : ""; 391 return w ? w->name() : "";
393 break; 392 break;
394 } 393 }
@@ -396,9 +395,7 @@ string ClientPattern::getProperty(WinProperty prop, const Focusable &client) {
396 if (!fbwin) 395 if (!fbwin)
397 return ""; 396 return "";
398 int head = client.screen().getHead(fbwin->fbWindow()); 397 int head = client.screen().getHead(fbwin->fbWindow());
399 char tmpstr[128]; 398 return FbTk::StringUtil::number2String(head);
400 sprintf(tmpstr, "%d", head);
401 return std::string(tmpstr);
402 break; 399 break;
403 } 400 }
404 case LAYER: 401 case LAYER:
@@ -408,6 +405,11 @@ string ClientPattern::getProperty(WinProperty prop, const Focusable &client) {
408 return Fluxbox::instance()->attentionHandler() 405 return Fluxbox::instance()->attentionHandler()
409 .isDemandingAttention(client) ? "yes" : "no"; 406 .isDemandingAttention(client) ? "yes" : "no";
410 break; 407 break;
408 case SCREEN: {
409 int screenId = client.screen().screenNumber();
410 return FbTk::StringUtil::number2String(screenId);
411 break;
412 }
411 } 413 }
412 return client.getWMClassName(); 414 return client.getWMClassName();
413} 415}