| 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 UI_VIEWS_MUS_MUS_CLIENT_H_ | 5 #ifndef UI_VIEWS_MUS_MUS_CLIENT_H_ |
| 6 #define UI_VIEWS_MUS_MUS_CLIENT_H_ | 6 #define UI_VIEWS_MUS_MUS_CLIENT_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 namespace internal { | 51 namespace internal { |
| 52 class NativeWidgetDelegate; | 52 class NativeWidgetDelegate; |
| 53 } | 53 } |
| 54 | 54 |
| 55 namespace test { | 55 namespace test { |
| 56 class MusClientTestApi; | 56 class MusClientTestApi; |
| 57 } | 57 } |
| 58 | 58 |
| 59 // MusClient establishes a connection to mus and sets up necessary state so that | 59 // MusClient establishes a connection to mus and sets up necessary state so that |
| 60 // aura and views target mus. This class is useful for typical clients, not the | 60 // aura and views target mus. This class is useful for typical clients, not the |
| 61 // WindowManager. This class is created by AuraInit when | 61 // WindowManager. Most clients don't create this directly, rather use |
| 62 // AuraInit::Mode::AURA_MUS is passed as the mode. | 62 // AuraInit. |
| 63 // AuraInit::Mode::AURA to AuraInit and MusClient will be created for us. | |
| 64 class VIEWS_MUS_EXPORT MusClient | 63 class VIEWS_MUS_EXPORT MusClient |
| 65 : public aura::WindowTreeClientDelegate, | 64 : public aura::WindowTreeClientDelegate, |
| 66 public ScreenMusDelegate, | 65 public ScreenMusDelegate, |
| 67 public ui::OSExchangeDataProviderFactory::Factory { | 66 public ui::OSExchangeDataProviderFactory::Factory { |
| 68 public: | 67 public: |
| 68 // Most clients should use AuraInit, which creates a MusClient. |
| 69 // |create_wm_state| indicates whether MusClient should create a wm::WMState. |
| 70 MusClient( |
| 71 service_manager::Connector* connector, |
| 72 const service_manager::Identity& identity, |
| 73 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner = nullptr, |
| 74 bool create_wm_state = true); |
| 69 ~MusClient() override; | 75 ~MusClient() override; |
| 70 | 76 |
| 71 static MusClient* Get() { return instance_; } | 77 static MusClient* Get() { return instance_; } |
| 78 static bool Exists() { return instance_ != nullptr; } |
| 72 | 79 |
| 73 // Returns true if a DesktopNativeWidgetAura should be created given the | 80 // Returns true if a DesktopNativeWidgetAura should be created given the |
| 74 // specified params. If this returns false a NativeWidgetAura should be | 81 // specified params. If this returns false a NativeWidgetAura should be |
| 75 // created. | 82 // created. |
| 76 static bool ShouldCreateDesktopNativeWidgetAura( | 83 static bool ShouldCreateDesktopNativeWidgetAura( |
| 77 const Widget::InitParams& init_params); | 84 const Widget::InitParams& init_params); |
| 78 | 85 |
| 79 // Returns the properties to supply to mus when creating a window. | 86 // Returns the properties to supply to mus when creating a window. |
| 80 static std::map<std::string, std::vector<uint8_t>> | 87 static std::map<std::string, std::vector<uint8_t>> |
| 81 ConfigurePropertiesFromParams(const Widget::InitParams& init_params); | 88 ConfigurePropertiesFromParams(const Widget::InitParams& init_params); |
| 82 | 89 |
| 83 aura::WindowTreeClient* window_tree_client() { | 90 aura::WindowTreeClient* window_tree_client() { |
| 84 return window_tree_client_.get(); | 91 return window_tree_client_.get(); |
| 85 } | 92 } |
| 86 | 93 |
| 87 PointerWatcherEventRouter2* pointer_watcher_event_router() { | 94 PointerWatcherEventRouter2* pointer_watcher_event_router() { |
| 88 return pointer_watcher_event_router_.get(); | 95 return pointer_watcher_event_router_.get(); |
| 89 } | 96 } |
| 90 | 97 |
| 98 ui::Gpu* gpu() { return gpu_.get(); } |
| 99 |
| 91 // Creates DesktopNativeWidgetAura with DesktopWindowTreeHostMus. This is | 100 // Creates DesktopNativeWidgetAura with DesktopWindowTreeHostMus. This is |
| 92 // set as the factory function used for creating NativeWidgets when a | 101 // set as the factory function used for creating NativeWidgets when a |
| 93 // NativeWidget has not been explicitly set. | 102 // NativeWidget has not been explicitly set. |
| 94 NativeWidget* CreateNativeWidget(const Widget::InitParams& init_params, | 103 NativeWidget* CreateNativeWidget(const Widget::InitParams& init_params, |
| 95 internal::NativeWidgetDelegate* delegate); | 104 internal::NativeWidgetDelegate* delegate); |
| 96 | 105 |
| 97 void AddObserver(MusClientObserver* observer); | 106 void AddObserver(MusClientObserver* observer); |
| 98 void RemoveObserver(MusClientObserver* observer); | 107 void RemoveObserver(MusClientObserver* observer); |
| 99 | 108 |
| 100 private: | 109 private: |
| 101 friend class AuraInit; | 110 friend class AuraInit; |
| 102 friend class test::MusClientTestApi; | 111 friend class test::MusClientTestApi; |
| 103 | 112 |
| 104 MusClient( | |
| 105 service_manager::Connector* connector, | |
| 106 const service_manager::Identity& identity, | |
| 107 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner = nullptr); | |
| 108 | |
| 109 // aura::WindowTreeClientDelegate: | 113 // aura::WindowTreeClientDelegate: |
| 110 void OnEmbed( | 114 void OnEmbed( |
| 111 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) override; | 115 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) override; |
| 112 void OnLostConnection(aura::WindowTreeClient* client) override; | 116 void OnLostConnection(aura::WindowTreeClient* client) override; |
| 113 void OnEmbedRootDestroyed(aura::WindowTreeHostMus* window_tree_host) override; | 117 void OnEmbedRootDestroyed(aura::WindowTreeHostMus* window_tree_host) override; |
| 114 void OnPointerEventObserved(const ui::PointerEvent& event, | 118 void OnPointerEventObserved(const ui::PointerEvent& event, |
| 115 aura::Window* target) override; | 119 aura::Window* target) override; |
| 116 aura::client::CaptureClient* GetCaptureClient() override; | 120 aura::client::CaptureClient* GetCaptureClient() override; |
| 117 aura::PropertyConverter* GetPropertyConverter() override; | 121 aura::PropertyConverter* GetPropertyConverter() override; |
| 118 | 122 |
| 119 // ScreenMusDelegate: | 123 // ScreenMusDelegate: |
| 120 void OnWindowManagerFrameValuesChanged() override; | 124 void OnWindowManagerFrameValuesChanged() override; |
| 121 gfx::Point GetCursorScreenPoint() override; | 125 gfx::Point GetCursorScreenPoint() override; |
| 122 aura::Window* GetWindowAtScreenPoint(const gfx::Point& point) override; | 126 aura::Window* GetWindowAtScreenPoint(const gfx::Point& point) override; |
| 123 | 127 |
| 124 // ui:OSExchangeDataProviderFactory::Factory: | 128 // ui:OSExchangeDataProviderFactory::Factory: |
| 125 std::unique_ptr<OSExchangeData::Provider> BuildProvider() override; | 129 std::unique_ptr<OSExchangeData::Provider> BuildProvider() override; |
| 126 | 130 |
| 127 static MusClient* instance_; | 131 static MusClient* instance_; |
| 128 | 132 |
| 129 service_manager::Identity identity_; | 133 service_manager::Identity identity_; |
| 130 | 134 |
| 131 base::ObserverList<MusClientObserver> observer_list_; | 135 base::ObserverList<MusClientObserver> observer_list_; |
| 132 | 136 |
| 137 // NOTE: this may be null (creation is based on argument supplied to |
| 138 // constructor). |
| 133 std::unique_ptr<wm::WMState> wm_state_; | 139 std::unique_ptr<wm::WMState> wm_state_; |
| 134 | 140 |
| 135 std::unique_ptr<ScreenMus> screen_; | 141 std::unique_ptr<ScreenMus> screen_; |
| 136 | 142 |
| 137 std::unique_ptr<aura::PropertyConverter> property_converter_; | 143 std::unique_ptr<aura::PropertyConverter> property_converter_; |
| 138 | 144 |
| 139 std::unique_ptr<aura::WindowTreeClient> window_tree_client_; | 145 std::unique_ptr<aura::WindowTreeClient> window_tree_client_; |
| 140 | 146 |
| 141 std::unique_ptr<ui::Gpu> gpu_; | 147 std::unique_ptr<ui::Gpu> gpu_; |
| 142 | 148 |
| 143 std::unique_ptr<PointerWatcherEventRouter2> pointer_watcher_event_router_; | 149 std::unique_ptr<PointerWatcherEventRouter2> pointer_watcher_event_router_; |
| 144 | 150 |
| 145 std::unique_ptr<aura::MusContextFactory> compositor_context_factory_; | 151 std::unique_ptr<aura::MusContextFactory> compositor_context_factory_; |
| 146 | 152 |
| 147 DISALLOW_COPY_AND_ASSIGN(MusClient); | 153 DISALLOW_COPY_AND_ASSIGN(MusClient); |
| 148 }; | 154 }; |
| 149 | 155 |
| 150 } // namespace views | 156 } // namespace views |
| 151 | 157 |
| 152 #endif // UI_VIEWS_MUS_MUS_CLIENT_H_ | 158 #endif // UI_VIEWS_MUS_MUS_CLIENT_H_ |
| OLD | NEW |