diff --git a/src/apps/deskbar/BarApp.cpp b/src/apps/deskbar/BarApp.cpp index 01372cb2f4..ed7369d2a9 100644 --- a/src/apps/deskbar/BarApp.cpp +++ b/src/apps/deskbar/BarApp.cpp @@ -60,9 +60,9 @@ All rights reserved. #include "tracker_private.h" #include "BarView.h" #include "BarWindow.h" -#include "PreferencesWindow.h" #include "DeskbarUtils.h" #include "FSUtils.h" +#include "PreferencesWindow.h" #include "PublicCommands.h" #include "ResourceSet.h" #include "StatusView.h" diff --git a/src/apps/deskbar/BarView.cpp b/src/apps/deskbar/BarView.cpp index 483d66e238..d904e35bb7 100644 --- a/src/apps/deskbar/BarView.cpp +++ b/src/apps/deskbar/BarView.cpp @@ -125,6 +125,9 @@ BarViewMessageFilter::Filter(BMessage* message, BHandler** target) } +// #pragma mark - TBarView + + TBarView::TBarView(BRect frame, bool vertical, bool left, bool top, int32 state, float) : @@ -865,7 +868,7 @@ TBarView::DragStart() uint32 buttons; GetMouse(&loc, &buttons); - if (fExpandoMenuBar && fExpandoMenuBar->Frame().Contains(loc)) { + if (fExpandoMenuBar != NULL && fExpandoMenuBar->Frame().Contains(loc)) { ConvertToScreen(&loc); BPoint expandoLocation = fExpandoMenuBar->ConvertFromScreen(loc); TTeamMenuItem* item = fExpandoMenuBar->TeamItemAtPoint(expandoLocation); diff --git a/src/apps/deskbar/ExpandoMenuBar.cpp b/src/apps/deskbar/ExpandoMenuBar.cpp index 232a5acc6b..90d7551c36 100644 --- a/src/apps/deskbar/ExpandoMenuBar.cpp +++ b/src/apps/deskbar/ExpandoMenuBar.cpp @@ -515,7 +515,7 @@ bool TExpandoMenuBar::InDeskbarMenu(BPoint loc) const { TBarWindow* window = dynamic_cast(Window()); - if (window) { + if (window != NULL) { if (TDeskbarMenu* bemenu = window->DeskbarMenu()) { bool inDeskbarMenu = false; if (bemenu->LockLooper()) { @@ -629,15 +629,14 @@ TExpandoMenuBar::AddTeam(BList* team, BBitmap* icon, char* name, void TExpandoMenuBar::AddTeam(team_id team, const char* signature) { - int32 count = CountItems(); - for (int32 i = 0; i < count; i++) { + int32 itemCount = CountItems(); + for (int32 i = 0; i < itemCount; i++) { // Only add to team menu items - if (TTeamMenuItem* item = dynamic_cast(ItemAt(i))) { - if (strcasecmp(item->Signature(), signature) == 0) { - if (!(item->Teams()->HasItem((void*)(addr_t)team))) - item->Teams()->AddItem((void*)(addr_t)team); - break; - } + TTeamMenuItem* item = dynamic_cast(ItemAt(i)); + if (item != NULL && strcasecmp(item->Signature(), signature) == 0 + && !(item->Teams()->HasItem((void*)(addr_t)team))) { + item->Teams()->AddItem((void*)(addr_t)team); + break; } } } @@ -649,36 +648,35 @@ TExpandoMenuBar::RemoveTeam(team_id team, bool partial) TWindowMenuItem* windowItem = NULL; for (int32 i = CountItems() - 1; i >= 0; i--) { - if (TTeamMenuItem* item = dynamic_cast(ItemAt(i))) { - if (item->Teams()->HasItem((void*)(addr_t)team)) { - item->Teams()->RemoveItem(team); - if (partial) - return; - - BAutolock locker(sMonLocker); - // make the update thread wait - 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) { - // Also remove window items (if there are any) - RemoveItem(i); - if (windowItem == fLastMousedOverItem) - fLastMousedOverItem = NULL; - if (windowItem == fLastClickedItem) - fLastClickedItem = NULL; - delete windowItem; - } - SizeWindow(-1); - Window()->UpdateIfNeeded(); + TTeamMenuItem* item = dynamic_cast(ItemAt(i)); + if (item != NULL && item->Teams()->HasItem((void*)(addr_t)team)) { + item->Teams()->RemoveItem(team); + if (partial) return; + + BAutolock locker(sMonLocker); + // make the update thread wait + 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) { + // Also remove window items (if there are any) + RemoveItem(i); + if (windowItem == fLastMousedOverItem) + fLastMousedOverItem = NULL; + if (windowItem == fLastClickedItem) + fLastClickedItem = NULL; + delete windowItem; } + SizeWindow(-1); + Window()->UpdateIfNeeded(); + return; } } } @@ -882,7 +880,8 @@ TExpandoMenuBar::monitor_team_windows(void* arg) // Perform SetTo() on all the items that still exist as well as add // new items. - bool itemModified = false, resize = false; + bool itemModified = false; + bool resize = false; TTeamMenuItem* teamItem = NULL; for (int32 i = 0; i < totalItems; i++) { @@ -895,7 +894,7 @@ TExpandoMenuBar::monitor_team_windows(void* arg) for (int32 j = 0; j < teamCount; j++) { // The following code is almost a copy/paste from // WindowMenu.cpp - team_id theTeam = (addr_t)teamItem->Teams()->ItemAt(j); + team_id theTeam = (addr_t)teamItem->Teams()->ItemAt(j); int32 count = 0; int32* tokens = get_token_list(theTeam, &count); @@ -909,14 +908,13 @@ TExpandoMenuBar::monitor_team_windows(void* arg) // Check if we have a matching window item... item = teamItem->ExpandedWindowItem( wInfo->server_token); - if (item) { + if (item != NULL) { item->SetTo(wInfo->name, wInfo->server_token, wInfo->is_mini, ((1 << current_workspace()) & wInfo->workspaces) != 0); - if (strcmp(wInfo->name, - item->Label()) != 0) + if (strcmp(wInfo->name, item->Label()) != 0) item->SetLabel(wInfo->name); if (item->ChangedState()) diff --git a/src/apps/deskbar/TeamMenuItem.h b/src/apps/deskbar/TeamMenuItem.h index 4cbfb8522a..14c86b4893 100644 --- a/src/apps/deskbar/TeamMenuItem.h +++ b/src/apps/deskbar/TeamMenuItem.h @@ -32,8 +32,8 @@ brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ -#ifndef TEAMMENUITEM_H -#define TEAMMENUITEM_H +#ifndef TEAM_MENU_ITEM_H +#define TEAM_MENU_ITEM_H // Individual team/application listing @@ -122,4 +122,4 @@ private: }; -#endif // TEAMMENUITEM_H +#endif // TEAM_MENU_ITEM_H diff --git a/src/apps/deskbar/WindowMenu.cpp b/src/apps/deskbar/WindowMenu.cpp index d4fcad4fc9..88960e0b1b 100644 --- a/src/apps/deskbar/WindowMenu.cpp +++ b/src/apps/deskbar/WindowMenu.cpp @@ -77,7 +77,8 @@ TWindowMenu::WindowShouldBeListed(client_window_info* info) TWindowMenu::TWindowMenu(const BList* team, const char* signature) - : BMenu("Deskbar Team Menu"), + : + BMenu("Deskbar Team Menu"), fTeam(team), fApplicationSignature(signature), fExpanded(false), @@ -96,7 +97,7 @@ TWindowMenu::AttachedToWindow() bool dragging = false; TBarView* barview =(static_cast(be_app))->BarView(); - if (barview && barview->LockLooper()) { + if (barview != NULL && barview->LockLooper()) { // 'dragging' mode set in BarView::CacheDragData // invoke in MouseEnter in ExpandoMenuBar dragging = barview->Dragging();