DeskBar raise-to-front: reintroduce fLastClickTime

This was removed in hrev33708 when enabling the "double click to raise"
feature. It results in all clicks after the first one just raising the
team again.

Fixes #8471
This commit is contained in:
Adrien Destugues
2020-08-08 15:18:54 +02:00
parent 836100d505
commit 26d0a387e8
2 changed files with 13 additions and 2 deletions
+12 -2
View File
@@ -96,7 +96,8 @@ TExpandoMenuBar::TExpandoMenuBar(menu_layout layout, TBarView* barView)
fFirstBuild(true),
fPreviousDragTargetItem(NULL),
fLastMousedOverItem(NULL),
fLastClickedItem(NULL)
fLastClickedItem(NULL),
fLastClickTime(0)
{
SetItemMargins(0.0f, 0.0f, 0.0f, 0.0f);
SetFont(be_plain_font);
@@ -333,14 +334,23 @@ TExpandoMenuBar::MouseDown(BPoint where)
// double-click on an item brings the team to front
int32 clicks;
bigtime_t clickSpeed = 0;
get_click_speed(&clickSpeed);
bigtime_t delta = system_time() - fLastClickTime;
if (message->FindInt32("clicks", &clicks) == B_OK && clicks > 1
&& item == menuItem && item == fLastClickedItem) {
&& item == menuItem && item == fLastClickedItem
&& delta <= clickSpeed) {
be_roster->ActivateApp((addr_t)item->Teams()->ItemAt(0));
// activate this team
return;
// absorb the message
}
// Update fLastClickTime only if we are not already triggering the
// double-click action. Otherwise the delay is renewed at every subsequent
// click and they keep triggering the double click action
fLastClickTime = system_time();
BMenuBar::MouseDown(where);
}
+1
View File
@@ -129,6 +129,7 @@ private:
TTeamMenuItem* fPreviousDragTargetItem;
BMenuItem* fLastMousedOverItem;
BMenuItem* fLastClickedItem;
bigtime_t fLastClickTime;
BList fTeamList;
static bool sDoMonitor;