| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_MUS_PUBLIC_CPP_LIB_WINDOW_TREE_CLIENT_IMPL_H_ | 5 #ifndef COMPONENTS_MUS_PUBLIC_CPP_LIB_WINDOW_TREE_CLIENT_IMPL_H_ |
| 6 #define COMPONENTS_MUS_PUBLIC_CPP_LIB_WINDOW_TREE_CLIENT_IMPL_H_ | 6 #define COMPONENTS_MUS_PUBLIC_CPP_LIB_WINDOW_TREE_CLIENT_IMPL_H_ |
| 7 | 7 |
| 8 #include "components/mus/public/cpp/types.h" | 8 #include "components/mus/public/cpp/types.h" |
| 9 #include "components/mus/public/cpp/window.h" | 9 #include "components/mus/public/cpp/window.h" |
| 10 #include "components/mus/public/cpp/window_tree_connection.h" | 10 #include "components/mus/public/cpp/window_tree_connection.h" |
| 11 #include "components/mus/public/interfaces/view_tree.mojom.h" | 11 #include "components/mus/public/interfaces/window_tree.mojom.h" |
| 12 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h" | 12 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h" |
| 13 | 13 |
| 14 namespace mus { | 14 namespace mus { |
| 15 class WindowTreeConnection; | 15 class WindowTreeConnection; |
| 16 class WindowTreeDelegate; | 16 class WindowTreeDelegate; |
| 17 | 17 |
| 18 // Manages the connection with the Window Server service. | 18 // Manages the connection with the Window Server service. |
| 19 class WindowTreeClientImpl : public WindowTreeConnection, | 19 class WindowTreeClientImpl : public WindowTreeConnection, |
| 20 public mojo::ViewTreeClient { | 20 public mus::mojom::WindowTreeClient { |
| 21 public: | 21 public: |
| 22 WindowTreeClientImpl(WindowTreeDelegate* delegate, | 22 WindowTreeClientImpl( |
| 23 mojo::InterfaceRequest<mojo::ViewTreeClient> request); | 23 WindowTreeDelegate* delegate, |
| 24 mojo::InterfaceRequest<mus::mojom::WindowTreeClient> request); |
| 24 ~WindowTreeClientImpl() override; | 25 ~WindowTreeClientImpl() override; |
| 25 | 26 |
| 26 // Wait for OnEmbed(), returning when done. | 27 // Wait for OnEmbed(), returning when done. |
| 27 void WaitForEmbed(); | 28 void WaitForEmbed(); |
| 28 | 29 |
| 29 bool connected() const { return tree_; } | 30 bool connected() const { return tree_; } |
| 30 ConnectionSpecificId connection_id() const { return connection_id_; } | 31 ConnectionSpecificId connection_id() const { return connection_id_; } |
| 31 | 32 |
| 32 // API exposed to the window implementations that pushes local changes to the | 33 // API exposed to the window implementations that pushes local changes to the |
| 33 // service. | 34 // service. |
| 34 void DestroyWindow(Id window_id); | 35 void DestroyWindow(Id window_id); |
| 35 | 36 |
| 36 // These methods take TransportIds. For windows owned by the current | 37 // These methods take TransportIds. For windows owned by the current |
| 37 // connection, | 38 // connection, |
| 38 // the connection id high word can be zero. In all cases, the TransportId 0x1 | 39 // the connection id high word can be zero. In all cases, the TransportId 0x1 |
| 39 // refers to the root window. | 40 // refers to the root window. |
| 40 void AddChild(Id child_id, Id parent_id); | 41 void AddChild(Id child_id, Id parent_id); |
| 41 void RemoveChild(Id child_id, Id parent_id); | 42 void RemoveChild(Id child_id, Id parent_id); |
| 42 | 43 |
| 43 void Reorder(Id window_id, | 44 void Reorder(Id window_id, |
| 44 Id relative_window_id, | 45 Id relative_window_id, |
| 45 mojo::OrderDirection direction); | 46 mojom::OrderDirection direction); |
| 46 | 47 |
| 47 // Returns true if the specified window was created by this connection. | 48 // Returns true if the specified window was created by this connection. |
| 48 bool OwnsWindow(Id id) const; | 49 bool OwnsWindow(Id id) const; |
| 49 | 50 |
| 50 void SetBounds(Id window_id, const mojo::Rect& bounds); | 51 void SetBounds(Id window_id, const mojo::Rect& bounds); |
| 51 void SetClientArea(Id window_id, const mojo::Rect& client_area); | 52 void SetClientArea(Id window_id, const mojo::Rect& client_area); |
| 52 void SetFocus(Id window_id); | 53 void SetFocus(Id window_id); |
| 53 void SetVisible(Id window_id, bool visible); | 54 void SetVisible(Id window_id, bool visible); |
| 54 void SetProperty(Id window_id, | 55 void SetProperty(Id window_id, |
| 55 const std::string& name, | 56 const std::string& name, |
| 56 const std::vector<uint8_t>& data); | 57 const std::vector<uint8_t>& data); |
| 57 void SetViewTextInputState(Id window_id, mojo::TextInputStatePtr state); | 58 void SetWindowTextInputState(Id window_id, mojo::TextInputStatePtr state); |
| 58 void SetImeVisibility(Id window_id, | 59 void SetImeVisibility(Id window_id, |
| 59 bool visible, | 60 bool visible, |
| 60 mojo::TextInputStatePtr state); | 61 mojo::TextInputStatePtr state); |
| 61 | 62 |
| 62 void Embed(Id window_id, | 63 void Embed(Id window_id, |
| 63 mojo::ViewTreeClientPtr client, | 64 mus::mojom::WindowTreeClientPtr client, |
| 64 uint32_t policy_bitmask, | 65 uint32_t policy_bitmask, |
| 65 const mojo::ViewTree::EmbedCallback& callback); | 66 const mus::mojom::WindowTree::EmbedCallback& callback); |
| 66 | 67 |
| 67 void RequestSurface(Id window_id, | 68 void RequestSurface(Id window_id, |
| 68 mojo::InterfaceRequest<mojo::Surface> surface, | 69 mojo::InterfaceRequest<mojom::Surface> surface, |
| 69 mojo::SurfaceClientPtr client); | 70 mojom::SurfaceClientPtr client); |
| 70 | 71 |
| 71 void set_change_acked_callback(const mojo::Callback<void(void)>& callback) { | 72 void set_change_acked_callback(const mojo::Callback<void(void)>& callback) { |
| 72 change_acked_callback_ = callback; | 73 change_acked_callback_ = callback; |
| 73 } | 74 } |
| 74 void ClearChangeAckedCallback() { change_acked_callback_.reset(); } | 75 void ClearChangeAckedCallback() { change_acked_callback_.reset(); } |
| 75 | 76 |
| 76 // Start/stop tracking views. While tracked, they can be retrieved via | 77 // Start/stop tracking views. While tracked, they can be retrieved via |
| 77 // WindowTreeConnection::GetWindowById. | 78 // WindowTreeConnection::GetWindowById. |
| 78 void AddWindow(Window* window); | 79 void AddWindow(Window* window); |
| 79 void RemoveWindow(Id window_id); | 80 void RemoveWindow(Id window_id); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 91 Id CreateWindowOnServer(); | 92 Id CreateWindowOnServer(); |
| 92 | 93 |
| 93 // Overridden from WindowTreeConnection: | 94 // Overridden from WindowTreeConnection: |
| 94 Window* GetRoot() override; | 95 Window* GetRoot() override; |
| 95 Window* GetWindowById(Id id) override; | 96 Window* GetWindowById(Id id) override; |
| 96 Window* GetFocusedWindow() override; | 97 Window* GetFocusedWindow() override; |
| 97 Window* CreateWindow() override; | 98 Window* CreateWindow() override; |
| 98 bool IsEmbedRoot() override; | 99 bool IsEmbedRoot() override; |
| 99 ConnectionSpecificId GetConnectionId() override; | 100 ConnectionSpecificId GetConnectionId() override; |
| 100 | 101 |
| 101 // Overridden from ViewTreeClient: | 102 // Overridden from WindowTreeClient: |
| 102 void OnEmbed(ConnectionSpecificId connection_id, | 103 void OnEmbed(ConnectionSpecificId connection_id, |
| 103 mojo::ViewDataPtr root, | 104 mojom::WindowDataPtr root, |
| 104 mojo::ViewTreePtr tree, | 105 mojom::WindowTreePtr tree, |
| 105 Id focused_window_id, | 106 Id focused_window_id, |
| 106 uint32_t access_policy) override; | 107 uint32_t access_policy) override; |
| 107 void OnEmbeddedAppDisconnected(Id window_id) override; | 108 void OnEmbeddedAppDisconnected(Id window_id) override; |
| 108 void OnUnembed() override; | 109 void OnUnembed() override; |
| 109 void OnWindowBoundsChanged(Id window_id, | 110 void OnWindowBoundsChanged(Id window_id, |
| 110 mojo::RectPtr old_bounds, | 111 mojo::RectPtr old_bounds, |
| 111 mojo::RectPtr new_bounds) override; | 112 mojo::RectPtr new_bounds) override; |
| 112 void OnClientAreaChanged(uint32_t window_id, | 113 void OnClientAreaChanged(uint32_t window_id, |
| 113 mojo::RectPtr old_client_area, | 114 mojo::RectPtr old_client_area, |
| 114 mojo::RectPtr new_client_area) override; | 115 mojo::RectPtr new_client_area) override; |
| 115 void OnWindowViewportMetricsChanged( | 116 void OnWindowViewportMetricsChanged( |
| 116 mojo::ViewportMetricsPtr old_metrics, | 117 mojom::ViewportMetricsPtr old_metrics, |
| 117 mojo::ViewportMetricsPtr new_metrics) override; | 118 mojom::ViewportMetricsPtr new_metrics) override; |
| 118 void OnWindowHierarchyChanged( | 119 void OnWindowHierarchyChanged( |
| 119 Id window_id, | 120 Id window_id, |
| 120 Id new_parent_id, | 121 Id new_parent_id, |
| 121 Id old_parent_id, | 122 Id old_parent_id, |
| 122 mojo::Array<mojo::ViewDataPtr> windows) override; | 123 mojo::Array<mojom::WindowDataPtr> windows) override; |
| 123 void OnWindowReordered(Id window_id, | 124 void OnWindowReordered(Id window_id, |
| 124 Id relative_window_id, | 125 Id relative_window_id, |
| 125 mojo::OrderDirection direction) override; | 126 mojom::OrderDirection direction) override; |
| 126 void OnWindowDeleted(Id window_id) override; | 127 void OnWindowDeleted(Id window_id) override; |
| 127 void OnWindowVisibilityChanged(Id window_id, bool visible) override; | 128 void OnWindowVisibilityChanged(Id window_id, bool visible) override; |
| 128 void OnWindowDrawnStateChanged(Id window_id, bool drawn) override; | 129 void OnWindowDrawnStateChanged(Id window_id, bool drawn) override; |
| 129 void OnWindowSharedPropertyChanged(Id window_id, | 130 void OnWindowSharedPropertyChanged(Id window_id, |
| 130 const mojo::String& name, | 131 const mojo::String& name, |
| 131 mojo::Array<uint8_t> new_data) override; | 132 mojo::Array<uint8_t> new_data) override; |
| 132 void OnWindowInputEvent(Id window_id, | 133 void OnWindowInputEvent(Id window_id, |
| 133 mojo::EventPtr event, | 134 mojo::EventPtr event, |
| 134 const mojo::Callback<void()>& callback) override; | 135 const mojo::Callback<void()>& callback) override; |
| 135 void OnWindowFocused(Id focused_window_id) override; | 136 void OnWindowFocused(Id focused_window_id) override; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 148 WindowTreeDelegate* delegate_; | 149 WindowTreeDelegate* delegate_; |
| 149 | 150 |
| 150 Window* root_; | 151 Window* root_; |
| 151 | 152 |
| 152 IdToWindowMap windows_; | 153 IdToWindowMap windows_; |
| 153 | 154 |
| 154 Window* capture_window_; | 155 Window* capture_window_; |
| 155 Window* focused_window_; | 156 Window* focused_window_; |
| 156 Window* activated_window_; | 157 Window* activated_window_; |
| 157 | 158 |
| 158 mojo::Binding<ViewTreeClient> binding_; | 159 mojo::Binding<WindowTreeClient> binding_; |
| 159 mojo::ViewTreePtr tree_; | 160 mus::mojom::WindowTreePtr tree_; |
| 160 | 161 |
| 161 bool is_embed_root_; | 162 bool is_embed_root_; |
| 162 | 163 |
| 163 bool in_destructor_; | 164 bool in_destructor_; |
| 164 | 165 |
| 165 MOJO_DISALLOW_COPY_AND_ASSIGN(WindowTreeClientImpl); | 166 MOJO_DISALLOW_COPY_AND_ASSIGN(WindowTreeClientImpl); |
| 166 }; | 167 }; |
| 167 | 168 |
| 168 } // namespace mus | 169 } // namespace mus |
| 169 | 170 |
| 170 #endif // COMPONENTS_MUS_PUBLIC_CPP_LIB_WINDOW_TREE_CLIENT_IMPL_H_ | 171 #endif // COMPONENTS_MUS_PUBLIC_CPP_LIB_WINDOW_TREE_CLIENT_IMPL_H_ |
| OLD | NEW |