summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/FbCommands.cc9
-rw-r--r--src/FbTk/Menu.cc37
-rw-r--r--src/FbTk/Menu.hh3
-rw-r--r--src/IconbarTool.cc3
-rw-r--r--src/MenuCreator.cc6
-rw-r--r--src/Screen.cc37
-rw-r--r--src/Screen.hh6
-rw-r--r--src/ToolFactory.cc1
-rw-r--r--src/Toolbar.cc36
-rw-r--r--src/Window.cc3
-rw-r--r--src/fluxbox.cc13
-rw-r--r--src/fluxbox.hh2
12 files changed, 39 insertions, 117 deletions
diff --git a/src/FbCommands.cc b/src/FbCommands.cc
index 1cc1afe..de14f73 100644
--- a/src/FbCommands.cc
+++ b/src/FbCommands.cc
@@ -261,14 +261,7 @@ void KeyModeCmd::execute() {
261} 261}
262 262
263void HideMenuCmd::execute() { 263void HideMenuCmd::execute() {
264 BScreen *screen = Fluxbox::instance()->mouseScreen(); 264 FbTk::Menu::hideShownMenu();
265 screen->hideMenus();
266 if (screen->rootMenu().isVisible())
267 screen->rootMenu().hide();
268 if (screen->workspaceMenu().isVisible())
269 screen->workspaceMenu().hide();
270 if (FbTk::Menu::shownMenu())
271 FbTk::Menu::shownMenu()->hide();
272} 265}
273 266
274void ShowClientMenuCmd::execute() { 267void ShowClientMenuCmd::execute() {
diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc
index 23efcfe..4c41161 100644
--- a/src/FbTk/Menu.cc
+++ b/src/FbTk/Menu.cc
@@ -207,7 +207,6 @@ int Menu::insert(const FbString &label, int pos) {
207} 207}
208 208
209int Menu::insert(const FbString &label, Menu *submenu, int pos) { 209int Menu::insert(const FbString &label, Menu *submenu, int pos) {
210 submenu->m_parent = this;
211 return insert(new MenuItem(label, submenu), pos); 210 return insert(new MenuItem(label, submenu), pos);
212} 211}
213 212
@@ -516,32 +515,24 @@ void Menu::show() {
516 menu.window.show(); 515 menu.window.show();
517 raise(); 516 raise();
518 517
519 if (! m_parent && shown != this) { 518 if (shown && shown != this && shown != m_parent)
520 if (shown && (! shown->m_torn)) 519 shown->hide(true);
521 shown->hide(); 520 shown = this;
522
523 shown = this;
524 }
525 521
526} 522}
527 523
528 524
529void Menu::hide() { 525void Menu::hide(bool force) {
530 526
531 if (!isVisible()) 527 if (!isVisible() || m_torn && !force)
532 return; 528 return;
533 529
534 // if not m_torn and parent is m_visible, go to first parent 530 // if parent is visible, go to first parent and hide it
535 // and hide it 531 Menu *p = this;
536 if (!m_torn && m_parent && m_parent->isVisible()) { 532 while (p->m_parent && p->m_parent->isVisible())
537 Menu *p = m_parent; 533 p = p->m_parent;
538 534
539 while ((! p->m_torn) && p->m_parent && p->m_parent->isVisible()) 535 p->internal_hide();
540 p = p->m_parent;
541
542 p->internal_hide();
543 } else if (!m_torn) // if we dont have a parent then do hide here
544 internal_hide();
545 536
546} 537}
547 538
@@ -590,7 +581,7 @@ void Menu::internal_hide(bool first) {
590 m_active_index = -1; 581 m_active_index = -1;
591 clearItem(old); // clear old area from highlight 582 clearItem(old); // clear old area from highlight
592 583
593 if (shown && shown->menu.window == menu.window) { 584 if (shown == this) {
594 if (m_parent && m_parent->isVisible()) 585 if (m_parent && m_parent->isVisible())
595 shown = m_parent; 586 shown = m_parent;
596 else 587 else
@@ -604,6 +595,7 @@ void Menu::internal_hide(bool first) {
604 s_focused && !s_focused->isVisible()) 595 s_focused && !s_focused->isVisible())
605 m_parent->grabInputFocus(); 596 m_parent->grabInputFocus();
606 597
598 m_parent = 0;
607 menu.window.hide(); 599 menu.window.hide();
608} 600}
609 601
@@ -1281,4 +1273,9 @@ void Menu::drawLine(int index, int size){
1281 item->drawLine(menu.frame, theme(), size, item_x, item_y, menu.item_w); 1273 item->drawLine(menu.frame, theme(), size, item_x, item_y, menu.item_w);
1282} 1274}
1283 1275
1276void Menu::hideShownMenu(bool force) {
1277 if (shown)
1278 shown->hide(force);
1279}
1280
1284}; // end namespace FbTk 1281}; // end namespace FbTk
diff --git a/src/FbTk/Menu.hh b/src/FbTk/Menu.hh
index 06af08d..2a84c77 100644
--- a/src/FbTk/Menu.hh
+++ b/src/FbTk/Menu.hh
@@ -124,7 +124,7 @@ public:
124 /// show menu 124 /// show menu
125 virtual void show(); 125 virtual void show();
126 /// hide menu 126 /// hide menu
127 virtual void hide(); 127 virtual void hide(bool force = false);
128 virtual void clearWindow(); 128 virtual void clearWindow();
129#ifdef NOT_USED 129#ifdef NOT_USED
130 void setActiveIndex(int index) { m_active_index = index; } 130 void setActiveIndex(int index) { m_active_index = index; }
@@ -160,6 +160,7 @@ public:
160 inline unsigned char alpha() const { return theme().alpha(); } 160 inline unsigned char alpha() const { return theme().alpha(); }
161 inline static Menu *shownMenu() { return shown; } 161 inline static Menu *shownMenu() { return shown; }
162 inline static Menu *focused() { return s_focused; } 162 inline static Menu *focused() { return s_focused; }
163 static void hideShownMenu(bool force = true);
163 /// @return menuitem at index 164 /// @return menuitem at index
164 inline const MenuItem *find(unsigned int index) const { return menuitems[index]; } 165 inline const MenuItem *find(unsigned int index) const { return menuitems[index]; }
165 inline MenuItem *find(unsigned int index) { return menuitems[index]; } 166 inline MenuItem *find(unsigned int index) { return menuitems[index]; }
diff --git a/src/IconbarTool.cc b/src/IconbarTool.cc
index 625d358..2574762 100644
--- a/src/IconbarTool.cc
+++ b/src/IconbarTool.cc
@@ -217,10 +217,9 @@ public:
217 void execute() { 217 void execute() {
218 // hide the menu if it's already showing for this FluxboxWindow 218 // hide the menu if it's already showing for this FluxboxWindow
219 if (m_win.menu().isVisible() && WindowCmd<void>::window() == &m_win) { 219 if (m_win.menu().isVisible() && WindowCmd<void>::window() == &m_win) {
220 m_win.screen().hideMenus(); 220 m_win.menu().hide();
221 return; 221 return;
222 } 222 }
223 m_win.screen().hideMenus();
224 // get last button pos 223 // get last button pos
225 const XEvent &event = Fluxbox::instance()->lastEvent(); 224 const XEvent &event = Fluxbox::instance()->lastEvent();
226 int x = event.xbutton.x_root - (m_win.menu().width() / 2); 225 int x = event.xbutton.x_root - (m_win.menu().width() / 2);
diff --git a/src/MenuCreator.cc b/src/MenuCreator.cc
index a99d785..8cc483a 100644
--- a/src/MenuCreator.cc
+++ b/src/MenuCreator.cc
@@ -256,8 +256,7 @@ static void translateMenuItem(Parser &parse, ParseItem &pitem, FbTk::StringConve
256 // execute and hide menu 256 // execute and hide menu
257 using namespace FbTk; 257 using namespace FbTk;
258 RefCount<Command> exec_cmd(CommandParser::instance().parseLine("exec " + str_cmd)); 258 RefCount<Command> exec_cmd(CommandParser::instance().parseLine("exec " + str_cmd));
259 RefCount<Command> hide_menu(new SimpleCommand<FbTk::Menu>(menu, 259 RefCount<Command> hide_menu(CommandParser::instance().parseLine("hidemenus"));
260 &Menu::hide));
261 MacroCommand *exec_and_hide = new FbTk::MacroCommand(); 260 MacroCommand *exec_and_hide = new FbTk::MacroCommand();
262 exec_and_hide->add(hide_menu); 261 exec_and_hide->add(hide_menu);
263 exec_and_hide->add(exec_cmd); 262 exec_and_hide->add(exec_cmd);
@@ -266,8 +265,7 @@ static void translateMenuItem(Parser &parse, ParseItem &pitem, FbTk::StringConve
266 } else if (str_key == "macrocmd") { 265 } else if (str_key == "macrocmd") {
267 using namespace FbTk; 266 using namespace FbTk;
268 RefCount<Command> macro_cmd(CommandParser::instance().parseLine("macrocmd " + str_cmd)); 267 RefCount<Command> macro_cmd(CommandParser::instance().parseLine("macrocmd " + str_cmd));
269 RefCount<Command> hide_menu(new SimpleCommand<FbTk::Menu>(menu, 268 RefCount<Command> hide_menu(CommandParser::instance().parseLine("hidemenus"));
270 &Menu::hide));
271 MacroCommand *exec_and_hide = new FbTk::MacroCommand(); 269 MacroCommand *exec_and_hide = new FbTk::MacroCommand();
272 exec_and_hide->add(hide_menu); 270 exec_and_hide->add(hide_menu);
273 exec_and_hide->add(macro_cmd); 271 exec_and_hide->add(macro_cmd);
diff --git a/src/Screen.cc b/src/Screen.cc
index 7682075..79a75ef 100644
--- a/src/Screen.cc
+++ b/src/Screen.cc
@@ -909,43 +909,6 @@ void BScreen::addExtraWindowMenu(const FbTk::FbString &label, FbTk::Menu *menu)
909 m_windowmenu->setInternalMenu(); 909 m_windowmenu->setInternalMenu();
910} 910}
911 911
912void BScreen::hideMenus() {
913 // hide extra menus
914 Fluxbox::instance()->hideExtraMenus(*this);
915
916#ifdef SLIT
917 // hide slit menu
918 if (slit())
919 slit()->menu().hide();
920#endif // SLIT
921
922 // hide icon menus
923 if (!iconList().empty()) {
924 Icons::iterator it = iconList().begin();
925 const Icons::iterator it_end = iconList().end();
926 for (; it != it_end; ++it)
927 (*it)->menu().hide();
928 }
929 // hide all client menus
930 hideWindowMenus();
931
932}
933
934void BScreen::hideWindowMenus(const FluxboxWindow* except) {
935 Workspaces::iterator w_it = getWorkspacesList().begin();
936 const Workspaces::iterator w_it_end = getWorkspacesList().end();
937 for (; w_it != w_it_end; ++w_it) {
938 if (!(*w_it)->windowList().empty()) {
939 Workspace::Windows::iterator win_it = (*w_it)->windowList().begin();
940 const Workspace::Windows::iterator win_it_end = (*w_it)->windowList().end();
941 for (; win_it != win_it_end; ++win_it) {
942 if (*win_it != except)
943 (*win_it)->menu().hide();
944 }
945 }
946 }
947}
948
949void BScreen::reconfigure() { 912void BScreen::reconfigure() {
950 Fluxbox *fluxbox = Fluxbox::instance(); 913 Fluxbox *fluxbox = Fluxbox::instance();
951 914
diff --git a/src/Screen.hh b/src/Screen.hh
index ac27df1..41a7b90 100644
--- a/src/Screen.hh
+++ b/src/Screen.hh
@@ -260,9 +260,6 @@ public:
260 */ 260 */
261 FbTk::Menu *createToggleMenu(const std::string &label); 261 FbTk::Menu *createToggleMenu(const std::string &label);
262 262
263 /// hides all menus that are visible on this screen
264 void hideMenus();
265
266 /** 263 /**
267 * For extras to add menus. 264 * For extras to add menus.
268 * These menus will be marked internal, 265 * These menus will be marked internal,
@@ -270,9 +267,6 @@ public:
270 */ 267 */
271 void addExtraWindowMenu(const FbTk::FbString &label, FbTk::Menu *menu); 268 void addExtraWindowMenu(const FbTk::FbString &label, FbTk::Menu *menu);
272 269
273 /// hide all windowmenus except the given one (if given)
274 void hideWindowMenus(const FluxboxWindow* except= 0);
275
276 inline int getEdgeSnapThreshold() const { return *resource.edge_snap_threshold; } 270 inline int getEdgeSnapThreshold() const { return *resource.edge_snap_threshold; }
277 271
278 void setRootColormapInstalled(bool r) { root_colormap_installed = r; } 272 void setRootColormapInstalled(bool r) { root_colormap_installed = r; }
diff --git a/src/ToolFactory.cc b/src/ToolFactory.cc
index ee1316a..3fa8714 100644
--- a/src/ToolFactory.cc
+++ b/src/ToolFactory.cc
@@ -50,7 +50,6 @@ class ShowMenuAboveToolbar: public FbTk::Command {
50public: 50public:
51 explicit ShowMenuAboveToolbar(Toolbar &tbar):m_tbar(tbar) { } 51 explicit ShowMenuAboveToolbar(Toolbar &tbar):m_tbar(tbar) { }
52 void execute() { 52 void execute() {
53 m_tbar.screen().hideMenus();
54 // get last button pos 53 // get last button pos
55 const XEvent &event = Fluxbox::instance()->lastEvent(); 54 const XEvent &event = Fluxbox::instance()->lastEvent();
56 int head = m_tbar.screen().getHead(event.xbutton.x_root, event.xbutton.y_root); 55 int head = m_tbar.screen().getHead(event.xbutton.x_root, event.xbutton.y_root);
diff --git a/src/Toolbar.cc b/src/Toolbar.cc
index f67311c..55ae1d3 100644
--- a/src/Toolbar.cc
+++ b/src/Toolbar.cc
@@ -534,27 +534,21 @@ void Toolbar::buttonPressEvent(XButtonEvent &be) {
534 if (be.button != 3) 534 if (be.button != 3)
535 return; 535 return;
536 536
537 screen().hideMenus(); 537 int head = screen().getHead(be.x_root, be.y_root);
538 538 int borderw = menu().fbwindow().borderWidth();
539 if (! menu().isVisible()) { 539 pair<int, int> m = screen().clampToHead(head,
540 540 be.x_root - (menu().width() / 2),
541 int head = screen().getHead(be.x_root, be.y_root); 541 be.y_root - (menu().titleWindow().height() / 2),
542 int borderw = menu().fbwindow().borderWidth(); 542 menu().width() + 2*borderw,
543 pair<int, int> m = screen().clampToHead(head, 543 menu().height() + 2*borderw);
544 be.x_root - (menu().width() / 2), 544
545 be.y_root - (menu().titleWindow().height() / 2), 545 menu().setScreen(screen().getHeadX(head),
546 menu().width() + 2*borderw, 546 screen().getHeadY(head),
547 menu().height() + 2*borderw); 547 screen().getHeadWidth(head),
548 548 screen().getHeadHeight(head));
549 menu().setScreen(screen().getHeadX(head), 549 menu().move(m.first, m.second);
550 screen().getHeadY(head), 550 menu().show();
551 screen().getHeadWidth(head), 551 menu().grabInputFocus();
552 screen().getHeadHeight(head));
553 menu().move(m.first, m.second);
554 menu().show();
555 menu().grabInputFocus();
556 } else
557 menu().hide();
558 552
559} 553}
560 554
diff --git a/src/Window.cc b/src/Window.cc
index 82bdc5e..2997794 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -2595,8 +2595,7 @@ void FluxboxWindow::buttonPressEvent(XButtonEvent &be) {
2595 } else if (frame().handle() == be.window) 2595 } else if (frame().handle() == be.window)
2596 raise(); 2596 raise();
2597 2597
2598 Fluxbox::instance()->hideExtraMenus(screen()); 2598 menu().hide();
2599 screen().hideWindowMenus(this);
2600 } 2599 }
2601} 2600}
2602 2601
diff --git a/src/fluxbox.cc b/src/fluxbox.cc
index 7cf165e..d22f496 100644
--- a/src/fluxbox.cc
+++ b/src/fluxbox.cc
@@ -1581,19 +1581,6 @@ bool Fluxbox::menuTimestampsChanged() const {
1581 return false; 1581 return false;
1582} 1582}
1583 1583
1584void Fluxbox::hideExtraMenus(BScreen &screen) {
1585
1586#ifdef USE_TOOLBAR
1587 // hide toolbar that matches screen
1588 for (size_t toolbar = 0; toolbar < m_toolbars.size(); ++toolbar) {
1589 if (&(m_toolbars[toolbar]->screen()) == &screen)
1590 m_toolbars[toolbar]->menu().hide();
1591 }
1592
1593#endif // USE_TOOLBAR
1594
1595}
1596
1597void Fluxbox::rereadMenu(bool show_after_reread) { 1584void Fluxbox::rereadMenu(bool show_after_reread) {
1598 m_reread_menu_wait = true; 1585 m_reread_menu_wait = true;
1599 m_show_menu_after_reread = show_after_reread; 1586 m_show_menu_after_reread = show_after_reread;
diff --git a/src/fluxbox.hh b/src/fluxbox.hh
index d5a48c6..a6544e3 100644
--- a/src/fluxbox.hh
+++ b/src/fluxbox.hh
@@ -157,8 +157,6 @@ public:
157 void rereadMenu(bool show_after_reread = false); 157 void rereadMenu(bool show_after_reread = false);
158 /// reloads the menus if the timestamps changed 158 /// reloads the menus if the timestamps changed
159 159
160 void hideExtraMenus(BScreen &screen);
161
162 /// handle any system signal sent to the application 160 /// handle any system signal sent to the application
163 void handleSignal(int signum); 161 void handleSignal(int signum);
164 void update(FbTk::Subject *changed); 162 void update(FbTk::Subject *changed);