Skip to content

Commit

Permalink
Refactor TExpandoMenuBar::MouseDown() style.
Browse files Browse the repository at this point in the history
No functional change intended.
* Check for NULL fields in the beginning and return decreasing the
  indent level of the rest of the method.
* Move some comments to next line indented
  • Loading branch information
jscipione committed Feb 24, 2013
1 parent da17915 commit 88571c9
Showing 1 changed file with 50 additions and 50 deletions.
100 changes: 50 additions & 50 deletions src/apps/deskbar/ExpandoMenuBar.cpp
Expand Up @@ -337,66 +337,66 @@ TExpandoMenuBar::MouseDown(BPoint where)
BMenuItem* menuItem;
TTeamMenuItem* item = TeamItemAtPoint(where, &menuItem);

// check for three finger salute, a.k.a. Vulcan Death Grip
if (message != NULL && item != NULL && !fBarView->Dragging()) {
int32 modifiers = 0;
message->FindInt32("modifiers", &modifiers);

if ((modifiers & B_COMMAND_KEY) != 0
&& (modifiers & B_CONTROL_KEY) != 0
&& (modifiers & B_SHIFT_KEY) != 0) {
const BList* teams = item->Teams();
int32 teamCount = teams->CountItems();

team_id teamID;
for (int32 team = 0; team < teamCount; team++) {
teamID = (addr_t)teams->ItemAt(team);
kill_team(teamID);
// remove the team immediately from display
RemoveTeam(teamID, false);
}
if (message == NULL || item == NULL || fBarView->Dragging()) {
BMenuBar::MouseDown(where);
return;
}

return;
}
int32 modifiers = 0;
message->FindInt32("modifiers", &modifiers);

// control click - show all/hide all shortcut
if ((modifiers & B_CONTROL_KEY) != 0) {
// show/hide item's teams
BMessage showMessage((modifiers & B_SHIFT_KEY) != 0
? kMinimizeTeam : kBringTeamToFront);
showMessage.AddInt32("itemIndex", IndexOf(item));
Window()->PostMessage(&showMessage, this);
return;
// check for three finger salute, a.k.a. Vulcan Death Grip
if ((modifiers & B_COMMAND_KEY) != 0
&& (modifiers & B_CONTROL_KEY) != 0
&& (modifiers & B_SHIFT_KEY) != 0) {
const BList* teams = item->Teams();
int32 teamCount = teams->CountItems();
team_id teamID;
for (int32 team = 0; team < teamCount; team++) {
teamID = (addr_t)teams->ItemAt(team);
kill_team(teamID);
RemoveTeam(teamID, false);
// remove the team from display immediately
}
return;
// absorb the message
}

// Check the bounds of the expand Team icon
if (fShowTeamExpander && fVertical) {
BRect expanderRect = item->ExpanderBounds();
if (expanderRect.Contains(where)) {
// Let the update thread wait...
BAutolock locker(sMonLocker);

// Toggle the item
item->ToggleExpandState(true);
item->Draw();

// Absorb the message.
return;
}
}
// control click - show all/hide all shortcut
if ((modifiers & B_CONTROL_KEY) != 0) {
// show/hide item's teams
BMessage showMessage((modifiers & B_SHIFT_KEY) != 0
? kMinimizeTeam : kBringTeamToFront);
showMessage.AddInt32("itemIndex", IndexOf(item));
Window()->PostMessage(&showMessage, this);
return;
// absorb the message
}

// double-click on an item brings the team to front
int32 clicks;
if (message->FindInt32("clicks", &clicks) == B_OK && clicks > 1
&& item == menuItem && item == fLastClickItem) {
// activate this team
be_roster->ActivateApp((addr_t)item->Teams()->ItemAt(0));
// Check the bounds of the expand Team icon
if (fVertical && fShowTeamExpander) {
if (item->ExpanderBounds().Contains(where)) {
BAutolock locker(sMonLocker);
// let the update thread wait...
item->ToggleExpandState(true);
// toggle the item
item->Draw();
return;
// absorb the message
}
}

fLastClickItem = item;
// double-click on an item brings the team to front
int32 clicks;
if (message->FindInt32("clicks", &clicks) == B_OK && clicks > 1
&& item == menuItem && item == fLastClickItem) {
be_roster->ActivateApp((addr_t)item->Teams()->ItemAt(0));
// activate this team
return;
// absorb the message
}

fLastClickItem = item;
BMenuBar::MouseDown(where);
}

Expand Down

0 comments on commit 88571c9

Please sign in to comment.