diff --git a/headers/os/interface/Menu.h b/headers/os/interface/Menu.h index b96a7869e3..23db0c7aed 100644 --- a/headers/os/interface/Menu.h +++ b/headers/os/interface/Menu.h @@ -173,6 +173,7 @@ public: private: friend class BMenuBar; friend class BPrivate::MenuPrivate; + friend class TExpandoMenuBar; friend status_t _init_interface_kit_(); friend status_t set_menu_info(menu_info* info); friend status_t get_menu_info(menu_info* info); @@ -269,6 +270,7 @@ private: int _State(BMenuItem** _item = NULL) const; void _InvokeItem(BMenuItem* item, bool now = false); void _QuitTracking(bool onlyThis = true); + void _SetMenuLayout(menu_layout layout) { fLayout = layout; }; static menu_info sMenuInfo; diff --git a/src/apps/deskbar/BarApp.cpp b/src/apps/deskbar/BarApp.cpp index ed7369d2a9..f2a7fc8f52 100644 --- a/src/apps/deskbar/BarApp.cpp +++ b/src/apps/deskbar/BarApp.cpp @@ -129,8 +129,6 @@ TBarApp::TBarApp() fSwitcherMessenger = BMessenger(new TSwitchManager(fSettings.switcherLoc)); fBarWindow->Show(); - // Call UpdatePlacement() after the window is shown because expanded - // apps need to resize the window. fBarWindow->Lock(); fBarView->UpdatePlacement(); fBarWindow->Unlock(); @@ -505,7 +503,6 @@ TBarApp::MessageReceived(BMessage* message) break; fBarWindow->Lock(); - fBarView->SaveExpandedItems(); fBarView->PlaceApplicationBar(); fBarWindow->Unlock(); break; @@ -521,7 +518,6 @@ TBarApp::MessageReceived(BMessage* message) break; fBarWindow->Lock(); - fBarView->SaveExpandedItems(); fBarView->PlaceApplicationBar(); fBarWindow->Unlock(); break; @@ -545,7 +541,6 @@ TBarApp::MessageReceived(BMessage* message) break; fBarWindow->Lock(); - fBarView->SaveExpandedItems(); fBarView->PlaceApplicationBar(); fBarWindow->Unlock(); break; @@ -561,7 +556,6 @@ TBarApp::MessageReceived(BMessage* message) break; fBarWindow->Lock(); - fBarView->SaveExpandedItems(); fBarView->PlaceApplicationBar(); fBarWindow->Unlock(); break; @@ -577,7 +571,6 @@ TBarApp::MessageReceived(BMessage* message) break; fBarWindow->Lock(); - fBarView->SaveExpandedItems(); fBarView->PlaceApplicationBar(); fBarWindow->Unlock(); break; @@ -611,7 +604,6 @@ TBarApp::MessageReceived(BMessage* message) break; fBarWindow->Lock(); - fBarView->SaveExpandedItems(); if (!fBarView->Vertical()) { // Must also resize the Deskbar menu and replicant tray in // horizontal mode @@ -805,9 +797,6 @@ TBarApp::AddTeam(team_id team, uint32 flags, const char* sig, entry_ref* ref) barInfo->teams->AddItem((void*)(addr_t)team); sBarTeamInfoList.AddItem(barInfo); - if (fSettings.expandNewTeams) - fBarView->AddExpandedItem(sig); - int32 subsCount = sSubscribers.CountItems(); if (subsCount > 0) { for (int32 i = 0; i < subsCount; i++) { diff --git a/src/apps/deskbar/BarView.cpp b/src/apps/deskbar/BarView.cpp index 6f5e9e87fd..8255f2a51b 100644 --- a/src/apps/deskbar/BarView.cpp +++ b/src/apps/deskbar/BarView.cpp @@ -168,10 +168,9 @@ TBarView::TBarView(BRect frame, bool vertical, bool left, bool top, AddChild(fDragRegion); // create and add the application menubar - fExpandoMenuBar = new TExpandoMenuBar(BRect(0, 0, 0, 0), - "ExpandoMenuBar", this, fVertical); - fInlineScrollView = new TInlineScrollView(BRect(0, 0, 0, 0), - fExpandoMenuBar, fVertical ? B_VERTICAL : B_HORIZONTAL); + fExpandoMenuBar = new TExpandoMenuBar("ExpandoMenuBar", this, fVertical); + fInlineScrollView = new TInlineScrollView(fExpandoMenuBar, + fVertical ? B_VERTICAL : B_HORIZONTAL); AddChild(fInlineScrollView); // If mini mode, hide the application menubar @@ -185,8 +184,6 @@ TBarView::~TBarView() delete fDragMessage; delete fCachedTypesList; delete fBarMenuBar; - - RemoveExpandedItems(); } @@ -473,19 +470,12 @@ TBarView::PlaceApplicationBar() BRect expandoFrame(0, 0, 0, 0); if (fVertical) { // left or right - if (fTrayLocation != 0) { - expandoFrame.top = fDragRegion->Frame().bottom + 1; - expandoFrame.left = fDragRegion->Frame().left; - } else { - expandoFrame.top = fBarMenuBar->Frame().bottom + 1; - expandoFrame.left = fDragRegion->Frame().left; - } - + expandoFrame.top = fTrayLocation != 0 ? fDragRegion->Frame().bottom + 1 + : fBarMenuBar->Frame().bottom + 1; + expandoFrame.left = fDragRegion->Frame().left; expandoFrame.right = expandoFrame.left + sMinimumWindowWidth; - if (fState == kFullState) - expandoFrame.bottom = screenFrame.bottom; - else - expandoFrame.bottom = expandoFrame.top + 1; + expandoFrame.bottom = fState == kFullState ? screenFrame.bottom + : expandoFrame.top + 1; } else { // top or bottom expandoFrame.top = 0; @@ -514,9 +504,8 @@ TBarView::PlaceApplicationBar() fExpandoMenuBar->SetMaxItemWidth(); } - fExpandoMenuBar->BuildItems(); - if (fVertical) - ExpandItems(); + if (fState == kExpandoState) + fExpandoMenuBar->BuildItems(); SizeWindow(screenFrame); PositionWindow(screenFrame); @@ -581,7 +570,8 @@ TBarView::GetPreferredWindowSize(BRect screenFrame, float* width, float* height) void TBarView::SizeWindow(BRect screenFrame) { - float windowWidth, windowHeight; + float windowWidth; + float windowHeight; GetPreferredWindowSize(screenFrame, &windowWidth, &windowHeight); Window()->ResizeTo(windowWidth, windowHeight); } @@ -590,7 +580,8 @@ TBarView::SizeWindow(BRect screenFrame) void TBarView::PositionWindow(BRect screenFrame) { - float windowWidth, windowHeight; + float windowWidth; + float windowHeight; GetPreferredWindowSize(screenFrame, &windowWidth, &windowHeight); BPoint moveLoc(0, 0); @@ -661,73 +652,6 @@ TBarView::ChangeState(int32 state, bool vertical, bool left, bool top, } -void -TBarView::SaveExpandedItems() -{ - if (fExpandoMenuBar == NULL) - return; - - // Get a list of the signatures of expanded apps. Can't use - // team_id because there can be more than one team per application - int32 count = fExpandoMenuBar->CountItems(); - for (int32 i = 0; i < count; i++) { - TTeamMenuItem* teamItem - = dynamic_cast(fExpandoMenuBar->ItemAt(i)); - - if (teamItem != NULL && teamItem->IsExpanded()) - AddExpandedItem(teamItem->Signature()); - } -} - - -void -TBarView::RemoveExpandedItems() -{ - while (!fExpandedItems.IsEmpty()) - delete static_cast(fExpandedItems.RemoveItem((int32)0)); - fExpandedItems.MakeEmpty(); -} - - -void -TBarView::ExpandItems() -{ - if (fExpandoMenuBar == NULL || !fVertical || fState != kExpandoState - || !fBarApp->Settings()->superExpando - || fExpandedItems.CountItems() <= 0) { - return; - } - - // Start at the 'bottom' of the list working up. - // Prevents being thrown off by expanding items. - for (int32 i = fExpandoMenuBar->CountItems() - 1; i >= 0; i--) { - TTeamMenuItem* teamItem - = dynamic_cast(fExpandoMenuBar->ItemAt(i)); - - if (teamItem != NULL) { - // Start at the 'bottom' of the fExpandedItems list working up - // matching the order of the fExpandoMenuBar list in the outer loop. - for (int32 j = fExpandedItems.CountItems() - 1; j >= 0; j--) { - BString* itemSig = - static_cast(fExpandedItems.ItemAt(j)); - - if (itemSig->Compare(teamItem->Signature()) == 0) { - // Found it, expand the item and delete signature from - // the list so that we don't consider it for later items. - teamItem->ToggleExpandState(false); - fExpandedItems.RemoveItem(j); - delete itemSig; - break; - } - } - } - } - - // Clean up the expanded items list - RemoveExpandedItems(); -} - - void TBarView::_ChangeState(BMessage* message) { @@ -745,31 +669,21 @@ TBarView::_ChangeState(BMessage* message) fLeft = left; fTop = top; - SaveExpandedItems(); - if (stateChanged || vertSwap) { be_app->PostMessage(kStateChanged); // Send a message to the preferences window to let it know to // enable or disable preference items. - // If switching to expando state, rebuild expando menu bar. - if (fState == kExpandoState) { - if (fInlineScrollView != NULL) { - fInlineScrollView->DetachScrollers(); - fInlineScrollView->RemoveSelf(); - delete fInlineScrollView; - fInlineScrollView = NULL; + if (vertSwap && fExpandoMenuBar != NULL) { + if (fVertical) { + fInlineScrollView->SetOrientation(B_VERTICAL); + fExpandoMenuBar->SetMenuLayout(B_ITEMS_IN_COLUMN); + fExpandoMenuBar->StartMonitoringWindows(); + } else { + fInlineScrollView->SetOrientation(B_HORIZONTAL); + fExpandoMenuBar->SetMenuLayout(B_ITEMS_IN_ROW); + fExpandoMenuBar->StopMonitoringWindows(); } - if (fExpandoMenuBar != NULL) { - delete fExpandoMenuBar; - fExpandoMenuBar = NULL; - } - - fExpandoMenuBar = new TExpandoMenuBar(BRect(0, 0, 0, 0), - "ExpandoMenuBar", this, fVertical); - fInlineScrollView = new TInlineScrollView(BRect(0, 0, 0, 0), - fExpandoMenuBar, fVertical ? B_VERTICAL : B_HORIZONTAL); - AddChild(fInlineScrollView); } } @@ -779,25 +693,6 @@ TBarView::_ChangeState(BMessage* message) } -void -TBarView::AddExpandedItem(const char* signature) -{ - bool shouldAdd = true; - - for (int32 i = 0; i < fExpandedItems.CountItems(); i++) { - BString *itemSig = static_cast(fExpandedItems.ItemAt(i)); - if (itemSig->Compare(signature) == 0) { - // already in the list, don't add the signature - shouldAdd = false; - break; - } - } - - if (shouldAdd) - fExpandedItems.AddItem(static_cast(new BString(signature))); -} - - void TBarView::RaiseDeskbar(bool raise) { @@ -1040,7 +935,7 @@ status_t TBarView::SendDragMessage(const char* signature, entry_ref* ref) { status_t err = B_ERROR; - if (fDragMessage) { + if (fDragMessage != NULL) { if (fRefsRcvdOnly) { // current message sent to apps is only B_REFS_RECEIVED fDragMessage->what = B_REFS_RECEIVED; @@ -1059,6 +954,7 @@ TBarView::SendDragMessage(const char* signature, entry_ref* ref) } else if (signature != NULL && *signature != '\0') roster.Launch(signature, fDragMessage); } + return err; } diff --git a/src/apps/deskbar/BarView.h b/src/apps/deskbar/BarView.h index af76aefb2c..69cc999e2a 100644 --- a/src/apps/deskbar/BarView.h +++ b/src/apps/deskbar/BarView.h @@ -158,7 +158,6 @@ public: float* width, float* height); void SizeWindow(BRect screenFrame); void PositionWindow(BRect screenFrame); - void AddExpandedItem(const char* signature); void CheckForScrolling(); @@ -179,10 +178,6 @@ private: void PlaceTray(bool vertSwap, bool leftSwap); void PlaceApplicationBar(); - void SaveExpandedItems(); - void RemoveExpandedItems(); - void ExpandItems(); - void _ChangeState(BMessage* message); TBarApp* fBarApp; @@ -209,7 +204,6 @@ private: uint32 fMaxRecentApps; TTeamMenuItem* fLastDragItem; - BList fExpandedItems; BMessageFilter* fMouseFilter; }; diff --git a/src/apps/deskbar/ExpandoMenuBar.cpp b/src/apps/deskbar/ExpandoMenuBar.cpp index e962c50482..5f38fc3ea0 100644 --- a/src/apps/deskbar/ExpandoMenuBar.cpp +++ b/src/apps/deskbar/ExpandoMenuBar.cpp @@ -38,6 +38,8 @@ All rights reserved. #include +#include + #include #include #include @@ -77,11 +79,16 @@ bool TExpandoMenuBar::sDoMonitor = false; thread_id TExpandoMenuBar::sMonThread = B_ERROR; BLocker TExpandoMenuBar::sMonLocker("expando monitor"); +typedef std::map TeamMenuItemMap; -TExpandoMenuBar::TExpandoMenuBar(BRect frame, const char* name, - TBarView* barView, bool vertical) + +// #pragma mark - TExpandoMenuBar + + +TExpandoMenuBar::TExpandoMenuBar(const char* name, TBarView* barView, + bool vertical) : - BMenuBar(frame, name, B_FOLLOW_NONE, + BMenuBar(BRect(0, 0, 0, 0), name, B_FOLLOW_NONE, vertical ? B_ITEMS_IN_COLUMN : B_ITEMS_IN_ROW), fBarView(barView), fVertical(vertical), @@ -122,12 +129,8 @@ TExpandoMenuBar::AttachedToWindow() fTeamList.MakeEmpty(); - if (fVertical) { - sDoMonitor = true; - sMonThread = spawn_thread(monitor_team_windows, - "Expando Window Watcher", B_LOW_PRIORITY, this); - resume_thread(sMonThread); - } + if (fVertical) + StartMonitoringWindows(); } @@ -136,14 +139,7 @@ TExpandoMenuBar::DetachedFromWindow() { BMenuBar::DetachedFromWindow(); - if (sMonThread != B_ERROR) { - sDoMonitor = false; - - status_t returnCode; - wait_for_thread(sMonThread, &returnCode); - - sMonThread = B_ERROR; - } + StopMonitoringWindows(); BMessenger self(this); BMessage message(kUnsubscribe); @@ -471,37 +467,79 @@ TExpandoMenuBar::BuildItems() fShowTeamExpander = settings->superExpando; fExpandNewTeams = settings->expandNewTeams; - float itemWidth = -0.1f; - if (fVertical) - itemWidth = Frame().Width(); - else { - itemWidth = iconSize; - if (fDrawLabel) - itemWidth += sMinimumWindowWidth - kMinimumIconSize; - else - itemWidth += kIconPadding * 2; - } + float itemWidth = fVertical ? Frame().Width() + : iconSize + (fDrawLabel ? sMinimumWindowWidth - kMinimumIconSize + : kIconPadding * 2); float itemHeight = -1.0f; - RemoveItems(0, CountItems(), true); - // remove all items + TeamMenuItemMap items; + int32 itemCount = CountItems(); + BList itemList(itemCount); + for (int32 i = 0; i < itemCount; i++) { + BMenuItem* menuItem = RemoveItem((int32)0); + itemList.AddItem(menuItem); + TTeamMenuItem* item = dynamic_cast(menuItem); + if (item != NULL) + items[BString(item->Signature()).ToLower()] = item; + } if (settings->sortRunningApps) fTeamList.SortItems(CompareByName); - int32 count = fTeamList.CountItems(); - for (int32 i = 0; i < count; i++) { - // add items back + int32 teamCount = fTeamList.CountItems(); + for (int32 i = 0; i < teamCount; i++) { BarTeamInfo* barInfo = (BarTeamInfo*)fTeamList.ItemAt(i); - TTeamMenuItem* item = new TTeamMenuItem(barInfo->teams, - barInfo->icon, barInfo->name, barInfo->sig, itemWidth, - itemHeight, fDrawLabel, fVertical); + TeamMenuItemMap::const_iterator iter + = items.find(BString(barInfo->sig).ToLower()); + if (iter == items.end()) { + // new team + TTeamMenuItem* item = new TTeamMenuItem(barInfo->teams, + barInfo->icon, barInfo->name, barInfo->sig, itemWidth, + itemHeight); - if (settings->trackerAlwaysFirst - && strcmp(barInfo->sig, kTrackerSignature) == 0) { - AddItem(item, 0); - } else - AddItem(item); + if (settings->trackerAlwaysFirst + && strcasecmp(barInfo->sig, kTrackerSignature) == 0) { + AddItem(item, 0); + } else + AddItem(item); + } else { + // existing team, update info and add it + TTeamMenuItem* item = iter->second; + item->SetIcon(barInfo->icon); + item->SetOverrideWidth(itemWidth); + item->SetOverrideHeight(itemHeight); + + if (settings->trackerAlwaysFirst + && strcasecmp(barInfo->sig, kTrackerSignature) == 0) { + AddItem(item, 0); + } else + AddItem(item); + + // add window items back + int32 index = itemList.IndexOf(item); + TWindowMenuItem* windowItem; + TWindowMenu* submenu = dynamic_cast(item->Submenu()); + bool hasWindowItems = false; + while ((windowItem = dynamic_cast( + (BMenuItem*)(itemList.ItemAt(++index)))) != NULL) { + if (fVertical) + AddItem(windowItem); + else { + delete windowItem; + hasWindowItems = submenu != NULL; + } + } + + // unexpand if turn off show team expander + if (fVertical && !fShowTeamExpander && item->IsExpanded()) + item->ToggleExpandState(false); + + if (hasWindowItems) { + // add (new) window items in submenu + submenu->SetExpanded(false, 0); + submenu->AttachedToWindow(); + } + } } if (CountItems() == 0) { @@ -572,16 +610,9 @@ TExpandoMenuBar::AddTeam(BList* team, BBitmap* icon, char* name, desk_settings* settings = static_cast(be_app)->Settings(); int32 iconSize = static_cast(be_app)->IconSize(); - float itemWidth = -1.0f; - if (fVertical) - itemWidth = fBarView->Bounds().Width(); - else { - itemWidth = iconSize; - if (fDrawLabel) - itemWidth += sMinimumWindowWidth - kMinimumIconSize; - else - itemWidth += kIconPadding * 2; - } + float itemWidth = fVertical ? Frame().Width() + : iconSize + (fDrawLabel ? sMinimumWindowWidth - kMinimumIconSize + : kIconPadding * 2); float itemHeight = -1.0f; TTeamMenuItem* item = new TTeamMenuItem(team, icon, name, signature, @@ -597,7 +628,7 @@ TExpandoMenuBar::AddTeam(BList* team, BBitmap* icon, char* name, // if Tracker should always be the first item, we need to skip it // when sorting in the current item if (settings->trackerAlwaysFirst && teamItem != NULL - && !strcasecmp(teamItem->Signature(), kTrackerSignature)) { + && strcasecmp(teamItem->Signature(), kTrackerSignature) == 0) { firstApp++; } @@ -617,10 +648,8 @@ TExpandoMenuBar::AddTeam(BList* team, BBitmap* icon, char* name, } else AddItem(item); - if (fVertical) { - if (item && fShowTeamExpander && fExpandNewTeams) - item->ToggleExpandState(false); - } + if (fShowTeamExpander && fExpandNewTeams) + item->ToggleExpandState(false); SizeWindow(1); Window()->UpdateIfNeeded(); @@ -660,10 +689,13 @@ TExpandoMenuBar::RemoveTeam(team_id team, bool partial) RemoveItem(i); if (item == fPreviousDragTargetItem) fPreviousDragTargetItem = NULL; + if (item == fLastMousedOverItem) fLastMousedOverItem = NULL; + if (item == fLastClickedItem) fLastClickedItem = NULL; + delete item; while ((windowItem = dynamic_cast( ItemAt(i))) != NULL) { @@ -671,8 +703,10 @@ TExpandoMenuBar::RemoveTeam(team_id team, bool partial) RemoveItem(i); if (windowItem == fLastMousedOverItem) fLastMousedOverItem = NULL; + if (windowItem == fLastClickedItem) fLastClickedItem = NULL; + delete windowItem; } SizeWindow(-1); @@ -751,6 +785,16 @@ TExpandoMenuBar::MenuLayout() const } +void +TExpandoMenuBar::SetMenuLayout(menu_layout layout) +{ + fVertical = layout == B_ITEMS_IN_COLUMN; + BMenu::_SetMenuLayout(layout); + SetMaxItemWidth(); + // when the menu layout changes, make sure to set the max width +} + + void TExpandoMenuBar::Draw(BRect updateRect) { @@ -859,6 +903,33 @@ TExpandoMenuBar::SizeWindow(int32 delta) } +void +TExpandoMenuBar::StartMonitoringWindows() +{ + if (sMonThread != B_ERROR) + return; + + sDoMonitor = true; + sMonThread = spawn_thread(monitor_team_windows, + "Expando Window Watcher", B_LOW_PRIORITY, this); + resume_thread(sMonThread); +} + + +void +TExpandoMenuBar::StopMonitoringWindows() +{ + if (sMonThread == B_ERROR) + return; + + sDoMonitor = false; + status_t returnCode; + wait_for_thread(sMonThread, &returnCode); + + sMonThread = B_ERROR; +} + + int32 TExpandoMenuBar::monitor_team_windows(void* arg) { diff --git a/src/apps/deskbar/ExpandoMenuBar.h b/src/apps/deskbar/ExpandoMenuBar.h index 19e0627d07..ed1cc3bf97 100644 --- a/src/apps/deskbar/ExpandoMenuBar.h +++ b/src/apps/deskbar/ExpandoMenuBar.h @@ -61,7 +61,7 @@ class TTeamMenuItem; class TExpandoMenuBar : public BMenuBar { public: - TExpandoMenuBar(BRect frame, const char* name, + TExpandoMenuBar(const char* name, TBarView* barView, bool vertical); virtual void AttachedToWindow(); @@ -86,12 +86,16 @@ public: void CheckItemSizes(int32 delta); menu_layout MenuLayout() const; + void SetMenuLayout(menu_layout layout); void SetMaxItemWidth(); void SizeWindow(int32 delta); bool CheckForSizeOverrun(); + void StartMonitoringWindows(); + void StopMonitoringWindows(); + private: static int CompareByName(const void* first, const void* second); diff --git a/src/apps/deskbar/InlineScrollView.cpp b/src/apps/deskbar/InlineScrollView.cpp index 5af41d718a..e80591b2f4 100644 --- a/src/apps/deskbar/InlineScrollView.cpp +++ b/src/apps/deskbar/InlineScrollView.cpp @@ -363,10 +363,10 @@ RightScrollArrow::MouseDown(BPoint where) // #pragma mark - -TInlineScrollView::TInlineScrollView(BRect frame, BView* target, +TInlineScrollView::TInlineScrollView(BView* target, enum orientation orientation) : - BView(frame, "inline scroll view", B_FOLLOW_NONE, B_WILL_DRAW), + BView(BRect(0, 0, 0, 0), "inline scroll view", B_FOLLOW_NONE, B_WILL_DRAW), fTarget(target), fBeginScrollArrow(NULL), fEndScrollArrow(NULL), diff --git a/src/apps/deskbar/InlineScrollView.h b/src/apps/deskbar/InlineScrollView.h index 0a80cbead5..8c57a688ce 100644 --- a/src/apps/deskbar/InlineScrollView.h +++ b/src/apps/deskbar/InlineScrollView.h @@ -20,7 +20,7 @@ class ScrollArrow; class TInlineScrollView : public BView { public: - TInlineScrollView(BRect frame, BView* target, + TInlineScrollView(BView* target, enum orientation orientation = B_VERTICAL); virtual ~TInlineScrollView(); @@ -38,6 +38,10 @@ public: float* _largeStep) const; void ScrollBy(const float& step); + bool Orientation() const { return fOrientation; }; + void SetOrientation(int32 orienation) + { fOrientation = orienation; }; + private: BView* fTarget; ScrollArrow* fBeginScrollArrow; diff --git a/src/apps/deskbar/StatusView.cpp b/src/apps/deskbar/StatusView.cpp index 952d40dde6..df9cde0899 100644 --- a/src/apps/deskbar/StatusView.cpp +++ b/src/apps/deskbar/StatusView.cpp @@ -142,7 +142,7 @@ TReplicantTray::TReplicantTray(TBarView* parent, bool vertical) const BBitmap* logoBitmap = AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_LeafLogoBitmap); if (logoBitmap != NULL) { - sMinimumWindowWidth = max_c(sMinimumWindowWidth, + sMinimumWindowWidth = std::max(sMinimumWindowWidth, 2 * (logoBitmap->Bounds().Width() + 8)); fMinimumTrayWidth = sMinimumWindowWidth - kGutter - kDragRegionWidth; } diff --git a/src/apps/deskbar/TeamMenuItem.cpp b/src/apps/deskbar/TeamMenuItem.cpp index 660cd9d81b..65c81294db 100644 --- a/src/apps/deskbar/TeamMenuItem.cpp +++ b/src/apps/deskbar/TeamMenuItem.cpp @@ -371,8 +371,8 @@ TTeamMenuItem::ToggleExpandState(bool resizeWindow) int myindex = parent->IndexOf(this) + 1; TWindowMenuItem* windowItem = NULL; - int childIndex = 0; - int totalChildren = sub->CountItems() - 4; + int32 childIndex = 0; + int32 totalChildren = sub->CountItems() - 4; // hide, show, close, separator. for (; childIndex < totalChildren; childIndex++) { windowItem = static_cast @@ -393,11 +393,11 @@ TTeamMenuItem::ToggleExpandState(bool resizeWindow) TExpandoMenuBar* parent = static_cast(Menu()); TWindowMenuItem* windowItem = NULL; - int childIndex = parent->IndexOf(this) + 1; - while (!parent->SubmenuAt(childIndex) && childIndex - < parent->CountItems()) { - windowItem = static_cast - (parent->RemoveItem(childIndex)); + int32 childIndex = parent->IndexOf(this) + 1; + while (parent->SubmenuAt(childIndex) == NULL + && childIndex < parent->CountItems()) { + windowItem + = static_cast(parent->RemoveItem(childIndex)); sub->AddItem(windowItem, 0); windowItem->ExpandedItem(false); }