always_on_top_controller.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // Copyright (c) 2012 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. #ifndef ASH_WM_ALWAYS_ON_TOP_CONTROLLER_H_
  5. #define ASH_WM_ALWAYS_ON_TOP_CONTROLLER_H_
  6. #include <memory>
  7. #include "ash/ash_export.h"
  8. #include "ash/wm/window_state_observer.h"
  9. #include "ui/aura/window_observer.h"
  10. namespace ash {
  11. class WorkspaceLayoutManager;
  12. // AlwaysOnTopController puts window into proper containers based on its
  13. // 'AlwaysOnTop' property. That is, putting a window into the worskpace
  14. // container if its "AlwaysOnTop" property is false. Otherwise, put it in
  15. // |always_on_top_container_|.
  16. class ASH_EXPORT AlwaysOnTopController : public aura::WindowObserver,
  17. WindowStateObserver {
  18. public:
  19. explicit AlwaysOnTopController(aura::Window* always_on_top_container,
  20. aura::Window* pip_container);
  21. AlwaysOnTopController(const AlwaysOnTopController&) = delete;
  22. AlwaysOnTopController& operator=(const AlwaysOnTopController&) = delete;
  23. ~AlwaysOnTopController() override;
  24. static void SetDisallowReparent(aura::Window* window);
  25. // Gets container for given |window| based on its "AlwaysOnTop" property.
  26. aura::Window* GetContainer(aura::Window* window) const;
  27. // Clears the layout managers for |always_on_top_container_| and
  28. // |pip_container_|. This should only be called when the RootWindowController
  29. // is shutting down, to prevent the layout managers from doing unnecessary and
  30. // complex work.
  31. void ClearLayoutManagers();
  32. void SetLayoutManagerForTest(
  33. std::unique_ptr<WorkspaceLayoutManager> layout_manager);
  34. private:
  35. void AddWindow(aura::Window* window);
  36. void RemoveWindow(aura::Window* window);
  37. void ReparentWindow(aura::Window* window);
  38. // Overridden from aura::WindowObserver:
  39. void OnWindowHierarchyChanged(const HierarchyChangeParams& params) override;
  40. void OnWindowPropertyChanged(aura::Window* window,
  41. const void* key,
  42. intptr_t old) override;
  43. void OnWindowDestroying(aura::Window* window) override;
  44. // Overridden from WindowStateObserver:
  45. void OnPreWindowStateTypeChange(WindowState* window_state,
  46. chromeos::WindowStateType old_type) override;
  47. aura::Window* always_on_top_container_;
  48. aura::Window* pip_container_;
  49. };
  50. } // namespace ash
  51. #endif // ASH_WM_ALWAYS_ON_TOP_CONTROLLER_H_