aboutsummaryrefslogtreecommitdiff
path: root/src
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
parent9dec17611fba493b028fb6664231822a07b3c4c1 (diff)
downloadfluxbox_pavel-0116a83aa6b5275cbe3cd2bd851dc6959cacf79b.zip
fluxbox_pavel-0116a83aa6b5275cbe3cd2bd851dc6959cacf79b.tar.bz2
add SendToNextHead/SendToPrevHead commands, plus some cleanup in CurrentWindowCmd
Diffstat (limited to 'src')
-rw-r--r--src/CurrentWindowCmd.cc75
-rw-r--r--src/CurrentWindowCmd.hh40
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
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() {
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
75class SendToWorkspaceCmd: public WindowHelperCmd { 75class SendToWorkspaceCmd: public WindowHelperCmd {
76public: 76public:
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) { }
78protected: 79protected:
79 void real_execute(); 80 void real_execute();
80private: 81private:
81 const int m_workspace_num; 82 const int m_workspace_num;
83 const bool m_take;
82}; 84};
83 85
84class SendToNextWorkspaceCmd: public WindowHelperCmd { 86class SendToNextWorkspaceCmd: public WindowHelperCmd {
85public: 87public:
86 explicit SendToNextWorkspaceCmd(int delta):m_delta(delta) { } 88 explicit SendToNextWorkspaceCmd(int delta, bool take = false):
89 m_delta(delta), m_take(take) { }
87protected: 90protected:
88 void real_execute(); 91 void real_execute();
89private: 92private:
90 const int m_delta; 93 const int m_delta;
94 const bool m_take;
91}; 95};
92 96
93class SendToPrevWorkspaceCmd: public WindowHelperCmd { 97class SendToNextHeadCmd: public WindowHelperCmd {
94public: 98public:
95 explicit SendToPrevWorkspaceCmd(int delta):m_delta(delta) { } 99 explicit SendToNextHeadCmd(int delta): m_delta(delta) { }
96protected: 100protected:
97 void real_execute(); 101 void real_execute();
98private: 102private:
99 const int m_delta; 103 const int m_delta;
100}; 104};
101 105
102class TakeToWorkspaceCmd : public WindowHelperCmd {
103public:
104 explicit TakeToWorkspaceCmd(int workspace_num) : m_workspace_num(workspace_num) { }
105protected:
106 void real_execute();
107private:
108 const int m_workspace_num;
109};
110
111class TakeToNextWorkspaceCmd : public WindowHelperCmd {
112public:
113 explicit TakeToNextWorkspaceCmd(int delta) : m_delta(delta) { }
114protected:
115 void real_execute();
116private:
117 const int m_delta;
118};
119
120class TakeToPrevWorkspaceCmd : public WindowHelperCmd {
121public:
122 explicit TakeToPrevWorkspaceCmd(int delta) : m_delta(delta) { }
123protected:
124 void real_execute();
125private:
126 const int m_delta;
127};
128
129
130// goto tab 106// goto tab
131class GoToTabCmd: public WindowHelperCmd { 107class GoToTabCmd: public WindowHelperCmd {
132public: 108public: