OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_WINDOW_MANAGER_CONNECTION_H_ | 5 #ifndef UI_VIEWS_MUS_WINDOW_MANAGER_CONNECTION_H_ |
6 #define UI_VIEWS_MUS_WINDOW_MANAGER_CONNECTION_H_ | 6 #define UI_VIEWS_MUS_WINDOW_MANAGER_CONNECTION_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/observer_list.h" |
13 #include "components/mus/public/cpp/window_tree_delegate.h" | 14 #include "components/mus/public/cpp/window_tree_delegate.h" |
14 #include "services/shell/public/cpp/identity.h" | 15 #include "services/shell/public/cpp/identity.h" |
15 #include "ui/views/mus/mus_export.h" | 16 #include "ui/views/mus/mus_export.h" |
16 #include "ui/views/mus/screen_mus_delegate.h" | 17 #include "ui/views/mus/screen_mus_delegate.h" |
17 #include "ui/views/widget/widget.h" | 18 #include "ui/views/widget/widget.h" |
18 | 19 |
19 namespace shell { | 20 namespace shell { |
20 class Connector; | 21 class Connector; |
21 } | 22 } |
22 | 23 |
23 namespace views { | 24 namespace views { |
24 class NativeWidget; | 25 class NativeWidget; |
| 26 class PointerWatcher; |
25 class ScreenMus; | 27 class ScreenMus; |
26 namespace internal { | 28 namespace internal { |
27 class NativeWidgetDelegate; | 29 class NativeWidgetDelegate; |
28 } | 30 } |
29 | 31 |
30 // Provides configuration to mus in views. This consists of the following: | 32 // Provides configuration to mus in views. This consists of the following: |
31 // . Provides a Screen implementation backed by mus. | 33 // . Provides a Screen implementation backed by mus. |
32 // . Creates and owns a WindowTreeConnection. | 34 // . Creates and owns a WindowTreeConnection. |
33 // . Registers itself as the factory for creating NativeWidgets so that a | 35 // . Registers itself as the factory for creating NativeWidgets so that a |
34 // NativeWidgetMus is created. | 36 // NativeWidgetMus is created. |
(...skipping 15 matching lines...) Expand all Loading... |
50 shell::Connector* connector() { return connector_; } | 52 shell::Connector* connector() { return connector_; } |
51 | 53 |
52 mus::Window* NewWindow(const std::map<std::string, | 54 mus::Window* NewWindow(const std::map<std::string, |
53 std::vector<uint8_t>>& properties); | 55 std::vector<uint8_t>>& properties); |
54 | 56 |
55 NativeWidget* CreateNativeWidgetMus( | 57 NativeWidget* CreateNativeWidgetMus( |
56 const std::map<std::string, std::vector<uint8_t>>& properties, | 58 const std::map<std::string, std::vector<uint8_t>>& properties, |
57 const Widget::InitParams& init_params, | 59 const Widget::InitParams& init_params, |
58 internal::NativeWidgetDelegate* delegate); | 60 internal::NativeWidgetDelegate* delegate); |
59 | 61 |
| 62 void AddPointerWatcher(PointerWatcher* watcher); |
| 63 void RemovePointerWatcher(PointerWatcher* watcher); |
| 64 |
60 private: | 65 private: |
| 66 friend class WindowManagerConnectionTest; |
| 67 |
61 WindowManagerConnection(shell::Connector* connector, | 68 WindowManagerConnection(shell::Connector* connector, |
62 const shell::Identity& identity); | 69 const shell::Identity& identity); |
63 ~WindowManagerConnection() override; | 70 ~WindowManagerConnection() override; |
64 | 71 |
| 72 // Returns true if there is one or more pointer watchers for this client. |
| 73 bool HasPointerWatcher(); |
| 74 |
65 // mus::WindowTreeDelegate: | 75 // mus::WindowTreeDelegate: |
66 void OnEmbed(mus::Window* root) override; | 76 void OnEmbed(mus::Window* root) override; |
67 void OnConnectionLost(mus::WindowTreeConnection* connection) override; | 77 void OnConnectionLost(mus::WindowTreeConnection* connection) override; |
| 78 void OnEventObserved(const ui::Event& event) override; |
68 | 79 |
69 // ScreenMusDelegate: | 80 // ScreenMusDelegate: |
70 void OnWindowManagerFrameValuesChanged() override; | 81 void OnWindowManagerFrameValuesChanged() override; |
71 | 82 |
72 shell::Connector* connector_; | 83 shell::Connector* connector_; |
73 shell::Identity identity_; | 84 shell::Identity identity_; |
74 std::unique_ptr<ScreenMus> screen_; | 85 std::unique_ptr<ScreenMus> screen_; |
75 std::unique_ptr<mus::WindowTreeConnection> window_tree_connection_; | 86 std::unique_ptr<mus::WindowTreeConnection> window_tree_connection_; |
| 87 // Must be empty on destruction. |
| 88 base::ObserverList<PointerWatcher, true> pointer_watchers_; |
76 | 89 |
77 DISALLOW_COPY_AND_ASSIGN(WindowManagerConnection); | 90 DISALLOW_COPY_AND_ASSIGN(WindowManagerConnection); |
78 }; | 91 }; |
79 | 92 |
80 } // namespace views | 93 } // namespace views |
81 | 94 |
82 #endif // UI_VIEWS_MUS_WINDOW_MANAGER_CONNECTION_H_ | 95 #endif // UI_VIEWS_MUS_WINDOW_MANAGER_CONNECTION_H_ |
OLD | NEW |