diff options
Diffstat (limited to 'src/CurrentWindowCmd.cc')
-rw-r--r-- | src/CurrentWindowCmd.cc | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/src/CurrentWindowCmd.cc b/src/CurrentWindowCmd.cc new file mode 100644 index 0000000..4320f73 --- /dev/null +++ b/src/CurrentWindowCmd.cc | |||
@@ -0,0 +1,98 @@ | |||
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.8 2003/10/26 12:36:55 fluxgen Exp $ | ||
24 | |||
25 | #include "CurrentWindowCmd.hh" | ||
26 | |||
27 | #include "fluxbox.hh" | ||
28 | #include "Window.hh" | ||
29 | #include "Screen.hh" | ||
30 | #include "WinClient.hh" | ||
31 | |||
32 | CurrentWindowCmd::CurrentWindowCmd(Action act):m_action(act) { } | ||
33 | |||
34 | void CurrentWindowCmd::execute() { | ||
35 | WinClient *client = Fluxbox::instance()->getFocusedWindow(); | ||
36 | if (client && client->fbwindow()) | ||
37 | (client->fbwindow()->*m_action)(); | ||
38 | } | ||
39 | |||
40 | |||
41 | void KillWindowCmd::real_execute() { | ||
42 | winclient().sendClose(true); | ||
43 | } | ||
44 | |||
45 | void SendToWorkspaceCmd::real_execute() { | ||
46 | if (m_workspace_num >= 0 && m_workspace_num < fbwindow().screen().getNumberOfWorkspaces()) | ||
47 | fbwindow().screen().sendToWorkspace(m_workspace_num, &fbwindow()); | ||
48 | } | ||
49 | |||
50 | void WindowHelperCmd::execute() { | ||
51 | WinClient *client = Fluxbox::instance()->getFocusedWindow(); | ||
52 | if (client && client->fbwindow()) // guarantee that fbwindow() exists too | ||
53 | real_execute(); | ||
54 | } | ||
55 | |||
56 | WinClient &WindowHelperCmd::winclient() { | ||
57 | // will exist from execute above | ||
58 | return *Fluxbox::instance()->getFocusedWindow(); | ||
59 | } | ||
60 | |||
61 | FluxboxWindow &WindowHelperCmd::fbwindow() { | ||
62 | // will exist from execute above | ||
63 | return *Fluxbox::instance()->getFocusedWindow()->fbwindow(); | ||
64 | } | ||
65 | |||
66 | MoveCmd::MoveCmd(const int step_size_x, const int step_size_y) : | ||
67 | m_step_size_x(step_size_x), m_step_size_y(step_size_y) { } | ||
68 | |||
69 | void MoveCmd::real_execute() { | ||
70 | fbwindow().move( | ||
71 | fbwindow().x() + m_step_size_x, | ||
72 | fbwindow().y() + m_step_size_y); | ||
73 | } | ||
74 | |||
75 | ResizeCmd::ResizeCmd(const int step_size_x, const int step_size_y) : | ||
76 | m_step_size_x(step_size_x), m_step_size_y(step_size_y) { } | ||
77 | |||
78 | void ResizeCmd::real_execute() { | ||
79 | fbwindow().resize( | ||
80 | fbwindow().width() + | ||
81 | m_step_size_x * fbwindow().winClient().width_inc, | ||
82 | fbwindow().height() + | ||
83 | m_step_size_y * fbwindow().winClient().height_inc); | ||
84 | } | ||
85 | |||
86 | MoveToCmd::MoveToCmd(const int step_size_x, const int step_size_y) : | ||
87 | m_step_size_x(step_size_x), m_step_size_y(step_size_y) { } | ||
88 | |||
89 | void MoveToCmd::real_execute() { | ||
90 | fbwindow().move(m_step_size_x, m_step_size_y); | ||
91 | } | ||
92 | |||
93 | ResizeToCmd::ResizeToCmd(const int step_size_x, const int step_size_y) : | ||
94 | m_step_size_x(step_size_x), m_step_size_y(step_size_y) { } | ||
95 | |||
96 | void ResizeToCmd::real_execute() { | ||
97 | fbwindow().resize(m_step_size_x, m_step_size_y); | ||
98 | } | ||