This commit fixes a bug described in ticket #7051 where Deskbar forgets expanded
items when you switch away from expando mode. It does this by keeping a list of expanded item signatures in a fExpandedItems BList on the BarView class. I can't use team_id because there can be more than one team per application. If you have checked the 'Expand new applications' option in the Deskbar preferences then the signatures of new applications will be added to the fExpandedItems list expanding the item. If you open a new application while not in expando mode then the app will be expanded upon returning to expando mode. Since 'Expand new applications' automatically adds any new item's signature to the fExpandedItems list Tracker is expanded on startup since it is 'new'. Also if Deskbar is restarted all applications will be considered 'new' so they are expanded. This fixes ticket #4830 git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43092 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -95,6 +95,8 @@ TBarApp::TBarApp()
|
||||
InitSettings();
|
||||
InitIconPreloader();
|
||||
|
||||
fBarWindow = new TBarWindow();
|
||||
|
||||
be_roster->StartWatching(this);
|
||||
|
||||
gLocalizedNamePreferred
|
||||
@@ -119,9 +121,15 @@ TBarApp::TBarApp()
|
||||
|
||||
fSwitcherMessenger = BMessenger(new TSwitchManager(fSettings.switcherLoc));
|
||||
|
||||
fBarWindow = new TBarWindow();
|
||||
fBarWindow->Show();
|
||||
|
||||
// Call UpdatePlacement() after the window is shown because expanded apps
|
||||
// need to resize the window.
|
||||
if (fBarWindow->Lock()) {
|
||||
BarView()->UpdatePlacement();
|
||||
fBarWindow->Unlock();
|
||||
}
|
||||
|
||||
// this messenger now targets the barview instead of the
|
||||
// statusview so that all additions to the tray
|
||||
// follow the same path
|
||||
@@ -645,6 +653,9 @@ TBarApp::AddTeam(team_id team, uint32 flags, const char* sig, entry_ref* ref)
|
||||
|
||||
sBarTeamInfoList.AddItem(barInfo);
|
||||
|
||||
if (fSettings.expandNewTeams)
|
||||
BarView()->AddExpandedItem(sig);
|
||||
|
||||
int32 subsCount = sSubscribers.CountItems();
|
||||
if (subsCount > 0) {
|
||||
for (int32 i = 0; i < subsCount; i++) {
|
||||
|
||||
@@ -68,6 +68,7 @@ const int32 kDefaultRecentAppCount = 10;
|
||||
|
||||
const int32 kMenuTrackMargin = 20;
|
||||
|
||||
|
||||
TBarView::TBarView(BRect frame, bool vertical, bool left, bool top,
|
||||
bool showInterval, uint32 state, float, bool showTime)
|
||||
: BView(frame, "BarView", B_FOLLOW_ALL_SIDES, B_WILL_DRAW),
|
||||
@@ -99,6 +100,8 @@ TBarView::~TBarView()
|
||||
{
|
||||
delete fDragMessage;
|
||||
delete fCachedTypesList;
|
||||
|
||||
RemoveExpandedItems();
|
||||
}
|
||||
|
||||
|
||||
@@ -405,10 +408,10 @@ TBarView::GetPreferredWindowSize(BRect screenFrame, float* width, float* height)
|
||||
windowHeight = screenFrame.bottom;
|
||||
windowWidth = fBarMenuBar->Frame().Width();
|
||||
} else if (fState == kExpandoState) {
|
||||
if (fVertical)
|
||||
if (fVertical) {
|
||||
// top left or right
|
||||
windowHeight = fExpando->Frame().bottom;
|
||||
else {
|
||||
} else {
|
||||
// top or bottom, full
|
||||
fExpando->CheckItemSizes(0);
|
||||
windowHeight = kHModeHeight;
|
||||
@@ -528,58 +531,103 @@ TBarView::ChangeState(int32 state, bool vertical, bool left, bool top)
|
||||
PlaceBeMenu();
|
||||
PlaceTray(vertSwap, leftSwap, screenFrame);
|
||||
|
||||
// We need to keep track of what apps are expanded.
|
||||
BList expandedItems;
|
||||
BString* signature = NULL;
|
||||
if (fVertical && Expando()
|
||||
&& static_cast<TBarApp*>(be_app)->Settings()->superExpando) {
|
||||
// Get a list of the signatures of expanded apps. Can't use
|
||||
// team_id because there can be more than one team per application
|
||||
if (fVertical && Expando() && vertical && fExpando) {
|
||||
for (int index = 0; index < fExpando->CountItems(); index++) {
|
||||
TTeamMenuItem* item
|
||||
= dynamic_cast<TTeamMenuItem*>(fExpando->ItemAt(index));
|
||||
if (item != NULL && item->IsExpanded()) {
|
||||
signature = new BString(item->Signature());
|
||||
expandedItems.AddItem((void*)signature);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Keep track of which apps are expanded
|
||||
SaveExpandedItems();
|
||||
|
||||
PlaceApplicationBar(screenFrame);
|
||||
SizeWindow(screenFrame);
|
||||
PositionWindow(screenFrame);
|
||||
Window()->UpdateIfNeeded();
|
||||
|
||||
// Re-expand those apps.
|
||||
if (expandedItems.CountItems() > 0) {
|
||||
for (int sigIndex = expandedItems.CountItems(); sigIndex-- > 0;) {
|
||||
signature = static_cast<BString*>(expandedItems.ItemAt(sigIndex));
|
||||
if (signature == NULL)
|
||||
continue;
|
||||
// Re-expand apps
|
||||
ExpandItems();
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
// Start at the 'bottom' of the list working up.
|
||||
// Prevents being thrown off by expanding items.
|
||||
for (int teamIndex = fExpando->CountItems(); teamIndex-- > 0;) {
|
||||
TTeamMenuItem* item
|
||||
= dynamic_cast<TTeamMenuItem*>(fExpando->ItemAt(teamIndex));
|
||||
if (item != NULL && !signature->Compare(item->Signature())) {
|
||||
item->ToggleExpandState(false);
|
||||
|
||||
void
|
||||
TBarView::SaveExpandedItems()
|
||||
{
|
||||
if (fExpando == NULL || fExpando->CountItems() <= 0)
|
||||
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
|
||||
for (int32 i = 0; i < fExpando->CountItems(); i++) {
|
||||
TTeamMenuItem* teamItem
|
||||
= dynamic_cast<TTeamMenuItem*>(fExpando->ItemAt(i));
|
||||
|
||||
if (teamItem != NULL && teamItem->IsExpanded())
|
||||
AddExpandedItem(teamItem->Signature());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarView::RemoveExpandedItems()
|
||||
{
|
||||
while (!fExpandedItems.IsEmpty())
|
||||
delete static_cast<BString*>(fExpandedItems.RemoveItem((int32)0));
|
||||
fExpandedItems.MakeEmpty();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarView::ExpandItems()
|
||||
{
|
||||
if (fExpando == NULL || !fVertical || !Expando()
|
||||
|| !static_cast<TBarApp*>(be_app)->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 = fExpando->CountItems() - 1; i >= 0; i--) {
|
||||
TTeamMenuItem* teamItem
|
||||
= dynamic_cast<TTeamMenuItem*>(fExpando->ItemAt(i));
|
||||
|
||||
if (teamItem != NULL) {
|
||||
// Start at the 'bottom' of the fExpandedItems list working up
|
||||
// matching the order of the fExpando list in the outer loop.
|
||||
for (int32 j = fExpandedItems.CountItems() - 1; j >= 0; j--) {
|
||||
BString* itemSig =
|
||||
static_cast<BString*>(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 expanded signature list.
|
||||
while (!expandedItems.IsEmpty()) {
|
||||
delete static_cast<BString*>(expandedItems.RemoveItem((int32)0));
|
||||
}
|
||||
|
||||
fExpando->SizeWindow();
|
||||
}
|
||||
|
||||
Invalidate();
|
||||
// Clean up the expanded items list
|
||||
RemoveExpandedItems();
|
||||
|
||||
fExpando->SizeWindow();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarView::AddExpandedItem(const char* signature)
|
||||
{
|
||||
bool shouldAdd = true;
|
||||
|
||||
for (int32 i = 0; i < fExpandedItems.CountItems(); i++) {
|
||||
BString *itemSig = static_cast<BString*>(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<void*>(new BString(signature)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -142,7 +142,8 @@ class TBarView : public BView {
|
||||
TExpandoMenuBar* ExpandoMenuBar() const;
|
||||
TBarMenuBar* BarMenuBar() const;
|
||||
TDragRegion* DragRegion() const { return fDragRegion; }
|
||||
|
||||
void AddExpandedItem(const char* signature);
|
||||
|
||||
private:
|
||||
friend class TBeMenu;
|
||||
friend class PreferencesWindow;
|
||||
@@ -152,6 +153,9 @@ class TBarView : public BView {
|
||||
void PlaceBeMenu();
|
||||
void PlaceTray(bool vertSwap, bool leftSwap, BRect screenFrame);
|
||||
void PlaceApplicationBar(BRect screenFrame);
|
||||
void SaveExpandedItems();
|
||||
void RemoveExpandedItems();
|
||||
void ExpandItems();
|
||||
|
||||
TBarMenuBar* fBarMenuBar;
|
||||
TExpandoMenuBar* fExpando;
|
||||
@@ -178,6 +182,7 @@ class TBarView : public BView {
|
||||
uint32 fMaxRecentApps;
|
||||
|
||||
TTeamMenuItem* fLastDragItem;
|
||||
BList fExpandedItems;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user