| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_EXO_WM_HELPER_H_ | 5 #ifndef COMPONENTS_EXO_WM_HELPER_H_ |
| 6 #define COMPONENTS_EXO_WM_HELPER_H_ | 6 #define COMPONENTS_EXO_WM_HELPER_H_ |
| 7 | 7 |
| 8 #include "ash/common/shell_observer.h" | |
| 9 #include "base/macros.h" | 8 #include "base/macros.h" |
| 10 #include "base/observer_list.h" | 9 #include "base/observer_list.h" |
| 11 #include "ui/aura/client/cursor_client_observer.h" | 10 #include "ui/base/cursor/cursor.h" |
| 12 #include "ui/aura/client/focus_change_observer.h" | |
| 13 #include "ui/wm/public/activation_change_observer.h" | |
| 14 | 11 |
| 15 namespace ash { | 12 namespace ash { |
| 16 class DisplayInfo; | 13 class DisplayInfo; |
| 17 } | 14 } |
| 18 | 15 |
| 19 namespace aura { | 16 namespace aura { |
| 20 class Window; | 17 class Window; |
| 21 } | 18 } |
| 22 | 19 |
| 23 namespace ui { | 20 namespace ui { |
| 24 class EventHandler; | 21 class EventHandler; |
| 25 } | 22 } |
| 26 | 23 |
| 27 namespace base { | |
| 28 template <typename T> | |
| 29 struct DefaultSingletonTraits; | |
| 30 } | |
| 31 | |
| 32 namespace exo { | 24 namespace exo { |
| 33 | 25 |
| 34 // A helper class for accessing WindowManager related features. | 26 // A helper class for accessing WindowManager related features. |
| 35 class WMHelper : public aura::client::ActivationChangeObserver, | 27 class WMHelper { |
| 36 public aura::client::FocusChangeObserver, | |
| 37 public aura::client::CursorClientObserver, | |
| 38 public ash::ShellObserver { | |
| 39 public: | 28 public: |
| 40 class ActivationObserver { | 29 class ActivationObserver { |
| 41 public: | 30 public: |
| 42 virtual void OnWindowActivated(aura::Window* gained_active, | 31 virtual void OnWindowActivated(aura::Window* gained_active, |
| 43 aura::Window* lost_active) = 0; | 32 aura::Window* lost_active) = 0; |
| 44 | 33 |
| 45 protected: | 34 protected: |
| 46 virtual ~ActivationObserver() {} | 35 virtual ~ActivationObserver() {} |
| 47 }; | 36 }; |
| 48 | 37 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 66 | 55 |
| 67 class MaximizeModeObserver { | 56 class MaximizeModeObserver { |
| 68 public: | 57 public: |
| 69 virtual void OnMaximizeModeStarted() = 0; | 58 virtual void OnMaximizeModeStarted() = 0; |
| 70 virtual void OnMaximizeModeEnded() = 0; | 59 virtual void OnMaximizeModeEnded() = 0; |
| 71 | 60 |
| 72 protected: | 61 protected: |
| 73 virtual ~MaximizeModeObserver() {} | 62 virtual ~MaximizeModeObserver() {} |
| 74 }; | 63 }; |
| 75 | 64 |
| 65 virtual ~WMHelper(); |
| 66 |
| 67 static void SetInstance(WMHelper* helper); |
| 76 static WMHelper* GetInstance(); | 68 static WMHelper* GetInstance(); |
| 77 | 69 |
| 78 const ash::DisplayInfo& GetDisplayInfo(int64_t display_id) const; | |
| 79 aura::Window* GetContainer(int container_id); | |
| 80 | |
| 81 aura::Window* GetActiveWindow() const; | |
| 82 void AddActivationObserver(ActivationObserver* observer); | 70 void AddActivationObserver(ActivationObserver* observer); |
| 83 void RemoveActivationObserver(ActivationObserver* observer); | 71 void RemoveActivationObserver(ActivationObserver* observer); |
| 84 | |
| 85 aura::Window* GetFocusedWindow() const; | |
| 86 void AddFocusObserver(FocusObserver* observer); | 72 void AddFocusObserver(FocusObserver* observer); |
| 87 void RemoveFocusObserver(FocusObserver* observer); | 73 void RemoveFocusObserver(FocusObserver* observer); |
| 88 | |
| 89 ui::CursorSetType GetCursorSet() const; | |
| 90 void AddCursorObserver(CursorObserver* observer); | 74 void AddCursorObserver(CursorObserver* observer); |
| 91 void RemoveCursorObserver(CursorObserver* observer); | 75 void RemoveCursorObserver(CursorObserver* observer); |
| 92 | |
| 93 void AddPreTargetHandler(ui::EventHandler* handler); | |
| 94 void PrependPreTargetHandler(ui::EventHandler* handler); | |
| 95 void RemovePreTargetHandler(ui::EventHandler* handler); | |
| 96 | |
| 97 void AddPostTargetHandler(ui::EventHandler* handler); | |
| 98 void RemovePostTargetHandler(ui::EventHandler* handler); | |
| 99 | |
| 100 bool IsMaximizeModeWindowManagerEnabled() const; | |
| 101 void AddMaximizeModeObserver(MaximizeModeObserver* observer); | 76 void AddMaximizeModeObserver(MaximizeModeObserver* observer); |
| 102 void RemoveMaximizeModeObserver(MaximizeModeObserver* observer); | 77 void RemoveMaximizeModeObserver(MaximizeModeObserver* observer); |
| 103 | 78 |
| 79 virtual const ash::DisplayInfo GetDisplayInfo(int64_t display_id) const = 0; |
| 80 virtual aura::Window* GetContainer(int container_id) = 0; |
| 81 virtual aura::Window* GetActiveWindow() const = 0; |
| 82 virtual aura::Window* GetFocusedWindow() const = 0; |
| 83 virtual ui::CursorSetType GetCursorSet() const = 0; |
| 84 virtual void AddPreTargetHandler(ui::EventHandler* handler) = 0; |
| 85 virtual void PrependPreTargetHandler(ui::EventHandler* handler) = 0; |
| 86 virtual void RemovePreTargetHandler(ui::EventHandler* handler) = 0; |
| 87 virtual void AddPostTargetHandler(ui::EventHandler* handler) = 0; |
| 88 virtual void RemovePostTargetHandler(ui::EventHandler* handler) = 0; |
| 89 virtual bool IsMaximizeModeWindowManagerEnabled() const = 0; |
| 90 |
| 91 protected: |
| 92 WMHelper(); |
| 93 |
| 94 void NotifyWindowActivated(aura::Window* gained_active, |
| 95 aura::Window* lost_active); |
| 96 void NotifyWindowFocused(aura::Window* gained_focus, |
| 97 aura::Window* lost_focus); |
| 98 void NotifyCursorVisibilityChanged(bool is_visible); |
| 99 void NotifyCursorSetChanged(ui::CursorSetType cursor_set); |
| 100 void NotifyMaximizeModeStarted(); |
| 101 void NotifyMaximizeModeEnded(); |
| 102 |
| 104 private: | 103 private: |
| 105 WMHelper(); | |
| 106 ~WMHelper() override; | |
| 107 | |
| 108 friend struct base::DefaultSingletonTraits<WMHelper>; | |
| 109 | |
| 110 // Overriden from aura::client::ActivationChangeObserver: | |
| 111 void OnWindowActivated( | |
| 112 aura::client::ActivationChangeObserver::ActivationReason reason, | |
| 113 aura::Window* gained_active, | |
| 114 aura::Window* lost_active) override; | |
| 115 | |
| 116 // Overriden from aura::client::FocusChangeObserver: | |
| 117 void OnWindowFocused(aura::Window* gained_focus, | |
| 118 aura::Window* lost_focus) override; | |
| 119 | |
| 120 // Overriden from aura::client::CursorClientObserver: | |
| 121 void OnCursorVisibilityChanged(bool is_visible) override; | |
| 122 void OnCursorSetChanged(ui::CursorSetType cursor_set) override; | |
| 123 | |
| 124 // Overriden from ash::ShellObserver: | |
| 125 void OnMaximizeModeStarted() override; | |
| 126 void OnMaximizeModeEnded() override; | |
| 127 | |
| 128 base::ObserverList<ActivationObserver> activation_observers_; | 104 base::ObserverList<ActivationObserver> activation_observers_; |
| 129 base::ObserverList<FocusObserver> focus_observers_; | 105 base::ObserverList<FocusObserver> focus_observers_; |
| 130 base::ObserverList<CursorObserver> cursor_observers_; | 106 base::ObserverList<CursorObserver> cursor_observers_; |
| 131 base::ObserverList<MaximizeModeObserver> maximize_mode_observers_; | 107 base::ObserverList<MaximizeModeObserver> maximize_mode_observers_; |
| 132 | 108 |
| 133 DISALLOW_COPY_AND_ASSIGN(WMHelper); | 109 DISALLOW_COPY_AND_ASSIGN(WMHelper); |
| 134 }; | 110 }; |
| 135 | 111 |
| 136 } // namespace exo | 112 } // namespace exo |
| 137 | 113 |
| 138 #endif // COMPONENTS_EXO_WM_HELPER_H_ | 114 #endif // COMPONENTS_EXO_WM_HELPER_H_ |
| OLD | NEW |