diff options
author | Mark Tiefenbruck <mark@fluxbox.org> | 2008-01-11 07:41:22 (GMT) |
---|---|---|
committer | Mark Tiefenbruck <mark@fluxbox.org> | 2008-01-11 07:41:22 (GMT) |
commit | 9f2f65a698c4cc71373a7fe9d73a0889e0d3487b (patch) | |
tree | 4ad67db771d73ea3c48f80a1244037fc9754edd2 /src/CurrentWindowCmd.cc | |
parent | 1f01d84c080d607a91eb417efcaf5e500b5f1d7e (diff) | |
download | fluxbox_pavel-9f2f65a698c4cc71373a7fe9d73a0889e0d3487b.zip fluxbox_pavel-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.cc | 124 |
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 | ||
38 | namespace { | 38 | namespace { |
39 | 39 | ||
40 | FbTk::Command *createCurrentWindowCmd(const std::string &command, | 40 | FbTk::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 | ||
89 | REGISTER_OBJECT_PARSER(minimizewindow, createCurrentWindowCmd, Command); | 89 | REGISTER_COMMAND_PARSER(minimizewindow, createCurrentWindowCmd, void); |
90 | REGISTER_OBJECT_PARSER(minimize, createCurrentWindowCmd, Command); | 90 | REGISTER_COMMAND_PARSER(minimize, createCurrentWindowCmd, void); |
91 | REGISTER_OBJECT_PARSER(iconify, createCurrentWindowCmd, Command); | 91 | REGISTER_COMMAND_PARSER(iconify, createCurrentWindowCmd, void); |
92 | REGISTER_OBJECT_PARSER(maximizewindow, createCurrentWindowCmd, Command); | 92 | REGISTER_COMMAND_PARSER(maximizewindow, createCurrentWindowCmd, void); |
93 | REGISTER_OBJECT_PARSER(maximize, createCurrentWindowCmd, Command); | 93 | REGISTER_COMMAND_PARSER(maximize, createCurrentWindowCmd, void); |
94 | REGISTER_OBJECT_PARSER(maximizevertical, createCurrentWindowCmd, Command); | 94 | REGISTER_COMMAND_PARSER(maximizevertical, createCurrentWindowCmd, void); |
95 | REGISTER_OBJECT_PARSER(maximizehorizontal, createCurrentWindowCmd, Command); | 95 | REGISTER_COMMAND_PARSER(maximizehorizontal, createCurrentWindowCmd, void); |
96 | REGISTER_OBJECT_PARSER(raise, createCurrentWindowCmd, Command); | 96 | REGISTER_COMMAND_PARSER(raise, createCurrentWindowCmd, void); |
97 | REGISTER_OBJECT_PARSER(raiselayer, createCurrentWindowCmd, Command); | 97 | REGISTER_COMMAND_PARSER(raiselayer, createCurrentWindowCmd, void); |
98 | REGISTER_OBJECT_PARSER(lower, createCurrentWindowCmd, Command); | 98 | REGISTER_COMMAND_PARSER(lower, createCurrentWindowCmd, void); |
99 | REGISTER_OBJECT_PARSER(lowerlayer, createCurrentWindowCmd, Command); | 99 | REGISTER_COMMAND_PARSER(lowerlayer, createCurrentWindowCmd, void); |
100 | REGISTER_OBJECT_PARSER(activate, createCurrentWindowCmd, Command); | 100 | REGISTER_COMMAND_PARSER(activate, createCurrentWindowCmd, void); |
101 | REGISTER_OBJECT_PARSER(focus, createCurrentWindowCmd, Command); | 101 | REGISTER_COMMAND_PARSER(focus, createCurrentWindowCmd, void); |
102 | REGISTER_OBJECT_PARSER(close, createCurrentWindowCmd, Command); | 102 | REGISTER_COMMAND_PARSER(close, createCurrentWindowCmd, void); |
103 | REGISTER_OBJECT_PARSER(killwindow, createCurrentWindowCmd, Command); | 103 | REGISTER_COMMAND_PARSER(killwindow, createCurrentWindowCmd, void); |
104 | REGISTER_OBJECT_PARSER(kill, createCurrentWindowCmd, Command); | 104 | REGISTER_COMMAND_PARSER(kill, createCurrentWindowCmd, void); |
105 | REGISTER_OBJECT_PARSER(shade, createCurrentWindowCmd, Command); | 105 | REGISTER_COMMAND_PARSER(shade, createCurrentWindowCmd, void); |
106 | REGISTER_OBJECT_PARSER(shadewindow, createCurrentWindowCmd, Command); | 106 | REGISTER_COMMAND_PARSER(shadewindow, createCurrentWindowCmd, void); |
107 | REGISTER_OBJECT_PARSER(shadeon, createCurrentWindowCmd, Command); | 107 | REGISTER_COMMAND_PARSER(shadeon, createCurrentWindowCmd, void); |
108 | REGISTER_OBJECT_PARSER(shadeoff, createCurrentWindowCmd, Command); | 108 | REGISTER_COMMAND_PARSER(shadeoff, createCurrentWindowCmd, void); |
109 | REGISTER_OBJECT_PARSER(stick, createCurrentWindowCmd, Command); | 109 | REGISTER_COMMAND_PARSER(stick, createCurrentWindowCmd, void); |
110 | REGISTER_OBJECT_PARSER(stickwindow, createCurrentWindowCmd, Command); | 110 | REGISTER_COMMAND_PARSER(stickwindow, createCurrentWindowCmd, void); |
111 | REGISTER_OBJECT_PARSER(toggledecor, createCurrentWindowCmd, Command); | 111 | REGISTER_COMMAND_PARSER(toggledecor, createCurrentWindowCmd, void); |
112 | REGISTER_OBJECT_PARSER(nexttab, createCurrentWindowCmd, Command); | 112 | REGISTER_COMMAND_PARSER(nexttab, createCurrentWindowCmd, void); |
113 | REGISTER_OBJECT_PARSER(prevtab, createCurrentWindowCmd, Command); | 113 | REGISTER_COMMAND_PARSER(prevtab, createCurrentWindowCmd, void); |
114 | REGISTER_OBJECT_PARSER(movetableft, createCurrentWindowCmd, Command); | 114 | REGISTER_COMMAND_PARSER(movetableft, createCurrentWindowCmd, void); |
115 | REGISTER_OBJECT_PARSER(movetabright, createCurrentWindowCmd, Command); | 115 | REGISTER_COMMAND_PARSER(movetabright, createCurrentWindowCmd, void); |
116 | REGISTER_OBJECT_PARSER(detachclient, createCurrentWindowCmd, Command); | 116 | REGISTER_COMMAND_PARSER(detachclient, createCurrentWindowCmd, void); |
117 | REGISTER_OBJECT_PARSER(windowmenu, createCurrentWindowCmd, Command); | 117 | REGISTER_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 | ||
133 | bool WindowHelperBoolCmd::bool_execute() { | 133 | bool 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 | ||
157 | namespace { | 157 | namespace { |
158 | 158 | ||
159 | FbTk::Command *parseIntCmd(const string &command, const string &args, | 159 | FbTk::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 | ||
184 | REGISTER_OBJECT_PARSER(sethead, parseIntCmd, Command); | 184 | REGISTER_COMMAND_PARSER(sethead, parseIntCmd, void); |
185 | REGISTER_OBJECT_PARSER(tab, parseIntCmd, Command); | 185 | REGISTER_COMMAND_PARSER(tab, parseIntCmd, void); |
186 | REGISTER_OBJECT_PARSER(sendtonextworkspace, parseIntCmd, Command); | 186 | REGISTER_COMMAND_PARSER(sendtonextworkspace, parseIntCmd, void); |
187 | REGISTER_OBJECT_PARSER(sendtoprevworkspace, parseIntCmd, Command); | 187 | REGISTER_COMMAND_PARSER(sendtoprevworkspace, parseIntCmd, void); |
188 | REGISTER_OBJECT_PARSER(taketonextworkspace, parseIntCmd, Command); | 188 | REGISTER_COMMAND_PARSER(taketonextworkspace, parseIntCmd, void); |
189 | REGISTER_OBJECT_PARSER(taketoprevworkspace, parseIntCmd, Command); | 189 | REGISTER_COMMAND_PARSER(taketoprevworkspace, parseIntCmd, void); |
190 | REGISTER_OBJECT_PARSER(sendtoworkspace, parseIntCmd, Command); | 190 | REGISTER_COMMAND_PARSER(sendtoworkspace, parseIntCmd, void); |
191 | REGISTER_OBJECT_PARSER(taketoworkspace, parseIntCmd, Command); | 191 | REGISTER_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 | ||
254 | REGISTER_OBJECT(startmoving, StartMovingCmd, Command); | 254 | REGISTER_COMMAND(startmoving, StartMovingCmd, void); |
255 | 255 | ||
256 | void StartMovingCmd::real_execute() { | 256 | void 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 | ||
264 | FbTk::Command *StartResizingCmd::parse(const string &cmd, const string &args, | 264 | FbTk::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 | ||
297 | REGISTER_OBJECT_PARSER(startresizing, StartResizingCmd::parse, Command); | 297 | REGISTER_COMMAND_PARSER(startresizing, StartResizingCmd::parse, void); |
298 | 298 | ||
299 | void StartResizingCmd::real_execute() { | 299 | void 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 | ||
311 | REGISTER_OBJECT(starttabbing, StartTabbingCmd, Command); | 311 | REGISTER_COMMAND(starttabbing, StartTabbingCmd, void); |
312 | 312 | ||
313 | void StartTabbingCmd::real_execute() { | 313 | void 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 | ||
321 | FbTk::Command *MoveCmd::parse(const string &command, const string &args, | 321 | FbTk::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 | ||
342 | REGISTER_OBJECT_PARSER(move, MoveCmd::parse, Command); | 342 | REGISTER_COMMAND_PARSER(move, MoveCmd::parse, void); |
343 | REGISTER_OBJECT_PARSER(moveright, MoveCmd::parse, Command); | 343 | REGISTER_COMMAND_PARSER(moveright, MoveCmd::parse, void); |
344 | REGISTER_OBJECT_PARSER(moveleft, MoveCmd::parse, Command); | 344 | REGISTER_COMMAND_PARSER(moveleft, MoveCmd::parse, void); |
345 | REGISTER_OBJECT_PARSER(moveup, MoveCmd::parse, Command); | 345 | REGISTER_COMMAND_PARSER(moveup, MoveCmd::parse, void); |
346 | REGISTER_OBJECT_PARSER(movedown, MoveCmd::parse, Command); | 346 | REGISTER_COMMAND_PARSER(movedown, MoveCmd::parse, void); |
347 | 347 | ||
348 | MoveCmd::MoveCmd(const int step_size_x, const int step_size_y) : | 348 | MoveCmd::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 | ||
357 | FbTk::Command *ResizeCmd::parse(const string &command, const string &args, | 357 | FbTk::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 | ||
374 | REGISTER_OBJECT_PARSER(resize, ResizeCmd::parse, Command); | 374 | REGISTER_COMMAND_PARSER(resize, ResizeCmd::parse, void); |
375 | REGISTER_OBJECT_PARSER(resizeto, ResizeCmd::parse, Command); | 375 | REGISTER_COMMAND_PARSER(resizeto, ResizeCmd::parse, void); |
376 | REGISTER_OBJECT_PARSER(resizehorizontal, ResizeCmd::parse, Command); | 376 | REGISTER_COMMAND_PARSER(resizehorizontal, ResizeCmd::parse, void); |
377 | REGISTER_OBJECT_PARSER(resizevertical, ResizeCmd::parse, Command); | 377 | REGISTER_COMMAND_PARSER(resizevertical, ResizeCmd::parse, void); |
378 | 378 | ||
379 | ResizeCmd::ResizeCmd(const int step_size_x, const int step_size_y) : | 379 | ResizeCmd::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 | ||
393 | FbTk::Command *MoveToCmd::parse(const string &cmd, const string &args, | 393 | FbTk::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 | ||
438 | REGISTER_OBJECT_PARSER(moveto, MoveToCmd::parse, Command); | 438 | REGISTER_COMMAND_PARSER(moveto, MoveToCmd::parse, void); |
439 | 439 | ||
440 | MoveToCmd::MoveToCmd(const int step_size_x, const int step_size_y, const unsigned int refc) : | 440 | MoveToCmd::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 | ||
475 | REGISTER_OBJECT(fullscreen, FullscreenCmd, Command); | 475 | REGISTER_COMMAND(fullscreen, FullscreenCmd, void); |
476 | 476 | ||
477 | FullscreenCmd::FullscreenCmd() { } | 477 | FullscreenCmd::FullscreenCmd() { } |
478 | void FullscreenCmd::real_execute() { | 478 | void FullscreenCmd::real_execute() { |
479 | fbwindow().setFullscreen(!fbwindow().isFullscreen()); | 479 | fbwindow().setFullscreen(!fbwindow().isFullscreen()); |
480 | } | 480 | } |
481 | 481 | ||
482 | FbTk::Command *SetAlphaCmd::parse(const string &command, const string &args, | 482 | FbTk::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 | ||
507 | REGISTER_OBJECT_PARSER(setalpha, SetAlphaCmd::parse, Command); | 507 | REGISTER_COMMAND_PARSER(setalpha, SetAlphaCmd::parse, void); |
508 | 508 | ||
509 | SetAlphaCmd::SetAlphaCmd(int focused, bool relative, | 509 | SetAlphaCmd::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 | ||
539 | REGISTER_OBJECT_WITH_ARGS_NSBASE(matches, MatchCmd, FbTk, BoolCommand); | 539 | REGISTER_COMMAND_WITH_ARGS(matches, MatchCmd, bool); |
540 | 540 | ||
541 | bool MatchCmd::real_execute() { | 541 | bool MatchCmd::real_execute() { |
542 | return m_pat.match(winclient()); | 542 | return m_pat.match(winclient()); |