From 6ba7744f65453a2705ba1bb88ce355c4cfde9276 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Fri, 10 Dec 2004 09:49:01 +0000 Subject: Tab command, thanks Steeve Lennmark, steeve dot lennmark at mediasvar dot se --- src/CurrentWindowCmd.cc | 12 ++++++++++++ src/CurrentWindowCmd.hh | 10 ++++++++++ src/FbCommandFactory.cc | 9 ++++++++- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/CurrentWindowCmd.cc b/src/CurrentWindowCmd.cc index e68ec8f..a07dbb2 100644 --- a/src/CurrentWindowCmd.cc +++ b/src/CurrentWindowCmd.cc @@ -60,6 +60,18 @@ void SendToPrevWorkspaceCmd::real_execute() { fbwindow().screen().sendToWorkspace(workspace_num, &fbwindow()); } +void GoToTabCmd::real_execute() { + if (fbwindow().numClients() <= 1 || m_tab_num > fbwindow().numClients()) + return; + + FluxboxWindow::ClientList::iterator it = fbwindow().clientList().begin(); + + int num = m_tab_num; + while (--num > 0) ++it; + + fbwindow().setCurrentClient(**it, true); +} + void WindowHelperCmd::execute() { WinClient *client = Fluxbox::instance()->getFocusedWindow(); if (client && client->fbwindow()) // guarantee that fbwindow() exists too diff --git a/src/CurrentWindowCmd.hh b/src/CurrentWindowCmd.hh index 2bc2c81..9b8e8fb 100644 --- a/src/CurrentWindowCmd.hh +++ b/src/CurrentWindowCmd.hh @@ -87,6 +87,16 @@ private: const int m_workspace_num; }; +// goto tab +class GoToTabCmd: public WindowHelperCmd { +public: + explicit GoToTabCmd(int tab_num):m_tab_num(tab_num) { } +protected: + void real_execute(); +private: + const int m_tab_num; +}; + // move cmd, relative position class MoveCmd: public WindowHelperCmd { public: diff --git a/src/FbCommandFactory.cc b/src/FbCommandFactory.cc index 5c0794e..a70e09b 100644 --- a/src/FbCommandFactory.cc +++ b/src/FbCommandFactory.cc @@ -131,6 +131,7 @@ FbCommandFactory::FbCommandFactory() { "showdesktop", "stick", "stickwindow", + "tab", "toggledecor", "windowmenu", "workspace", @@ -286,7 +287,13 @@ FbTk::Command *FbCommandFactory::stringToCommand(const std::string &command, return new SendToPrevWorkspaceCmd(atoi(arguments.c_str())); else if (command == "killwindow" || command == "kill") return new KillWindowCmd(); - else if (command == "nexttab") + else if (command == "tab") { + // XXX + int num = 1; + if (!arguments.empty()) + num = atoi(arguments.c_str()); + return new GoToTabCmd(num); + } else if (command == "nexttab") return new CurrentWindowCmd(&FluxboxWindow::nextClient); else if (command == "prevtab") return new CurrentWindowCmd(&FluxboxWindow::prevClient); -- cgit v0.11.2