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

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

Issue 2456843004: Wires up transient windows for aura-mus (Closed)
Patch Set: 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
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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 window_manager_delegate_(window_manager_delegate), 150 window_manager_delegate_(window_manager_delegate),
150 binding_(this), 151 binding_(this),
151 tree_(nullptr), 152 tree_(nullptr),
152 in_destructor_(false), 153 in_destructor_(false),
153 weak_factory_(this) { 154 weak_factory_(this) {
154 // Allow for a null request in tests. 155 // Allow for a null request in tests.
155 if (request.is_pending()) 156 if (request.is_pending())
156 binding_.Bind(std::move(request)); 157 binding_.Bind(std::move(request));
157 delegate_->GetFocusClient()->AddObserver(this); 158 delegate_->GetFocusClient()->AddObserver(this);
158 delegate_->GetCaptureClient()->AddObserver(this); 159 delegate_->GetCaptureClient()->AddObserver(this);
160 client::GetTransientWindowClient()->AddObserver(this);
159 if (window_manager_delegate) 161 if (window_manager_delegate)
160 window_manager_delegate->SetWindowManagerClient(this); 162 window_manager_delegate->SetWindowManagerClient(this);
161 } 163 }
162 164
163 WindowTreeClient::~WindowTreeClient() { 165 WindowTreeClient::~WindowTreeClient() {
164 in_destructor_ = true; 166 in_destructor_ = true;
165 167
166 for (WindowTreeClientObserver& observer : observers_) 168 for (WindowTreeClientObserver& observer : observers_)
167 observer.OnWillDestroyClient(this); 169 observer.OnWillDestroyClient(this);
168 170
(...skipping 13 matching lines...) Expand all
182 184
183 // Delete the non-owned windows last. In the typical case these are roots. The 185 // Delete the non-owned windows last. In the typical case these are roots. The
184 // exception is the window manager and embed roots, which may know about 186 // exception is the window manager and embed roots, which may know about
185 // other random windows that it doesn't own. 187 // other random windows that it doesn't own.
186 while (!tracker.windows().empty()) 188 while (!tracker.windows().empty())
187 delete tracker.windows().front(); 189 delete tracker.windows().front();
188 190
189 for (WindowTreeClientObserver& observer : observers_) 191 for (WindowTreeClientObserver& observer : observers_)
190 observer.OnDidDestroyClient(this); 192 observer.OnDidDestroyClient(this);
191 193
194 client::GetTransientWindowClient()->RemoveObserver(this);
195 delegate_->GetCaptureClient()->RemoveObserver(this);
192 delegate_->GetFocusClient()->RemoveObserver(this); 196 delegate_->GetFocusClient()->RemoveObserver(this);
193 delegate_->GetCaptureClient()->RemoveObserver(this);
194 } 197 }
195 198
196 void WindowTreeClient::ConnectViaWindowTreeFactory( 199 void WindowTreeClient::ConnectViaWindowTreeFactory(
197 service_manager::Connector* connector) { 200 service_manager::Connector* connector) {
198 // The client id doesn't really matter, we use 101 purely for debugging. 201 // The client id doesn't really matter, we use 101 purely for debugging.
199 client_id_ = 101; 202 client_id_ = 101;
200 203
201 ui::mojom::WindowTreeFactoryPtr factory; 204 ui::mojom::WindowTreeFactoryPtr factory;
202 connector->ConnectToInterface("service:ui", &factory); 205 connector->ConnectToInterface("service:ui", &factory);
203 ui::mojom::WindowTreePtr window_tree; 206 ui::mojom::WindowTreePtr window_tree;
(...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after
1084 if (window) { 1087 if (window) {
1085 WindowPrivate(window).LocalSetClientArea( 1088 WindowPrivate(window).LocalSetClientArea(
1086 new_client_area, 1089 new_client_area,
1087 new_additional_client_areas.To<std::vector<gfx::Rect>>()); 1090 new_additional_client_areas.To<std::vector<gfx::Rect>>());
1088 } 1091 }
1089 */ 1092 */
1090 } 1093 }
1091 1094
1092 void WindowTreeClient::OnTransientWindowAdded(uint32_t window_id, 1095 void WindowTreeClient::OnTransientWindowAdded(uint32_t window_id,
1093 uint32_t transient_window_id) { 1096 uint32_t transient_window_id) {
1094 // TODO: needs to route to StackingClient. 1097 WindowMus* window = GetWindowByServerId(window_id);
1095 /* 1098 WindowMus* transient_window = GetWindowByServerId(transient_window_id);
1096 Window* window = GetWindowByServerId(window_id);
1097 Window* transient_window = GetWindowByServerId(transient_window_id);
1098 // window or transient_window or both may be null if a local delete occurs 1099 // window or transient_window or both may be null if a local delete occurs
1099 // with an in flight add from the server. 1100 // with an in flight add from the server.
1100 if (window && transient_window) 1101 if (window && transient_window)
1101 WindowPrivate(window).LocalAddTransientWindow(transient_window); 1102 window->AddTransientChildFromServer(transient_window);
1102 */
1103 } 1103 }
1104 1104
1105 void WindowTreeClient::OnTransientWindowRemoved(uint32_t window_id, 1105 void WindowTreeClient::OnTransientWindowRemoved(uint32_t window_id,
1106 uint32_t transient_window_id) { 1106 uint32_t transient_window_id) {
1107 // TODO: needs to route to StackingClient. 1107 WindowMus* window = GetWindowByServerId(window_id);
1108 /* 1108 WindowMus* transient_window = GetWindowByServerId(transient_window_id);
1109 Window* window = GetWindowByServerId(window_id);
1110 Window* transient_window = GetWindowByServerId(transient_window_id);
1111 // window or transient_window or both may be null if a local delete occurs 1109 // window or transient_window or both may be null if a local delete occurs
1112 // with an in flight delete from the server. 1110 // with an in flight delete from the server.
1113 if (window && transient_window) 1111 if (window && transient_window)
1114 WindowPrivate(window).LocalRemoveTransientWindow(transient_window); 1112 window->RemoveTransientChildFromServer(transient_window);
1115 */
1116 } 1113 }
1117 1114
1118 void WindowTreeClient::OnWindowHierarchyChanged( 1115 void WindowTreeClient::OnWindowHierarchyChanged(
1119 Id window_id, 1116 Id window_id,
1120 Id old_parent_id, 1117 Id old_parent_id,
1121 Id new_parent_id, 1118 Id new_parent_id,
1122 mojo::Array<ui::mojom::WindowDataPtr> windows) { 1119 mojo::Array<ui::mojom::WindowDataPtr> windows) {
1123 WindowMus* initial_parent = 1120 WindowMus* initial_parent =
1124 windows.size() ? GetWindowByServerId(windows[0]->parent_id) : nullptr; 1121 windows.size() ? GetWindowByServerId(windows[0]->parent_id) : nullptr;
1125 1122
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
1729 window_tree_host->GetDisplay().bounds().OffsetFromOrigin(); 1726 window_tree_host->GetDisplay().bounds().OffsetFromOrigin();
1730 bounds->set_origin(display_relative_origin); 1727 bounds->set_origin(display_relative_origin);
1731 break; 1728 break;
1732 } 1729 }
1733 } 1730 }
1734 // We need the root window to always have an origin of 0x0 locally. 1731 // We need the root window to always have an origin of 0x0 locally.
1735 window_tree_host->set_origin_offset(bounds->OffsetFromOrigin()); 1732 window_tree_host->set_origin_offset(bounds->OffsetFromOrigin());
1736 bounds->set_origin(gfx::Point()); 1733 bounds->set_origin(gfx::Point());
1737 } 1734 }
1738 1735
1736 void WindowTreeClient::OnTransientChildWindowAdded(Window* parent,
1737 Window* transient_child) {
1738 if (WindowMus::Get(parent)->OnTransientChildAdded(
1739 WindowMus::Get(transient_child)) == WindowMus::ChangeSource::SERVER) {
1740 return;
1741 }
1742 DCHECK(tree_);
1743 WindowMus* parent_mus = WindowMus::Get(parent);
1744 const uint32_t change_id =
1745 ScheduleInFlightChange(base::MakeUnique<CrashInFlightChange>(
1746 parent_mus, ChangeType::ADD_TRANSIENT_WINDOW));
1747 tree_->AddTransientWindow(change_id, parent_mus->server_id(),
1748 WindowMus::Get(transient_child)->server_id());
1749 }
1750
1751 void WindowTreeClient::OnTransientChildWindowRemoved(Window* parent,
1752 Window* transient_child) {
1753 if (WindowMus::Get(parent)->OnTransientChildRemoved(
1754 WindowMus::Get(transient_child)) == WindowMus::ChangeSource::SERVER) {
1755 return;
1756 }
1757 DCHECK(tree_);
1758 WindowMus* child_mus = WindowMus::Get(transient_child);
1759 const uint32_t change_id =
1760 ScheduleInFlightChange(base::MakeUnique<CrashInFlightChange>(
1761 child_mus, ChangeType::REMOVE_TRANSIENT_WINDOW_FROM_PARENT));
1762 tree_->RemoveTransientWindowFromParent(change_id, child_mus->server_id());
1763 }
1764
1739 } // namespace aura 1765 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698