aboutsummaryrefslogtreecommitdiff
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
parent9dec17611fba493b028fb6664231822a07b3c4c1 (diff)
downloadfluxbox-0116a83aa6b5275cbe3cd2bd851dc6959cacf79b.zip
fluxbox-0116a83aa6b5275cbe3cd2bd851dc6959cacf79b.tar.bz2
add SendToNextHead/SendToPrevHead commands, plus some cleanup in CurrentWindowCmd
-rw-r--r--ChangeLog3
-rw-r--r--doc/asciidoc/fluxbox-keys.txt6
-rw-r--r--doc/fluxbox-keys.512
-rw-r--r--src/CurrentWindowCmd.cc75
-rw-r--r--src/CurrentWindowCmd.hh40
5 files changed, 60 insertions, 76 deletions
diff --git a/ChangeLog b/ChangeLog
index be9f9db..c3882f4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
1 (Format: Year/Month/Day) 1 (Format: Year/Month/Day)
2Changes for 1.1 2Changes for 1.1
3*08/08/21:
4 * Added SendToNextHead and SendToPrevHead commands (Mark)
5 CurrentWindowCmd.cc/hh
3*08/08/20: 6*08/08/20:
4 * Added SetDecor key command (Mark) 7 * Added SetDecor key command (Mark)
5 CurrentWindowCmd.cc/hh 8 CurrentWindowCmd.cc/hh
diff --git a/doc/asciidoc/fluxbox-keys.txt b/doc/asciidoc/fluxbox-keys.txt
index 8ba93ca..aaec83c 100644
--- a/doc/asciidoc/fluxbox-keys.txt
+++ b/doc/asciidoc/fluxbox-keys.txt
@@ -292,6 +292,12 @@ two arguments;;
292 Moves the window to the given display head. Only available when fluxbox 292 Moves the window to the given display head. Only available when fluxbox
293 has been compiled with Xinerama support. 293 has been compiled with Xinerama support.
294 294
295*SendToNextHead* ['offset'] / *SendToPrevHead* ['offset']::
296 Sends the current window to the next/previous display head. If you
297 specify an 'offset' greater than *1*, it will move the window that many
298 heads. If this takes the window beyond the total number of heads, it
299 will wrap around to the beginning.
300
295Workspace Commands 301Workspace Commands
296~~~~~~~~~~~~~~~~~~ 302~~~~~~~~~~~~~~~~~~
297These commands affect the entire workspace (or "desktop" as it is sometimes 303These commands affect the entire workspace (or "desktop" as it is sometimes
diff --git a/doc/fluxbox-keys.5 b/doc/fluxbox-keys.5
index 61fa49a..f4155d3 100644
--- a/doc/fluxbox-keys.5
+++ b/doc/fluxbox-keys.5
@@ -1,11 +1,11 @@
1.\" Title: fluxbox-keys 1.\" Title: fluxbox-keys
2.\" Author: 2.\" Author:
3.\" Generator: DocBook XSL Stylesheets v1.73.2 <http://docbook.sf.net/> 3.\" Generator: DocBook XSL Stylesheets v1.73.2 <http://docbook.sf.net/>
4.\" Date: 08/20/2008 4.\" Date: 08/21/2008
5.\" Manual: 5.\" Manual:
6.\" Source: 6.\" Source:
7.\" 7.\"
8.TH "FLUXBOX\-KEYS" "5" "08/20/2008" "" "" 8.TH "FLUXBOX\-KEYS" "5" "08/21/2008" "" ""
9.\" disable hyphenation 9.\" disable hyphenation
10.nh 10.nh
11.\" disable justification (adjust text to left margin only) 11.\" disable justification (adjust text to left margin only)
@@ -381,6 +381,14 @@ First value becomes the focused alpha, second becomes the unfocused alpha value\
381.RS 4 381.RS 4
382Moves the window to the given display head\. Only available when fluxbox has been compiled with Xinerama support\. 382Moves the window to the given display head\. Only available when fluxbox has been compiled with Xinerama support\.
383.RE 383.RE
384.PP
385\fBSendToNextHead\fR [\fIoffset\fR] / \fBSendToPrevHead\fR [\fIoffset\fR]
386.RS 4
387Sends the current window to the next/previous display head\. If you specify an
388\fIoffset\fR
389greater than
390\fB1\fR, it will move the window that many heads\. If this takes the window beyond the total number of heads, it will wrap around to the beginning\.
391.RE
384.SS "Workspace Commands" 392.SS "Workspace Commands"
385These commands affect the entire workspace (or "desktop" as it is sometimes called)\. 393These commands affect the entire workspace (or "desktop" as it is sometimes called)\.
386.PP 394.PP
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: