From fc192b1161bf9d1ca0ca9a35397c99ee1a41c7f3 Mon Sep 17 00:00:00 2001 From: Peter Hercek Date: Thu, 3 Feb 2011 18:50:17 +0100 Subject: allow to override 'FocusNewWindow' via .fluxbox/apps --- doc/asciidoc/fluxbox-apps.txt | 4 ++++ src/Remember.cc | 24 ++++++++++++++++++++++++ src/Remember.hh | 1 + src/Window.hh | 1 + 4 files changed, 30 insertions(+) diff --git a/doc/asciidoc/fluxbox-apps.txt b/doc/asciidoc/fluxbox-apps.txt index c278962..cf27987 100644 --- a/doc/asciidoc/fluxbox-apps.txt +++ b/doc/asciidoc/fluxbox-apps.txt @@ -156,6 +156,10 @@ enabled, Focus Enabled. *[Tab]* {'bool'}:: Whether the window has tabs enabled. +*[FocusNewWindow]* {'bool'}:: + If enabled, a new window will grab X focus as soon as it is opened. + If disabled, a new window will not grab X focus as soon as it is opened. + *[FocusHidden]* {'bool'}:: If enabled, the window will not appear in 'NextWindow'/'PrevWindow' lists. diff --git a/src/Remember.cc b/src/Remember.cc index b94b2e6..a9be4bc 100644 --- a/src/Remember.cc +++ b/src/Remember.cc @@ -86,6 +86,7 @@ public: void forgetFocusHiddenstate() { focushiddenstate_remember= false; } void forgetIconHiddenstate() { iconhiddenstate_remember= false; } void forgetStuckstate() { stuckstate_remember = false; } + void forgetFocusNewWindow() { focusnewwindow_remember = false; } void forgetJumpworkspace() { jumpworkspace_remember = false; } void forgetLayer() { layer_remember = false; } void forgetSaveOnClose() { save_on_close_remember = false; } @@ -115,6 +116,8 @@ 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 rememberJumpworkspace(bool state) { jumpworkspace = state; jumpworkspace_remember = true; } void rememberLayer(int layernum) @@ -159,6 +162,9 @@ public: bool stuckstate_remember; bool stuckstate; + bool focusnewwindow_remember; + bool focusnewwindow; + bool focushiddenstate_remember; bool focushiddenstate; @@ -209,6 +215,7 @@ void Application::reset() { position_remember = shadedstate_remember = stuckstate_remember = + focusnewwindow_remember = tabstate_remember = workspace_remember = head_remember = @@ -527,6 +534,8 @@ int parseApp(ifstream &file, Application &app, string *first_line = 0) { } } else if (str_key == "sticky") { app.rememberStuckstate((strcasecmp(str_label.c_str(), "yes") == 0)); + } else if (str_key == "focusnewwindow") { + app.rememberFocusNewWindow((strcasecmp(str_label.c_str(), "yes") == 0)); } else if (str_key == "minimized") { app.rememberMinimizedstate((strcasecmp(str_label.c_str(), "yes") == 0)); } else if (str_key == "maximized") { @@ -981,6 +990,9 @@ void Remember::save() { 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.minimizedstate_remember) { apps_file << " [Minimized]\t{" << ((a.minimizedstate)?"yes":"no") << "}" << endl; } @@ -1052,6 +1064,9 @@ bool Remember::isRemembered(WinClient &winclient, Attribute attrib) { case REM_STUCKSTATE: return app->stuckstate_remember; break; + case REM_FOCUSNEWWINDOW: + return app->focusnewwindow_remember; + break; case REM_MINIMIZEDSTATE: return app->minimizedstate_remember; break; @@ -1129,6 +1144,9 @@ 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_MINIMIZEDSTATE: app->rememberMinimizedstate(win->isIconic()); break; @@ -1189,6 +1207,9 @@ void Remember::forgetAttrib(WinClient &winclient, Attribute attrib) { case REM_STUCKSTATE: app->forgetStuckstate(); break; + case REM_FOCUSNEWWINDOW: + app->forgetFocusNewWindow(); + break; case REM_MINIMIZEDSTATE: app->forgetMinimizedstate(); break; @@ -1291,6 +1312,9 @@ void Remember::setupFrame(FluxboxWindow &win) { (!win.isStuck() && app->stuckstate)) win.stick(); // toggles + if (app->focusnewwindow_remember) + win.setFocusNew(app->focusnewwindow); + if (app->minimizedstate_remember) { // if inconsistent... // this one doesn't actually work, but I can't imagine needing it diff --git a/src/Remember.hh b/src/Remember.hh index 0adbfa9..a1abf5a 100644 --- a/src/Remember.hh +++ b/src/Remember.hh @@ -73,6 +73,7 @@ public: REM_MINIMIZEDSTATE, REM_MAXIMIZEDSTATE, REM_FULLSCREENSTATE, + REM_FOCUSNEWWINDOW, REM_LASTATTRIB // not actually used }; diff --git a/src/Window.hh b/src/Window.hh index 7f8133e..8ce9563 100644 --- a/src/Window.hh +++ b/src/Window.hh @@ -387,6 +387,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 hasTitlebar() const { return decorations.titlebar; } bool isMoving() const { return moving; } bool isResizing() const { return resizing; } -- cgit v0.11.2