From 311cb38f295ae3f389a65cdfea664750e822cb3e Mon Sep 17 00:00:00 2001 From: simonb Date: Sat, 31 Mar 2007 13:34:44 +0000 Subject: Fix window menu context when opened by clicking on tab --- ChangeLog | 3 +++ src/Window.cc | 31 ++++++++++++++++++++++++++++--- src/Window.hh | 2 +- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5958735..1400ad2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,9 @@ (Format: Year/Month/Day) Changes for 1.0.0: *07/03/31: + * Fix window menu context when opened by clicking on tab (Simon) + sf.net bug #1652185 + Window.hh/cc * Default value for $LAUNCHER, plus add util and util/fbrun to the PATH when generating install menu so it can find fbrun (Simon) fluxbox-generate_menu.in Makefile.am data/Makefile.am diff --git a/src/Window.cc b/src/Window.cc index 079126b..ebc5923 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -2188,7 +2188,7 @@ void FluxboxWindow::restoreAttributes() { /** Show the window menu at pos mx, my */ -void FluxboxWindow::showMenu(int menu_x, int menu_y) { +void FluxboxWindow::showMenu(int menu_x, int menu_y, WinClient *client) { // move menu directly under titlebar int head = screen().getHead(menu_x, menu_y); @@ -2204,7 +2204,11 @@ void FluxboxWindow::showMenu(int menu_x, int menu_y) { else if (menu_x + static_cast(menu().width()) >= static_cast(screen().maxRight(head))) menu_x = screen().maxRight(head) - menu().width() - 1; - WindowCmd::setWindow(this); + if (client && (client->fbwindow() == this)) + WindowCmd::setClient(client); + else + WindowCmd::setWindow(this); + menu().move(menu_x, menu_y); menu().show(); menu().raise(); @@ -2223,13 +2227,34 @@ void FluxboxWindow::popupMenu() { return; } + /* Check if we're on a tab, we should make the menu for that tab */ + WinClient *client = 0; + Window labelbutton = 0; + int dest_x = 0, dest_y = 0; + if (XTranslateCoordinates(FbTk::App::instance()->display(), + parent().window(), frame().tabcontainer().window(), + m_last_button_x, m_last_button_y, &dest_x, &dest_y, + &labelbutton)) { + + Client2ButtonMap::iterator it = + find_if(m_labelbuttons.begin(), + m_labelbuttons.end(), + Compose(bind2nd(equal_to(), labelbutton), + Compose(mem_fun(&TextButton::window), + Select2nd()))); + + // label button not found + if (it != m_labelbuttons.end()) + client = it->first; + } + 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()); + showMenu(m_last_button_x, menu_y + frame().y(), client); } diff --git a/src/Window.hh b/src/Window.hh index 3206fdd..82cd492 100644 --- a/src/Window.hh +++ b/src/Window.hh @@ -266,7 +266,7 @@ public: void changeBlackboxHints(const BlackboxHints &bh); void updateFunctions(); void restoreAttributes(); - void showMenu(int mx, int my); + void showMenu(int mx, int my, WinClient *client = 0); // popup menu on last button press position void popupMenu(); -- cgit v0.11.2