Tab command, thanks Steeve Lennmark, steeve dot lennmark at mediasvar dot se

This commit is contained in:
fluxgen 2004-12-10 09:49:01 +00:00
parent cc486c194f
commit 6ba7744f65
3 changed files with 30 additions and 1 deletions

View file

@ -60,6 +60,18 @@ void SendToPrevWorkspaceCmd::real_execute() {
fbwindow().screen().sendToWorkspace(workspace_num, &fbwindow()); 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() { void WindowHelperCmd::execute() {
WinClient *client = Fluxbox::instance()->getFocusedWindow(); WinClient *client = Fluxbox::instance()->getFocusedWindow();
if (client && client->fbwindow()) // guarantee that fbwindow() exists too if (client && client->fbwindow()) // guarantee that fbwindow() exists too

View file

@ -87,6 +87,16 @@ private:
const int m_workspace_num; 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 // move cmd, relative position
class MoveCmd: public WindowHelperCmd { class MoveCmd: public WindowHelperCmd {
public: public:

View file

@ -131,6 +131,7 @@ FbCommandFactory::FbCommandFactory() {
"showdesktop", "showdesktop",
"stick", "stick",
"stickwindow", "stickwindow",
"tab",
"toggledecor", "toggledecor",
"windowmenu", "windowmenu",
"workspace", "workspace",
@ -286,7 +287,13 @@ FbTk::Command *FbCommandFactory::stringToCommand(const std::string &command,
return new SendToPrevWorkspaceCmd(atoi(arguments.c_str())); return new SendToPrevWorkspaceCmd(atoi(arguments.c_str()));
else if (command == "killwindow" || command == "kill") else if (command == "killwindow" || command == "kill")
return new KillWindowCmd(); 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); return new CurrentWindowCmd(&FluxboxWindow::nextClient);
else if (command == "prevtab") else if (command == "prevtab")
return new CurrentWindowCmd(&FluxboxWindow::prevClient); return new CurrentWindowCmd(&FluxboxWindow::prevClient);