aboutsummaryrefslogtreecommitdiff
path: root/src/CurrentWindowCmd.cc
diff options
context:
space:
mode:
authorMathias Gumz <akira at fluxbox dot org>2010-09-09 13:31:54 (GMT)
committerMathias Gumz <akira at fluxbox dot org>2010-09-09 13:31:54 (GMT)
commit77f39235cf3ad79c5ff7d2b0f4717660476f3cf4 (patch)
tree45cc07526285fc74af54f340782eb11a9d7bc55c /src/CurrentWindowCmd.cc
parent1657374940998176c7b63eb3296265fe6fbb5458 (diff)
downloadfluxbox-77f39235cf3ad79c5ff7d2b0f4717660476f3cf4.zip
fluxbox-77f39235cf3ad79c5ff7d2b0f4717660476f3cf4.tar.bz2
added FbTk::Util::clamp() and simplified related code
Diffstat (limited to 'src/CurrentWindowCmd.cc')
-rw-r--r--src/CurrentWindowCmd.cc33
1 files changed, 11 insertions, 22 deletions
diff --git a/src/CurrentWindowCmd.cc b/src/CurrentWindowCmd.cc
index 4d25d54..e2fdb94 100644
--- a/src/CurrentWindowCmd.cc
+++ b/src/CurrentWindowCmd.cc
@@ -35,6 +35,7 @@
35#include "FbTk/I18n.hh" 35#include "FbTk/I18n.hh"
36#include "FbTk/stringstream.hh" 36#include "FbTk/stringstream.hh"
37#include "FbTk/StringUtil.hh" 37#include "FbTk/StringUtil.hh"
38#include "FbTk/Util.hh"
38 39
39#ifdef HAVE_CONFIG_H 40#ifdef HAVE_CONFIG_H
40#include "config.h" 41#include "config.h"
@@ -250,8 +251,7 @@ void SetHeadCmd::real_execute() {
250 int num = m_head; 251 int num = m_head;
251 int total = fbwindow().screen().numHeads(); 252 int total = fbwindow().screen().numHeads();
252 if (num < 0) num += total + 1; 253 if (num < 0) num += total + 1;
253 if (num < 1) num = 1; 254 num = FbTk::Util::clamp(num, 1, total);
254 if (num > total) num = total;
255 fbwindow().setOnHead(num); 255 fbwindow().setOnHead(num);
256} 256}
257 257
@@ -259,8 +259,7 @@ void SendToWorkspaceCmd::real_execute() {
259 int num = m_workspace_num; 259 int num = m_workspace_num;
260 int total = fbwindow().screen().numberOfWorkspaces(); 260 int total = fbwindow().screen().numberOfWorkspaces();
261 if (num < 0) num += total + 1; 261 if (num < 0) num += total + 1;
262 if (num < 1) num = 1; 262 num = FbTk::Util::clamp(num, 1, total);
263 if (num > total) num = total;
264 fbwindow().screen().sendToWorkspace(num-1, &fbwindow(), m_take); 263 fbwindow().screen().sendToWorkspace(num-1, &fbwindow(), m_take);
265} 264}
266 265
@@ -281,8 +280,7 @@ void SendToNextHeadCmd::real_execute() {
281void GoToTabCmd::real_execute() { 280void GoToTabCmd::real_execute() {
282 int num = m_tab_num; 281 int num = m_tab_num;
283 if (num < 0) num += fbwindow().numClients() + 1; 282 if (num < 0) num += fbwindow().numClients() + 1;
284 if (num < 1) num = 1; 283 num = FbTk::Util::clamp(num, 1, fbwindow().numClients());
285 if (num > fbwindow().numClients()) num = fbwindow().numClients();
286 284
287 FluxboxWindow::ClientList::iterator it = fbwindow().clientList().begin(); 285 FluxboxWindow::ClientList::iterator it = fbwindow().clientList().begin();
288 286
@@ -670,22 +668,13 @@ void SetAlphaCmd::real_execute() {
670 return; 668 return;
671 } 669 }
672 670
673 int new_alpha; 671 fbwindow().setFocusedAlpha(m_relative
674 if (m_relative) { 672 ? FbTk::Util::clamp(fbwindow().getFocusedAlpha() + m_focus, 0, 255)
675 new_alpha = fbwindow().getFocusedAlpha() + m_focus; 673 : m_focus);
676 if (new_alpha < 0) new_alpha = 0; 674
677 if (new_alpha > 255) new_alpha = 255; 675 fbwindow().setUnfocusedAlpha(m_un_relative
678 fbwindow().setFocusedAlpha(new_alpha); 676 ? FbTk::Util::clamp(fbwindow().getUnfocusedAlpha() + m_unfocus, 0, 255)
679 } else 677 : m_unfocus);
680 fbwindow().setFocusedAlpha(m_focus);
681
682 if (m_un_relative) {
683 new_alpha = fbwindow().getUnfocusedAlpha() + m_unfocus;
684 if (new_alpha < 0) new_alpha = 0;
685 if (new_alpha > 255) new_alpha = 255;
686 fbwindow().setUnfocusedAlpha(new_alpha);
687 } else
688 fbwindow().setUnfocusedAlpha(m_unfocus);
689} 678}
690 679
691REGISTER_COMMAND_WITH_ARGS(matches, MatchCmd, bool); 680REGISTER_COMMAND_WITH_ARGS(matches, MatchCmd, bool);