aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2003-06-30 14:49:23 (GMT)
committerfluxgen <fluxgen>2003-06-30 14:49:23 (GMT)
commit5c657dabaea8b7d0f7f44c73be37662ff8eff988 (patch)
tree5306dba1010f7466c86c370388a8518e42725a7d
parentbbe279233a210fe8ef23b0d265421b8f18d2b358 (diff)
downloadfluxbox-5c657dabaea8b7d0f7f44c73be37662ff8eff988.zip
fluxbox-5c657dabaea8b7d0f7f44c73be37662ff8eff988.tar.bz2
command factory for basic fluxbox commands
-rw-r--r--src/FbCommandFactory.cc163
-rw-r--r--src/FbCommandFactory.hh35
2 files changed, 198 insertions, 0 deletions
diff --git a/src/FbCommandFactory.cc b/src/FbCommandFactory.cc
new file mode 100644
index 0000000..9c4e172
--- /dev/null
+++ b/src/FbCommandFactory.cc
@@ -0,0 +1,163 @@
1// FbCommandFactory.cc for Fluxbox Window manager
2// Copyright (c) 2003 Henrik Kinnunen (fluxgen at users.sourceforge.net)
3// and Simon Bowden (rathnor at users.sourceforge.net)
4//
5// Permission is hereby granted, free of charge, to any person obtaining a
6// copy of this software and associated documentation files (the "Software"),
7// to deal in the Software without restriction, including without limitation
8// the rights to use, copy, modify, merge, publish, distribute, sublicense,
9// and/or sell copies of the Software, and to permit persons to whom the
10// Software is furnished to do so, subject to the following conditions:
11//
12// The above copyright notice and this permission notice shall be included in
13// all copies or substantial portions of the Software.
14//
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21// DEALINGS IN THE SOFTWARE.
22
23// $Id: FbCommandFactory.cc,v 1.1 2003/06/30 14:49:23 fluxgen Exp $
24
25#include "FbCommandFactory.hh"
26
27#include "CurrentWindowCmd.hh"
28#include "FbCommands.hh"
29#include "Window.hh"
30#include "WorkspaceCmd.hh"
31#include "fluxbox.hh"
32#include "SimpleCommand.hh"
33
34// autoregister this module to command parser
35FbCommandFactory FbCommandFactory::s_autoreg;
36
37
38FbCommandFactory::FbCommandFactory() {
39 // setup commands that we can handle
40 const char commands[][20] = {
41 "execcommand",
42 "exec",
43 "execute",
44 "quit",
45 "restart",
46 "minimizewindow",
47 "minimize",
48 "iconfiy",
49 "maximizewindow",
50 "maximize",
51 "maximizevertical",
52 "maximizehorizontal",
53 "moveright",
54 "moveleft",
55 "moveup",
56 "movedown",
57 "raise",
58 "lower",
59 "close",
60 "shade",
61 "stick",
62 "sendtoworkspace",
63 "killwindow",
64 "nexttab",
65 "prevtab",
66 "detachclient",
67 "nextworkspace",
68 "prevworkspace",
69 "nextwindow",
70 "prevwindow",
71 "showdesktop",
72 "arrangewindows",
73 ""
74 };
75
76 for (int i=0;; ++i) {
77 if (strcmp(commands[i], "") == 0)
78 break;
79 addCommand(commands[i]);
80 }
81
82}
83
84FbTk::Command *FbCommandFactory::stringToCommand(const std::string &command,
85 const std::string &arguments) {
86 using namespace FbCommands;
87 //
88 // WM commands
89 //
90 if (command == "restart")
91 return new RestartFluxboxCmd(arguments);
92 else if (command == "reconfigure")
93 return new ReconfigureFluxboxCmd();
94 else if (command == "setstyle")
95 return new SetStyleCmd(arguments);
96 else if (command == "saverc")
97 return new SaveResources();
98 else if (command == "execcommand" || command == "execute" || command == "exec")
99 return new ExecuteCmd(arguments); // execute command on key screen
100 else if (command == "quit")
101 return new FbTk::SimpleCommand<Fluxbox>(*Fluxbox::instance(), &Fluxbox::shutdown);
102 //
103 // Current focused window commands
104 //
105 else if (command == "minimizewindow" || command == "mimimize" || command == "iconify")
106 return new CurrentWindowCmd(&FluxboxWindow::iconify);
107 else if (command == "maximizewindow" || command == "maximize")
108 return new CurrentWindowCmd(&FluxboxWindow::maximize);
109 else if (command == "maximizevertical")
110 return new CurrentWindowCmd(&FluxboxWindow::maximizeVertical);
111 else if (command == "maximizehorizontal")
112 return new CurrentWindowCmd(&FluxboxWindow::maximizeHorizontal);
113 else if (command == "moveright")
114 return new MoveRightCmd(atoi(arguments.c_str()));
115 else if (command == "moveleft")
116 return new MoveLeftCmd(atoi(arguments.c_str()));
117 else if (command == "moveup")
118 return new MoveUpCmd(atoi(arguments.c_str()));
119 else if (command == "movedown")
120 return new MoveDownCmd(atoi(arguments.c_str()));
121 else if (command == "raise")
122 return new CurrentWindowCmd(&FluxboxWindow::raise);
123 else if (command == "lower")
124 return new CurrentWindowCmd(&FluxboxWindow::lower);
125 else if (command == "close")
126 return new CurrentWindowCmd(&FluxboxWindow::close);
127 else if (command == "shade" || command == "shadewindow")
128 return new CurrentWindowCmd(&FluxboxWindow::shade);
129 else if (command == "stick" || command == "stickwindow")
130 return new CurrentWindowCmd(&FluxboxWindow::stick);
131 else if (command == "sendtoworkspace")
132 return new SendToWorkspaceCmd(atoi(arguments.c_str()));
133 else if (command == "killwindow")
134 return new KillWindowCmd();
135 else if (command == "nexttab")
136 return new CurrentWindowCmd(&FluxboxWindow::nextClient);
137 else if (command == "prevtab")
138 return new CurrentWindowCmd(&FluxboxWindow::prevClient);
139 else if (command == "detachclient")
140 return new CurrentWindowCmd(&FluxboxWindow::detachCurrentClient);
141 //
142 // Workspace commands
143 //
144 else if (command == "nextworkspace" && arguments.size() == 0)
145 return new NextWorkspaceCmd();
146 else if (command == "prevworkspace" && arguments.size() == 0)
147 return new PrevWorkspaceCmd();
148 else if (command == "workspace") {
149 int num = 0;
150 if (!arguments.empty())
151 num = atoi(arguments.c_str());
152 return new JumpToWorkspaceCmd(num);
153 } else if (command == "nextwindow")
154 return new NextWindowCmd(atoi(arguments.c_str()));
155 else if (command == "prevwindow")
156 return new PrevWindowCmd(atoi(arguments.c_str()));
157 else if (command == "arrangewindows")
158 return new ArrangeWindowsCmd();
159 else if (command == "showdesktop")
160 return new ShowDesktopCmd();
161
162 return 0;
163}
diff --git a/src/FbCommandFactory.hh b/src/FbCommandFactory.hh
new file mode 100644
index 0000000..135c87f
--- /dev/null
+++ b/src/FbCommandFactory.hh
@@ -0,0 +1,35 @@
1// FbCommandFactory.hh for Fluxbox Window manager
2// Copyright (c) 2003 Henrik Kinnunen (fluxgen at users.sourceforge.net)
3// and Simon Bowden (rathnor at users.sourceforge.net)
4//
5// Permission is hereby granted, free of charge, to any person obtaining a
6// copy of this software and associated documentation files (the "Software"),
7// to deal in the Software without restriction, including without limitation
8// the rights to use, copy, modify, merge, publish, distribute, sublicense,
9// and/or sell copies of the Software, and to permit persons to whom the
10// Software is furnished to do so, subject to the following conditions:
11//
12// The above copyright notice and this permission notice shall be included in
13// all copies or substantial portions of the Software.
14//
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21// DEALINGS IN THE SOFTWARE.
22
23// $Id: FbCommandFactory.hh,v 1.1 2003/06/30 14:49:23 fluxgen Exp $
24
25#include "CommandParser.hh"
26
27class FbCommandFactory: public CommandFactory {
28public:
29 FbTk::Command *stringToCommand(const std::string &command,
30 const std::string &arguments);
31
32private:
33 FbCommandFactory();
34 static FbCommandFactory s_autoreg; ///< autoregister variable
35};