aboutsummaryrefslogtreecommitdiff
path: root/src/CurrentWindowCmd.cc
diff options
context:
space:
mode:
authorMark Tiefenbruck <mark@fluxbox.org>2008-08-21 10:22:57 (GMT)
committerMark Tiefenbruck <mark@fluxbox.org>2008-08-21 10:22:57 (GMT)
commit0116a83aa6b5275cbe3cd2bd851dc6959cacf79b (patch)
treed1f5d891549f9a5ee24c69e0d437c6746e6e7a23 /src/CurrentWindowCmd.cc
parent9dec17611fba493b028fb6664231822a07b3c4c1 (diff)
downloadfluxbox-0116a83aa6b5275cbe3cd2bd851dc6959cacf79b.zip
fluxbox-0116a83aa6b5275cbe3cd2bd851dc6959cacf79b.tar.bz2
add SendToNextHead/SendToPrevHead commands, plus some cleanup in CurrentWindowCmd
Diffstat (limited to 'src/CurrentWindowCmd.cc')
-rw-r--r--src/CurrentWindowCmd.cc75
1 files changed, 33 insertions, 42 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
158FbTk::Command<void> *parseIntCmd(const string &command, const string &args, 158FbTk::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);
188REGISTER_COMMAND_PARSER(taketoprevworkspace, parseIntCmd, void); 191REGISTER_COMMAND_PARSER(taketoprevworkspace, parseIntCmd, void);
189REGISTER_COMMAND_PARSER(sendtoworkspace, parseIntCmd, void); 192REGISTER_COMMAND_PARSER(sendtoworkspace, parseIntCmd, void);
190REGISTER_COMMAND_PARSER(taketoworkspace, parseIntCmd, void); 193REGISTER_COMMAND_PARSER(taketoworkspace, parseIntCmd, void);
194REGISTER_COMMAND_PARSER(sendtonexthead, parseIntCmd, void);
195REGISTER_COMMAND_PARSER(sendtoprevhead, parseIntCmd, void);
191 196
192FbTk::Command<void> *parseFocusCmd(const string &command, const string &args, 197FbTk::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
207void SetHeadCmd::real_execute() { 212void 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
211void SendToWorkspaceCmd::real_execute() { 221void 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
215void SendToNextWorkspaceCmd::real_execute() { 230void 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
222void SendToPrevWorkspaceCmd::real_execute() { 236void 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
232void TakeToWorkspaceCmd::real_execute() {
233 fbwindow().screen().sendToWorkspace(m_workspace_num, &fbwindow());
234}
235
236void 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
243void 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
253void GoToTabCmd::real_execute() { 244void GoToTabCmd::real_execute() {