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

Side by Side Diff: components/mus/ws/window_tree_host_impl.cc

Issue 1352043005: mus: Implement Window Server Capture Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added capture unit tests Created 5 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 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 #include "components/mus/ws/window_tree_host_impl.h" 5 #include "components/mus/ws/window_tree_host_impl.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "components/mus/common/types.h" 8 #include "components/mus/common/types.h"
9 #include "components/mus/ws/connection_manager.h" 9 #include "components/mus/ws/connection_manager.h"
10 #include "components/mus/ws/display_manager.h" 10 #include "components/mus/ws/display_manager.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 if (windows_needing_frame_destruction_.count(window)) 76 if (windows_needing_frame_destruction_.count(window))
77 return; 77 return;
78 windows_needing_frame_destruction_.insert(window); 78 windows_needing_frame_destruction_.insert(window);
79 window->AddObserver(this); 79 window->AddObserver(this);
80 } 80 }
81 81
82 const mojom::ViewportMetrics& WindowTreeHostImpl::GetViewportMetrics() const { 82 const mojom::ViewportMetrics& WindowTreeHostImpl::GetViewportMetrics() const {
83 return display_manager_->GetViewportMetrics(); 83 return display_manager_->GetViewportMetrics();
84 } 84 }
85 85
86 void WindowTreeHostImpl::SetCapture(ServerWindow* window) {
87 ServerWindow* capture_window = event_dispatcher_.capture_window();
88 if (capture_window) {
89 WindowTreeImpl* connection =
90 connection_manager_->GetConnection(capture_window->id().connection_id);
91 if (connection)
92 connection->ProcessLostCapture(capture_window);
93 }
94 event_dispatcher_.SetCaptureWindow(window);
95 if (window)
96 display_manager_->SetCapture();
97 else
98 display_manager_->ReleaseCapture();
99 }
100
86 void WindowTreeHostImpl::SetFocusedWindow(ServerWindow* new_focused_window) { 101 void WindowTreeHostImpl::SetFocusedWindow(ServerWindow* new_focused_window) {
87 ServerWindow* old_focused_window = focus_controller_->GetFocusedWindow(); 102 ServerWindow* old_focused_window = focus_controller_->GetFocusedWindow();
88 if (old_focused_window == new_focused_window) 103 if (old_focused_window == new_focused_window)
89 return; 104 return;
90 DCHECK(root_window()->Contains(new_focused_window)); 105 DCHECK(root_window()->Contains(new_focused_window));
91 focus_controller_->SetFocusedWindow(new_focused_window); 106 focus_controller_->SetFocusedWindow(new_focused_window);
92 // TODO(beng): have the FocusController notify us via FocusControllerDelegate. 107 // TODO(beng): have the FocusController notify us via FocusControllerDelegate.
93 OnFocusChanged(old_focused_window, new_focused_window); 108 OnFocusChanged(old_focused_window, new_focused_window);
94 } 109 }
95 110
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 } 158 }
144 159
145 ServerWindow* WindowTreeHostImpl::GetRootWindow() { 160 ServerWindow* WindowTreeHostImpl::GetRootWindow() {
146 return root_.get(); 161 return root_.get();
147 } 162 }
148 163
149 void WindowTreeHostImpl::OnEvent(mojom::EventPtr event) { 164 void WindowTreeHostImpl::OnEvent(mojom::EventPtr event) {
150 event_dispatcher_.OnEvent(event.Pass()); 165 event_dispatcher_.OnEvent(event.Pass());
151 } 166 }
152 167
168 void WindowTreeHostImpl::OnLostCapture() {
169 SetCapture(nullptr);
170 }
171
153 void WindowTreeHostImpl::OnDisplayClosed() { 172 void WindowTreeHostImpl::OnDisplayClosed() {
154 if (delegate_) 173 if (delegate_)
155 delegate_->OnDisplayClosed(); 174 delegate_->OnDisplayClosed();
156 } 175 }
157 176
158 void WindowTreeHostImpl::OnViewportMetricsChanged( 177 void WindowTreeHostImpl::OnViewportMetricsChanged(
159 const mojom::ViewportMetrics& old_metrics, 178 const mojom::ViewportMetrics& old_metrics,
160 const mojom::ViewportMetrics& new_metrics) { 179 const mojom::ViewportMetrics& new_metrics) {
161 if (!root_) { 180 if (!root_) {
162 root_.reset(connection_manager_->CreateServerWindow( 181 root_.reset(connection_manager_->CreateServerWindow(
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 273
255 void WindowTreeHostImpl::SetFocusedWindowFromEventDispatcher( 274 void WindowTreeHostImpl::SetFocusedWindowFromEventDispatcher(
256 ServerWindow* new_focused_window) { 275 ServerWindow* new_focused_window) {
257 SetFocusedWindow(new_focused_window); 276 SetFocusedWindow(new_focused_window);
258 } 277 }
259 278
260 ServerWindow* WindowTreeHostImpl::GetFocusedWindowForEventDispatcher() { 279 ServerWindow* WindowTreeHostImpl::GetFocusedWindowForEventDispatcher() {
261 return GetFocusedWindow(); 280 return GetFocusedWindow();
262 } 281 }
263 282
283 void WindowTreeHostImpl::OnLostCapture(ServerWindow* window) {
284 DCHECK(window);
285 WindowTreeImpl* connection =
286 connection_manager_->GetConnection(window->id().connection_id);
287 if (connection)
288 connection->ProcessLostCapture(window);
289 }
290
264 void WindowTreeHostImpl::DispatchInputEventToWindow(ServerWindow* target, 291 void WindowTreeHostImpl::DispatchInputEventToWindow(ServerWindow* target,
265 bool in_nonclient_area, 292 bool in_nonclient_area,
266 mojom::EventPtr event) { 293 mojom::EventPtr event) {
267 // If the event is in the non-client area the event goes to the owner of 294 // If the event is in the non-client area the event goes to the owner of
268 // the window. Otherwise if the window is an embed root, forward to the 295 // the window. Otherwise if the window is an embed root, forward to the
269 // embedded window. 296 // embedded window.
270 WindowTreeImpl* connection = 297 WindowTreeImpl* connection =
271 in_nonclient_area 298 in_nonclient_area
272 ? connection_manager_->GetConnection(target->id().connection_id) 299 ? connection_manager_->GetConnection(target->id().connection_id)
273 : connection_manager_->GetConnectionWithRoot(target->id()); 300 : connection_manager_->GetConnectionWithRoot(target->id());
274 if (!connection) { 301 if (!connection) {
275 DCHECK(!in_nonclient_area); 302 DCHECK(!in_nonclient_area);
276 connection = connection_manager_->GetConnection(target->id().connection_id); 303 connection = connection_manager_->GetConnection(target->id().connection_id);
277 } 304 }
278 connection->client()->OnWindowInputEvent(WindowIdToTransportId(target->id()), 305 connection->client()->OnWindowInputEvent(WindowIdToTransportId(target->id()),
279 event.Pass(), 306 event.Pass(),
280 base::Bind(&base::DoNothing)); 307 base::Bind(&base::DoNothing));
281 } 308 }
282 309
283 void WindowTreeHostImpl::OnWindowDestroyed(ServerWindow* window) { 310 void WindowTreeHostImpl::OnWindowDestroyed(ServerWindow* window) {
284 windows_needing_frame_destruction_.erase(window); 311 windows_needing_frame_destruction_.erase(window);
285 window->RemoveObserver(this); 312 window->RemoveObserver(this);
286 } 313 }
287 314
288 } // namespace ws 315 } // namespace ws
289 } // namespace mus 316 } // namespace mus
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698