aboutsummaryrefslogtreecommitdiff
path: root/src/Remember.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/Remember.cc
parent1657374940998176c7b63eb3296265fe6fbb5458 (diff)
downloadfluxbox_pavel-77f39235cf3ad79c5ff7d2b0f4717660476f3cf4.zip
fluxbox_pavel-77f39235cf3ad79c5ff7d2b0f4717660476f3cf4.tar.bz2
added FbTk::Util::clamp() and simplified related code
Diffstat (limited to 'src/Remember.cc')
-rw-r--r--src/Remember.cc31
1 files changed, 11 insertions, 20 deletions
diff --git a/src/Remember.cc b/src/Remember.cc
index f70217e..54b5b0d 100644
--- a/src/Remember.cc
+++ b/src/Remember.cc
@@ -41,6 +41,7 @@
41#include "FbTk/Transparent.hh" 41#include "FbTk/Transparent.hh"
42#include "FbTk/AutoReloadHelper.hh" 42#include "FbTk/AutoReloadHelper.hh"
43#include "FbTk/RefCount.hh" 43#include "FbTk/RefCount.hh"
44#include "FbTk/Util.hh"
44 45
45#ifdef HAVE_CSTRING 46#ifdef HAVE_CSTRING
46 #include <cstring> 47 #include <cstring>
@@ -512,28 +513,18 @@ int parseApp(ifstream &file, Application &app, string *first_line = 0) {
512 app.rememberDecostate((unsigned int)deco); 513 app.rememberDecostate((unsigned int)deco);
513 } else if (str_key == "alpha") { 514 } else if (str_key == "alpha") {
514 int focused_a, unfocused_a; 515 int focused_a, unfocused_a;
515 if (sscanf(str_label.c_str(), "%i %i", &focused_a, &unfocused_a) == 2) 516 switch (sscanf(str_label.c_str(), "%i %i", &focused_a, &unfocused_a)) {
516 { 517 case 1: // 'alpha <focus>'
517 // clamp; 518 unfocused_a = focused_a;
518 if (focused_a > 255) 519 case 2: // 'alpha <focus> <unfocus>'
519 focused_a = 255; 520 focused_a = FbTk::Util::clamp(focused_a, 0, 255);
520 if (unfocused_a > 255) 521 unfocused_a = FbTk::Util::clamp(unfocused_a, 0, 255);
521 unfocused_a = 255;
522 if (focused_a <= 0)
523 focused_a = 0;
524 if (unfocused_a <= 0)
525 unfocused_a = 0;
526
527 app.rememberAlpha(focused_a, unfocused_a); 522 app.rememberAlpha(focused_a, unfocused_a);
528 } else if (sscanf(str_label.c_str(), "%i", &focused_a) == 1) { 523 break;
529 if (focused_a > 255) 524 default:
530 focused_a = 255; 525 had_error = true;
531 if (focused_a <= 0) 526 break;
532 focused_a = 0;
533 app.rememberAlpha(focused_a, focused_a);
534 } 527 }
535 else
536 had_error = 1;
537 } else if (str_key == "sticky") { 528 } else if (str_key == "sticky") {
538 app.rememberStuckstate((strcasecmp(str_label.c_str(), "yes") == 0)); 529 app.rememberStuckstate((strcasecmp(str_label.c_str(), "yes") == 0));
539 } else if (str_key == "minimized") { 530 } else if (str_key == "minimized") {