From 5f9f2475b72e977fa96214e368c34c588b265888 Mon Sep 17 00:00:00 2001 From: Mark Tiefenbruck Date: Sun, 28 Jun 2009 10:15:06 -0700 Subject: make Raise/LowerLayer accept integer argument for number of layers, default 2 --- ChangeLog | 2 ++ doc/asciidoc/fluxbox-keys.txt | 2 +- doc/fluxbox-keys.5.in | 2 +- src/CurrentWindowCmd.cc | 25 +++++++++++++++++++------ src/CurrentWindowCmd.hh | 11 +++++++++++ src/Window.cc | 9 ++------- src/Window.hh | 3 +-- 7 files changed, 37 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 925e20e..da33f82 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ (Format: Year/Month/Day) Changes for 1.1.2 *09/06/28: + * Make Raise/LowerLayer commands accept integer argument, defualt 2 (Mark) + CurrentWindowCmd.cc/hh Window.cc/hh * Change default toolbar head to 1 (Mark) Toolbar.cc * Add window menu and alt-tab to error case for keys file (Mark) diff --git a/doc/asciidoc/fluxbox-keys.txt b/doc/asciidoc/fluxbox-keys.txt index ae9abb0..58f59b1 100644 --- a/doc/asciidoc/fluxbox-keys.txt +++ b/doc/asciidoc/fluxbox-keys.txt @@ -195,7 +195,7 @@ These commands ordinarily affect only the currently focused window. The Reorder this window to the top or bottom of the window stack, within its current layer. See 'fluxbox(1)' for a discussion of layers. -*RaiseLayer* / *LowerLayer*:: +*RaiseLayer* / *LowerLayer* ['offset']:: Raise the window up to the layer above, or lower it to the layer below. See 'fluxbox(1)' for a discussion of layers. diff --git a/doc/fluxbox-keys.5.in b/doc/fluxbox-keys.5.in index f1ee22f..1420162 100644 --- a/doc/fluxbox-keys.5.in +++ b/doc/fluxbox-keys.5.in @@ -278,7 +278,7 @@ Reorder this window to the top or bottom of the window stack, within its current for a discussion of layers\&. .RE .PP -\fBRaiseLayer\fR / \fBLowerLayer\fR +\fBRaiseLayer\fR / \fBLowerLayer\fR [\fIoffset\fR] .RS 4 Raise the window up to the layer above, or lower it to the layer below\&. See \fIfluxbox(1)\fR diff --git a/src/CurrentWindowCmd.cc b/src/CurrentWindowCmd.cc index dfb5c19..6cb5c08 100644 --- a/src/CurrentWindowCmd.cc +++ b/src/CurrentWindowCmd.cc @@ -52,12 +52,8 @@ FbTk::Command *createCurrentWindowCmd(const std::string &command, return new CurrentWindowCmd(&FluxboxWindow::maximizeHorizontal); else if (command == "raise") return new CurrentWindowCmd(&FluxboxWindow::raise); - else if (command == "raiselayer") - return new CurrentWindowCmd(&FluxboxWindow::raiseLayer); else if (command == "lower") return new CurrentWindowCmd(&FluxboxWindow::lower); - else if (command == "lowerlayer") - return new CurrentWindowCmd(&FluxboxWindow::lowerLayer); else if (command == "close") return new CurrentWindowCmd(&FluxboxWindow::close); else if (command == "killwindow" || command == "kill") @@ -95,9 +91,7 @@ REGISTER_COMMAND_PARSER(maximize, createCurrentWindowCmd, void); REGISTER_COMMAND_PARSER(maximizevertical, createCurrentWindowCmd, void); REGISTER_COMMAND_PARSER(maximizehorizontal, createCurrentWindowCmd, void); REGISTER_COMMAND_PARSER(raise, createCurrentWindowCmd, void); -REGISTER_COMMAND_PARSER(raiselayer, createCurrentWindowCmd, void); REGISTER_COMMAND_PARSER(lower, createCurrentWindowCmd, void); -REGISTER_COMMAND_PARSER(lowerlayer, createCurrentWindowCmd, void); REGISTER_COMMAND_PARSER(close, createCurrentWindowCmd, void); REGISTER_COMMAND_PARSER(killwindow, createCurrentWindowCmd, void); REGISTER_COMMAND_PARSER(kill, createCurrentWindowCmd, void); @@ -466,6 +460,25 @@ void SetLayerCmd::real_execute() { fbwindow().moveToLayer(m_layer); } +FbTk::Command *ChangeLayerCmd::parse(const string &command, + const string &args, bool trusted) { + int num = 2; + FbTk_istringstream iss(args.c_str()); + iss >> num; + if (command == "raiselayer") + return new ChangeLayerCmd(-num); + else if (command == "lowerlayer") + return new ChangeLayerCmd(num); + return 0; +} + +REGISTER_COMMAND_PARSER(raiselayer, ChangeLayerCmd::parse, void); +REGISTER_COMMAND_PARSER(lowerlayer, ChangeLayerCmd::parse, void); + +void ChangeLayerCmd::real_execute() { + fbwindow().changeLayer(m_diff); +} + namespace { class SetTitleDialog: public TextDialog, public FbTk::Observer { public: diff --git a/src/CurrentWindowCmd.hh b/src/CurrentWindowCmd.hh index 32cc5f0..edf00fa 100644 --- a/src/CurrentWindowCmd.hh +++ b/src/CurrentWindowCmd.hh @@ -255,6 +255,17 @@ private: int m_layer; }; +class ChangeLayerCmd: public WindowHelperCmd { +public: + explicit ChangeLayerCmd(int diff): m_diff(diff) { } + static FbTk::Command *parse(const std::string &command, + const std::string &args, bool trusted); +protected: + void real_execute(); +private: + int m_diff; +}; + class MatchCmd: public WindowHelperBoolCmd { public: MatchCmd(const std::string &pat): m_pat(pat.c_str()) { }; diff --git a/src/Window.cc b/src/Window.cc index 825c050..defa6cc 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -1697,15 +1697,10 @@ void FluxboxWindow::tempRaise() { } -void FluxboxWindow::raiseLayer() { - moveToLayer(m_state.layernum-1); +void FluxboxWindow::changeLayer(int diff) { + moveToLayer(m_state.layernum+diff); } -void FluxboxWindow::lowerLayer() { - moveToLayer(m_state.layernum+1); -} - - void FluxboxWindow::moveToLayer(int layernum, bool force) { #ifdef DEBUG cerr<<"FluxboxWindow("<