From 07d8fbfba806e10d8e57629b0ade029989c0b9d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20L=C3=BCbking?= Date: Sun, 26 Jun 2016 12:09:28 +0200 Subject: merge remember focusnew into focusprotection The FocusNewWindow key is still read, but not written and OVERRIDDEN in case of conflict with the FocusProtection key --- src/Remember.cc | 39 +++++++++++++-------------------------- src/Remember.hh | 1 - src/Window.cc | 19 +++++++++++++------ src/Window.hh | 10 +++++++--- 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: 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 @@ public: { 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 @@ public: bool stuckstate_remember; bool stuckstate; - bool focusnewwindow_remember; - bool focusnewwindow; - bool focusprotection_remember; unsigned int focusprotection; @@ -247,7 +241,6 @@ void Application::reset() { position_remember = shadedstate_remember = stuckstate_remember = - focusnewwindow_remember = focusprotection_remember = tabstate_remember = workspace_remember = @@ -436,6 +429,8 @@ bool handleStartupItem(const string &line, int offset) { 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 @@ int parseApp(ifstream &file, Application &app, string *first_line = 0) { } 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 labels; FbTk::StringUtil::stringtok(labels, str_label, ", "); std::list::iterator it = labels.begin(); @@ -575,7 +576,6 @@ int parseApp(ifstream &file, Application &app, string *first_line = 0) { 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 @@ int parseApp(ifstream &file, Application &app, string *first_line = 0) { } 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 @@ int parseApp(ifstream &file, Application &app, string *first_line = 0) { cerr<<"Error parsing apps entry: ("<stuckstate_remember; break; - case REM_FOCUSNEWWINDOW: - return app->focusnewwindow_remember; - break; case REM_FOCUSPROTECTION: return app->focusprotection_remember; break; @@ -1218,9 +1214,6 @@ void Remember::rememberAttrib(WinClient &winclient, Attribute attrib) { case REM_STUCKSTATE: app->rememberStuckstate(win->isStuck()); break; - case REM_FOCUSNEWWINDOW: - app->rememberFocusNewWindow(win->isFocusNew()); - break; case REM_FOCUSPROTECTION: app->rememberFocusProtection(win->focusProtection()); break; @@ -1284,9 +1277,6 @@ void Remember::forgetAttrib(WinClient &winclient, Attribute attrib) { case REM_STUCKSTATE: app->forgetStuckstate(); break; - case REM_FOCUSNEWWINDOW: - app->forgetFocusNewWindow(); - break; case REM_FOCUSPROTECTION: app->forgetFocusProtection(); break; @@ -1413,9 +1403,6 @@ void Remember::setupFrame(FluxboxWindow &win) { (!win.isStuck() && app->stuckstate)) win.stick(); // toggles - if (app->focusnewwindow_remember) - win.setFocusNew(app->focusnewwindow); - if (app->focusprotection_remember) { win.setFocusProtection(app->focusprotection); } 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: REM_MINIMIZEDSTATE, REM_MAXIMIZEDSTATE, REM_FULLSCREENSTATE, - REM_FOCUSNEWWINDOW, REM_FOCUSPROTECTION, REM_LASTATTRIB // not actually used }; 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): 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 @@ void FluxboxWindow::init() { 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 @@ void FluxboxWindow::attachClient(WinClient &client, int x, int y) { 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 @@ bool FluxboxWindow::isGroupable() const { 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 @@ void FluxboxWindow::deiconify(bool do_raise) { // 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 @@ void FluxboxWindow::mapRequestEvent(XMapRequestEvent &re) { 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" 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: /// 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 @@ public: 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 @@ private: typedef FbTk::ConstObjectAccessor BoolAcc; /// if the window is normally focused when mapped - FbTk::DefaultValue m_focus_new; /// special focus permissions Focus::Protection m_focus_protection; /// if the window is focused with EnterNotify -- cgit v0.11.2