Author: anevilyak Date: 2010-08-23 06:11:55 +0200 (Mon, 23 Aug 2010) New Revision: 38311 Changeset: http://dev.haiku-os.org/changeset/38311 Ticket: http://dev.haiku-os.org/ticket/4290 Modified: haiku/trunk/src/apps/deskbar/Switcher.cpp haiku/trunk/src/apps/deskbar/Switcher.h Log: Fix a logic hole that would result in hidden teams being visible in switcher (sans icon) on ctrl+~. Fixes #4290. Modified: haiku/trunk/src/apps/deskbar/Switcher.cpp =================================================================== --- haiku/trunk/src/apps/deskbar/Switcher.cpp 2010-08-22 11:37:53 UTC (rev 38310) +++ haiku/trunk/src/apps/deskbar/Switcher.cpp 2010-08-23 04:11:55 UTC (rev 38311) @@ -308,7 +308,7 @@ if ((teamGroup->Flags() & B_BACKGROUND_APP) != 0) return false; - // skip the Deakbar itself + // skip the Deskbar itself if (strcasecmp(teamGroup->Signature(), kDeskbarSignature) == 0) return false; @@ -858,6 +858,23 @@ TSwitchManager::CycleApp(bool forward, bool activateNow) { int32 startIndex = fCurrentIndex; + + if (_FindNextValidApp(forward)) { + // if we're here then we found a good one + SwitchToApp(startIndex, fCurrentIndex, forward); + + if (!activateNow) + return; + + ActivateApp(false, false); + } +} + + +bool +TSwitchManager::_FindNextValidApp(bool forward) +{ + int32 startIndex = fCurrentIndex; int32 max = fGroupList.CountItems(); for (;;) { @@ -873,30 +890,25 @@ if (fCurrentIndex == startIndex) { // we've gone completely through the list without finding // a good app. Oh well. - return; + break; } - if (!OKToUse((TTeamGroup*)fGroupList.ItemAt(fCurrentIndex))) - continue; + if (OKToUse((TTeamGroup*)fGroupList.ItemAt(fCurrentIndex))) + return true; + } - // if we're here then we found a good one - SwitchToApp(startIndex, fCurrentIndex, forward); - - if (!activateNow) - break; - - if (ActivateApp(false, false)) - break; - } + return false; } - void TSwitchManager::SwitchToApp(int32 previousIndex, int32 newIndex, bool forward) { int32 previousSlot = fCurrentSlot; fCurrentIndex = newIndex; + if (!OKToUse((TTeamGroup *)fGroupList.ItemAt(fCurrentIndex))) + _FindNextValidApp(forward); + fCurrentSlot = fWindow->SlotOf(fCurrentIndex); fCurrentWindow = 0; Modified: haiku/trunk/src/apps/deskbar/Switcher.h =================================================================== --- haiku/trunk/src/apps/deskbar/Switcher.h 2010-08-22 11:37:53 UTC (rev 38310) +++ haiku/trunk/src/apps/deskbar/Switcher.h 2010-08-23 04:11:55 UTC (rev 38311) @@ -85,6 +85,8 @@ bool allowWorkspaceSwitch); void ActivateWindow(int32 windowID = -1); void _SortApps(); + + bool _FindNextValidApp(bool forward); TSwitcherWindow* fWindow; sem_id fMainMonitor;