From 5aecf58d47702e6d12ff1174b03a797b516245b7 Mon Sep 17 00:00:00 2001 From: markt Date: Sun, 15 Jul 2007 16:32:54 +0000 Subject: make sure menus close only when right clicking down and up on the titlebar --- src/FbTk/Menu.cc | 12 ++++++++---- src/FbTk/Menu.hh | 1 + src/Gnome.cc | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc index 491ad76..ec0a061 100644 --- a/src/FbTk/Menu.cc +++ b/src/FbTk/Menu.cc @@ -600,7 +600,7 @@ void Menu::internal_hide(bool first) { shown = (Menu *) 0; } - m_torn = m_visible = false; + m_torn = m_visible = m_closing = false; m_which_sub = -1; if (first && m_parent && m_parent->isVisible() && @@ -835,12 +835,16 @@ void Menu::handleEvent(XEvent &event) { if (validIndex(m_which_sub) && menuitems[m_which_sub]->submenu()->isVisible()) menuitems[m_which_sub]->submenu()->grabInputFocus(); - } + } else if (event.type == LeaveNotify) + m_closing = false; } void Menu::buttonPressEvent(XButtonEvent &be) { - if (be.window == menu.title) + if (be.window == menu.title) { grabInputFocus(); + m_closing = (be.button == 3); + } else + m_closing = false; if (be.window == menu.frame && menu.item_w != 0) { @@ -879,7 +883,7 @@ void Menu::buttonReleaseEvent(XButtonEvent &re) { } } - if (re.button == 3) + if (re.button == 3 && m_closing) internal_hide(); } else if (re.window == menu.frame) { diff --git a/src/FbTk/Menu.hh b/src/FbTk/Menu.hh index 576c9f3..34df40a 100644 --- a/src/FbTk/Menu.hh +++ b/src/FbTk/Menu.hh @@ -220,6 +220,7 @@ private: int m_screen_x, m_screen_y; unsigned int m_screen_width, m_screen_height; bool m_moving; ///< if we're moving/draging or not + bool m_closing; ///< if we're right clicking on the menu title bool m_visible; ///< menu visibility bool m_torn; ///< torn from parent bool m_internal_menu; ///< whether we should destroy this menu or if it's managed somewhere else diff --git a/src/Gnome.cc b/src/Gnome.cc index 94ff9e7..5bdb986 100644 --- a/src/Gnome.cc +++ b/src/Gnome.cc @@ -216,7 +216,7 @@ void Gnome::updateClientList(BScreen &screen) { } void Gnome::updateClientClose(WinClient &client) { - if (client.screen().isShuttingdown()) { + if (!client.screen().isShuttingdown()) { XDeleteProperty(FbTk::App::instance()->display(), client.window(), m_gnome_wm_win_workspace); XDeleteProperty(FbTk::App::instance()->display(), client.window(), -- cgit v0.11.2