From 9c843719a37eb3f63276f338bbc7cc227dc4e439 Mon Sep 17 00:00:00 2001
From: markt <markt>
Date: Sun, 15 Jul 2007 16:33:32 +0000
Subject: only close menus when right clicking down and up on 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 8f795ac..0559f0d 100644
--- a/src/FbTk/Menu.cc
+++ b/src/FbTk/Menu.cc
@@ -596,7 +596,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() &&
@@ -831,12 +831,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) {
 
@@ -875,7 +879,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 8d112ca..06af08d 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