diff options
author | Mark Tiefenbruck <mark@fluxbox.org> | 2008-08-21 10:22:57 (GMT) |
---|---|---|
committer | Mark Tiefenbruck <mark@fluxbox.org> | 2008-08-21 10:22:57 (GMT) |
commit | 0116a83aa6b5275cbe3cd2bd851dc6959cacf79b (patch) | |
tree | d1f5d891549f9a5ee24c69e0d437c6746e6e7a23 /src | |
parent | 9dec17611fba493b028fb6664231822a07b3c4c1 (diff) | |
download | fluxbox_paul-0116a83aa6b5275cbe3cd2bd851dc6959cacf79b.zip fluxbox_paul-0116a83aa6b5275cbe3cd2bd851dc6959cacf79b.tar.bz2 |
add SendToNextHead/SendToPrevHead commands, plus some cleanup in CurrentWindowCmd
Diffstat (limited to 'src')
-rw-r--r-- | src/CurrentWindowCmd.cc | 75 | ||||
-rw-r--r-- | src/CurrentWindowCmd.hh | 40 |
2 files changed, 41 insertions, 74 deletions
diff --git a/src/CurrentWindowCmd.cc b/src/CurrentWindowCmd.cc index 6918db9..95f2933 100644 --- a/src/CurrentWindowCmd.cc +++ b/src/CurrentWindowCmd.cc | |||
@@ -157,7 +157,7 @@ namespace { | |||
157 | 157 | ||
158 | FbTk::Command<void> *parseIntCmd(const string &command, const string &args, | 158 | FbTk::Command<void> *parseIntCmd(const string &command, const string &args, |
159 | bool trusted) { | 159 | bool trusted) { |
160 | int num = (command == "sethead" ? 0 : 1); | 160 | int num = 1; |
161 | FbTk_istringstream iss(args.c_str()); | 161 | FbTk_istringstream iss(args.c_str()); |
162 | iss >> num; | 162 | iss >> num; |
163 | if (command == "sethead") | 163 | if (command == "sethead") |
@@ -167,16 +167,19 @@ FbTk::Command<void> *parseIntCmd(const string &command, const string &args, | |||
167 | else if (command == "sendtonextworkspace") | 167 | else if (command == "sendtonextworkspace") |
168 | return new SendToNextWorkspaceCmd(num); | 168 | return new SendToNextWorkspaceCmd(num); |
169 | else if (command == "sendtoprevworkspace") | 169 | else if (command == "sendtoprevworkspace") |
170 | return new SendToPrevWorkspaceCmd(num); | 170 | return new SendToNextWorkspaceCmd(-num); |
171 | else if (command == "taketonextworkspace") | 171 | else if (command == "taketonextworkspace") |
172 | return new TakeToNextWorkspaceCmd(num); | 172 | return new SendToNextWorkspaceCmd(num, true); |
173 | else if (command == "taketoprevworkspace") | 173 | else if (command == "taketoprevworkspace") |
174 | return new TakeToPrevWorkspaceCmd(num); | 174 | return new SendToNextWorkspaceCmd(-num, true); |
175 | else if (command == "sendtoworkspace") | 175 | else if (command == "sendtoworkspace") |
176 | // workspaces appear 1-indexed to the user, hence the minus 1 | 176 | return new SendToWorkspaceCmd(num); |
177 | return new SendToWorkspaceCmd(num-1); | ||
178 | else if (command == "taketoworkspace") | 177 | else if (command == "taketoworkspace") |
179 | return new TakeToWorkspaceCmd(num-1); | 178 | return new SendToWorkspaceCmd(num, true); |
179 | else if (command == "sendtonexthead") | ||
180 | return new SendToNextHeadCmd(num); | ||
181 | else if (command == "sendtoprevhead") | ||
182 | return new SendToNextHeadCmd(-num); | ||
180 | return 0; | 183 | return 0; |
181 | } | 184 | } |
182 | 185 | ||
@@ -188,6 +191,8 @@ REGISTER_COMMAND_PARSER(taketonextworkspace, parseIntCmd, void); | |||
188 | REGISTER_COMMAND_PARSER(taketoprevworkspace, parseIntCmd, void); | 191 | REGISTER_COMMAND_PARSER(taketoprevworkspace, parseIntCmd, void); |
189 | REGISTER_COMMAND_PARSER(sendtoworkspace, parseIntCmd, void); | 192 | REGISTER_COMMAND_PARSER(sendtoworkspace, parseIntCmd, void); |
190 | REGISTER_COMMAND_PARSER(taketoworkspace, parseIntCmd, void); | 193 | REGISTER_COMMAND_PARSER(taketoworkspace, parseIntCmd, void); |
194 | REGISTER_COMMAND_PARSER(sendtonexthead, parseIntCmd, void); | ||
195 | REGISTER_COMMAND_PARSER(sendtoprevhead, parseIntCmd, void); | ||
191 | 196 | ||
192 | FbTk::Command<void> *parseFocusCmd(const string &command, const string &args, | 197 | FbTk::Command<void> *parseFocusCmd(const string &command, const string &args, |
193 | bool trusted) { | 198 | bool trusted) { |
@@ -205,49 +210,35 @@ REGISTER_COMMAND_PARSER(focus, parseFocusCmd, void); | |||
205 | }; // end anonymous namespace | 210 | }; // end anonymous namespace |
206 | 211 | ||
207 | void SetHeadCmd::real_execute() { | 212 | void SetHeadCmd::real_execute() { |
208 | fbwindow().setOnHead(m_head); | 213 | int num = m_head; |
214 | int total = fbwindow().screen().numHeads(); | ||
215 | if (num < 0) num += total + 1; | ||
216 | if (num < 1) num = 1; | ||
217 | if (num > total) num = total; | ||
218 | fbwindow().setOnHead(num); | ||
209 | } | 219 | } |
210 | 220 | ||
211 | void SendToWorkspaceCmd::real_execute() { | 221 | void SendToWorkspaceCmd::real_execute() { |
212 | fbwindow().screen().sendToWorkspace(m_workspace_num, &fbwindow(), false); | 222 | int num = m_workspace_num; |
223 | int total = fbwindow().screen().numberOfWorkspaces(); | ||
224 | if (num < 0) num += total + 1; | ||
225 | if (num < 1) num = 1; | ||
226 | if (num > total) num = total; | ||
227 | fbwindow().screen().sendToWorkspace(num-1, &fbwindow(), m_take); | ||
213 | } | 228 | } |
214 | 229 | ||
215 | void SendToNextWorkspaceCmd::real_execute() { | 230 | void SendToNextWorkspaceCmd::real_execute() { |
216 | const int ws_nr = | 231 | int total = fbwindow().screen().numberOfWorkspaces(); |
217 | ( fbwindow().workspaceNumber() + m_delta ) % | 232 | const int ws_nr = (total + (fbwindow().workspaceNumber() + m_delta % total)) % total; |
218 | fbwindow().screen().numberOfWorkspaces(); | 233 | fbwindow().screen().sendToWorkspace(ws_nr, &fbwindow(), m_take); |
219 | fbwindow().screen().sendToWorkspace(ws_nr, &fbwindow(), false); | ||
220 | } | 234 | } |
221 | 235 | ||
222 | void SendToPrevWorkspaceCmd::real_execute() { | 236 | void SendToNextHeadCmd::real_execute() { |
223 | int ws_nr = (fbwindow().workspaceNumber() - m_delta ); | 237 | int total = fbwindow().screen().numHeads(); |
224 | if ( ws_nr < 0 ) | 238 | if (total < 2) |
225 | ws_nr += fbwindow().screen().numberOfWorkspaces(); | 239 | return; |
226 | 240 | int num = (total + fbwindow().getOnHead() - 1 + (m_delta % total)) % total; | |
227 | ws_nr = ws_nr % fbwindow().screen().numberOfWorkspaces(); | 241 | fbwindow().setOnHead(1 + num); |
228 | |||
229 | fbwindow().screen().sendToWorkspace(ws_nr, &fbwindow(), false); | ||
230 | } | ||
231 | |||
232 | void TakeToWorkspaceCmd::real_execute() { | ||
233 | fbwindow().screen().sendToWorkspace(m_workspace_num, &fbwindow()); | ||
234 | } | ||
235 | |||
236 | void TakeToNextWorkspaceCmd::real_execute() { | ||
237 | unsigned int ws_nr = | ||
238 | ( fbwindow().workspaceNumber() + m_delta) % | ||
239 | fbwindow().screen().numberOfWorkspaces(); | ||
240 | fbwindow().screen().sendToWorkspace(ws_nr, &fbwindow()); | ||
241 | } | ||
242 | |||
243 | void TakeToPrevWorkspaceCmd::real_execute() { | ||
244 | int ws_nr = (fbwindow().workspaceNumber() - m_delta); | ||
245 | if ( ws_nr < 0 ) | ||
246 | ws_nr += fbwindow().screen().numberOfWorkspaces(); | ||
247 | |||
248 | ws_nr = ws_nr % fbwindow().screen().numberOfWorkspaces(); | ||
249 | |||
250 | fbwindow().screen().sendToWorkspace(ws_nr, &fbwindow()); | ||
251 | } | 242 | } |
252 | 243 | ||
253 | void GoToTabCmd::real_execute() { | 244 | void GoToTabCmd::real_execute() { |
diff --git a/src/CurrentWindowCmd.hh b/src/CurrentWindowCmd.hh index 9b7d181..32cc5f0 100644 --- a/src/CurrentWindowCmd.hh +++ b/src/CurrentWindowCmd.hh | |||
@@ -74,59 +74,35 @@ private: | |||
74 | 74 | ||
75 | class SendToWorkspaceCmd: public WindowHelperCmd { | 75 | class SendToWorkspaceCmd: public WindowHelperCmd { |
76 | public: | 76 | public: |
77 | explicit SendToWorkspaceCmd(int workspace_num):m_workspace_num(workspace_num) { } | 77 | explicit SendToWorkspaceCmd(int workspace_num, bool take = false): |
78 | m_workspace_num(workspace_num), m_take(take) { } | ||
78 | protected: | 79 | protected: |
79 | void real_execute(); | 80 | void real_execute(); |
80 | private: | 81 | private: |
81 | const int m_workspace_num; | 82 | const int m_workspace_num; |
83 | const bool m_take; | ||
82 | }; | 84 | }; |
83 | 85 | ||
84 | class SendToNextWorkspaceCmd: public WindowHelperCmd { | 86 | class SendToNextWorkspaceCmd: public WindowHelperCmd { |
85 | public: | 87 | public: |
86 | explicit SendToNextWorkspaceCmd(int delta):m_delta(delta) { } | 88 | explicit SendToNextWorkspaceCmd(int delta, bool take = false): |
89 | m_delta(delta), m_take(take) { } | ||
87 | protected: | 90 | protected: |
88 | void real_execute(); | 91 | void real_execute(); |
89 | private: | 92 | private: |
90 | const int m_delta; | 93 | const int m_delta; |
94 | const bool m_take; | ||
91 | }; | 95 | }; |
92 | 96 | ||
93 | class SendToPrevWorkspaceCmd: public WindowHelperCmd { | 97 | class SendToNextHeadCmd: public WindowHelperCmd { |
94 | public: | 98 | public: |
95 | explicit SendToPrevWorkspaceCmd(int delta):m_delta(delta) { } | 99 | explicit SendToNextHeadCmd(int delta): m_delta(delta) { } |
96 | protected: | 100 | protected: |
97 | void real_execute(); | 101 | void real_execute(); |
98 | private: | 102 | private: |
99 | const int m_delta; | 103 | const int m_delta; |
100 | }; | 104 | }; |
101 | 105 | ||
102 | class TakeToWorkspaceCmd : public WindowHelperCmd { | ||
103 | public: | ||
104 | explicit TakeToWorkspaceCmd(int workspace_num) : m_workspace_num(workspace_num) { } | ||
105 | protected: | ||
106 | void real_execute(); | ||
107 | private: | ||
108 | const int m_workspace_num; | ||
109 | }; | ||
110 | |||
111 | class TakeToNextWorkspaceCmd : public WindowHelperCmd { | ||
112 | public: | ||
113 | explicit TakeToNextWorkspaceCmd(int delta) : m_delta(delta) { } | ||
114 | protected: | ||
115 | void real_execute(); | ||
116 | private: | ||
117 | const int m_delta; | ||
118 | }; | ||
119 | |||
120 | class TakeToPrevWorkspaceCmd : public WindowHelperCmd { | ||
121 | public: | ||
122 | explicit TakeToPrevWorkspaceCmd(int delta) : m_delta(delta) { } | ||
123 | protected: | ||
124 | void real_execute(); | ||
125 | private: | ||
126 | const int m_delta; | ||
127 | }; | ||
128 | |||
129 | |||
130 | // goto tab | 106 | // goto tab |
131 | class GoToTabCmd: public WindowHelperCmd { | 107 | class GoToTabCmd: public WindowHelperCmd { |
132 | public: | 108 | public: |