diff options
author | Mathias Gumz <akira at fluxbox dot org> | 2009-10-01 06:57:31 (GMT) |
---|---|---|
committer | Mathias Gumz <akira at fluxbox dot org> | 2009-10-01 06:57:31 (GMT) |
commit | c4c96ec830f7e22c5f5183886de1f399333f60cd (patch) | |
tree | 3ded4864f71f3f092697268ea879e73b8dc978e7 /src/ClientPattern.cc | |
parent | 710ad1d4568239bbb1c19e82d764215b492d94db (diff) | |
download | fluxbox-c4c96ec830f7e22c5f5183886de1f399333f60cd.zip fluxbox-c4c96ec830f7e22c5f5183886de1f399333f60cd.tar.bz2 |
simpler code
Diffstat (limited to 'src/ClientPattern.cc')
-rw-r--r-- | src/ClientPattern.cc | 64 |
1 files changed, 27 insertions, 37 deletions
diff --git a/src/ClientPattern.cc b/src/ClientPattern.cc index 84f421a..41080fa 100644 --- a/src/ClientPattern.cc +++ b/src/ClientPattern.cc | |||
@@ -102,39 +102,42 @@ 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; |
137 | } else if (strcasecmp(memstr.c_str(), "screen") == 0) { | 140 | } else if (memstr == "screen") { |
138 | prop = SCREEN; | 141 | prop = SCREEN; |
139 | } else { | 142 | } else { |
140 | prop = NAME; | 143 | prop = NAME; |
@@ -279,9 +282,7 @@ bool ClientPattern::match(const Focusable &win) const { | |||
279 | if ((*it)->orig == "[current]") { | 282 | if ((*it)->orig == "[current]") { |
280 | WinClient *focused = FocusControl::focusedWindow(); | 283 | WinClient *focused = FocusControl::focusedWindow(); |
281 | if ((*it)->prop == WORKSPACE) { | 284 | if ((*it)->prop == WORKSPACE) { |
282 | char tmpstr[128]; | 285 | if (!(*it)->negate ^ (getProperty((*it)->prop, win) == FbTk::StringUtil::number2String(win.screen().currentWorkspaceID()))) |
283 | sprintf(tmpstr, "%d", win.screen().currentWorkspaceID()); | ||
284 | if (!(*it)->negate ^ (getProperty((*it)->prop, win) == tmpstr)) | ||
285 | return false; | 286 | return false; |
286 | } else if ((*it)->prop == WORKSPACENAME) { | 287 | } else if ((*it)->prop == WORKSPACENAME) { |
287 | const Workspace *w = win.screen().currentWorkspace(); | 288 | const Workspace *w = win.screen().currentWorkspace(); |
@@ -292,16 +293,11 @@ bool ClientPattern::match(const Focusable &win) const { | |||
292 | (getProperty((*it)->prop, win) == | 293 | (getProperty((*it)->prop, win) == |
293 | getProperty((*it)->prop, *focused)))) | 294 | getProperty((*it)->prop, *focused)))) |
294 | return false; | 295 | return false; |
295 | } else if ((*it)->prop == HEAD && | 296 | } else if ((*it)->prop == HEAD && (*it)->orig == "[mouse]") { |
296 | (*it)->orig == "[mouse]") { | 297 | if (!(*it)->negate ^ (getProperty((*it)->prop, win) == FbTk::StringUtil::number2String(win.screen().getCurrHead()))) |
297 | int mouse_head = win.screen().getCurrHead(); | ||
298 | char num[32]; | ||
299 | sprintf(num, "%d", mouse_head); | ||
300 | if (!(*it)->negate ^ (getProperty((*it)->prop, win) == num)) | ||
301 | return false; | 298 | return false; |
302 | 299 | ||
303 | } else if (!(*it)->negate ^ | 300 | } else if (!(*it)->negate ^ (*it)->regexp.match(getProperty((*it)->prop, win))) |
304 | (*it)->regexp.match(getProperty((*it)->prop, win))) | ||
305 | return false; | 301 | return false; |
306 | } | 302 | } |
307 | return true; | 303 | return true; |
@@ -385,9 +381,7 @@ string ClientPattern::getProperty(WinProperty prop, const Focusable &client) { | |||
385 | break; | 381 | break; |
386 | case WORKSPACE: { | 382 | case WORKSPACE: { |
387 | unsigned int wsnum = (fbwin ? fbwin->workspaceNumber() : client.screen().currentWorkspaceID()); | 383 | unsigned int wsnum = (fbwin ? fbwin->workspaceNumber() : client.screen().currentWorkspaceID()); |
388 | char tmpstr[128]; | 384 | return FbTk::StringUtil::number2String(wsnum); |
389 | sprintf(tmpstr, "%d", wsnum); | ||
390 | return std::string(tmpstr); | ||
391 | break; | 385 | break; |
392 | } | 386 | } |
393 | case WORKSPACENAME: { | 387 | case WORKSPACENAME: { |
@@ -401,9 +395,7 @@ string ClientPattern::getProperty(WinProperty prop, const Focusable &client) { | |||
401 | if (!fbwin) | 395 | if (!fbwin) |
402 | return ""; | 396 | return ""; |
403 | int head = client.screen().getHead(fbwin->fbWindow()); | 397 | int head = client.screen().getHead(fbwin->fbWindow()); |
404 | char tmpstr[128]; | 398 | return FbTk::StringUtil::number2String(head); |
405 | sprintf(tmpstr, "%d", head); | ||
406 | return std::string(tmpstr); | ||
407 | break; | 399 | break; |
408 | } | 400 | } |
409 | case LAYER: | 401 | case LAYER: |
@@ -415,9 +407,7 @@ string ClientPattern::getProperty(WinProperty prop, const Focusable &client) { | |||
415 | break; | 407 | break; |
416 | case SCREEN: { | 408 | case SCREEN: { |
417 | int screenId = client.screen().screenNumber(); | 409 | int screenId = client.screen().screenNumber(); |
418 | char tmpstr[32]; | 410 | return FbTk::StringUtil::number2String(screenId); |
419 | sprintf(tmpstr, "%d", screenId); | ||
420 | return std::string(tmpstr); | ||
421 | break; | 411 | break; |
422 | } | 412 | } |
423 | } | 413 | } |