merge remember focusnew into focusprotection The FocusNewWindow key is still read, but not written and OVERRIDDEN in case of conflict with the FocusProtection key
@@ -97,7 +97,6 @@ void forgetDecostate() { decostate_remember = false; }
void forgetFocusHiddenstate() { focushiddenstate_remember= false; } void forgetIconHiddenstate() { iconhiddenstate_remember= false; } void forgetStuckstate() { stuckstate_remember = false; } - void forgetFocusNewWindow() { focusnewwindow_remember = false; } void forgetFocusProtection() { focusprotection_remember = false; } void forgetJumpworkspace() { jumpworkspace_remember = false; } void forgetLayer() { layer_remember = false; }@@ -139,8 +138,6 @@ void rememberDecostate(unsigned int state)
{ decostate = state; decostate_remember = true; } void rememberStuckstate(bool state) { stuckstate = state; stuckstate_remember = true; } - void rememberFocusNewWindow(bool state) - { focusnewwindow = state; focusnewwindow_remember = true; } void rememberFocusProtection(unsigned int protect) { focusprotection = protect; focusprotection_remember = true; } void rememberJumpworkspace(bool state)@@ -191,9 +188,6 @@
bool stuckstate_remember; bool stuckstate; - bool focusnewwindow_remember; - bool focusnewwindow; - bool focusprotection_remember; unsigned int focusprotection;@@ -247,7 +241,6 @@ layer_remember =
position_remember = shadedstate_remember = stuckstate_remember = - focusnewwindow_remember = focusprotection_remember = tabstate_remember = workspace_remember =@@ -436,6 +429,8 @@ // optionally can give a line to read before the first (lookahead line)
int parseApp(ifstream &file, Application &app, string *first_line = 0) { string line; _FB_USES_NLS; + Focus::Protection protect = Focus::NoProtection; + bool remember_protect = false; int row = 0; while (! file.eof()) { if (!(first_line || getline(file, line))) {@@ -555,9 +550,15 @@ }
} else if (str_key == "sticky") { app.rememberStuckstate(str_label == "yes"); } else if (str_key == "focusnewwindow") { - app.rememberFocusNewWindow(str_label == "yes"); + remember_protect = true; + if (!(protect & (Focus::Gain|Focus::Refuse))) { // cut back on contradiction + if (str_label == "yes") + protect |= Focus::Gain; + else + protect |= Focus::Refuse; + } } else if (str_key == "focusprotection") { - Focus::Protection protect = Focus::NoProtection; + remember_protect = true; std::list<std::string> labels; FbTk::StringUtil::stringtok(labels, str_label, ", "); std::list<std::string>::iterator it = labels.begin();@@ -575,7 +576,6 @@ protect = Focus::NoProtection;
else had_error = 1; } - app.rememberFocusProtection(protect); } else if (str_key == "minimized") { app.rememberMinimizedstate(str_label == "yes"); } else if (str_key == "maximized") {@@ -594,7 +594,7 @@ app.rememberJumpworkspace(str_label == "yes");
} else if (str_key == "close") { app.rememberSaveOnClose(str_label == "yes"); } else if (str_key == "end") { - return row; + break; } else { cerr << _FB_CONSOLETEXT(Remember, Unknown, "Unknown apps key", "apps entry type not known")<<" = " << str_key << endl; }@@ -602,6 +602,8 @@ if (had_error) {
cerr<<"Error parsing apps entry: ("<<line<<")"<<endl; } } + if (remember_protect) + app.rememberFocusProtection(protect); return row; }@@ -1033,9 +1035,6 @@ }
if (a.stuckstate_remember) { apps_file << " [Sticky]\t{" << ((a.stuckstate)?"yes":"no") << "}" << endl; } - if (a.focusnewwindow_remember) { - apps_file << " [FocusNewWindow]\t{" << ((a.focusnewwindow)?"yes":"no") << "}" << endl; - } if (a.focusprotection_remember) { apps_file << " [FocusProtection]\t{"; if (a.focusprotection == Focus::NoProtection) {@@ -1132,9 +1131,6 @@ break;
case REM_STUCKSTATE: return app->stuckstate_remember; break; - case REM_FOCUSNEWWINDOW: - return app->focusnewwindow_remember; - break; case REM_FOCUSPROTECTION: return app->focusprotection_remember; break;@@ -1218,9 +1214,6 @@ break;
case REM_STUCKSTATE: app->rememberStuckstate(win->isStuck()); break; - case REM_FOCUSNEWWINDOW: - app->rememberFocusNewWindow(win->isFocusNew()); - break; case REM_FOCUSPROTECTION: app->rememberFocusProtection(win->focusProtection()); break;@@ -1283,9 +1276,6 @@ app->forgetIconHiddenstate();
break; case REM_STUCKSTATE: app->forgetStuckstate(); - break; - case REM_FOCUSNEWWINDOW: - app->forgetFocusNewWindow(); break; case REM_FOCUSPROTECTION: app->forgetFocusProtection();@@ -1412,9 +1402,6 @@ // if inconsistent...
if ((win.isStuck() && !app->stuckstate) || (!win.isStuck() && app->stuckstate)) win.stick(); // toggles - - if (app->focusnewwindow_remember) - win.setFocusNew(app->focusnewwindow); if (app->focusprotection_remember) { win.setFocusProtection(app->focusprotection);
@@ -74,7 +74,6 @@ REM_ALPHA,
REM_MINIMIZEDSTATE, REM_MAXIMIZEDSTATE, REM_FULLSCREENSTATE, - REM_FOCUSNEWWINDOW, REM_FOCUSPROTECTION, REM_LASTATTRIB // not actually used };
@@ -290,7 +290,6 @@ m_current_state(0),
m_old_decoration_mask(0), m_client(&client), m_toggled_decos(false), - m_focus_new(BoolAcc(screen().focusControl(), &FocusControl::focusNew)), m_focus_protection(Focus::NoProtection), m_mouse_focus(BoolAcc(screen().focusControl(), &FocusControl::isMouseFocus)), m_click_focus(true),@@ -563,7 +562,7 @@ m_state.iconic = true;
deiconify(false); // check if we should prevent this window from gaining focus m_focused = false; // deiconify sets this - if (!Fluxbox::instance()->isStartup() && m_focus_new) { + if (!Fluxbox::instance()->isStartup() && isFocusNew()) { Focus::Protection fp = m_focus_protection; m_focus_protection &= ~Focus::Deny; // new windows run as "Refuse" m_focused = focusRequestFromClient(*m_client);@@ -658,9 +657,9 @@ // right now, this block only happens with new windows or on restart
bool is_startup = Fluxbox::instance()->isStartup(); // we use m_focused as a signal to focus the window when mapped - if (m_focus_new && !is_startup) + if (isFocusNew() && !is_startup) m_focused = focusRequestFromClient(client); - focused_win = (m_focus_new || is_startup) ? &client : m_client; + focused_win = (isFocusNew() || is_startup) ? &client : m_client; m_clientlist.push_back(&client); }@@ -1025,6 +1024,14 @@ return true;
return false; } +bool FluxboxWindow::isFocusNew() const { + if (m_focus_protection & Focus::Gain) + return true; + if (m_focus_protection & Focus::Refuse) + return false; + return screen().focusControl().focusNew(); +} + void FluxboxWindow::associateClientWindow() { frame().setShapingClient(m_client, false);@@ -1432,7 +1439,7 @@ // focus new, OR if it's the only window on the workspace
// but not on startup: focus will be handled after creating everything // we use m_focused as a signal to focus the window when mapped if (screen().currentWorkspace()->numberOfWindows() == 1 || - m_focus_new || m_client->isTransient()) + isFocusNew() || m_client->isTransient()) m_focused = true; oplock = false;@@ -2027,7 +2034,7 @@
setCurrentClient(*client, false); // focus handled on MapNotify deiconify(); - if (m_focus_new) { + if (isFocusNew()) { m_focused = false; // deiconify sets this Focus::Protection fp = m_focus_protection; m_focus_protection &= ~Focus::Deny; // goes by "Refuse"
@@ -267,7 +267,12 @@ void setFocusHidden(bool value);
/// sets the window icon hidden state void setIconHidden(bool value); /// sets whether or not the window normally gets focus when mapped - void setFocusNew(bool value) { m_focus_new = value; } + void setFocusNew(bool value) { + if (value) + m_focus_protection = (m_focus_protection & ~Focus::Refuse) | Focus::Gain; + else + m_focus_protection = (m_focus_protection & ~Focus::Gain) | Focus::Refuse; + } /// sets how to protect the focus on or against this window void setFocusProtection(Focus::Protection value) { m_focus_protection = value; } /// sets whether or not the window gets focused with mouse@@ -397,7 +402,7 @@ bool isResizable() const { return functions.resize; }
bool isClosable() const { return functions.close; } bool isMoveable() const { return functions.move; } bool isStuck() const { return m_state.stuck; } - bool isFocusNew() const { return m_focus_new; } + bool isFocusNew() const; Focus::Protection focusProtection() const { return m_focus_protection; } bool hasTitlebar() const { return decorations.titlebar; } bool isMoving() const { return moving; }@@ -586,7 +591,6 @@ } functions;
typedef FbTk::ConstObjectAccessor<bool, FocusControl> BoolAcc; /// if the window is normally focused when mapped - FbTk::DefaultValue<bool, BoolAcc> m_focus_new; /// special focus permissions Focus::Protection m_focus_protection; /// if the window is focused with EnterNotify