aboutsummaryrefslogtreecommitdiff
path: root/src/CurrentWindowCmd.cc
diff options
context:
space:
mode:
authorMark Tiefenbruck <mark@fluxbox.org>2008-01-11 07:41:22 (GMT)
committerMark Tiefenbruck <mark@fluxbox.org>2008-01-11 07:41:22 (GMT)
commit9f2f65a698c4cc71373a7fe9d73a0889e0d3487b (patch)
tree4ad67db771d73ea3c48f80a1244037fc9754edd2 /src/CurrentWindowCmd.cc
parent1f01d84c080d607a91eb417efcaf5e500b5f1d7e (diff)
downloadfluxbox-9f2f65a698c4cc71373a7fe9d73a0889e0d3487b.zip
fluxbox-9f2f65a698c4cc71373a7fe9d73a0889e0d3487b.tar.bz2
make FbTk::Command a template class, split parsing information out of ObjectRegistry
Diffstat (limited to 'src/CurrentWindowCmd.cc')
-rw-r--r--src/CurrentWindowCmd.cc124
1 files changed, 62 insertions, 62 deletions
diff --git a/src/CurrentWindowCmd.cc b/src/CurrentWindowCmd.cc
index f08112b..4c027d9 100644
--- a/src/CurrentWindowCmd.cc
+++ b/src/CurrentWindowCmd.cc
@@ -29,7 +29,7 @@
29#include "WinClient.hh" 29#include "WinClient.hh"
30 30
31#include "FocusControl.hh" 31#include "FocusControl.hh"
32#include "FbTk/ObjectRegistry.hh" 32#include "FbTk/CommandParser.hh"
33#include "FbTk/stringstream.hh" 33#include "FbTk/stringstream.hh"
34#include "FbTk/StringUtil.hh" 34#include "FbTk/StringUtil.hh"
35 35
@@ -37,7 +37,7 @@ using FbTk::Command;
37 37
38namespace { 38namespace {
39 39
40FbTk::Command *createCurrentWindowCmd(const std::string &command, 40FbTk::Command<void> *createCurrentWindowCmd(const std::string &command,
41 const std::string &args, bool trusted) { 41 const std::string &args, bool trusted) {
42 if (command == "minimizewindow" || command == "minimize" || command == "iconify") 42 if (command == "minimizewindow" || command == "minimize" || command == "iconify")
43 return new CurrentWindowCmd(&FluxboxWindow::iconify); 43 return new CurrentWindowCmd(&FluxboxWindow::iconify);
@@ -86,35 +86,35 @@ FbTk::Command *createCurrentWindowCmd(const std::string &command,
86 return 0; 86 return 0;
87} 87}
88 88
89REGISTER_OBJECT_PARSER(minimizewindow, createCurrentWindowCmd, Command); 89REGISTER_COMMAND_PARSER(minimizewindow, createCurrentWindowCmd, void);
90REGISTER_OBJECT_PARSER(minimize, createCurrentWindowCmd, Command); 90REGISTER_COMMAND_PARSER(minimize, createCurrentWindowCmd, void);
91REGISTER_OBJECT_PARSER(iconify, createCurrentWindowCmd, Command); 91REGISTER_COMMAND_PARSER(iconify, createCurrentWindowCmd, void);
92REGISTER_OBJECT_PARSER(maximizewindow, createCurrentWindowCmd, Command); 92REGISTER_COMMAND_PARSER(maximizewindow, createCurrentWindowCmd, void);
93REGISTER_OBJECT_PARSER(maximize, createCurrentWindowCmd, Command); 93REGISTER_COMMAND_PARSER(maximize, createCurrentWindowCmd, void);
94REGISTER_OBJECT_PARSER(maximizevertical, createCurrentWindowCmd, Command); 94REGISTER_COMMAND_PARSER(maximizevertical, createCurrentWindowCmd, void);
95REGISTER_OBJECT_PARSER(maximizehorizontal, createCurrentWindowCmd, Command); 95REGISTER_COMMAND_PARSER(maximizehorizontal, createCurrentWindowCmd, void);
96REGISTER_OBJECT_PARSER(raise, createCurrentWindowCmd, Command); 96REGISTER_COMMAND_PARSER(raise, createCurrentWindowCmd, void);
97REGISTER_OBJECT_PARSER(raiselayer, createCurrentWindowCmd, Command); 97REGISTER_COMMAND_PARSER(raiselayer, createCurrentWindowCmd, void);
98REGISTER_OBJECT_PARSER(lower, createCurrentWindowCmd, Command); 98REGISTER_COMMAND_PARSER(lower, createCurrentWindowCmd, void);
99REGISTER_OBJECT_PARSER(lowerlayer, createCurrentWindowCmd, Command); 99REGISTER_COMMAND_PARSER(lowerlayer, createCurrentWindowCmd, void);
100REGISTER_OBJECT_PARSER(activate, createCurrentWindowCmd, Command); 100REGISTER_COMMAND_PARSER(activate, createCurrentWindowCmd, void);
101REGISTER_OBJECT_PARSER(focus, createCurrentWindowCmd, Command); 101REGISTER_COMMAND_PARSER(focus, createCurrentWindowCmd, void);
102REGISTER_OBJECT_PARSER(close, createCurrentWindowCmd, Command); 102REGISTER_COMMAND_PARSER(close, createCurrentWindowCmd, void);
103REGISTER_OBJECT_PARSER(killwindow, createCurrentWindowCmd, Command); 103REGISTER_COMMAND_PARSER(killwindow, createCurrentWindowCmd, void);
104REGISTER_OBJECT_PARSER(kill, createCurrentWindowCmd, Command); 104REGISTER_COMMAND_PARSER(kill, createCurrentWindowCmd, void);
105REGISTER_OBJECT_PARSER(shade, createCurrentWindowCmd, Command); 105REGISTER_COMMAND_PARSER(shade, createCurrentWindowCmd, void);
106REGISTER_OBJECT_PARSER(shadewindow, createCurrentWindowCmd, Command); 106REGISTER_COMMAND_PARSER(shadewindow, createCurrentWindowCmd, void);
107REGISTER_OBJECT_PARSER(shadeon, createCurrentWindowCmd, Command); 107REGISTER_COMMAND_PARSER(shadeon, createCurrentWindowCmd, void);
108REGISTER_OBJECT_PARSER(shadeoff, createCurrentWindowCmd, Command); 108REGISTER_COMMAND_PARSER(shadeoff, createCurrentWindowCmd, void);
109REGISTER_OBJECT_PARSER(stick, createCurrentWindowCmd, Command); 109REGISTER_COMMAND_PARSER(stick, createCurrentWindowCmd, void);
110REGISTER_OBJECT_PARSER(stickwindow, createCurrentWindowCmd, Command); 110REGISTER_COMMAND_PARSER(stickwindow, createCurrentWindowCmd, void);
111REGISTER_OBJECT_PARSER(toggledecor, createCurrentWindowCmd, Command); 111REGISTER_COMMAND_PARSER(toggledecor, createCurrentWindowCmd, void);
112REGISTER_OBJECT_PARSER(nexttab, createCurrentWindowCmd, Command); 112REGISTER_COMMAND_PARSER(nexttab, createCurrentWindowCmd, void);
113REGISTER_OBJECT_PARSER(prevtab, createCurrentWindowCmd, Command); 113REGISTER_COMMAND_PARSER(prevtab, createCurrentWindowCmd, void);
114REGISTER_OBJECT_PARSER(movetableft, createCurrentWindowCmd, Command); 114REGISTER_COMMAND_PARSER(movetableft, createCurrentWindowCmd, void);
115REGISTER_OBJECT_PARSER(movetabright, createCurrentWindowCmd, Command); 115REGISTER_COMMAND_PARSER(movetabright, createCurrentWindowCmd, void);
116REGISTER_OBJECT_PARSER(detachclient, createCurrentWindowCmd, Command); 116REGISTER_COMMAND_PARSER(detachclient, createCurrentWindowCmd, void);
117REGISTER_OBJECT_PARSER(windowmenu, createCurrentWindowCmd, Command); 117REGISTER_COMMAND_PARSER(windowmenu, createCurrentWindowCmd, void);
118 118
119}; // end anonymous namespace 119}; // end anonymous namespace
120 120
@@ -130,7 +130,7 @@ FluxboxWindow &WindowHelperCmd::fbwindow() {
130 return *FocusControl::focusedFbWindow(); 130 return *FocusControl::focusedFbWindow();
131} 131}
132 132
133bool WindowHelperBoolCmd::bool_execute() { 133bool WindowHelperBoolCmd::execute() {
134 if (WindowCmd<void>::window() || FocusControl::focusedFbWindow()) 134 if (WindowCmd<void>::window() || FocusControl::focusedFbWindow())
135 return real_execute(); 135 return real_execute();
136 return false; 136 return false;
@@ -156,7 +156,7 @@ void CurrentWindowCmd::real_execute() {
156 156
157namespace { 157namespace {
158 158
159FbTk::Command *parseIntCmd(const string &command, const string &args, 159FbTk::Command<void> *parseIntCmd(const string &command, const string &args,
160 bool trusted) { 160 bool trusted) {
161 int num = (command == "sethead" ? 0 : 1); 161 int num = (command == "sethead" ? 0 : 1);
162 FbTk_istringstream iss(args.c_str()); 162 FbTk_istringstream iss(args.c_str());
@@ -181,14 +181,14 @@ FbTk::Command *parseIntCmd(const string &command, const string &args,
181 return 0; 181 return 0;
182} 182}
183 183
184REGISTER_OBJECT_PARSER(sethead, parseIntCmd, Command); 184REGISTER_COMMAND_PARSER(sethead, parseIntCmd, void);
185REGISTER_OBJECT_PARSER(tab, parseIntCmd, Command); 185REGISTER_COMMAND_PARSER(tab, parseIntCmd, void);
186REGISTER_OBJECT_PARSER(sendtonextworkspace, parseIntCmd, Command); 186REGISTER_COMMAND_PARSER(sendtonextworkspace, parseIntCmd, void);
187REGISTER_OBJECT_PARSER(sendtoprevworkspace, parseIntCmd, Command); 187REGISTER_COMMAND_PARSER(sendtoprevworkspace, parseIntCmd, void);
188REGISTER_OBJECT_PARSER(taketonextworkspace, parseIntCmd, Command); 188REGISTER_COMMAND_PARSER(taketonextworkspace, parseIntCmd, void);
189REGISTER_OBJECT_PARSER(taketoprevworkspace, parseIntCmd, Command); 189REGISTER_COMMAND_PARSER(taketoprevworkspace, parseIntCmd, void);
190REGISTER_OBJECT_PARSER(sendtoworkspace, parseIntCmd, Command); 190REGISTER_COMMAND_PARSER(sendtoworkspace, parseIntCmd, void);
191REGISTER_OBJECT_PARSER(taketoworkspace, parseIntCmd, Command); 191REGISTER_COMMAND_PARSER(taketoworkspace, parseIntCmd, void);
192 192
193}; // end anonymous namespace 193}; // end anonymous namespace
194 194
@@ -251,7 +251,7 @@ void GoToTabCmd::real_execute() {
251 (*it)->focus(); 251 (*it)->focus();
252} 252}
253 253
254REGISTER_OBJECT(startmoving, StartMovingCmd, Command); 254REGISTER_COMMAND(startmoving, StartMovingCmd, void);
255 255
256void StartMovingCmd::real_execute() { 256void StartMovingCmd::real_execute() {
257 const XEvent &last = Fluxbox::instance()->lastEvent(); 257 const XEvent &last = Fluxbox::instance()->lastEvent();
@@ -261,7 +261,7 @@ void StartMovingCmd::real_execute() {
261 } 261 }
262} 262}
263 263
264FbTk::Command *StartResizingCmd::parse(const string &cmd, const string &args, 264FbTk::Command<void> *StartResizingCmd::parse(const string &cmd, const string &args,
265 bool trusted) { 265 bool trusted) {
266 FluxboxWindow::ResizeModel mode = FluxboxWindow::DEFAULTRESIZE; 266 FluxboxWindow::ResizeModel mode = FluxboxWindow::DEFAULTRESIZE;
267 std::vector<string> tokens; 267 std::vector<string> tokens;
@@ -294,7 +294,7 @@ FbTk::Command *StartResizingCmd::parse(const string &cmd, const string &args,
294 return new StartResizingCmd(mode); 294 return new StartResizingCmd(mode);
295} 295}
296 296
297REGISTER_OBJECT_PARSER(startresizing, StartResizingCmd::parse, Command); 297REGISTER_COMMAND_PARSER(startresizing, StartResizingCmd::parse, void);
298 298
299void StartResizingCmd::real_execute() { 299void StartResizingCmd::real_execute() {
300 const XEvent &last = Fluxbox::instance()->lastEvent(); 300 const XEvent &last = Fluxbox::instance()->lastEvent();
@@ -308,7 +308,7 @@ void StartResizingCmd::real_execute() {
308 } 308 }
309} 309}
310 310
311REGISTER_OBJECT(starttabbing, StartTabbingCmd, Command); 311REGISTER_COMMAND(starttabbing, StartTabbingCmd, void);
312 312
313void StartTabbingCmd::real_execute() { 313void StartTabbingCmd::real_execute() {
314 const XEvent &last = Fluxbox::instance()->lastEvent(); 314 const XEvent &last = Fluxbox::instance()->lastEvent();
@@ -318,7 +318,7 @@ void StartTabbingCmd::real_execute() {
318 } 318 }
319} 319}
320 320
321FbTk::Command *MoveCmd::parse(const string &command, const string &args, 321FbTk::Command<void> *MoveCmd::parse(const string &command, const string &args,
322 bool trusted) { 322 bool trusted) {
323 FbTk_istringstream is(args.c_str()); 323 FbTk_istringstream is(args.c_str());
324 int dx = 0, dy = 0; 324 int dx = 0, dy = 0;
@@ -339,11 +339,11 @@ FbTk::Command *MoveCmd::parse(const string &command, const string &args,
339 return new MoveCmd(dx, dy); 339 return new MoveCmd(dx, dy);
340} 340}
341 341
342REGISTER_OBJECT_PARSER(move, MoveCmd::parse, Command); 342REGISTER_COMMAND_PARSER(move, MoveCmd::parse, void);
343REGISTER_OBJECT_PARSER(moveright, MoveCmd::parse, Command); 343REGISTER_COMMAND_PARSER(moveright, MoveCmd::parse, void);
344REGISTER_OBJECT_PARSER(moveleft, MoveCmd::parse, Command); 344REGISTER_COMMAND_PARSER(moveleft, MoveCmd::parse, void);
345REGISTER_OBJECT_PARSER(moveup, MoveCmd::parse, Command); 345REGISTER_COMMAND_PARSER(moveup, MoveCmd::parse, void);
346REGISTER_OBJECT_PARSER(movedown, MoveCmd::parse, Command); 346REGISTER_COMMAND_PARSER(movedown, MoveCmd::parse, void);
347 347
348MoveCmd::MoveCmd(const int step_size_x, const int step_size_y) : 348MoveCmd::MoveCmd(const int step_size_x, const int step_size_y) :
349 m_step_size_x(step_size_x), m_step_size_y(step_size_y) { } 349 m_step_size_x(step_size_x), m_step_size_y(step_size_y) { }
@@ -354,7 +354,7 @@ void MoveCmd::real_execute() {
354 fbwindow().y() + m_step_size_y); 354 fbwindow().y() + m_step_size_y);
355} 355}
356 356
357FbTk::Command *ResizeCmd::parse(const string &command, const string &args, 357FbTk::Command<void> *ResizeCmd::parse(const string &command, const string &args,
358 bool trusted) { 358 bool trusted) {
359 FbTk_istringstream is(args.c_str()); 359 FbTk_istringstream is(args.c_str());
360 int dx = 0, dy = 0; 360 int dx = 0, dy = 0;
@@ -371,10 +371,10 @@ FbTk::Command *ResizeCmd::parse(const string &command, const string &args,
371 return new ResizeCmd(dx, dy); 371 return new ResizeCmd(dx, dy);
372} 372}
373 373
374REGISTER_OBJECT_PARSER(resize, ResizeCmd::parse, Command); 374REGISTER_COMMAND_PARSER(resize, ResizeCmd::parse, void);
375REGISTER_OBJECT_PARSER(resizeto, ResizeCmd::parse, Command); 375REGISTER_COMMAND_PARSER(resizeto, ResizeCmd::parse, void);
376REGISTER_OBJECT_PARSER(resizehorizontal, ResizeCmd::parse, Command); 376REGISTER_COMMAND_PARSER(resizehorizontal, ResizeCmd::parse, void);
377REGISTER_OBJECT_PARSER(resizevertical, ResizeCmd::parse, Command); 377REGISTER_COMMAND_PARSER(resizevertical, ResizeCmd::parse, void);
378 378
379ResizeCmd::ResizeCmd(const int step_size_x, const int step_size_y) : 379ResizeCmd::ResizeCmd(const int step_size_x, const int step_size_y) :
380 m_step_size_x(step_size_x), m_step_size_y(step_size_y) { } 380 m_step_size_x(step_size_x), m_step_size_y(step_size_y) { }
@@ -390,7 +390,7 @@ void ResizeCmd::real_execute() {
390 fbwindow().resize(w, h); 390 fbwindow().resize(w, h);
391} 391}
392 392
393FbTk::Command *MoveToCmd::parse(const string &cmd, const string &args, 393FbTk::Command<void> *MoveToCmd::parse(const string &cmd, const string &args,
394 bool trusted) { 394 bool trusted) {
395 typedef std::vector<string> StringTokens; 395 typedef std::vector<string> StringTokens;
396 StringTokens tokens; 396 StringTokens tokens;
@@ -435,7 +435,7 @@ FbTk::Command *MoveToCmd::parse(const string &cmd, const string &args,
435 435
436} 436}
437 437
438REGISTER_OBJECT_PARSER(moveto, MoveToCmd::parse, Command); 438REGISTER_COMMAND_PARSER(moveto, MoveToCmd::parse, void);
439 439
440MoveToCmd::MoveToCmd(const int step_size_x, const int step_size_y, const unsigned int refc) : 440MoveToCmd::MoveToCmd(const int step_size_x, const int step_size_y, const unsigned int refc) :
441 m_step_size_x(step_size_x), m_step_size_y(step_size_y), m_refc(refc) { } 441 m_step_size_x(step_size_x), m_step_size_y(step_size_y), m_refc(refc) { }
@@ -472,14 +472,14 @@ void ResizeToCmd::real_execute() {
472 fbwindow().resize(m_step_size_x, m_step_size_y); 472 fbwindow().resize(m_step_size_x, m_step_size_y);
473} 473}
474 474
475REGISTER_OBJECT(fullscreen, FullscreenCmd, Command); 475REGISTER_COMMAND(fullscreen, FullscreenCmd, void);
476 476
477FullscreenCmd::FullscreenCmd() { } 477FullscreenCmd::FullscreenCmd() { }
478void FullscreenCmd::real_execute() { 478void FullscreenCmd::real_execute() {
479 fbwindow().setFullscreen(!fbwindow().isFullscreen()); 479 fbwindow().setFullscreen(!fbwindow().isFullscreen());
480} 480}
481 481
482FbTk::Command *SetAlphaCmd::parse(const string &command, const string &args, 482FbTk::Command<void> *SetAlphaCmd::parse(const string &command, const string &args,
483 bool trusted) { 483 bool trusted) {
484 typedef std::vector<string> StringTokens; 484 typedef std::vector<string> StringTokens;
485 StringTokens tokens; 485 StringTokens tokens;
@@ -504,7 +504,7 @@ FbTk::Command *SetAlphaCmd::parse(const string &command, const string &args,
504 return new SetAlphaCmd(focused, relative, unfocused, un_rel); 504 return new SetAlphaCmd(focused, relative, unfocused, un_rel);
505} 505}
506 506
507REGISTER_OBJECT_PARSER(setalpha, SetAlphaCmd::parse, Command); 507REGISTER_COMMAND_PARSER(setalpha, SetAlphaCmd::parse, void);
508 508
509SetAlphaCmd::SetAlphaCmd(int focused, bool relative, 509SetAlphaCmd::SetAlphaCmd(int focused, bool relative,
510 int unfocused, bool un_relative) : 510 int unfocused, bool un_relative) :
@@ -536,7 +536,7 @@ void SetAlphaCmd::real_execute() {
536 fbwindow().setUnfocusedAlpha(m_unfocus); 536 fbwindow().setUnfocusedAlpha(m_unfocus);
537} 537}
538 538
539REGISTER_OBJECT_WITH_ARGS_NSBASE(matches, MatchCmd, FbTk, BoolCommand); 539REGISTER_COMMAND_WITH_ARGS(matches, MatchCmd, bool);
540 540
541bool MatchCmd::real_execute() { 541bool MatchCmd::real_execute() {
542 return m_pat.match(winclient()); 542 return m_pat.match(winclient());