aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Remember.cc39
-rw-r--r--src/Remember.hh1
-rw-r--r--src/Window.cc19
-rw-r--r--src/Window.hh10
4 files changed, 33 insertions, 36 deletions
diff --git a/src/Remember.cc b/src/Remember.cc
index 43a4d16..6545b50 100644
--- a/src/Remember.cc
+++ b/src/Remember.cc
@@ -97,7 +97,6 @@ public:
97 void forgetFocusHiddenstate() { focushiddenstate_remember= false; } 97 void forgetFocusHiddenstate() { focushiddenstate_remember= false; }
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; }
101 void forgetFocusProtection() { focusprotection_remember = false; } 100 void forgetFocusProtection() { focusprotection_remember = false; }
102 void forgetJumpworkspace() { jumpworkspace_remember = false; } 101 void forgetJumpworkspace() { jumpworkspace_remember = false; }
103 void forgetLayer() { layer_remember = false; } 102 void forgetLayer() { layer_remember = false; }
@@ -139,8 +138,6 @@ public:
139 { decostate = state; decostate_remember = true; } 138 { decostate = state; decostate_remember = true; }
140 void rememberStuckstate(bool state) 139 void rememberStuckstate(bool state)
141 { stuckstate = state; stuckstate_remember = true; } 140 { stuckstate = state; stuckstate_remember = true; }
142 void rememberFocusNewWindow(bool state)
143 { focusnewwindow = state; focusnewwindow_remember = true; }
144 void rememberFocusProtection(unsigned int protect) 141 void rememberFocusProtection(unsigned int protect)
145 { focusprotection = protect; focusprotection_remember = true; } 142 { focusprotection = protect; focusprotection_remember = true; }
146 void rememberJumpworkspace(bool state) 143 void rememberJumpworkspace(bool state)
@@ -191,9 +188,6 @@ public:
191 bool stuckstate_remember; 188 bool stuckstate_remember;
192 bool stuckstate; 189 bool stuckstate;
193 190
194 bool focusnewwindow_remember;
195 bool focusnewwindow;
196
197 bool focusprotection_remember; 191 bool focusprotection_remember;
198 unsigned int focusprotection; 192 unsigned int focusprotection;
199 193
@@ -247,7 +241,6 @@ void Application::reset() {
247 position_remember = 241 position_remember =
248 shadedstate_remember = 242 shadedstate_remember =
249 stuckstate_remember = 243 stuckstate_remember =
250 focusnewwindow_remember =
251 focusprotection_remember = 244 focusprotection_remember =
252 tabstate_remember = 245 tabstate_remember =
253 workspace_remember = 246 workspace_remember =
@@ -436,6 +429,8 @@ bool handleStartupItem(const string &line, int offset) {
436int parseApp(ifstream &file, Application &app, string *first_line = 0) { 429int parseApp(ifstream &file, Application &app, string *first_line = 0) {
437 string line; 430 string line;
438 _FB_USES_NLS; 431 _FB_USES_NLS;
432 Focus::Protection protect = Focus::NoProtection;
433 bool remember_protect = false;
439 int row = 0; 434 int row = 0;
440 while (! file.eof()) { 435 while (! file.eof()) {
441 if (!(first_line || getline(file, line))) { 436 if (!(first_line || getline(file, line))) {
@@ -555,9 +550,15 @@ int parseApp(ifstream &file, Application &app, string *first_line = 0) {
555 } else if (str_key == "sticky") { 550 } else if (str_key == "sticky") {
556 app.rememberStuckstate(str_label == "yes"); 551 app.rememberStuckstate(str_label == "yes");
557 } else if (str_key == "focusnewwindow") { 552 } else if (str_key == "focusnewwindow") {
558 app.rememberFocusNewWindow(str_label == "yes"); 553 remember_protect = true;
554 if (!(protect & (Focus::Gain|Focus::Refuse))) { // cut back on contradiction
555 if (str_label == "yes")
556 protect |= Focus::Gain;
557 else
558 protect |= Focus::Refuse;
559 }
559 } else if (str_key == "focusprotection") { 560 } else if (str_key == "focusprotection") {
560 Focus::Protection protect = Focus::NoProtection; 561 remember_protect = true;
561 std::list<std::string> labels; 562 std::list<std::string> labels;
562 FbTk::StringUtil::stringtok(labels, str_label, ", "); 563 FbTk::StringUtil::stringtok(labels, str_label, ", ");
563 std::list<std::string>::iterator it = labels.begin(); 564 std::list<std::string>::iterator it = labels.begin();
@@ -575,7 +576,6 @@ int parseApp(ifstream &file, Application &app, string *first_line = 0) {
575 else 576 else
576 had_error = 1; 577 had_error = 1;
577 } 578 }
578 app.rememberFocusProtection(protect);
579 } else if (str_key == "minimized") { 579 } else if (str_key == "minimized") {
580 app.rememberMinimizedstate(str_label == "yes"); 580 app.rememberMinimizedstate(str_label == "yes");
581 } else if (str_key == "maximized") { 581 } else if (str_key == "maximized") {
@@ -594,7 +594,7 @@ int parseApp(ifstream &file, Application &app, string *first_line = 0) {
594 } else if (str_key == "close") { 594 } else if (str_key == "close") {
595 app.rememberSaveOnClose(str_label == "yes"); 595 app.rememberSaveOnClose(str_label == "yes");
596 } else if (str_key == "end") { 596 } else if (str_key == "end") {
597 return row; 597 break;
598 } else { 598 } else {
599 cerr << _FB_CONSOLETEXT(Remember, Unknown, "Unknown apps key", "apps entry type not known")<<" = " << str_key << endl; 599 cerr << _FB_CONSOLETEXT(Remember, Unknown, "Unknown apps key", "apps entry type not known")<<" = " << str_key << endl;
600 } 600 }
@@ -602,6 +602,8 @@ int parseApp(ifstream &file, Application &app, string *first_line = 0) {
602 cerr<<"Error parsing apps entry: ("<<line<<")"<<endl; 602 cerr<<"Error parsing apps entry: ("<<line<<")"<<endl;
603 } 603 }
604 } 604 }
605 if (remember_protect)
606 app.rememberFocusProtection(protect);
605 return row; 607 return row;
606} 608}
607 609
@@ -1033,9 +1035,6 @@ void Remember::save() {
1033 if (a.stuckstate_remember) { 1035 if (a.stuckstate_remember) {
1034 apps_file << " [Sticky]\t{" << ((a.stuckstate)?"yes":"no") << "}" << endl; 1036 apps_file << " [Sticky]\t{" << ((a.stuckstate)?"yes":"no") << "}" << endl;
1035 } 1037 }
1036 if (a.focusnewwindow_remember) {
1037 apps_file << " [FocusNewWindow]\t{" << ((a.focusnewwindow)?"yes":"no") << "}" << endl;
1038 }
1039 if (a.focusprotection_remember) { 1038 if (a.focusprotection_remember) {
1040 apps_file << " [FocusProtection]\t{"; 1039 apps_file << " [FocusProtection]\t{";
1041 if (a.focusprotection == Focus::NoProtection) { 1040 if (a.focusprotection == Focus::NoProtection) {
@@ -1132,9 +1131,6 @@ bool Remember::isRemembered(WinClient &winclient, Attribute attrib) {
1132 case REM_STUCKSTATE: 1131 case REM_STUCKSTATE:
1133 return app->stuckstate_remember; 1132 return app->stuckstate_remember;
1134 break; 1133 break;
1135 case REM_FOCUSNEWWINDOW:
1136 return app->focusnewwindow_remember;
1137 break;
1138 case REM_FOCUSPROTECTION: 1134 case REM_FOCUSPROTECTION:
1139 return app->focusprotection_remember; 1135 return app->focusprotection_remember;
1140 break; 1136 break;
@@ -1218,9 +1214,6 @@ void Remember::rememberAttrib(WinClient &winclient, Attribute attrib) {
1218 case REM_STUCKSTATE: 1214 case REM_STUCKSTATE:
1219 app->rememberStuckstate(win->isStuck()); 1215 app->rememberStuckstate(win->isStuck());
1220 break; 1216 break;
1221 case REM_FOCUSNEWWINDOW:
1222 app->rememberFocusNewWindow(win->isFocusNew());
1223 break;
1224 case REM_FOCUSPROTECTION: 1217 case REM_FOCUSPROTECTION:
1225 app->rememberFocusProtection(win->focusProtection()); 1218 app->rememberFocusProtection(win->focusProtection());
1226 break; 1219 break;
@@ -1284,9 +1277,6 @@ void Remember::forgetAttrib(WinClient &winclient, Attribute attrib) {
1284 case REM_STUCKSTATE: 1277 case REM_STUCKSTATE:
1285 app->forgetStuckstate(); 1278 app->forgetStuckstate();
1286 break; 1279 break;
1287 case REM_FOCUSNEWWINDOW:
1288 app->forgetFocusNewWindow();
1289 break;
1290 case REM_FOCUSPROTECTION: 1280 case REM_FOCUSPROTECTION:
1291 app->forgetFocusProtection(); 1281 app->forgetFocusProtection();
1292 break; 1282 break;
@@ -1413,9 +1403,6 @@ void Remember::setupFrame(FluxboxWindow &win) {
1413 (!win.isStuck() && app->stuckstate)) 1403 (!win.isStuck() && app->stuckstate))
1414 win.stick(); // toggles 1404 win.stick(); // toggles
1415 1405
1416 if (app->focusnewwindow_remember)
1417 win.setFocusNew(app->focusnewwindow);
1418
1419 if (app->focusprotection_remember) { 1406 if (app->focusprotection_remember) {
1420 win.setFocusProtection(app->focusprotection); 1407 win.setFocusProtection(app->focusprotection);
1421 } 1408 }
diff --git a/src/Remember.hh b/src/Remember.hh
index 59fb1d3..fe33192 100644
--- a/src/Remember.hh
+++ b/src/Remember.hh
@@ -74,7 +74,6 @@ public:
74 REM_MINIMIZEDSTATE, 74 REM_MINIMIZEDSTATE,
75 REM_MAXIMIZEDSTATE, 75 REM_MAXIMIZEDSTATE,
76 REM_FULLSCREENSTATE, 76 REM_FULLSCREENSTATE,
77 REM_FOCUSNEWWINDOW,
78 REM_FOCUSPROTECTION, 77 REM_FOCUSPROTECTION,
79 REM_LASTATTRIB // not actually used 78 REM_LASTATTRIB // not actually used
80 }; 79 };
diff --git a/src/Window.cc b/src/Window.cc
index 929cec8..37fb6c4 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -290,7 +290,6 @@ FluxboxWindow::FluxboxWindow(WinClient &client):
290 m_old_decoration_mask(0), 290 m_old_decoration_mask(0),
291 m_client(&client), 291 m_client(&client),
292 m_toggled_decos(false), 292 m_toggled_decos(false),
293 m_focus_new(BoolAcc(screen().focusControl(), &FocusControl::focusNew)),
294 m_focus_protection(Focus::NoProtection), 293 m_focus_protection(Focus::NoProtection),
295 m_mouse_focus(BoolAcc(screen().focusControl(), &FocusControl::isMouseFocus)), 294 m_mouse_focus(BoolAcc(screen().focusControl(), &FocusControl::isMouseFocus)),
296 m_click_focus(true), 295 m_click_focus(true),
@@ -563,7 +562,7 @@ void FluxboxWindow::init() {
563 deiconify(false); 562 deiconify(false);
564 // check if we should prevent this window from gaining focus 563 // check if we should prevent this window from gaining focus
565 m_focused = false; // deiconify sets this 564 m_focused = false; // deiconify sets this
566 if (!Fluxbox::instance()->isStartup() && m_focus_new) { 565 if (!Fluxbox::instance()->isStartup() && isFocusNew()) {
567 Focus::Protection fp = m_focus_protection; 566 Focus::Protection fp = m_focus_protection;
568 m_focus_protection &= ~Focus::Deny; // new windows run as "Refuse" 567 m_focus_protection &= ~Focus::Deny; // new windows run as "Refuse"
569 m_focused = focusRequestFromClient(*m_client); 568 m_focused = focusRequestFromClient(*m_client);
@@ -658,9 +657,9 @@ void FluxboxWindow::attachClient(WinClient &client, int x, int y) {
658 bool is_startup = Fluxbox::instance()->isStartup(); 657 bool is_startup = Fluxbox::instance()->isStartup();
659 658
660 // we use m_focused as a signal to focus the window when mapped 659 // we use m_focused as a signal to focus the window when mapped
661 if (m_focus_new && !is_startup) 660 if (isFocusNew() && !is_startup)
662 m_focused = focusRequestFromClient(client); 661 m_focused = focusRequestFromClient(client);
663 focused_win = (m_focus_new || is_startup) ? &client : m_client; 662 focused_win = (isFocusNew() || is_startup) ? &client : m_client;
664 663
665 m_clientlist.push_back(&client); 664 m_clientlist.push_back(&client);
666 } 665 }
@@ -1025,6 +1024,14 @@ bool FluxboxWindow::isGroupable() const {
1025 return false; 1024 return false;
1026} 1025}
1027 1026
1027bool FluxboxWindow::isFocusNew() const {
1028 if (m_focus_protection & Focus::Gain)
1029 return true;
1030 if (m_focus_protection & Focus::Refuse)
1031 return false;
1032 return screen().focusControl().focusNew();
1033}
1034
1028void FluxboxWindow::associateClientWindow() { 1035void FluxboxWindow::associateClientWindow() {
1029 frame().setShapingClient(m_client, false); 1036 frame().setShapingClient(m_client, false);
1030 1037
@@ -1432,7 +1439,7 @@ void FluxboxWindow::deiconify(bool do_raise) {
1432 // but not on startup: focus will be handled after creating everything 1439 // but not on startup: focus will be handled after creating everything
1433 // we use m_focused as a signal to focus the window when mapped 1440 // we use m_focused as a signal to focus the window when mapped
1434 if (screen().currentWorkspace()->numberOfWindows() == 1 || 1441 if (screen().currentWorkspace()->numberOfWindows() == 1 ||
1435 m_focus_new || m_client->isTransient()) 1442 isFocusNew() || m_client->isTransient())
1436 m_focused = true; 1443 m_focused = true;
1437 1444
1438 oplock = false; 1445 oplock = false;
@@ -2027,7 +2034,7 @@ void FluxboxWindow::mapRequestEvent(XMapRequestEvent &re) {
2027 setCurrentClient(*client, false); // focus handled on MapNotify 2034 setCurrentClient(*client, false); // focus handled on MapNotify
2028 deiconify(); 2035 deiconify();
2029 2036
2030 if (m_focus_new) { 2037 if (isFocusNew()) {
2031 m_focused = false; // deiconify sets this 2038 m_focused = false; // deiconify sets this
2032 Focus::Protection fp = m_focus_protection; 2039 Focus::Protection fp = m_focus_protection;
2033 m_focus_protection &= ~Focus::Deny; // goes by "Refuse" 2040 m_focus_protection &= ~Focus::Deny; // goes by "Refuse"
diff --git a/src/Window.hh b/src/Window.hh
index 706f8ed..4235106 100644
--- a/src/Window.hh
+++ b/src/Window.hh
@@ -267,7 +267,12 @@ public:
267 /// sets the window icon hidden state 267 /// sets the window icon hidden state
268 void setIconHidden(bool value); 268 void setIconHidden(bool value);
269 /// sets whether or not the window normally gets focus when mapped 269 /// sets whether or not the window normally gets focus when mapped
270 void setFocusNew(bool value) { m_focus_new = value; } 270 void setFocusNew(bool value) {
271 if (value)
272 m_focus_protection = (m_focus_protection & ~Focus::Refuse) | Focus::Gain;
273 else
274 m_focus_protection = (m_focus_protection & ~Focus::Gain) | Focus::Refuse;
275 }
271 /// sets how to protect the focus on or against this window 276 /// sets how to protect the focus on or against this window
272 void setFocusProtection(Focus::Protection value) { m_focus_protection = value; } 277 void setFocusProtection(Focus::Protection value) { m_focus_protection = value; }
273 /// sets whether or not the window gets focused with mouse 278 /// sets whether or not the window gets focused with mouse
@@ -397,7 +402,7 @@ public:
397 bool isClosable() const { return functions.close; } 402 bool isClosable() const { return functions.close; }
398 bool isMoveable() const { return functions.move; } 403 bool isMoveable() const { return functions.move; }
399 bool isStuck() const { return m_state.stuck; } 404 bool isStuck() const { return m_state.stuck; }
400 bool isFocusNew() const { return m_focus_new; } 405 bool isFocusNew() const;
401 Focus::Protection focusProtection() const { return m_focus_protection; } 406 Focus::Protection focusProtection() const { return m_focus_protection; }
402 bool hasTitlebar() const { return decorations.titlebar; } 407 bool hasTitlebar() const { return decorations.titlebar; }
403 bool isMoving() const { return moving; } 408 bool isMoving() const { return moving; }
@@ -586,7 +591,6 @@ private:
586 591
587 typedef FbTk::ConstObjectAccessor<bool, FocusControl> BoolAcc; 592 typedef FbTk::ConstObjectAccessor<bool, FocusControl> BoolAcc;
588 /// if the window is normally focused when mapped 593 /// if the window is normally focused when mapped
589 FbTk::DefaultValue<bool, BoolAcc> m_focus_new;
590 /// special focus permissions 594 /// special focus permissions
591 Focus::Protection m_focus_protection; 595 Focus::Protection m_focus_protection;
592 /// if the window is focused with EnterNotify 596 /// if the window is focused with EnterNotify