all repos — fluxbox @ 474e2017454d3c6492eb9f428aee039d36d76e05

custom fork of the fluxbox windowmanager

only allow one open menu at a time
markt markt
commit

474e2017454d3c6492eb9f428aee039d36d76e05

parent

38877987c43857f79481bedeb036380b32019a0f

M ChangeLogChangeLog

@@ -1,5 +1,8 @@

(Format: Year/Month/Day) Changes for 1.0.1: +*07/12/11: + * Only allow one menu to be open at a time (Mark) + FbTk/Menu.cc/hh *07/12/09: * Added OnTitlebar and Double modifiers to the keys file for clicks on the titlebar and double clicks, respectively (Mark, thanks Matteo Galiazzo)
M src/FbCommands.ccsrc/FbCommands.cc

@@ -261,14 +261,7 @@ Fluxbox::instance()->keys()->keyMode(m_keymode);

} void HideMenuCmd::execute() { - BScreen *screen = Fluxbox::instance()->mouseScreen(); - screen->hideMenus(); - if (screen->rootMenu().isVisible()) - screen->rootMenu().hide(); - if (screen->workspaceMenu().isVisible()) - screen->workspaceMenu().hide(); - if (FbTk::Menu::shownMenu()) - FbTk::Menu::shownMenu()->hide(); + FbTk::Menu::hideShownMenu(); } void ShowClientMenuCmd::execute() {
M src/FbTk/Menu.ccsrc/FbTk/Menu.cc

@@ -207,7 +207,6 @@ return insert(new MenuItem(label), pos);

} int Menu::insert(const FbString &label, Menu *submenu, int pos) { - submenu->m_parent = this; return insert(new MenuItem(label, submenu), pos); }

@@ -516,32 +515,24 @@ menu.window.showSubwindows();

menu.window.show(); raise(); - if (! m_parent && shown != this) { - if (shown && (! shown->m_torn)) - shown->hide(); - - shown = this; - } + if (shown && shown != this && shown != m_parent) + shown->hide(true); + shown = this; } -void Menu::hide() { +void Menu::hide(bool force) { - if (!isVisible()) + if (!isVisible() || m_torn && !force) return; - // if not m_torn and parent is m_visible, go to first parent - // and hide it - if (!m_torn && m_parent && m_parent->isVisible()) { - Menu *p = m_parent; - - while ((! p->m_torn) && p->m_parent && p->m_parent->isVisible()) - p = p->m_parent; + // if parent is visible, go to first parent and hide it + Menu *p = this; + while (p->m_parent && p->m_parent->isVisible()) + p = p->m_parent; - p->internal_hide(); - } else if (!m_torn) // if we dont have a parent then do hide here - internal_hide(); + p->internal_hide(); }

@@ -590,7 +581,7 @@ int old = m_active_index;

m_active_index = -1; clearItem(old); // clear old area from highlight - if (shown && shown->menu.window == menu.window) { + if (shown == this) { if (m_parent && m_parent->isVisible()) shown = m_parent; else

@@ -604,6 +595,7 @@ if (first && m_parent && m_parent->isVisible() &&

s_focused && !s_focused->isVisible()) m_parent->grabInputFocus(); + m_parent = 0; menu.window.hide(); }

@@ -1279,6 +1271,11 @@ int item_x = (sbl * menu.item_w), item_y = (i * theme().itemHeight());

FbTk::MenuItem *item = find(index); item->drawLine(menu.frame, theme(), size, item_x, item_y, menu.item_w); +} + +void Menu::hideShownMenu(bool force) { + if (shown) + shown->hide(force); } }; // end namespace FbTk
M src/FbTk/Menu.hhsrc/FbTk/Menu.hh

@@ -124,7 +124,7 @@ virtual void drawSubmenu(unsigned int index);

/// show menu virtual void show(); /// hide menu - virtual void hide(); + virtual void hide(bool force = false); virtual void clearWindow(); #ifdef NOT_USED void setActiveIndex(int index) { m_active_index = index; }

@@ -160,6 +160,7 @@ inline const MenuTheme &theme() const { return m_theme; }

inline unsigned char alpha() const { return theme().alpha(); } inline static Menu *shownMenu() { return shown; } inline static Menu *focused() { return s_focused; } + static void hideShownMenu(bool force = true); /// @return menuitem at index inline const MenuItem *find(unsigned int index) const { return menuitems[index]; } inline MenuItem *find(unsigned int index) { return menuitems[index]; }
M src/IconbarTool.ccsrc/IconbarTool.cc

@@ -217,10 +217,9 @@ explicit ShowMenu(FluxboxWindow &win):m_win(win) { }

void execute() { // hide the menu if it's already showing for this FluxboxWindow if (m_win.menu().isVisible() && WindowCmd<void>::window() == &m_win) { - m_win.screen().hideMenus(); + m_win.menu().hide(); return; } - m_win.screen().hideMenus(); // get last button pos const XEvent &event = Fluxbox::instance()->lastEvent(); int x = event.xbutton.x_root - (m_win.menu().width() / 2);
M src/MenuCreator.ccsrc/MenuCreator.cc

@@ -256,8 +256,7 @@ } else if (str_key == "exec") {

// execute and hide menu using namespace FbTk; RefCount<Command> exec_cmd(CommandParser::instance().parseLine("exec " + str_cmd)); - RefCount<Command> hide_menu(new SimpleCommand<FbTk::Menu>(menu, - &Menu::hide)); + RefCount<Command> hide_menu(CommandParser::instance().parseLine("hidemenus")); MacroCommand *exec_and_hide = new FbTk::MacroCommand(); exec_and_hide->add(hide_menu); exec_and_hide->add(exec_cmd);

@@ -266,8 +265,7 @@ menu.insert(str_label, exec_and_hide_cmd);

} else if (str_key == "macrocmd") { using namespace FbTk; RefCount<Command> macro_cmd(CommandParser::instance().parseLine("macrocmd " + str_cmd)); - RefCount<Command> hide_menu(new SimpleCommand<FbTk::Menu>(menu, - &Menu::hide)); + RefCount<Command> hide_menu(CommandParser::instance().parseLine("hidemenus")); MacroCommand *exec_and_hide = new FbTk::MacroCommand(); exec_and_hide->add(hide_menu); exec_and_hide->add(macro_cmd);
M src/Screen.ccsrc/Screen.cc

@@ -909,43 +909,6 @@ m_windowmenu.reset(MenuCreator::createMenuType("windowmenu", screenNumber()));

m_windowmenu->setInternalMenu(); } -void BScreen::hideMenus() { - // hide extra menus - Fluxbox::instance()->hideExtraMenus(*this); - -#ifdef SLIT - // hide slit menu - if (slit()) - slit()->menu().hide(); -#endif // SLIT - - // hide icon menus - if (!iconList().empty()) { - Icons::iterator it = iconList().begin(); - const Icons::iterator it_end = iconList().end(); - for (; it != it_end; ++it) - (*it)->menu().hide(); - } - // hide all client menus - hideWindowMenus(); - -} - -void BScreen::hideWindowMenus(const FluxboxWindow* except) { - Workspaces::iterator w_it = getWorkspacesList().begin(); - const Workspaces::iterator w_it_end = getWorkspacesList().end(); - for (; w_it != w_it_end; ++w_it) { - if (!(*w_it)->windowList().empty()) { - Workspace::Windows::iterator win_it = (*w_it)->windowList().begin(); - const Workspace::Windows::iterator win_it_end = (*w_it)->windowList().end(); - for (; win_it != win_it_end; ++win_it) { - if (*win_it != except) - (*win_it)->menu().hide(); - } - } - } -} - void BScreen::reconfigure() { Fluxbox *fluxbox = Fluxbox::instance();
M src/Screen.hhsrc/Screen.hh

@@ -260,18 +260,12 @@ * @return created menu

*/ FbTk::Menu *createToggleMenu(const std::string &label); - /// hides all menus that are visible on this screen - void hideMenus(); - /** * For extras to add menus. * These menus will be marked internal, * and deleted when the window dies (as opposed to Screen */ void addExtraWindowMenu(const FbTk::FbString &label, FbTk::Menu *menu); - - /// hide all windowmenus except the given one (if given) - void hideWindowMenus(const FluxboxWindow* except= 0); inline int getEdgeSnapThreshold() const { return *resource.edge_snap_threshold; }
M src/ToolFactory.ccsrc/ToolFactory.cc

@@ -50,7 +50,6 @@ class ShowMenuAboveToolbar: public FbTk::Command {

public: explicit ShowMenuAboveToolbar(Toolbar &tbar):m_tbar(tbar) { } void execute() { - m_tbar.screen().hideMenus(); // get last button pos const XEvent &event = Fluxbox::instance()->lastEvent(); int head = m_tbar.screen().getHead(event.xbutton.x_root, event.xbutton.y_root);
M src/Toolbar.ccsrc/Toolbar.cc

@@ -534,27 +534,21 @@ raise();

if (be.button != 3) return; - screen().hideMenus(); - - if (! menu().isVisible()) { - - int head = screen().getHead(be.x_root, be.y_root); - int borderw = menu().fbwindow().borderWidth(); - pair<int, int> m = screen().clampToHead(head, - be.x_root - (menu().width() / 2), - be.y_root - (menu().titleWindow().height() / 2), - menu().width() + 2*borderw, - menu().height() + 2*borderw); + int head = screen().getHead(be.x_root, be.y_root); + int borderw = menu().fbwindow().borderWidth(); + pair<int, int> m = screen().clampToHead(head, + be.x_root - (menu().width() / 2), + be.y_root - (menu().titleWindow().height() / 2), + menu().width() + 2*borderw, + menu().height() + 2*borderw); - menu().setScreen(screen().getHeadX(head), - screen().getHeadY(head), - screen().getHeadWidth(head), - screen().getHeadHeight(head)); - menu().move(m.first, m.second); - menu().show(); - menu().grabInputFocus(); - } else - menu().hide(); + menu().setScreen(screen().getHeadX(head), + screen().getHeadY(head), + screen().getHeadWidth(head), + screen().getHeadHeight(head)); + menu().move(m.first, m.second); + menu().show(); + menu().grabInputFocus(); }
M src/Window.ccsrc/Window.cc

@@ -2595,8 +2595,7 @@ m_button_grab_y = be.y_root - frame().y() - frame().window().borderWidth();

} else if (frame().handle() == be.window) raise(); - Fluxbox::instance()->hideExtraMenus(screen()); - screen().hideWindowMenus(this); + menu().hide(); } }
M src/fluxbox.ccsrc/fluxbox.cc

@@ -1581,19 +1581,6 @@ // no timestamp changed

return false; } -void Fluxbox::hideExtraMenus(BScreen &screen) { - -#ifdef USE_TOOLBAR - // hide toolbar that matches screen - for (size_t toolbar = 0; toolbar < m_toolbars.size(); ++toolbar) { - if (&(m_toolbars[toolbar]->screen()) == &screen) - m_toolbars[toolbar]->menu().hide(); - } - -#endif // USE_TOOLBAR - -} - void Fluxbox::rereadMenu(bool show_after_reread) { m_reread_menu_wait = true; m_show_menu_after_reread = show_after_reread;
M src/fluxbox.hhsrc/fluxbox.hh

@@ -157,8 +157,6 @@ void reconfigure();

void rereadMenu(bool show_after_reread = false); /// reloads the menus if the timestamps changed - void hideExtraMenus(BScreen &screen); - /// handle any system signal sent to the application void handleSignal(int signum); void update(FbTk::Subject *changed);