aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2004-09-11 20:28:35 (GMT)
committerfluxgen <fluxgen>2004-09-11 20:28:35 (GMT)
commit323f5188fdcf9aa5fbdbd9182ab310c8f9a7ca97 (patch)
tree64e7faef809a7ef26af4cd1199206e806b817fe5
parent93ffd19686f27ae16fb547f1dafd298f9dc041ae (diff)
downloadfluxbox-323f5188fdcf9aa5fbdbd9182ab310c8f9a7ca97.zip
fluxbox-323f5188fdcf9aa5fbdbd9182ab310c8f9a7ca97.tar.bz2
workspace menu and root menu inside visible area
-rw-r--r--src/FbCommands.cc145
1 files changed, 72 insertions, 73 deletions
diff --git a/src/FbCommands.cc b/src/FbCommands.cc
index 8186e71..6a9c548 100644
--- a/src/FbCommands.cc
+++ b/src/FbCommands.cc
@@ -19,7 +19,7 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22// $Id: FbCommands.cc,v 1.26 2004/08/30 12:19:52 akir Exp $ 22// $Id: FbCommands.cc,v 1.27 2004/09/11 20:28:35 fluxgen Exp $
23 23
24#include "FbCommands.hh" 24#include "FbCommands.hh"
25#include "fluxbox.hh" 25#include "fluxbox.hh"
@@ -48,6 +48,45 @@
48 48
49using namespace std; 49using namespace std;
50 50
51namespace {
52
53void showMenu(const BScreen &screen, FbTk::Menu &menu) {
54 Window root_ret; // not used
55 Window window_ret; // not used
56
57 int rx = 0, ry = 0;
58 int wx, wy; // not used
59 unsigned int mask; // not used
60
61 XQueryPointer(menu.fbwindow().display(),
62 screen.rootWindow().window(), &root_ret, &window_ret,
63 &rx, &ry, &wx, &wy, &mask);
64
65 int borderw = menu.fbwindow().borderWidth();
66 int head = screen.getHead(rx, ry);
67
68 pair<int, int> m =
69 screen.clampToHead(head,
70 rx - menu.width() / 2,
71 ry - menu.titleWindow().height() / 2,
72 menu.width() + 2*borderw,
73 menu.height() + 2*borderw);
74
75 menu.move(m.first, m.second);
76 menu.setScreen(screen.getHeadX(head),
77 screen.getHeadY(head),
78 screen.getHeadWidth(head),
79 screen.getHeadHeight(head));
80 // special case for root menu
81 if (&menu == &screen.getRootmenu())
82 Fluxbox::instance()->checkMenu();
83
84 menu.show();
85 menu.grabInputFocus();
86}
87
88}
89
51namespace FbCommands { 90namespace FbCommands {
52 91
53ExecuteCmd::ExecuteCmd(const std::string &cmd, int screen_num):m_cmd(cmd), m_screen_num(screen_num) { 92ExecuteCmd::ExecuteCmd(const std::string &cmd, int screen_num):m_cmd(cmd), m_screen_num(screen_num) {
@@ -123,59 +162,19 @@ void SetStyleCmd::execute() {
123} 162}
124 163
125void ShowRootMenuCmd::execute() { 164void ShowRootMenuCmd::execute() {
126 Fluxbox *fb = Fluxbox::instance(); 165 BScreen *screen = Fluxbox::instance()->mouseScreen();
127 BScreen *screen = fb->mouseScreen();
128 if (screen == 0) 166 if (screen == 0)
129 return; 167 return;
130 168
131 Window root_ret; 169 ::showMenu(*screen, screen->getRootmenu());
132 Window window_ret;
133
134 int rx, ry;
135 int wx, wy;
136 unsigned int mask;
137
138 if (XQueryPointer(fb->display(),
139 screen->rootWindow().window(), &root_ret, &window_ret,
140 &rx, &ry, &wx, &wy, &mask) ) {
141
142 if ( rx - (screen->getRootmenu().width()/2) > 0 )
143 rx-= screen->getRootmenu().width()/2;
144 screen->getRootmenu().move(rx, ry);
145 }
146 fb->checkMenu();
147 screen->getRootmenu().show();
148 screen->getRootmenu().grabInputFocus();
149
150} 170}
151 171
152void ShowWorkspaceMenuCmd::execute() { 172void ShowWorkspaceMenuCmd::execute() {
153 173 BScreen *screen = Fluxbox::instance()->mouseScreen();
154 Fluxbox *fb = Fluxbox::instance();
155 BScreen *screen = fb->mouseScreen();
156 if (screen == 0) 174 if (screen == 0)
157 return; 175 return;
158 176
159 177 ::showMenu(*screen, screen->getWorkspacemenu());
160 Window root_ret;
161 Window window_ret;
162
163 int rx, ry;
164 int wx, wy;
165 unsigned int mask;
166
167 if ( XQueryPointer(fb->display(),
168 screen->rootWindow().window(), &root_ret, &window_ret,
169 &rx, &ry, &wx, &wy, &mask) ) {
170
171 if ( rx - (screen->getWorkspacemenu().width()/2) > 0 )
172 rx-= screen->getWorkspacemenu().width()/2;
173 screen->getWorkspacemenu().move(rx, ry);
174 }
175 fb->checkMenu();
176 screen->getWorkspacemenu().show();
177 screen->getWorkspacemenu().grabInputFocus();
178
179} 178}
180 179
181 180
@@ -263,7 +262,7 @@ void BindKeyCmd::execute() {
263} 262}
264 263
265DeiconifyCmd::DeiconifyCmd(const Mode mode, 264DeiconifyCmd::DeiconifyCmd(const Mode mode,
266 const Destination dest) : m_mode(mode), m_dest(dest) { } 265 const Destination dest) : m_mode(mode), m_dest(dest) { }
267 266
268void DeiconifyCmd::execute() { 267void DeiconifyCmd::execute() {
269 BScreen *screen = Fluxbox::instance()->mouseScreen(); 268 BScreen *screen = Fluxbox::instance()->mouseScreen();
@@ -279,35 +278,35 @@ void DeiconifyCmd::execute() {
279 278
280 switch(m_mode) { 279 switch(m_mode) {
281 280
282 case ALL: 281 case ALL:
283 case ALLWORKSPACE: 282 case ALLWORKSPACE:
284 for(; it != itend; it++) { 283 for(; it != itend; it++) {
285 old_workspace_num= (*it)->workspaceNumber(); 284 old_workspace_num= (*it)->workspaceNumber();
286 if (m_mode == ALL || old_workspace_num == workspace_num) { 285 if (m_mode == ALL || old_workspace_num == workspace_num) {
287 if (m_dest == ORIGIN || m_dest == ORIGINQUIET) 286 if (m_dest == ORIGIN || m_dest == ORIGINQUIET)
288 screen->sendToWorkspace(old_workspace_num, (*it), change_ws); 287 screen->sendToWorkspace(old_workspace_num, (*it), change_ws);
289 else 288 else
290 (*it)->deiconify(false); 289 (*it)->deiconify(false);
291 }
292 } 290 }
293 break; 291 }
294 292 break;
295 case LAST: 293
296 case LASTWORKSPACE: 294 case LAST:
297 default: 295 case LASTWORKSPACE:
298 for (; it != itend; it++) { 296 default:
299 old_workspace_num= (*it)->workspaceNumber(); 297 for (; it != itend; it++) {
300 if(m_mode == LAST || old_workspace_num == workspace_num) { 298 old_workspace_num= (*it)->workspaceNumber();
301 if ((m_dest == ORIGIN || m_dest == ORIGINQUIET) && 299 if(m_mode == LAST || old_workspace_num == workspace_num) {
302 m_mode != LASTWORKSPACE) 300 if ((m_dest == ORIGIN || m_dest == ORIGINQUIET) &&
303 screen->sendToWorkspace(old_workspace_num, (*it), change_ws); 301 m_mode != LASTWORKSPACE)
304 else 302 screen->sendToWorkspace(old_workspace_num, (*it), change_ws);
305 (*it)->deiconify(false); 303 else
306 break; 304 (*it)->deiconify(false);
307 } 305 break;
308 } 306 }
309 break; 307 }
310 }; 308 break;
309 };
311} 310}
312 311
313}; // end namespace FbCommands 312}; // end namespace FbCommands