merge remember focusnew into focusprotection
The FocusNewWindow key is still read, but not written and OVERRIDDEN in case of conflict with the FocusProtection key
This commit is contained in:
parent
1a61881ec3
commit
07d8fbfba8
4 changed files with 33 additions and 36 deletions
|
@ -97,7 +97,6 @@ public:
|
||||||
void forgetFocusHiddenstate() { focushiddenstate_remember= false; }
|
void forgetFocusHiddenstate() { focushiddenstate_remember= false; }
|
||||||
void forgetIconHiddenstate() { iconhiddenstate_remember= false; }
|
void forgetIconHiddenstate() { iconhiddenstate_remember= false; }
|
||||||
void forgetStuckstate() { stuckstate_remember = false; }
|
void forgetStuckstate() { stuckstate_remember = false; }
|
||||||
void forgetFocusNewWindow() { focusnewwindow_remember = false; }
|
|
||||||
void forgetFocusProtection() { focusprotection_remember = false; }
|
void forgetFocusProtection() { focusprotection_remember = false; }
|
||||||
void forgetJumpworkspace() { jumpworkspace_remember = false; }
|
void forgetJumpworkspace() { jumpworkspace_remember = false; }
|
||||||
void forgetLayer() { layer_remember = false; }
|
void forgetLayer() { layer_remember = false; }
|
||||||
|
@ -139,8 +138,6 @@ public:
|
||||||
{ decostate = state; decostate_remember = true; }
|
{ decostate = state; decostate_remember = true; }
|
||||||
void rememberStuckstate(bool state)
|
void rememberStuckstate(bool state)
|
||||||
{ stuckstate = state; stuckstate_remember = true; }
|
{ stuckstate = state; stuckstate_remember = true; }
|
||||||
void rememberFocusNewWindow(bool state)
|
|
||||||
{ focusnewwindow = state; focusnewwindow_remember = true; }
|
|
||||||
void rememberFocusProtection(unsigned int protect)
|
void rememberFocusProtection(unsigned int protect)
|
||||||
{ focusprotection = protect; focusprotection_remember = true; }
|
{ focusprotection = protect; focusprotection_remember = true; }
|
||||||
void rememberJumpworkspace(bool state)
|
void rememberJumpworkspace(bool state)
|
||||||
|
@ -191,9 +188,6 @@ public:
|
||||||
bool stuckstate_remember;
|
bool stuckstate_remember;
|
||||||
bool stuckstate;
|
bool stuckstate;
|
||||||
|
|
||||||
bool focusnewwindow_remember;
|
|
||||||
bool focusnewwindow;
|
|
||||||
|
|
||||||
bool focusprotection_remember;
|
bool focusprotection_remember;
|
||||||
unsigned int focusprotection;
|
unsigned int focusprotection;
|
||||||
|
|
||||||
|
@ -247,7 +241,6 @@ void Application::reset() {
|
||||||
position_remember =
|
position_remember =
|
||||||
shadedstate_remember =
|
shadedstate_remember =
|
||||||
stuckstate_remember =
|
stuckstate_remember =
|
||||||
focusnewwindow_remember =
|
|
||||||
focusprotection_remember =
|
focusprotection_remember =
|
||||||
tabstate_remember =
|
tabstate_remember =
|
||||||
workspace_remember =
|
workspace_remember =
|
||||||
|
@ -436,6 +429,8 @@ bool handleStartupItem(const string &line, int offset) {
|
||||||
int parseApp(ifstream &file, Application &app, string *first_line = 0) {
|
int parseApp(ifstream &file, Application &app, string *first_line = 0) {
|
||||||
string line;
|
string line;
|
||||||
_FB_USES_NLS;
|
_FB_USES_NLS;
|
||||||
|
Focus::Protection protect = Focus::NoProtection;
|
||||||
|
bool remember_protect = false;
|
||||||
int row = 0;
|
int row = 0;
|
||||||
while (! file.eof()) {
|
while (! file.eof()) {
|
||||||
if (!(first_line || getline(file, line))) {
|
if (!(first_line || getline(file, line))) {
|
||||||
|
@ -555,9 +550,15 @@ int parseApp(ifstream &file, Application &app, string *first_line = 0) {
|
||||||
} else if (str_key == "sticky") {
|
} else if (str_key == "sticky") {
|
||||||
app.rememberStuckstate(str_label == "yes");
|
app.rememberStuckstate(str_label == "yes");
|
||||||
} else if (str_key == "focusnewwindow") {
|
} 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") {
|
} else if (str_key == "focusprotection") {
|
||||||
Focus::Protection protect = Focus::NoProtection;
|
remember_protect = true;
|
||||||
std::list<std::string> labels;
|
std::list<std::string> labels;
|
||||||
FbTk::StringUtil::stringtok(labels, str_label, ", ");
|
FbTk::StringUtil::stringtok(labels, str_label, ", ");
|
||||||
std::list<std::string>::iterator it = labels.begin();
|
std::list<std::string>::iterator it = labels.begin();
|
||||||
|
@ -575,7 +576,6 @@ int parseApp(ifstream &file, Application &app, string *first_line = 0) {
|
||||||
else
|
else
|
||||||
had_error = 1;
|
had_error = 1;
|
||||||
}
|
}
|
||||||
app.rememberFocusProtection(protect);
|
|
||||||
} else if (str_key == "minimized") {
|
} else if (str_key == "minimized") {
|
||||||
app.rememberMinimizedstate(str_label == "yes");
|
app.rememberMinimizedstate(str_label == "yes");
|
||||||
} else if (str_key == "maximized") {
|
} else if (str_key == "maximized") {
|
||||||
|
@ -594,7 +594,7 @@ int parseApp(ifstream &file, Application &app, string *first_line = 0) {
|
||||||
} else if (str_key == "close") {
|
} else if (str_key == "close") {
|
||||||
app.rememberSaveOnClose(str_label == "yes");
|
app.rememberSaveOnClose(str_label == "yes");
|
||||||
} else if (str_key == "end") {
|
} else if (str_key == "end") {
|
||||||
return row;
|
break;
|
||||||
} else {
|
} else {
|
||||||
cerr << _FB_CONSOLETEXT(Remember, Unknown, "Unknown apps key", "apps entry type not known")<<" = " << str_key << endl;
|
cerr << _FB_CONSOLETEXT(Remember, Unknown, "Unknown apps key", "apps entry type not known")<<" = " << str_key << endl;
|
||||||
}
|
}
|
||||||
|
@ -602,6 +602,8 @@ int parseApp(ifstream &file, Application &app, string *first_line = 0) {
|
||||||
cerr<<"Error parsing apps entry: ("<<line<<")"<<endl;
|
cerr<<"Error parsing apps entry: ("<<line<<")"<<endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (remember_protect)
|
||||||
|
app.rememberFocusProtection(protect);
|
||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1033,9 +1035,6 @@ void Remember::save() {
|
||||||
if (a.stuckstate_remember) {
|
if (a.stuckstate_remember) {
|
||||||
apps_file << " [Sticky]\t{" << ((a.stuckstate)?"yes":"no") << "}" << endl;
|
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) {
|
if (a.focusprotection_remember) {
|
||||||
apps_file << " [FocusProtection]\t{";
|
apps_file << " [FocusProtection]\t{";
|
||||||
if (a.focusprotection == Focus::NoProtection) {
|
if (a.focusprotection == Focus::NoProtection) {
|
||||||
|
@ -1132,9 +1131,6 @@ bool Remember::isRemembered(WinClient &winclient, Attribute attrib) {
|
||||||
case REM_STUCKSTATE:
|
case REM_STUCKSTATE:
|
||||||
return app->stuckstate_remember;
|
return app->stuckstate_remember;
|
||||||
break;
|
break;
|
||||||
case REM_FOCUSNEWWINDOW:
|
|
||||||
return app->focusnewwindow_remember;
|
|
||||||
break;
|
|
||||||
case REM_FOCUSPROTECTION:
|
case REM_FOCUSPROTECTION:
|
||||||
return app->focusprotection_remember;
|
return app->focusprotection_remember;
|
||||||
break;
|
break;
|
||||||
|
@ -1218,9 +1214,6 @@ void Remember::rememberAttrib(WinClient &winclient, Attribute attrib) {
|
||||||
case REM_STUCKSTATE:
|
case REM_STUCKSTATE:
|
||||||
app->rememberStuckstate(win->isStuck());
|
app->rememberStuckstate(win->isStuck());
|
||||||
break;
|
break;
|
||||||
case REM_FOCUSNEWWINDOW:
|
|
||||||
app->rememberFocusNewWindow(win->isFocusNew());
|
|
||||||
break;
|
|
||||||
case REM_FOCUSPROTECTION:
|
case REM_FOCUSPROTECTION:
|
||||||
app->rememberFocusProtection(win->focusProtection());
|
app->rememberFocusProtection(win->focusProtection());
|
||||||
break;
|
break;
|
||||||
|
@ -1284,9 +1277,6 @@ void Remember::forgetAttrib(WinClient &winclient, Attribute attrib) {
|
||||||
case REM_STUCKSTATE:
|
case REM_STUCKSTATE:
|
||||||
app->forgetStuckstate();
|
app->forgetStuckstate();
|
||||||
break;
|
break;
|
||||||
case REM_FOCUSNEWWINDOW:
|
|
||||||
app->forgetFocusNewWindow();
|
|
||||||
break;
|
|
||||||
case REM_FOCUSPROTECTION:
|
case REM_FOCUSPROTECTION:
|
||||||
app->forgetFocusProtection();
|
app->forgetFocusProtection();
|
||||||
break;
|
break;
|
||||||
|
@ -1413,9 +1403,6 @@ void Remember::setupFrame(FluxboxWindow &win) {
|
||||||
(!win.isStuck() && app->stuckstate))
|
(!win.isStuck() && app->stuckstate))
|
||||||
win.stick(); // toggles
|
win.stick(); // toggles
|
||||||
|
|
||||||
if (app->focusnewwindow_remember)
|
|
||||||
win.setFocusNew(app->focusnewwindow);
|
|
||||||
|
|
||||||
if (app->focusprotection_remember) {
|
if (app->focusprotection_remember) {
|
||||||
win.setFocusProtection(app->focusprotection);
|
win.setFocusProtection(app->focusprotection);
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,6 @@ public:
|
||||||
REM_MINIMIZEDSTATE,
|
REM_MINIMIZEDSTATE,
|
||||||
REM_MAXIMIZEDSTATE,
|
REM_MAXIMIZEDSTATE,
|
||||||
REM_FULLSCREENSTATE,
|
REM_FULLSCREENSTATE,
|
||||||
REM_FOCUSNEWWINDOW,
|
|
||||||
REM_FOCUSPROTECTION,
|
REM_FOCUSPROTECTION,
|
||||||
REM_LASTATTRIB // not actually used
|
REM_LASTATTRIB // not actually used
|
||||||
};
|
};
|
||||||
|
|
|
@ -290,7 +290,6 @@ FluxboxWindow::FluxboxWindow(WinClient &client):
|
||||||
m_old_decoration_mask(0),
|
m_old_decoration_mask(0),
|
||||||
m_client(&client),
|
m_client(&client),
|
||||||
m_toggled_decos(false),
|
m_toggled_decos(false),
|
||||||
m_focus_new(BoolAcc(screen().focusControl(), &FocusControl::focusNew)),
|
|
||||||
m_focus_protection(Focus::NoProtection),
|
m_focus_protection(Focus::NoProtection),
|
||||||
m_mouse_focus(BoolAcc(screen().focusControl(), &FocusControl::isMouseFocus)),
|
m_mouse_focus(BoolAcc(screen().focusControl(), &FocusControl::isMouseFocus)),
|
||||||
m_click_focus(true),
|
m_click_focus(true),
|
||||||
|
@ -563,7 +562,7 @@ void FluxboxWindow::init() {
|
||||||
deiconify(false);
|
deiconify(false);
|
||||||
// check if we should prevent this window from gaining focus
|
// check if we should prevent this window from gaining focus
|
||||||
m_focused = false; // deiconify sets this
|
m_focused = false; // deiconify sets this
|
||||||
if (!Fluxbox::instance()->isStartup() && m_focus_new) {
|
if (!Fluxbox::instance()->isStartup() && isFocusNew()) {
|
||||||
Focus::Protection fp = m_focus_protection;
|
Focus::Protection fp = m_focus_protection;
|
||||||
m_focus_protection &= ~Focus::Deny; // new windows run as "Refuse"
|
m_focus_protection &= ~Focus::Deny; // new windows run as "Refuse"
|
||||||
m_focused = focusRequestFromClient(*m_client);
|
m_focused = focusRequestFromClient(*m_client);
|
||||||
|
@ -658,9 +657,9 @@ void FluxboxWindow::attachClient(WinClient &client, int x, int y) {
|
||||||
bool is_startup = Fluxbox::instance()->isStartup();
|
bool is_startup = Fluxbox::instance()->isStartup();
|
||||||
|
|
||||||
// we use m_focused as a signal to focus the window when mapped
|
// 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);
|
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);
|
m_clientlist.push_back(&client);
|
||||||
}
|
}
|
||||||
|
@ -1025,6 +1024,14 @@ bool FluxboxWindow::isGroupable() const {
|
||||||
return false;
|
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() {
|
void FluxboxWindow::associateClientWindow() {
|
||||||
frame().setShapingClient(m_client, false);
|
frame().setShapingClient(m_client, false);
|
||||||
|
|
||||||
|
@ -1432,7 +1439,7 @@ void FluxboxWindow::deiconify(bool do_raise) {
|
||||||
// but not on startup: focus will be handled after creating everything
|
// but not on startup: focus will be handled after creating everything
|
||||||
// we use m_focused as a signal to focus the window when mapped
|
// we use m_focused as a signal to focus the window when mapped
|
||||||
if (screen().currentWorkspace()->numberOfWindows() == 1 ||
|
if (screen().currentWorkspace()->numberOfWindows() == 1 ||
|
||||||
m_focus_new || m_client->isTransient())
|
isFocusNew() || m_client->isTransient())
|
||||||
m_focused = true;
|
m_focused = true;
|
||||||
|
|
||||||
oplock = false;
|
oplock = false;
|
||||||
|
@ -2027,7 +2034,7 @@ void FluxboxWindow::mapRequestEvent(XMapRequestEvent &re) {
|
||||||
setCurrentClient(*client, false); // focus handled on MapNotify
|
setCurrentClient(*client, false); // focus handled on MapNotify
|
||||||
deiconify();
|
deiconify();
|
||||||
|
|
||||||
if (m_focus_new) {
|
if (isFocusNew()) {
|
||||||
m_focused = false; // deiconify sets this
|
m_focused = false; // deiconify sets this
|
||||||
Focus::Protection fp = m_focus_protection;
|
Focus::Protection fp = m_focus_protection;
|
||||||
m_focus_protection &= ~Focus::Deny; // goes by "Refuse"
|
m_focus_protection &= ~Focus::Deny; // goes by "Refuse"
|
||||||
|
|
|
@ -267,7 +267,12 @@ public:
|
||||||
/// sets the window icon hidden state
|
/// sets the window icon hidden state
|
||||||
void setIconHidden(bool value);
|
void setIconHidden(bool value);
|
||||||
/// sets whether or not the window normally gets focus when mapped
|
/// 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
|
/// sets how to protect the focus on or against this window
|
||||||
void setFocusProtection(Focus::Protection value) { m_focus_protection = value; }
|
void setFocusProtection(Focus::Protection value) { m_focus_protection = value; }
|
||||||
/// sets whether or not the window gets focused with mouse
|
/// sets whether or not the window gets focused with mouse
|
||||||
|
@ -397,7 +402,7 @@ public:
|
||||||
bool isClosable() const { return functions.close; }
|
bool isClosable() const { return functions.close; }
|
||||||
bool isMoveable() const { return functions.move; }
|
bool isMoveable() const { return functions.move; }
|
||||||
bool isStuck() const { return m_state.stuck; }
|
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; }
|
Focus::Protection focusProtection() const { return m_focus_protection; }
|
||||||
bool hasTitlebar() const { return decorations.titlebar; }
|
bool hasTitlebar() const { return decorations.titlebar; }
|
||||||
bool isMoving() const { return moving; }
|
bool isMoving() const { return moving; }
|
||||||
|
@ -586,7 +591,6 @@ private:
|
||||||
|
|
||||||
typedef FbTk::ConstObjectAccessor<bool, FocusControl> BoolAcc;
|
typedef FbTk::ConstObjectAccessor<bool, FocusControl> BoolAcc;
|
||||||
/// if the window is normally focused when mapped
|
/// if the window is normally focused when mapped
|
||||||
FbTk::DefaultValue<bool, BoolAcc> m_focus_new;
|
|
||||||
/// special focus permissions
|
/// special focus permissions
|
||||||
Focus::Protection m_focus_protection;
|
Focus::Protection m_focus_protection;
|
||||||
/// if the window is focused with EnterNotify
|
/// if the window is focused with EnterNotify
|
||||||
|
|
Loading…
Reference in a new issue