* Enabled and simplified the "double click team to front" feature, as it

actually works under Haiku (with a caveat, as there is apparently an
  app_server bug that prevents that most of the time).
* Simplified ExpandoMenuBar::MouseDown().
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33708 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2009-10-21 15:51:59 +00:00
parent 6c4570c807
commit 1192454dfc
3 changed files with 64 additions and 90 deletions
+58 -81
View File
@@ -72,8 +72,9 @@ BLocker TExpandoMenuBar::sMonLocker("expando monitor");
TExpandoMenuBar::TExpandoMenuBar(TBarView* bar, BRect frame, const char* name, TExpandoMenuBar::TExpandoMenuBar(TBarView* bar, BRect frame, const char* name,
bool vertical, bool drawLabel) bool vertical, bool drawLabel)
: BMenuBar(frame, name, B_FOLLOW_NONE, :
vertical ? B_ITEMS_IN_COLUMN : B_ITEMS_IN_ROW, vertical), BMenuBar(frame, name, B_FOLLOW_NONE,
vertical ? B_ITEMS_IN_COLUMN : B_ITEMS_IN_ROW, vertical),
fVertical(vertical), fVertical(vertical),
fOverflow(false), fOverflow(false),
fDrawLabel(drawLabel), fDrawLabel(drawLabel),
@@ -83,13 +84,9 @@ TExpandoMenuBar::TExpandoMenuBar(TBarView* bar, BRect frame, const char* name,
fBeMenuWidth(kDefaultBeMenuWidth), fBeMenuWidth(kDefaultBeMenuWidth),
fBarView(bar), fBarView(bar),
fFirstApp(0), fFirstApp(0),
fPreviousDragTargetItem(NULL) fPreviousDragTargetItem(NULL),
fLastClickItem(NULL)
{ {
#ifdef DOUBLECLICKBRINGSTOFRONT
fLastClickItem = -1;
fLastClickTime = 0;
#endif
SetItemMargins(0.0f, 0.0f, 0.0f, 0.0f); SetItemMargins(0.0f, 0.0f, 0.0f, 0.0f);
SetFont(be_plain_font); SetFont(be_plain_font);
SetMaxContentWidth(sMinimumWindowWidth); SetMaxContentWidth(sMinimumWindowWidth);
@@ -301,6 +298,8 @@ void
TExpandoMenuBar::MouseDown(BPoint where) TExpandoMenuBar::MouseDown(BPoint where)
{ {
BMessage* message = Window()->CurrentMessage(); BMessage* message = Window()->CurrentMessage();
BMenuItem* menuItem;
TTeamMenuItem* item = TeamItemAtPoint(where, &menuItem);
// check for three finger salute, a.k.a. Vulcan Death Grip // check for three finger salute, a.k.a. Vulcan Death Grip
if (message != NULL) { if (message != NULL) {
@@ -310,86 +309,65 @@ TExpandoMenuBar::MouseDown(BPoint where)
if ((modifiers & B_COMMAND_KEY) != 0 if ((modifiers & B_COMMAND_KEY) != 0
&& (modifiers & B_OPTION_KEY) != 0 && (modifiers & B_OPTION_KEY) != 0
&& (modifiers & B_SHIFT_KEY) != 0 && (modifiers & B_SHIFT_KEY) != 0
&& !fBarView->Dragging()) { && !fBarView->Dragging()
TTeamMenuItem* item = TeamItemAtPoint(where); && item != NULL) {
const BList *teams = item->Teams();
int32 teamCount = teams->CountItems();
if (item != NULL) { team_id teamID;
const BList *teams = item->Teams(); for (int32 team = 0; team < teamCount; team++) {
int32 teamCount = teams->CountItems(); teamID = (team_id)teams->ItemAt(team);
kill_team(teamID);
team_id teamID; // remove the team immediately from display
for (int32 team = 0; team < teamCount; team++) { RemoveTeam(teamID, false);
teamID = (team_id)teams->ItemAt(team);
kill_team(teamID);
// remove the team immediately
// from display
RemoveTeam(teamID, false);
}
return;
} }
return;
} }
} }
// This feature is broken because the menu bar never receives // double-click on an item brings the team to front
// the second click int32 clicks;
#ifdef DOUBLECLICKBRINGSTOFRONT if (message != NULL && message->FindInt32("clicks", &clicks) == B_OK
// doubleclick on an item brings all to front && clicks > 1) {
for (int32 i = fFirstApp; i < count; i++) { if (item == menuItem && item == fLastClickItem) {
TTeamMenuItem* item = (TTeamMenuItem*)ItemAt(i); // bring this team's window to the front
if (item->Frame().Contains(where)) { BMessage showMessage(kBringTeamToFront);
bigtime_t clickSpeed = 0; showMessage.AddInt32("itemIndex", IndexOf(item));
get_click_speed(&clickSpeed); Window()->PostMessage(&showMessage, this);
if (fLastClickItem == i return;
&& clickSpeed > system_time() - fLastClickTime) {
// bring this team's window to the front
BMessage showMessage(kBringTeamToFront);
showMessage.AddInt32("itemIndex", i);
Window()->PostMessage(&showMessage, this);
return;
}
fLastClickItem = i;
fLastClickTime = system_time();
break;
} }
} } else
#endif fLastClickItem = item;
// control click - show all/hide all shortcut // control click - show all/hide all shortcut
if (message != NULL) { int32 modifiers;
int32 modifiers = 0; if (message != NULL && message->FindInt32("modifiers", &modifiers) == B_OK
message->FindInt32("modifiers", &modifiers); && (modifiers & B_CONTROL_KEY) != 0
if ((modifiers & B_CONTROL_KEY) != 0 && !fBarView->Dragging()
&& ! fBarView->Dragging()) { && item != NULL) {
TTeamMenuItem* item = TeamItemAtPoint(where); // show/hide item's teams
if (item != NULL) { BMessage showMessage((modifiers & B_SHIFT_KEY) != 0
// show/hide item's teams ? kMinimizeTeam : kBringTeamToFront);
BMessage showMessage((modifiers & B_SHIFT_KEY) != 0 showMessage.AddInt32("itemIndex", IndexOf(item));
? kMinimizeTeam : kBringTeamToFront); Window()->PostMessage(&showMessage, this);
showMessage.AddInt32("itemIndex", IndexOf(item)); return;
Window()->PostMessage(&showMessage, this);
return;
}
}
} }
// Check the bounds of the expand Team icon // Check the bounds of the expand Team icon
if (fShowTeamExpander && fVertical && !fBarView->Dragging()) { if (fShowTeamExpander && fVertical && !fBarView->Dragging()
TTeamMenuItem* item = TeamItemAtPoint(where); && item != NULL) {
if (item != NULL) { BRect expanderRect = item->ExpanderBounds();
BRect expanderRect = item->ExpanderBounds(); if (expanderRect.Contains(where)) {
if (expanderRect.Contains(where)) { // Let the update thread wait...
// Let the update thread wait... BAutolock locker(sMonLocker);
BAutolock locker(sMonLocker);
// Toggle the item // Toggle the item
item->ToggleExpandState(true); item->ToggleExpandState(true);
item->Draw(); item->Draw();
// Absorb the message. // Absorb the message.
return; return;
}
} }
} }
@@ -492,12 +470,11 @@ TExpandoMenuBar::InBeMenu(BPoint loc) const
} }
/** Returns the team menu item that belongs to the item under the /*! Returns the team menu item that belongs to the item under the
* specified \a point. specified \a point.
* If \a _item is given, it will return the exact menu item under If \a _item is given, it will return the exact menu item under
* that point (which might be a window item when the expander is on). that point (which might be a window item when the expander is on).
*/ */
TTeamMenuItem* TTeamMenuItem*
TExpandoMenuBar::TeamItemAtPoint(BPoint point, BMenuItem** _item) TExpandoMenuBar::TeamItemAtPoint(BPoint point, BMenuItem** _item)
{ {
+1 -4
View File
@@ -108,10 +108,7 @@ class TExpandoMenuBar : public BMenuBar {
TTeamMenuItem* fSeparatorItem; TTeamMenuItem* fSeparatorItem;
TTeamMenuItem* fPreviousDragTargetItem; TTeamMenuItem* fPreviousDragTargetItem;
#ifdef DOUBLECLICKBRINGSTOFRONT BMenuItem* fLastClickItem;
int32 fLastClickItem;
bigtime_t fLastClickTime;
#endif
static bool sDoMonitor; static bool sDoMonitor;
static thread_id sMonThread; static thread_id sMonThread;
+5 -5
View File
@@ -93,7 +93,7 @@ TShowHideMenuItem::Invoke(BMessage*)
BRect zoomRect(0, 0, 0, 0); BRect zoomRect(0, 0, 0, 0);
BMenuItem* item = Menu()->Superitem(); BMenuItem* item = Menu()->Superitem();
if (item->Menu()->Window() != NULL) { if (item->Menu()->Window() != NULL) {
zoomRect = item->Menu()->ConvertToScreen(item->Frame()); zoomRect = item->Menu()->ConvertToScreen(item->Frame());
doZoom = true; doZoom = true;
} }
@@ -102,8 +102,8 @@ TShowHideMenuItem::Invoke(BMessage*)
} }
status_t status_t
TShowHideMenuItem::TeamShowHideCommon(int32 action, const BList* teamList, TShowHideMenuItem::TeamShowHideCommon(int32 action, const BList* teamList,
BRect zoomRect, bool doZoom) BRect zoomRect, bool doZoom)
{ {
if (teamList == NULL) if (teamList == NULL)
@@ -128,10 +128,10 @@ TShowHideMenuItem::TeamShowHideCommon(int32 action, const BList* teamList,
uint32 command = B_QUIT_REQUESTED; uint32 command = B_QUIT_REQUESTED;
app_info aInfo; app_info aInfo;
be_roster->GetRunningAppInfo(team, &aInfo); be_roster->GetRunningAppInfo(team, &aInfo);
if (strcasecmp(aInfo.signature, kTrackerSignature) == 0) if (strcasecmp(aInfo.signature, kTrackerSignature) == 0)
command = 'Tall'; command = 'Tall';
messenger.SendMessage(command); messenger.SendMessage(command);
break; break;
} }