deiconify cmd, patch from Mathias Gumz
fluxgen fluxgen
3 files changed,
110 insertions(+),
4 deletions(-)
M
src/FbCommandFactory.cc
→
src/FbCommandFactory.cc
@@ -20,7 +20,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// 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 @@ "arrangewindows",
"bindkey", "close", "commanddialog", + "deiconify", "detachclient", "exec", "execcommand",@@ -298,7 +299,39 @@ return new WorkspaceNameDialogCmd();
// // 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;
M
src/FbCommands.cc
→
src/FbCommands.cc
@@ -19,13 +19,14 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// 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 @@ }
} } +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
M
src/FbCommands.hh
→
src/FbCommands.hh
@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// 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@@ -133,6 +133,30 @@ BindKeyCmd(const std::string &keybind);
void execute(); 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