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).
This commit is contained in:
Henrik Kinnunen 2008-05-13 15:50:17 +02:00
parent c31638038a
commit 5ecebae477
3 changed files with 21 additions and 14 deletions

View file

@ -214,16 +214,11 @@ class ShowMenu: public FbTk::Command<void> {
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;

View file

@ -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<signed>(width()))
m_last_button_x = x();
showMenu(m_last_button_x, menu_y + frame().y());
popupMenu(m_last_button_x, menu_y + frame().y());
}

View file

@ -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();