From 507a03cfe0f3a52f3b3ec9bfd7d9498c9f3c754e Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Tue, 22 Apr 2014 16:29:11 +0200 Subject: [PATCH] Clsoe the tab list menu when clicking the button twice. The menu was closed, but immediately reopened by the click on the button. If the time since the menu closing is shorter than a double-click delay, don't open the menu again. Fixes #9538. --- src/apps/webpositive/tabview/TabManager.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/apps/webpositive/tabview/TabManager.cpp b/src/apps/webpositive/tabview/TabManager.cpp index d5c587c111..a4536138c4 100644 --- a/src/apps/webpositive/tabview/TabManager.cpp +++ b/src/apps/webpositive/tabview/TabManager.cpp @@ -160,6 +160,7 @@ class TabMenuTabButton : public TabButton { public: TabMenuTabButton(BMessage* message) : TabButton(message) + , fCloseTime(0) { } @@ -177,8 +178,13 @@ public: virtual void MouseDown(BPoint point) { - if (!IsEnabled()) + // Don't reopen the menu if it's already open or freshly closed. + bigtime_t clickSpeed = 2000000; + get_click_speed(&clickSpeed); + if (!IsEnabled() || (Value() == B_CONTROL_ON) + || real_time_clock_usecs() < fCloseTime + clickSpeed) { return; + } // Invoke must be called before setting B_CONTROL_ON // for the button to stay "down" @@ -193,8 +199,12 @@ public: void MenuClosed() { + fCloseTime = real_time_clock_usecs(); SetValue(B_CONTROL_OFF); } + +private: + bigtime_t fCloseTime; };