aboutsummaryrefslogtreecommitdiff
path: root/src/Remember.cc
diff options
context:
space:
mode:
authorThomas Lübking <thomas.luebking@gmail.com>2016-06-19 15:45:41 (GMT)
committerMathias Gumz <akira@fluxbox.org>2016-06-26 14:35:16 (GMT)
commit1a61881ec34a5f3691df1159f63a4b5afb1f53c4 (patch)
tree8ab844e8790c75a0e9dcc2ea44143dea47649758 /src/Remember.cc
parent69b0f0fa97f53f601a250dc1b5a6876f64796a91 (diff)
downloadfluxbox-1a61881ec34a5f3691df1159f63a4b5afb1f53c4.zip
fluxbox-1a61881ec34a5f3691df1159f63a4b5afb1f53c4.tar.bz2
Add FocusProtection features
The apps file gets a new key FocusProtection supporting a comma separated list. * None : regular behavior * Lock : If this window has the focus, no other may claim it * Deny : This window is not allowed to focus itself I addition there's preparation for a follow-up patch to incorporate and substitute the present FocusNewWindow feature: * Gain : Pass focus to new window * Refuse : Do not pass focus to new window rationale: clients stealing the focus sucks badly and while there's an input driven timeout, that only protects actual typing flow, but if eg. vlc proceeds on the playlist, you'll suddenly control vlc instead of your browser (ie. typing ctrl+w doesn't close the tab, but the playlist ...)
Diffstat (limited to 'src/Remember.cc')
-rw-r--r--src/Remember.cc65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/Remember.cc b/src/Remember.cc
index 6dcd378..43a4d16 100644
--- a/src/Remember.cc
+++ b/src/Remember.cc
@@ -98,6 +98,7 @@ public:
98 void forgetIconHiddenstate() { iconhiddenstate_remember= false; } 98 void forgetIconHiddenstate() { iconhiddenstate_remember= false; }
99 void forgetStuckstate() { stuckstate_remember = false; } 99 void forgetStuckstate() { stuckstate_remember = false; }
100 void forgetFocusNewWindow() { focusnewwindow_remember = false; } 100 void forgetFocusNewWindow() { focusnewwindow_remember = false; }
101 void forgetFocusProtection() { focusprotection_remember = false; }
101 void forgetJumpworkspace() { jumpworkspace_remember = false; } 102 void forgetJumpworkspace() { jumpworkspace_remember = false; }
102 void forgetLayer() { layer_remember = false; } 103 void forgetLayer() { layer_remember = false; }
103 void forgetSaveOnClose() { save_on_close_remember = false; } 104 void forgetSaveOnClose() { save_on_close_remember = false; }
@@ -140,6 +141,8 @@ public:
140 { stuckstate = state; stuckstate_remember = true; } 141 { stuckstate = state; stuckstate_remember = true; }
141 void rememberFocusNewWindow(bool state) 142 void rememberFocusNewWindow(bool state)
142 { focusnewwindow = state; focusnewwindow_remember = true; } 143 { focusnewwindow = state; focusnewwindow_remember = true; }
144 void rememberFocusProtection(unsigned int protect)
145 { focusprotection = protect; focusprotection_remember = true; }
143 void rememberJumpworkspace(bool state) 146 void rememberJumpworkspace(bool state)
144 { jumpworkspace = state; jumpworkspace_remember = true; } 147 { jumpworkspace = state; jumpworkspace_remember = true; }
145 void rememberLayer(int layernum) 148 void rememberLayer(int layernum)
@@ -191,6 +194,9 @@ public:
191 bool focusnewwindow_remember; 194 bool focusnewwindow_remember;
192 bool focusnewwindow; 195 bool focusnewwindow;
193 196
197 bool focusprotection_remember;
198 unsigned int focusprotection;
199
194 bool focushiddenstate_remember; 200 bool focushiddenstate_remember;
195 bool focushiddenstate; 201 bool focushiddenstate;
196 202
@@ -242,6 +248,7 @@ void Application::reset() {
242 shadedstate_remember = 248 shadedstate_remember =
243 stuckstate_remember = 249 stuckstate_remember =
244 focusnewwindow_remember = 250 focusnewwindow_remember =
251 focusprotection_remember =
245 tabstate_remember = 252 tabstate_remember =
246 workspace_remember = 253 workspace_remember =
247 head_remember = 254 head_remember =
@@ -549,6 +556,26 @@ int parseApp(ifstream &file, Application &app, string *first_line = 0) {
549 app.rememberStuckstate(str_label == "yes"); 556 app.rememberStuckstate(str_label == "yes");
550 } else if (str_key == "focusnewwindow") { 557 } else if (str_key == "focusnewwindow") {
551 app.rememberFocusNewWindow(str_label == "yes"); 558 app.rememberFocusNewWindow(str_label == "yes");
559 } else if (str_key == "focusprotection") {
560 Focus::Protection protect = Focus::NoProtection;
561 std::list<std::string> labels;
562 FbTk::StringUtil::stringtok(labels, str_label, ", ");
563 std::list<std::string>::iterator it = labels.begin();
564 for (; it != labels.end(); ++it) {
565 if (*it == "lock")
566 protect = (protect & ~Focus::Deny) | Focus::Lock;
567 else if (*it == "deny")
568 protect = (protect & ~Focus::Lock) | Focus::Deny;
569 else if (*it == "gain")
570 protect = (protect & ~Focus::Refuse) | Focus::Gain;
571 else if (*it == "refuse")
572 protect = (protect & ~Focus::Gain) | Focus::Refuse;
573 else if (*it == "none")
574 protect = Focus::NoProtection;
575 else
576 had_error = 1;
577 }
578 app.rememberFocusProtection(protect);
552 } else if (str_key == "minimized") { 579 } else if (str_key == "minimized") {
553 app.rememberMinimizedstate(str_label == "yes"); 580 app.rememberMinimizedstate(str_label == "yes");
554 } else if (str_key == "maximized") { 581 } else if (str_key == "maximized") {
@@ -1009,6 +1036,31 @@ void Remember::save() {
1009 if (a.focusnewwindow_remember) { 1036 if (a.focusnewwindow_remember) {
1010 apps_file << " [FocusNewWindow]\t{" << ((a.focusnewwindow)?"yes":"no") << "}" << endl; 1037 apps_file << " [FocusNewWindow]\t{" << ((a.focusnewwindow)?"yes":"no") << "}" << endl;
1011 } 1038 }
1039 if (a.focusprotection_remember) {
1040 apps_file << " [FocusProtection]\t{";
1041 if (a.focusprotection == Focus::NoProtection) {
1042 apps_file << "none";
1043 } else {
1044 bool b = false;
1045 if (a.focusprotection & Focus::Gain) {
1046 apps_file << (b?",":"") << "gain";
1047 b = true;
1048 }
1049 if (a.focusprotection & Focus::Refuse) {
1050 apps_file << (b?",":"") << "refuse";
1051 b = true;
1052 }
1053 if (a.focusprotection & Focus::Lock) {
1054 apps_file << (b?",":"") << "lock";
1055 b = true;
1056 }
1057 if (a.focusprotection & Focus::Deny) {
1058 apps_file << (b?",":"") << "deny";
1059 b = true;
1060 }
1061 }
1062 apps_file << "}" << endl;
1063 }
1012 if (a.minimizedstate_remember) { 1064 if (a.minimizedstate_remember) {
1013 apps_file << " [Minimized]\t{" << ((a.minimizedstate)?"yes":"no") << "}" << endl; 1065 apps_file << " [Minimized]\t{" << ((a.minimizedstate)?"yes":"no") << "}" << endl;
1014 } 1066 }
@@ -1083,6 +1135,9 @@ bool Remember::isRemembered(WinClient &winclient, Attribute attrib) {
1083 case REM_FOCUSNEWWINDOW: 1135 case REM_FOCUSNEWWINDOW:
1084 return app->focusnewwindow_remember; 1136 return app->focusnewwindow_remember;
1085 break; 1137 break;
1138 case REM_FOCUSPROTECTION:
1139 return app->focusprotection_remember;
1140 break;
1086 case REM_MINIMIZEDSTATE: 1141 case REM_MINIMIZEDSTATE:
1087 return app->minimizedstate_remember; 1142 return app->minimizedstate_remember;
1088 break; 1143 break;
@@ -1166,6 +1221,9 @@ void Remember::rememberAttrib(WinClient &winclient, Attribute attrib) {
1166 case REM_FOCUSNEWWINDOW: 1221 case REM_FOCUSNEWWINDOW:
1167 app->rememberFocusNewWindow(win->isFocusNew()); 1222 app->rememberFocusNewWindow(win->isFocusNew());
1168 break; 1223 break;
1224 case REM_FOCUSPROTECTION:
1225 app->rememberFocusProtection(win->focusProtection());
1226 break;
1169 case REM_MINIMIZEDSTATE: 1227 case REM_MINIMIZEDSTATE:
1170 app->rememberMinimizedstate(win->isIconic()); 1228 app->rememberMinimizedstate(win->isIconic());
1171 break; 1229 break;
@@ -1229,6 +1287,9 @@ void Remember::forgetAttrib(WinClient &winclient, Attribute attrib) {
1229 case REM_FOCUSNEWWINDOW: 1287 case REM_FOCUSNEWWINDOW:
1230 app->forgetFocusNewWindow(); 1288 app->forgetFocusNewWindow();
1231 break; 1289 break;
1290 case REM_FOCUSPROTECTION:
1291 app->forgetFocusProtection();
1292 break;
1232 case REM_MINIMIZEDSTATE: 1293 case REM_MINIMIZEDSTATE:
1233 app->forgetMinimizedstate(); 1294 app->forgetMinimizedstate();
1234 break; 1295 break;
@@ -1355,6 +1416,10 @@ void Remember::setupFrame(FluxboxWindow &win) {
1355 if (app->focusnewwindow_remember) 1416 if (app->focusnewwindow_remember)
1356 win.setFocusNew(app->focusnewwindow); 1417 win.setFocusNew(app->focusnewwindow);
1357 1418
1419 if (app->focusprotection_remember) {
1420 win.setFocusProtection(app->focusprotection);
1421 }
1422
1358 if (app->minimizedstate_remember) { 1423 if (app->minimizedstate_remember) {
1359 // if inconsistent... 1424 // if inconsistent...
1360 // this one doesn't actually work, but I can't imagine needing it 1425 // this one doesn't actually work, but I can't imagine needing it