* 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:
@@ -72,7 +72,8 @@ 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,
|
:
|
||||||
|
BMenuBar(frame, name, B_FOLLOW_NONE,
|
||||||
vertical ? B_ITEMS_IN_COLUMN : B_ITEMS_IN_ROW, vertical),
|
vertical ? B_ITEMS_IN_COLUMN : B_ITEMS_IN_ROW, vertical),
|
||||||
fVertical(vertical),
|
fVertical(vertical),
|
||||||
fOverflow(false),
|
fOverflow(false),
|
||||||
@@ -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,10 +309,8 @@ 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) {
|
||||||
|
|
||||||
if (item != NULL) {
|
|
||||||
const BList *teams = item->Teams();
|
const BList *teams = item->Teams();
|
||||||
int32 teamCount = teams->CountItems();
|
int32 teamCount = teams->CountItems();
|
||||||
|
|
||||||
@@ -321,49 +318,34 @@ TExpandoMenuBar::MouseDown(BPoint where)
|
|||||||
for (int32 team = 0; team < teamCount; team++) {
|
for (int32 team = 0; team < teamCount; team++) {
|
||||||
teamID = (team_id)teams->ItemAt(team);
|
teamID = (team_id)teams->ItemAt(team);
|
||||||
kill_team(teamID);
|
kill_team(teamID);
|
||||||
// remove the team immediately
|
// remove the team immediately from display
|
||||||
// from display
|
|
||||||
RemoveTeam(teamID, false);
|
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);
|
|
||||||
if (item->Frame().Contains(where)) {
|
|
||||||
bigtime_t clickSpeed = 0;
|
|
||||||
get_click_speed(&clickSpeed);
|
|
||||||
if (fLastClickItem == i
|
|
||||||
&& clickSpeed > system_time() - fLastClickTime) {
|
|
||||||
// bring this team's window to the front
|
// bring this team's window to the front
|
||||||
BMessage showMessage(kBringTeamToFront);
|
BMessage showMessage(kBringTeamToFront);
|
||||||
showMessage.AddInt32("itemIndex", i);
|
showMessage.AddInt32("itemIndex", IndexOf(item));
|
||||||
Window()->PostMessage(&showMessage, this);
|
Window()->PostMessage(&showMessage, this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
} else
|
||||||
fLastClickItem = i;
|
fLastClickItem = item;
|
||||||
fLastClickTime = system_time();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
if (item != NULL) {
|
|
||||||
// show/hide item's teams
|
// show/hide item's teams
|
||||||
BMessage showMessage((modifiers & B_SHIFT_KEY) != 0
|
BMessage showMessage((modifiers & B_SHIFT_KEY) != 0
|
||||||
? kMinimizeTeam : kBringTeamToFront);
|
? kMinimizeTeam : kBringTeamToFront);
|
||||||
@@ -371,13 +353,10 @@ TExpandoMenuBar::MouseDown(BPoint where)
|
|||||||
Window()->PostMessage(&showMessage, this);
|
Window()->PostMessage(&showMessage, this);
|
||||||
return;
|
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...
|
||||||
@@ -391,7 +370,6 @@ TExpandoMenuBar::MouseDown(BPoint where)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
BMenuBar::MouseDown(where);
|
BMenuBar::MouseDown(where);
|
||||||
}
|
}
|
||||||
@@ -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)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user