From c5fb252a6f75c6a07a90ea49623de259db2cbeb4 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Thu, 22 Apr 2004 21:12:34 +0000 Subject: deiconify cmd, patch from Mathias Gumz --- src/FbCommandFactory.cc | 37 +++++++++++++++++++++++++++++++++-- src/FbCommands.cc | 51 ++++++++++++++++++++++++++++++++++++++++++++++++- src/FbCommands.hh | 26 ++++++++++++++++++++++++- 3 files changed, 110 insertions(+), 4 deletions(-) diff --git a/src/FbCommandFactory.cc b/src/FbCommandFactory.cc index ee22b28..9853b50 100644 --- a/src/FbCommandFactory.cc +++ b/src/FbCommandFactory.cc @@ -20,7 +20,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: FbCommandFactory.cc,v 1.28 2004/03/08 12:23:16 rathnor Exp $ +// $Id: FbCommandFactory.cc,v 1.29 2004/04/22 21:12:34 fluxgen Exp $ #include "FbCommandFactory.hh" @@ -64,6 +64,7 @@ FbCommandFactory::FbCommandFactory() { "bindkey", "close", "commanddialog", + "deiconify", "detachclient", "exec", "execcommand", @@ -298,7 +299,39 @@ FbTk::Command *FbCommandFactory::stringToCommand(const std::string &command, // // special commands // - else if (command == "macrocmd") { + else if (command == "deiconify") { + + FB_istringstream iss(arguments); + string mode; + string d; + DeiconifyCmd::Destination dest; + + iss >> mode; + if (iss.fail()) + mode="lastworkspace"; + mode= FbTk::StringUtil::toLower(mode); + + iss >> d; + if (iss.fail()) + d="current"; + d= FbTk::StringUtil::toLower(d); + if (d == "origin" ) + dest= DeiconifyCmd::ORIGIN; + else if (d == "originquiet") + dest= DeiconifyCmd::ORIGINQUIET; + else + dest= DeiconifyCmd::CURRENT; + + if ( mode == "all" ) + return new DeiconifyCmd(DeiconifyCmd::ALL, dest); + else if ( mode == "allworkspace" ) + return new DeiconifyCmd(DeiconifyCmd::ALLWORKSPACE, dest); + else if ( mode == "last" ) + return new DeiconifyCmd(DeiconifyCmd::LAST, dest); + else // lastworkspace, default + return new DeiconifyCmd(DeiconifyCmd::LASTWORKSPACE, dest); + + } else if (command == "macrocmd") { std::string cmd; int err= 0; int parse_pos= 0; diff --git a/src/FbCommands.cc b/src/FbCommands.cc index 99c8eca..e7d1986 100644 --- a/src/FbCommands.cc +++ b/src/FbCommands.cc @@ -19,13 +19,14 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: FbCommands.cc,v 1.23 2004/01/21 14:11:15 fluxgen Exp $ +// $Id: FbCommands.cc,v 1.24 2004/04/22 21:12:32 fluxgen Exp $ #include "FbCommands.hh" #include "fluxbox.hh" #include "Screen.hh" #include "CommandDialog.hh" #include "Workspace.hh" +#include "Window.hh" #include "Keys.hh" #include "FbTk/Theme.hh" @@ -249,4 +250,52 @@ void BindKeyCmd::execute() { } } +DeiconifyCmd::DeiconifyCmd(const Mode mode, + const Destination dest) : m_mode(mode), m_dest(dest) { } + +void DeiconifyCmd::execute() { + BScreen *screen = Fluxbox::instance()->mouseScreen(); + if (screen == 0) + return; + + BScreen::Icons::reverse_iterator it= screen->getIconList().rbegin(); + BScreen::Icons::reverse_iterator itend= screen->getIconList().rend(); + unsigned int workspace_num= screen->currentWorkspaceID(); + unsigned int old_workspace_num; + + const bool change_ws= m_dest == ORIGIN; + + switch(m_mode) { + + case ALL: + case ALLWORKSPACE: + for(; it != itend; it++) { + old_workspace_num= (*it)->workspaceNumber(); + if (m_mode == ALL || old_workspace_num == workspace_num) { + if (m_dest == ORIGIN || m_dest == ORIGINQUIET) + screen->sendToWorkspace(old_workspace_num, (*it), change_ws); + else + (*it)->deiconify(false); + } + } + break; + + case LAST: + case LASTWORKSPACE: + default: + for (; it != itend; it++) { + old_workspace_num= (*it)->workspaceNumber(); + if(m_mode == LAST || old_workspace_num == workspace_num) { + if ((m_dest == ORIGIN || m_dest == ORIGINQUIET) && + m_mode != LASTWORKSPACE) + screen->sendToWorkspace(old_workspace_num, (*it), change_ws); + else + (*it)->deiconify(false); + break; + } + } + break; + }; +} + }; // end namespace FbCommands diff --git a/src/FbCommands.hh b/src/FbCommands.hh index f65869e..bc67610 100644 --- a/src/FbCommands.hh +++ b/src/FbCommands.hh @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: FbCommands.hh,v 1.18 2004/03/16 18:44:40 fluxgen Exp $ +// $Id: FbCommands.hh,v 1.19 2004/04/22 21:12:33 fluxgen Exp $ // \file contains basic commands to restart, reconfigure, execute command and exit fluxbox @@ -135,4 +135,28 @@ private: const std::string m_keybind; }; +/// deiconifies iconified windows +class DeiconifyCmd: public FbTk::Command { +public: + enum Mode { + LAST, + LASTWORKSPACE, + ALL, + ALLWORKSPACE + }; + + enum Destination { + CURRENT, /// deiconification on current workspace + ORIGIN, /// deiconification on origin workspace, change to that ws + ORIGINQUIET /// deiconification on origin workspace, dont change ws + }; + + DeiconifyCmd(const Mode mode= LASTWORKSPACE, + const Destination dest= CURRENT); + void execute(); +private: + Mode m_mode; + Destination m_dest; +}; + #endif // FBCOMMANDS_HH -- cgit v0.11.2