diff options
author | Mathias Gumz <akira at fluxbox dot org> | 2010-09-14 23:22:01 (GMT) |
---|---|---|
committer | Mathias Gumz <akira at fluxbox dot org> | 2010-09-14 23:22:01 (GMT) |
commit | 2b62cf973318978bc222db7719552148275887db (patch) | |
tree | 71722be7f293a2433bfbc1de8b32d2ca338d8aa8 /src | |
parent | c6047e9ebab5a0551c866078ed29fdda1e6b8174 (diff) | |
download | fluxbox_pavel-2b62cf973318978bc222db7719552148275887db.zip fluxbox_pavel-2b62cf973318978bc222db7719552148275887db.tar.bz2 |
cleanup and code deduplication
* ClientPattern.cc: make compiler happy (complaints about XPROP not handled in switch)
* FbTk/FbPixmap.cc FbTk/StringUtil.cc: signed vs unsigned
* FbTk/FbString.cc: missing return
* WinClient.cc: create atoms only once; use helper function
* Window.cc: use a helper function
Diffstat (limited to 'src')
-rw-r--r-- | src/ClientPattern.cc | 66 | ||||
-rw-r--r-- | src/FbTk/FbPixmap.cc | 2 | ||||
-rw-r--r-- | src/FbTk/FbString.cc | 1 | ||||
-rw-r--r-- | src/FbTk/StringUtil.cc | 2 | ||||
-rw-r--r-- | src/Window.cc | 34 |
5 files changed, 54 insertions, 51 deletions
diff --git a/src/ClientPattern.cc b/src/ClientPattern.cc index 71725fb..3802e59 100644 --- a/src/ClientPattern.cc +++ b/src/ClientPattern.cc | |||
@@ -373,7 +373,7 @@ bool ClientPattern::addTerm(const FbTk::FbString &str, WinProperty prop, bool ne | |||
373 | if (!term) | 373 | if (!term) |
374 | return rc; | 374 | return rc; |
375 | 375 | ||
376 | if (rc = !term->regexp.error()) { | 376 | if ((rc = !term->regexp.error())) { |
377 | m_terms.push_back(term); | 377 | m_terms.push_back(term); |
378 | } else { | 378 | } else { |
379 | delete term; | 379 | delete term; |
@@ -383,76 +383,84 @@ bool ClientPattern::addTerm(const FbTk::FbString &str, WinProperty prop, bool ne | |||
383 | } | 383 | } |
384 | 384 | ||
385 | FbTk::FbString ClientPattern::getProperty(WinProperty prop, const Focusable &client) { | 385 | FbTk::FbString ClientPattern::getProperty(WinProperty prop, const Focusable &client) { |
386 | |||
387 | FbTk::FbString result; | ||
388 | |||
386 | // we need this for some of the window properties | 389 | // we need this for some of the window properties |
387 | const FluxboxWindow *fbwin = client.fbwindow(); | 390 | const FluxboxWindow *fbwin = client.fbwindow(); |
388 | 391 | ||
389 | switch (prop) { | 392 | switch (prop) { |
390 | case TITLE: | 393 | case TITLE: |
391 | return client.title().logical(); | 394 | result = client.title().logical(); |
392 | break; | 395 | break; |
393 | case CLASS: | 396 | case CLASS: |
394 | return client.getWMClassClass(); | 397 | result = client.getWMClassClass(); |
395 | break; | ||
396 | case NAME: | ||
397 | return client.getWMClassName(); | ||
398 | break; | 398 | break; |
399 | case ROLE: | 399 | case ROLE: |
400 | return client.getWMRole(); | 400 | result = client.getWMRole(); |
401 | break; | 401 | break; |
402 | case TRANSIENT: | 402 | case TRANSIENT: |
403 | return client.isTransient() ? "yes" : "no"; | 403 | result = client.isTransient() ? "yes" : "no"; |
404 | break; | 404 | break; |
405 | case MAXIMIZED: | 405 | case MAXIMIZED: |
406 | return (fbwin && fbwin->isMaximized()) ? "yes" : "no"; | 406 | result = (fbwin && fbwin->isMaximized()) ? "yes" : "no"; |
407 | break; | 407 | break; |
408 | case MINIMIZED: | 408 | case MINIMIZED: |
409 | return (fbwin && fbwin->isIconic()) ? "yes" : "no"; | 409 | result = (fbwin && fbwin->isIconic()) ? "yes" : "no"; |
410 | break; | 410 | break; |
411 | case SHADED: | 411 | case SHADED: |
412 | return (fbwin && fbwin->isShaded()) ? "yes" : "no"; | 412 | result = (fbwin && fbwin->isShaded()) ? "yes" : "no"; |
413 | break; | 413 | break; |
414 | case STUCK: | 414 | case STUCK: |
415 | return (fbwin && fbwin->isStuck()) ? "yes" : "no"; | 415 | result = (fbwin && fbwin->isStuck()) ? "yes" : "no"; |
416 | break; | 416 | break; |
417 | case FOCUSHIDDEN: | 417 | case FOCUSHIDDEN: |
418 | return (fbwin && fbwin->isFocusHidden()) ? "yes" : "no"; | 418 | result = (fbwin && fbwin->isFocusHidden()) ? "yes" : "no"; |
419 | break; | 419 | break; |
420 | case ICONHIDDEN: | 420 | case ICONHIDDEN: |
421 | return (fbwin && fbwin->isIconHidden()) ? "yes" : "no"; | 421 | result = (fbwin && fbwin->isIconHidden()) ? "yes" : "no"; |
422 | break; | 422 | break; |
423 | case WORKSPACE: { | 423 | case WORKSPACE: { |
424 | unsigned int wsnum = (fbwin ? fbwin->workspaceNumber() : client.screen().currentWorkspaceID()); | 424 | unsigned int wsnum = (fbwin ? fbwin->workspaceNumber() : client.screen().currentWorkspaceID()); |
425 | return FbTk::StringUtil::number2String(wsnum); | 425 | result = FbTk::StringUtil::number2String(wsnum); |
426 | break; | 426 | break; |
427 | } | 427 | } |
428 | case WORKSPACENAME: { | 428 | case WORKSPACENAME: { |
429 | const Workspace *w = (fbwin ? | 429 | const Workspace *w = (fbwin ? |
430 | client.screen().getWorkspace(fbwin->workspaceNumber()) : | 430 | client.screen().getWorkspace(fbwin->workspaceNumber()) : |
431 | client.screen().currentWorkspace()); | 431 | client.screen().currentWorkspace()); |
432 | return w ? w->name() : ""; | 432 | if (w) { |
433 | result = w->name(); | ||
434 | } | ||
433 | break; | 435 | break; |
434 | } | 436 | } |
435 | case HEAD: { | 437 | case HEAD: |
436 | if (!fbwin) | 438 | if (fbwin) { |
437 | return ""; | 439 | result = FbTk::StringUtil::number2String(client.screen().getHead(fbwin->fbWindow())); |
438 | int head = client.screen().getHead(fbwin->fbWindow()); | 440 | } |
439 | return FbTk::StringUtil::number2String(head); | ||
440 | break; | 441 | break; |
441 | } | ||
442 | case LAYER: | 442 | case LAYER: |
443 | return fbwin ? ::Layer::getString(fbwin->layerNum()) : ""; | 443 | if (fbwin) { |
444 | result = ::Layer::getString(fbwin->layerNum()); | ||
445 | } | ||
444 | break; | 446 | break; |
445 | case URGENT: | 447 | case URGENT: |
446 | return Fluxbox::instance()->attentionHandler() | 448 | result = Fluxbox::instance()->attentionHandler() |
447 | .isDemandingAttention(client) ? "yes" : "no"; | 449 | .isDemandingAttention(client) ? "yes" : "no"; |
448 | break; | 450 | break; |
449 | case SCREEN: { | 451 | case SCREEN: |
450 | int screenId = client.screen().screenNumber(); | 452 | result = FbTk::StringUtil::number2String(client.screen().screenNumber()); |
451 | return FbTk::StringUtil::number2String(screenId); | 453 | break; |
454 | |||
455 | case XPROP: | ||
456 | break; | ||
457 | |||
458 | case NAME: | ||
459 | default: | ||
460 | result = client.getWMClassName(); | ||
452 | break; | 461 | break; |
453 | } | 462 | } |
454 | } | 463 | return result; |
455 | return client.getWMClassName(); | ||
456 | } | 464 | } |
457 | 465 | ||
458 | bool ClientPattern::operator ==(const ClientPattern &pat) const { | 466 | bool ClientPattern::operator ==(const ClientPattern &pat) const { |
diff --git a/src/FbTk/FbPixmap.cc b/src/FbTk/FbPixmap.cc index d63090e..a347e23 100644 --- a/src/FbTk/FbPixmap.cc +++ b/src/FbTk/FbPixmap.cc | |||
@@ -369,7 +369,7 @@ bool FbPixmap::rootwinPropertyNotify(int screen_num, Atom atom) { | |||
369 | return false; | 369 | return false; |
370 | 370 | ||
371 | checkAtoms(); | 371 | checkAtoms(); |
372 | for (int i=0; i < sizeof(root_props)/sizeof(RootProps); ++i) { | 372 | for (size_t i = 0; i < sizeof(root_props)/sizeof(RootProps); ++i) { |
373 | if (root_props[i].atom == atom) { | 373 | if (root_props[i].atom == atom) { |
374 | Pixmap root_pm = None; | 374 | Pixmap root_pm = None; |
375 | Atom real_type; | 375 | Atom real_type; |
diff --git a/src/FbTk/FbString.cc b/src/FbTk/FbString.cc index 79b773a..fd34693 100644 --- a/src/FbTk/FbString.cc +++ b/src/FbTk/FbString.cc | |||
@@ -126,6 +126,7 @@ const FbString& BiDiString::setLogical(const FbString& logical) { | |||
126 | m_visual_dirty = true; | 126 | m_visual_dirty = true; |
127 | } | 127 | } |
128 | #endif | 128 | #endif |
129 | return m_logical; | ||
129 | } | 130 | } |
130 | 131 | ||
131 | const FbString& BiDiString::visual() const { | 132 | const FbString& BiDiString::visual() const { |
diff --git a/src/FbTk/StringUtil.cc b/src/FbTk/StringUtil.cc index 691b600..182233b 100644 --- a/src/FbTk/StringUtil.cc +++ b/src/FbTk/StringUtil.cc | |||
@@ -183,7 +183,7 @@ string findExtension(const string &filename) { | |||
183 | string::size_type findCharFromAlphabetAfterTrigger(const std::string& in, char trigger, const char alphabet[], size_t len_alphabet, size_t* found) { | 183 | string::size_type findCharFromAlphabetAfterTrigger(const std::string& in, char trigger, const char alphabet[], size_t len_alphabet, size_t* found) { |
184 | for (const char* s = in.c_str(); *s != '\0'; ) { | 184 | for (const char* s = in.c_str(); *s != '\0'; ) { |
185 | if (*s++ == trigger && *s != '\0') { | 185 | if (*s++ == trigger && *s != '\0') { |
186 | for (const char* a = alphabet; (a - alphabet) < len_alphabet; ++a) { | 186 | for (const char* a = alphabet; (a - alphabet) < static_cast<ssize_t>(len_alphabet); ++a) { |
187 | if (*s == *a) { | 187 | if (*s == *a) { |
188 | if (found) { | 188 | if (found) { |
189 | *found = a - alphabet; | 189 | *found = a - alphabet; |
diff --git a/src/Window.cc b/src/Window.cc index 1837cee..79e9b43 100644 --- a/src/Window.cc +++ b/src/Window.cc | |||
@@ -133,6 +133,16 @@ WinClient *getRootTransientFor(WinClient *client) { | |||
133 | } | 133 | } |
134 | 134 | ||
135 | 135 | ||
136 | void callForAllTransient(FluxboxWindow& win, void (*callFunc)(FluxboxWindow&)) { | ||
137 | WinClient::TransientList::const_iterator it = win.winClient().transientList().begin(); | ||
138 | WinClient::TransientList::const_iterator it_end = win.winClient().transientList().end(); | ||
139 | for (; it != it_end; ++it) { | ||
140 | if ((*it)->fbwindow() && !(*it)->fbwindow()->isIconic()) | ||
141 | // TODO: should we also check if it is the active client? | ||
142 | callFunc(*(*it)->fbwindow()); | ||
143 | } | ||
144 | } | ||
145 | |||
136 | /// raise window and do the same for each transient of the current window | 146 | /// raise window and do the same for each transient of the current window |
137 | void raiseFluxboxWindow(FluxboxWindow &win) { | 147 | void raiseFluxboxWindow(FluxboxWindow &win) { |
138 | if (win.oplock) | 148 | if (win.oplock) |
@@ -150,19 +160,10 @@ void raiseFluxboxWindow(FluxboxWindow &win) { | |||
150 | 160 | ||
151 | win.layerItem().raise(); | 161 | win.layerItem().raise(); |
152 | 162 | ||
153 | // for each transient do raise | 163 | callForAllTransient(win, raiseFluxboxWindow); |
154 | |||
155 | WinClient::TransientList::const_iterator it = win.winClient().transientList().begin(); | ||
156 | WinClient::TransientList::const_iterator it_end = win.winClient().transientList().end(); | ||
157 | for (; it != it_end; ++it) { | ||
158 | if ((*it)->fbwindow() && !(*it)->fbwindow()->isIconic()) | ||
159 | // TODO: should we also check if it is the active client? | ||
160 | raiseFluxboxWindow(*(*it)->fbwindow()); | ||
161 | } | ||
162 | 164 | ||
163 | win.oplock = false; | 165 | win.oplock = false; |
164 | 166 | ||
165 | |||
166 | if (!win.winClient().transientList().empty()) | 167 | if (!win.winClient().transientList().empty()) |
167 | win.screen().layerManager().unlock(); | 168 | win.screen().layerManager().unlock(); |
168 | 169 | ||
@@ -210,16 +211,9 @@ void tempRaiseFluxboxWindow(FluxboxWindow &win) { | |||
210 | win.layerItem().tempRaise(); | 211 | win.layerItem().tempRaise(); |
211 | } | 212 | } |
212 | 213 | ||
213 | // for each transient do raise | 214 | callForAllTransient(win, tempRaiseFluxboxWindow); |
214 | WinClient::TransientList::const_iterator it = win.winClient().transientList().begin(); | ||
215 | WinClient::TransientList::const_iterator it_end = win.winClient().transientList().end(); | ||
216 | for (; it != it_end; ++it) { | ||
217 | if ((*it)->fbwindow() && !(*it)->fbwindow()->isIconic()) | ||
218 | // TODO: should we also check if it is the active client? | ||
219 | tempRaiseFluxboxWindow(*(*it)->fbwindow()); | ||
220 | } | ||
221 | win.oplock = false; | ||
222 | 215 | ||
216 | win.oplock = false; | ||
223 | } | 217 | } |
224 | 218 | ||
225 | class SetClientCmd:public FbTk::Command<void> { | 219 | class SetClientCmd:public FbTk::Command<void> { |
@@ -1063,8 +1057,8 @@ void FluxboxWindow::reconfigure() { | |||
1063 | m_timer.setTimeout(Fluxbox::instance()->getAutoRaiseDelay()); | 1057 | m_timer.setTimeout(Fluxbox::instance()->getAutoRaiseDelay()); |
1064 | 1058 | ||
1065 | updateButtons(); | 1059 | updateButtons(); |
1066 | frame().reconfigure(); | ||
1067 | 1060 | ||
1061 | frame().reconfigure(); | ||
1068 | menu().reconfigure(); | 1062 | menu().reconfigure(); |
1069 | 1063 | ||
1070 | Client2ButtonMap::iterator it = m_labelbuttons.begin(), | 1064 | Client2ButtonMap::iterator it = m_labelbuttons.begin(), |