diff options
author | fluxgen <fluxgen> | 2003-06-30 14:35:11 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2003-06-30 14:35:11 (GMT) |
commit | 695d926b2f56a602b62773f2a6aa4eaf2c5c40b2 (patch) | |
tree | bcae71c09ab4f35735e3223b8a1b201a564f7308 | |
parent | 4bf8a39f75a21c9c3146157e3bbb735e37a6788b (diff) | |
download | fluxbox_lack-695d926b2f56a602b62773f2a6aa4eaf2c5c40b2.zip fluxbox_lack-695d926b2f56a602b62773f2a6aa4eaf2c5c40b2.tar.bz2 |
commands on current window
-rw-r--r-- | src/CurrentWindowCmd.cc | 77 | ||||
-rw-r--r-- | src/CurrentWindowCmd.hh | 110 |
2 files changed, 187 insertions, 0 deletions
diff --git a/src/CurrentWindowCmd.cc b/src/CurrentWindowCmd.cc new file mode 100644 index 0000000..8e0a70c --- /dev/null +++ b/src/CurrentWindowCmd.cc | |||
@@ -0,0 +1,77 @@ | |||
1 | // CurrentWindowCmd.cc for Fluxbox - an X11 Window manager | ||
2 | // Copyright (c) 2003 Henrik Kinnunen (fluxgen{<a*t>}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: CurrentWindowCmd.cc,v 1.1 2003/06/30 14:35:11 fluxgen Exp $ | ||
24 | |||
25 | #include "CurrentWindowCmd.hh" | ||
26 | |||
27 | #include "fluxbox.hh" | ||
28 | #include "Window.hh" | ||
29 | #include "Screen.hh" | ||
30 | |||
31 | CurrentWindowCmd::CurrentWindowCmd(Action act):m_action(act) { } | ||
32 | |||
33 | void CurrentWindowCmd::execute() { | ||
34 | Fluxbox *fb = Fluxbox::instance(); | ||
35 | if (fb->getFocusedWindow() != 0) | ||
36 | (*fb->getFocusedWindow().*m_action)(); | ||
37 | } | ||
38 | |||
39 | |||
40 | void KillWindowCmd::real_execute() { | ||
41 | XKillClient(FbTk::App::instance()->display(), window().clientWindow()); | ||
42 | } | ||
43 | |||
44 | void SendToWorkspaceCmd::real_execute() { | ||
45 | if (m_workspace_num > 0 && m_workspace_num < window().screen().getNumberOfWorkspaces()) | ||
46 | window().screen().sendToWorkspace(m_workspace_num, &window()); | ||
47 | } | ||
48 | |||
49 | void WindowHelperCmd::execute() { | ||
50 | if (Fluxbox::instance()->getFocusedWindow()) | ||
51 | real_execute(); | ||
52 | } | ||
53 | |||
54 | FluxboxWindow &WindowHelperCmd::window() { | ||
55 | return *Fluxbox::instance()->getFocusedWindow(); | ||
56 | } | ||
57 | |||
58 | MoveLeftCmd::MoveLeftCmd(int step_size):MoveHelper(step_size) { } | ||
59 | void MoveLeftCmd::real_execute() { | ||
60 | window().move(window().x() - stepSize(), window().y()); | ||
61 | } | ||
62 | |||
63 | MoveRightCmd::MoveRightCmd(int step_size):MoveHelper(step_size) { } | ||
64 | void MoveRightCmd::real_execute() { | ||
65 | window().move(window().x() + stepSize(), window().y()); | ||
66 | } | ||
67 | |||
68 | MoveDownCmd::MoveDownCmd(int step_size):MoveHelper(step_size) { } | ||
69 | void MoveDownCmd::real_execute() { | ||
70 | window().move(window().x(), window().y() + stepSize()); | ||
71 | } | ||
72 | |||
73 | MoveUpCmd::MoveUpCmd(int step_size):MoveHelper(step_size) { } | ||
74 | void MoveUpCmd::real_execute() { | ||
75 | window().move(window().x(), window().y() - stepSize()); | ||
76 | } | ||
77 | |||
diff --git a/src/CurrentWindowCmd.hh b/src/CurrentWindowCmd.hh new file mode 100644 index 0000000..fd6ac40 --- /dev/null +++ b/src/CurrentWindowCmd.hh | |||
@@ -0,0 +1,110 @@ | |||
1 | // CurrentWindowCmd.hh for Fluxbox - an X11 Window manager | ||
2 | // Copyright (c) 2003 Henrik Kinnunen (fluxgen{<a*t>}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: CurrentWindowCmd.hh,v 1.1 2003/06/30 14:35:11 fluxgen Exp $ | ||
24 | |||
25 | #ifndef CURRENTWINDOWCMD_HH | ||
26 | #define CURRENTWINDOWCMD_HH | ||
27 | |||
28 | #include "Command.hh" | ||
29 | |||
30 | class FluxboxWindow; | ||
31 | /// command that calls FluxboxWindow::<the function> on execute() | ||
32 | /// similar to FbTk::SimpleCommand<T> | ||
33 | class CurrentWindowCmd: public FbTk::Command { | ||
34 | public: | ||
35 | typedef void (FluxboxWindow::* Action)(); | ||
36 | explicit CurrentWindowCmd(Action action); | ||
37 | void execute(); | ||
38 | private: | ||
39 | Action m_action; | ||
40 | }; | ||
41 | |||
42 | /// helper class for window commands | ||
43 | /// calls real_execute if there's a focused window or a window in button press/release window | ||
44 | class WindowHelperCmd: public FbTk::Command { | ||
45 | public: | ||
46 | void execute(); | ||
47 | |||
48 | protected: | ||
49 | |||
50 | FluxboxWindow &window(); | ||
51 | virtual void real_execute() = 0; | ||
52 | |||
53 | }; | ||
54 | |||
55 | class KillWindowCmd: public WindowHelperCmd { | ||
56 | protected: | ||
57 | void real_execute(); | ||
58 | }; | ||
59 | |||
60 | class SendToWorkspaceCmd: public WindowHelperCmd { | ||
61 | public: | ||
62 | explicit SendToWorkspaceCmd(int workspace_num):m_workspace_num(workspace_num) { } | ||
63 | protected: | ||
64 | void real_execute(); | ||
65 | private: | ||
66 | const int m_workspace_num; | ||
67 | }; | ||
68 | |||
69 | class MoveHelper: public WindowHelperCmd { | ||
70 | public: | ||
71 | explicit MoveHelper(int step_size):m_step_size(step_size) { } | ||
72 | protected: | ||
73 | int stepSize() const { return m_step_size; } | ||
74 | |||
75 | private: | ||
76 | const int m_step_size; | ||
77 | }; | ||
78 | /// move window to left | ||
79 | class MoveLeftCmd: public MoveHelper { | ||
80 | public: | ||
81 | explicit MoveLeftCmd(int step_size); | ||
82 | protected: | ||
83 | void real_execute(); | ||
84 | }; | ||
85 | |||
86 | /// move window to right | ||
87 | class MoveRightCmd: public MoveHelper { | ||
88 | public: | ||
89 | explicit MoveRightCmd(int step_size); | ||
90 | protected: | ||
91 | void real_execute(); | ||
92 | }; | ||
93 | |||
94 | /// move window up | ||
95 | class MoveUpCmd: public MoveHelper { | ||
96 | public: | ||
97 | explicit MoveUpCmd(int step_size); | ||
98 | protected: | ||
99 | void real_execute(); | ||
100 | }; | ||
101 | |||
102 | /// move window down | ||
103 | class MoveDownCmd: public MoveHelper { | ||
104 | public: | ||
105 | explicit MoveDownCmd(int step_size); | ||
106 | protected: | ||
107 | void real_execute(); | ||
108 | }; | ||
109 | |||
110 | #endif // CURRENTWINDOWCMD_HH | ||