From 5ecebae4770cbe7e4feea46d2c074a818f1c9662 Mon Sep 17 00:00:00 2001 From: Henrik Kinnunen Date: Tue, 13 May 2008 15:50:17 +0200 Subject: Fixed startup bug for window menu in iconbar. The window menu in the iconbutton was not updated properly the first time it was used ( before right clicking in the real window titlebar). --- src/IconbarTool.cc | 7 +------ src/Window.cc | 22 ++++++++++++++-------- src/Window.hh | 6 ++++++ 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/IconbarTool.cc b/src/IconbarTool.cc index b2a57d0..b6e2900 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 c16d366..3b5e917 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 de5bfe4..c05f525 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(); -- cgit v0.11.2