Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: ui/aura/mus/window_tree_client.cc

Issue 2456843004: Wires up transient windows for aura-mus (Closed)
Patch Set: relative to master Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/aura/mus/window_tree_client.h ('k') | ui/aura/mus/window_tree_client_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "ui/aura/mus/window_tree_client.h" 5 #include "ui/aura/mus/window_tree_client.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/auto_reset.h" 13 #include "base/auto_reset.h"
14 #include "base/bind.h" 14 #include "base/bind.h"
15 #include "base/memory/ptr_util.h" 15 #include "base/memory/ptr_util.h"
16 #include "services/service_manager/public/cpp/connector.h" 16 #include "services/service_manager/public/cpp/connector.h"
17 #include "services/ui/public/interfaces/window_manager_window_tree_factory.mojom .h" 17 #include "services/ui/public/interfaces/window_manager_window_tree_factory.mojom .h"
18 #include "ui/aura/client/aura_constants.h" 18 #include "ui/aura/client/aura_constants.h"
19 #include "ui/aura/client/capture_client.h" 19 #include "ui/aura/client/capture_client.h"
20 #include "ui/aura/client/focus_client.h" 20 #include "ui/aura/client/focus_client.h"
21 #include "ui/aura/client/transient_window_client.h"
21 #include "ui/aura/mus/in_flight_change.h" 22 #include "ui/aura/mus/in_flight_change.h"
22 #include "ui/aura/mus/input_method_mus.h" 23 #include "ui/aura/mus/input_method_mus.h"
23 #include "ui/aura/mus/property_converter.h" 24 #include "ui/aura/mus/property_converter.h"
24 #include "ui/aura/mus/surface_id_handler.h" 25 #include "ui/aura/mus/surface_id_handler.h"
25 #include "ui/aura/mus/window_manager_delegate.h" 26 #include "ui/aura/mus/window_manager_delegate.h"
26 #include "ui/aura/mus/window_mus.h" 27 #include "ui/aura/mus/window_mus.h"
27 #include "ui/aura/mus/window_port_mus.h" 28 #include "ui/aura/mus/window_port_mus.h"
28 #include "ui/aura/mus/window_tree_client_delegate.h" 29 #include "ui/aura/mus/window_tree_client_delegate.h"
29 #include "ui/aura/mus/window_tree_client_observer.h" 30 #include "ui/aura/mus/window_tree_client_observer.h"
30 #include "ui/aura/mus/window_tree_host_mus.h" 31 #include "ui/aura/mus/window_tree_host_mus.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 window_manager_delegate_(window_manager_delegate), 155 window_manager_delegate_(window_manager_delegate),
155 binding_(this), 156 binding_(this),
156 tree_(nullptr), 157 tree_(nullptr),
157 in_destructor_(false), 158 in_destructor_(false),
158 weak_factory_(this) { 159 weak_factory_(this) {
159 // Allow for a null request in tests. 160 // Allow for a null request in tests.
160 if (request.is_pending()) 161 if (request.is_pending())
161 binding_.Bind(std::move(request)); 162 binding_.Bind(std::move(request));
162 delegate_->GetFocusClient()->AddObserver(this); 163 delegate_->GetFocusClient()->AddObserver(this);
163 delegate_->GetCaptureClient()->AddObserver(this); 164 delegate_->GetCaptureClient()->AddObserver(this);
165 client::GetTransientWindowClient()->AddObserver(this);
164 if (window_manager_delegate) 166 if (window_manager_delegate)
165 window_manager_delegate->SetWindowManagerClient(this); 167 window_manager_delegate->SetWindowManagerClient(this);
166 } 168 }
167 169
168 WindowTreeClient::~WindowTreeClient() { 170 WindowTreeClient::~WindowTreeClient() {
169 in_destructor_ = true; 171 in_destructor_ = true;
170 172
171 for (WindowTreeClientObserver& observer : observers_) 173 for (WindowTreeClientObserver& observer : observers_)
172 observer.OnWillDestroyClient(this); 174 observer.OnWillDestroyClient(this);
173 175
(...skipping 13 matching lines...) Expand all
187 189
188 // Delete the non-owned windows last. In the typical case these are roots. The 190 // Delete the non-owned windows last. In the typical case these are roots. The
189 // exception is the window manager and embed roots, which may know about 191 // exception is the window manager and embed roots, which may know about
190 // other random windows that it doesn't own. 192 // other random windows that it doesn't own.
191 while (!tracker.windows().empty()) 193 while (!tracker.windows().empty())
192 delete tracker.windows().front(); 194 delete tracker.windows().front();
193 195
194 for (WindowTreeClientObserver& observer : observers_) 196 for (WindowTreeClientObserver& observer : observers_)
195 observer.OnDidDestroyClient(this); 197 observer.OnDidDestroyClient(this);
196 198
199 client::GetTransientWindowClient()->RemoveObserver(this);
200 delegate_->GetCaptureClient()->RemoveObserver(this);
197 delegate_->GetFocusClient()->RemoveObserver(this); 201 delegate_->GetFocusClient()->RemoveObserver(this);
198 delegate_->GetCaptureClient()->RemoveObserver(this);
199 } 202 }
200 203
201 void WindowTreeClient::ConnectViaWindowTreeFactory( 204 void WindowTreeClient::ConnectViaWindowTreeFactory(
202 service_manager::Connector* connector) { 205 service_manager::Connector* connector) {
203 // The client id doesn't really matter, we use 101 purely for debugging. 206 // The client id doesn't really matter, we use 101 purely for debugging.
204 client_id_ = 101; 207 client_id_ = 101;
205 208
206 ui::mojom::WindowTreeFactoryPtr factory; 209 ui::mojom::WindowTreeFactoryPtr factory;
207 connector->ConnectToInterface("service:ui", &factory); 210 connector->ConnectToInterface("service:ui", &factory);
208 ui::mojom::WindowTreePtr window_tree; 211 ui::mojom::WindowTreePtr window_tree;
(...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 if (window) { 1116 if (window) {
1114 WindowPrivate(window).LocalSetClientArea( 1117 WindowPrivate(window).LocalSetClientArea(
1115 new_client_area, 1118 new_client_area,
1116 new_additional_client_areas.To<std::vector<gfx::Rect>>()); 1119 new_additional_client_areas.To<std::vector<gfx::Rect>>());
1117 } 1120 }
1118 */ 1121 */
1119 } 1122 }
1120 1123
1121 void WindowTreeClient::OnTransientWindowAdded(uint32_t window_id, 1124 void WindowTreeClient::OnTransientWindowAdded(uint32_t window_id,
1122 uint32_t transient_window_id) { 1125 uint32_t transient_window_id) {
1123 // TODO: needs to route to StackingClient. 1126 WindowMus* window = GetWindowByServerId(window_id);
1124 /* 1127 WindowMus* transient_window = GetWindowByServerId(transient_window_id);
1125 Window* window = GetWindowByServerId(window_id);
1126 Window* transient_window = GetWindowByServerId(transient_window_id);
1127 // window or transient_window or both may be null if a local delete occurs 1128 // window or transient_window or both may be null if a local delete occurs
1128 // with an in flight add from the server. 1129 // with an in flight add from the server.
1129 if (window && transient_window) 1130 if (window && transient_window)
1130 WindowPrivate(window).LocalAddTransientWindow(transient_window); 1131 window->AddTransientChildFromServer(transient_window);
1131 */
1132 } 1132 }
1133 1133
1134 void WindowTreeClient::OnTransientWindowRemoved(uint32_t window_id, 1134 void WindowTreeClient::OnTransientWindowRemoved(uint32_t window_id,
1135 uint32_t transient_window_id) { 1135 uint32_t transient_window_id) {
1136 // TODO: needs to route to StackingClient. 1136 WindowMus* window = GetWindowByServerId(window_id);
1137 /* 1137 WindowMus* transient_window = GetWindowByServerId(transient_window_id);
1138 Window* window = GetWindowByServerId(window_id);
1139 Window* transient_window = GetWindowByServerId(transient_window_id);
1140 // window or transient_window or both may be null if a local delete occurs 1138 // window or transient_window or both may be null if a local delete occurs
1141 // with an in flight delete from the server. 1139 // with an in flight delete from the server.
1142 if (window && transient_window) 1140 if (window && transient_window)
1143 WindowPrivate(window).LocalRemoveTransientWindow(transient_window); 1141 window->RemoveTransientChildFromServer(transient_window);
1144 */
1145 } 1142 }
1146 1143
1147 void WindowTreeClient::OnWindowHierarchyChanged( 1144 void WindowTreeClient::OnWindowHierarchyChanged(
1148 Id window_id, 1145 Id window_id,
1149 Id old_parent_id, 1146 Id old_parent_id,
1150 Id new_parent_id, 1147 Id new_parent_id,
1151 mojo::Array<ui::mojom::WindowDataPtr> windows) { 1148 mojo::Array<ui::mojom::WindowDataPtr> windows) {
1152 WindowMus* initial_parent = 1149 WindowMus* initial_parent =
1153 windows.size() ? GetWindowByServerId(windows[0]->parent_id) : nullptr; 1150 windows.size() ? GetWindowByServerId(windows[0]->parent_id) : nullptr;
1154 1151
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
1758 window_tree_host->GetDisplay().bounds().OffsetFromOrigin(); 1755 window_tree_host->GetDisplay().bounds().OffsetFromOrigin();
1759 bounds->set_origin(display_relative_origin); 1756 bounds->set_origin(display_relative_origin);
1760 break; 1757 break;
1761 } 1758 }
1762 } 1759 }
1763 // We need the root window to always have an origin of 0x0 locally. 1760 // We need the root window to always have an origin of 0x0 locally.
1764 window_tree_host->set_origin_offset(bounds->OffsetFromOrigin()); 1761 window_tree_host->set_origin_offset(bounds->OffsetFromOrigin());
1765 bounds->set_origin(gfx::Point()); 1762 bounds->set_origin(gfx::Point());
1766 } 1763 }
1767 1764
1765 void WindowTreeClient::OnTransientChildWindowAdded(Window* parent,
1766 Window* transient_child) {
1767 if (WindowMus::Get(parent)->OnTransientChildAdded(
1768 WindowMus::Get(transient_child)) == WindowMus::ChangeSource::SERVER) {
1769 return;
1770 }
1771 // The change originated from client code and needs to be sent to the server.
1772 DCHECK(tree_);
1773 WindowMus* parent_mus = WindowMus::Get(parent);
1774 const uint32_t change_id =
1775 ScheduleInFlightChange(base::MakeUnique<CrashInFlightChange>(
1776 parent_mus, ChangeType::ADD_TRANSIENT_WINDOW));
1777 tree_->AddTransientWindow(change_id, parent_mus->server_id(),
1778 WindowMus::Get(transient_child)->server_id());
1779 }
1780
1781 void WindowTreeClient::OnTransientChildWindowRemoved(Window* parent,
1782 Window* transient_child) {
1783 if (WindowMus::Get(parent)->OnTransientChildRemoved(
1784 WindowMus::Get(transient_child)) == WindowMus::ChangeSource::SERVER) {
1785 return;
1786 }
1787 // The change originated from client code and needs to be sent to the server.
1788 DCHECK(tree_);
1789 WindowMus* child_mus = WindowMus::Get(transient_child);
1790 const uint32_t change_id =
1791 ScheduleInFlightChange(base::MakeUnique<CrashInFlightChange>(
1792 child_mus, ChangeType::REMOVE_TRANSIENT_WINDOW_FROM_PARENT));
1793 tree_->RemoveTransientWindowFromParent(change_id, child_mus->server_id());
1794 }
1795
1768 } // namespace aura 1796 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/mus/window_tree_client.h ('k') | ui/aura/mus/window_tree_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698