From a8e3f500c29c9d0c94233ce499e54fadd83fa764 Mon Sep 17 00:00:00 2001
From: markt <markt>
Date: Tue, 16 Jan 2007 16:25:43 +0000
Subject: right click on iconbutton toggles menu

---
 ChangeLog         |  2 ++
 src/IconButton.cc | 15 ++++++---------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a9b89ca..6b2735a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,8 @@
  (Format: Year/Month/Day)
 Changes for 1.0rc3:
 *07/01/16:
+   * Make right-clicking on iconbar button behave the same way as tabs (Mark)
+     IconButton.cc
    * Don't force user to reconfigure manually in order to apply menu and
      default window transparency changes; instead, in order to conserve system
      resources, do it a half-second after the user stops changing them (Mark)
diff --git a/src/IconButton.cc b/src/IconButton.cc
index eaae85e..545ee1d 100644
--- a/src/IconButton.cc
+++ b/src/IconButton.cc
@@ -30,6 +30,7 @@
 #include "Window.hh"
 #include "WinClient.hh"
 #include "CommandParser.hh"
+#include "WindowCmd.hh"
 
 #include "FbTk/App.hh"
 #include "FbTk/SimpleCommand.hh"
@@ -56,6 +57,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() && WindowCmd<void>::window() == &m_win) {
+            m_win.screen().hideMenus();
+            return;
+        }
         m_win.screen().hideMenus();
         // get last button pos
         const XEvent &event = Fluxbox::instance()->lastEvent();
@@ -146,15 +152,6 @@ IconButton::IconButton(const IconbarTool& tool, const FbTk::FbWindow &parent,
 
     RefCmd next_workspace(new ::WheelWorkspaceCmd(tool, m_win, "nextworkspace"));
     RefCmd prev_workspace(new ::WheelWorkspaceCmd(tool, m_win, "prevworkspace"));
-
-    //!! TODO: There're some issues with MacroCommand when
-    //         this object dies when the last macrocommand is executed (focused cmd)
-    //         In iconbar mode Icons
-    //
-    //    RefCmd hidemenus(new FbTk::SimpleCommand<BScreen>(win.screen(), &BScreen::hideMenus));
-    //    FbTk::MacroCommand *focus_macro = new FbTk::MacroCommand();
-    //    focus_macro->add(hidemenus);
-    //    focus_macro->add(focus);
     
     RefCmd focus_cmd(new ::FocusCommand(tool, m_win));
     RefCmd menu_cmd(new ::ShowMenu(m_win));
-- 
cgit v0.11.2