workspace_controller.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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_WORKSPACE_CONTROLLER_H_
  5. #define ASH_WM_WORKSPACE_CONTROLLER_H_
  6. #include <memory>
  7. #include "ash/ash_export.h"
  8. #include "ash/wm/workspace/workspace_types.h"
  9. #include "ui/aura/window.h"
  10. #include "ui/aura/window_observer.h"
  11. namespace ash {
  12. class WorkspaceEventHandler;
  13. class WorkspaceLayoutManager;
  14. // WorkspaceController acts as a central place that ties together all the
  15. // various workspace pieces.
  16. class ASH_EXPORT WorkspaceController : public aura::WindowObserver {
  17. public:
  18. // Installs WorkspaceLayoutManager on |viewport|.
  19. explicit WorkspaceController(aura::Window* viewport);
  20. WorkspaceController(const WorkspaceController&) = delete;
  21. WorkspaceController& operator=(const WorkspaceController&) = delete;
  22. ~WorkspaceController() override;
  23. // Returns the current window state.
  24. WorkspaceWindowState GetWindowState() const;
  25. // Starts the animation that occurs on first login.
  26. void DoInitialAnimation();
  27. WorkspaceLayoutManager* layout_manager() { return layout_manager_; }
  28. private:
  29. friend class WorkspaceControllerTestApi;
  30. // aura::WindowObserver:
  31. void OnWindowDestroying(aura::Window* window) override;
  32. aura::Window* viewport_;
  33. std::unique_ptr<WorkspaceEventHandler> event_handler_;
  34. // Owned by |viewport_|.
  35. WorkspaceLayoutManager* layout_manager_;
  36. };
  37. // Sets the given |workspace_controller| as a property of |desk_container|. Only
  38. // virtual desks containers are accepted. If |workspace_controller| is nullptr,
  39. // the property will be cleared from |desk_container|.
  40. ASH_EXPORT void SetWorkspaceController(
  41. aura::Window* desk_container,
  42. WorkspaceController* workspace_controller);
  43. // Gets the worspace controller from the properties of the specific given
  44. // |desk_container|. Only virtual desks containers are accepted.
  45. ASH_EXPORT WorkspaceController* GetWorkspaceController(
  46. aura::Window* desk_container);
  47. // Gets the workspace controller from the properties of the virtual desk
  48. // container anscestor of |context|. Returns nullptr if |context| doesn't belong
  49. // to any virtual desk.
  50. ASH_EXPORT WorkspaceController* GetWorkspaceControllerForContext(
  51. aura::Window* context);
  52. // Gets the workspace controller from the properties of the currently active
  53. // virtual desk container on the given |root|.
  54. ASH_EXPORT WorkspaceController* GetActiveWorkspaceController(
  55. aura::Window* root);
  56. } // namespace ash
  57. #endif // ASH_WM_WORKSPACE_CONTROLLER_H_