switchable_windows.cc 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // Copyright 2014 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "ash/wm/switchable_windows.h"
  5. #include <array>
  6. #include "ash/public/cpp/shell_window_ids.h"
  7. #include "ash/wm/desks/desks_util.h"
  8. #include "base/containers/contains.h"
  9. #include "ui/aura/window.h"
  10. namespace ash {
  11. namespace {
  12. constexpr std::array<int, 3> kSwitchableContainers = {
  13. kShellWindowId_AlwaysOnTopContainer,
  14. kShellWindowId_FloatContainer,
  15. kShellWindowId_PipContainer,
  16. };
  17. std::vector<int> GetSwitchableContainerIds() {
  18. std::vector<int> ids = desks_util::GetDesksContainersIds();
  19. for (const int id : kSwitchableContainers)
  20. ids.emplace_back(id);
  21. return ids;
  22. }
  23. } // namespace
  24. std::vector<aura::Window*> GetSwitchableContainersForRoot(
  25. aura::Window* root,
  26. bool active_desk_only) {
  27. DCHECK(root);
  28. DCHECK(root->IsRootWindow());
  29. std::vector<aura::Window*> containers;
  30. if (active_desk_only) {
  31. containers.push_back(desks_util::GetActiveDeskContainerForRoot(root));
  32. containers.push_back(
  33. root->GetChildById(kShellWindowId_AlwaysOnTopContainer));
  34. return containers;
  35. }
  36. for (const auto& id : GetSwitchableContainerIds()) {
  37. auto* container = root->GetChildById(id);
  38. DCHECK(container);
  39. containers.push_back(container);
  40. }
  41. return containers;
  42. }
  43. // TODO(afakhry): Rename this to a better name.
  44. bool IsSwitchableContainer(const aura::Window* window) {
  45. if (!window)
  46. return false;
  47. return base::Contains(GetSwitchableContainerIds(), window->GetId());
  48. }
  49. } // namespace ash