diff --git a/src/IconbarTool.cc b/src/IconbarTool.cc index b2a57d05..b6e2900b 100644 --- a/src/IconbarTool.cc +++ b/src/IconbarTool.cc @@ -214,16 +214,11 @@ class ShowMenu: public FbTk::Command { public: 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() && FbMenu::window() == &m_win) { - m_win.menu().hide(); - return; - } // get last button pos const XEvent &event = Fluxbox::instance()->lastEvent(); int x = event.xbutton.x_root - (m_win.menu().width() / 2); int y = event.xbutton.y_root - (m_win.menu().height() / 2); - m_win.showMenu(x, y); + m_win.popupMenu(x, y); } private: FluxboxWindow &m_win; diff --git a/src/Window.cc b/src/Window.cc index c16d3669..3b5e917c 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -2172,25 +2172,31 @@ void FluxboxWindow::showMenu(int menu_x, int menu_y) { menu().grabInputFocus(); } +void FluxboxWindow::popupMenu(int x, int y) { + // hide menu if it was opened for this window before + if (menu().isVisible() && FbMenu::window() == this) { + menu().hide(); + return; + } + + menu().disableTitle(); + + showMenu(x, y); +} + /** Moves the menu to last button press position and shows it, if it's already visible it'll be hidden */ void FluxboxWindow::popupMenu() { - // hide menu if it was opened for this window before - if (menu().isVisible() && FbMenu::window() == this) { - menu().hide(); - return; - } - - menu().disableTitle(); int menu_y = frame().titlebar().height() + frame().titlebar().borderWidth(); if (!decorations.titlebar) // if we don't have any titlebar menu_y = 0; if (m_last_button_x < x() || m_last_button_x > x() + static_cast(width())) m_last_button_x = x(); - showMenu(m_last_button_x, menu_y + frame().y()); + + popupMenu(m_last_button_x, menu_y + frame().y()); } diff --git a/src/Window.hh b/src/Window.hh index de5bfe4c..c05f5253 100644 --- a/src/Window.hh +++ b/src/Window.hh @@ -323,6 +323,12 @@ public: * @param my position */ void showMenu(int mx, int my); + + /** popup window menu at specific location + * @param x + * @param y + */ + void popupMenu(int x, int y); // popup menu on last button press position void popupMenu();