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

Side by Side Diff: components/mus/public/cpp/lib/window_tree_client_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 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 "components/mus/public/cpp/lib/window_tree_client_impl.h" 5 #include "components/mus/public/cpp/lib/window_tree_client_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "components/mus/common/util.h" 8 #include "components/mus/common/util.h"
9 #include "components/mus/public/cpp/lib/in_flight_change.h" 9 #include "components/mus/public/cpp/lib/in_flight_change.h"
10 #include "components/mus/public/cpp/lib/window_private.h" 10 #include "components/mus/public/cpp/lib/window_private.h"
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 200
201 void WindowTreeClientImpl::SetBounds(Window* window, 201 void WindowTreeClientImpl::SetBounds(Window* window,
202 const gfx::Rect& old_bounds, 202 const gfx::Rect& old_bounds,
203 const gfx::Rect& bounds) { 203 const gfx::Rect& bounds) {
204 DCHECK(tree_); 204 DCHECK(tree_);
205 const uint32_t change_id = ScheduleInFlightChange( 205 const uint32_t change_id = ScheduleInFlightChange(
206 make_scoped_ptr(new InFlightBoundsChange(window, old_bounds))); 206 make_scoped_ptr(new InFlightBoundsChange(window, old_bounds)));
207 tree_->SetWindowBounds(change_id, window->id(), mojo::Rect::From(bounds)); 207 tree_->SetWindowBounds(change_id, window->id(), mojo::Rect::From(bounds));
208 } 208 }
209 209
210 void WindowTreeClientImpl::SetCapture(Window* window) {
211 // In order for us to get here we had to have exposed a window, which implies
212 // we got a connection.
213 DCHECK(tree_);
214 const uint32_t change_id = ScheduleInFlightChange(make_scoped_ptr(
215 new CrashInFlightChange(window, ChangeType::SET_CAPTURE)));
216 tree_->SetCapture(change_id, window->id());
217 }
218
219 void WindowTreeClientImpl::ReleaseCapture(Window* window) {
220 // In order for us to get here we had to have exposed a window, which implies
221 // we got a connection.
222 DCHECK(tree_);
223 const uint32_t change_id = ScheduleInFlightChange(make_scoped_ptr(
224 new CrashInFlightChange(window, ChangeType::RELEASE_CAPTURE)));
225 tree_->ReleaseCapture(change_id, window->id());
226 }
227
210 void WindowTreeClientImpl::SetClientArea(Id window_id, 228 void WindowTreeClientImpl::SetClientArea(Id window_id,
211 const gfx::Insets& client_area) { 229 const gfx::Insets& client_area) {
212 DCHECK(tree_); 230 DCHECK(tree_);
213 tree_->SetClientArea(window_id, mojo::Insets::From(client_area)); 231 tree_->SetClientArea(window_id, mojo::Insets::From(client_area));
214 } 232 }
215 233
216 void WindowTreeClientImpl::SetFocus(Id window_id) { 234 void WindowTreeClientImpl::SetFocus(Id window_id) {
217 // In order for us to get here we had to have exposed a window, which implies 235 // In order for us to get here we had to have exposed a window, which implies
218 // we got a connection. 236 // we got a connection.
219 DCHECK(tree_); 237 DCHECK(tree_);
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 OnWindowEmbeddedAppDisconnected(window)); 445 OnWindowEmbeddedAppDisconnected(window));
428 } 446 }
429 } 447 }
430 448
431 void WindowTreeClientImpl::OnUnembed() { 449 void WindowTreeClientImpl::OnUnembed() {
432 delegate_->OnUnembed(); 450 delegate_->OnUnembed();
433 // This will send out the various notifications. 451 // This will send out the various notifications.
434 delete this; 452 delete this;
435 } 453 }
436 454
455 void WindowTreeClientImpl::OnLostCapture(Id window_id) {
456 Window* window = GetWindowById(window_id);
457 if (window) {
458 FOR_EACH_OBSERVER(WindowObserver, *WindowPrivate(window).observers(),
459 OnWindowLostCapture(window));
460 }
461 }
462
437 void WindowTreeClientImpl::OnWindowBoundsChanged(Id window_id, 463 void WindowTreeClientImpl::OnWindowBoundsChanged(Id window_id,
438 mojo::RectPtr old_bounds, 464 mojo::RectPtr old_bounds,
439 mojo::RectPtr new_bounds) { 465 mojo::RectPtr new_bounds) {
440 Window* window = GetWindowById(window_id); 466 Window* window = GetWindowById(window_id);
441 if (!window) 467 if (!window)
442 return; 468 return;
443 469
444 InFlightBoundsChange new_change(window, new_bounds.To<gfx::Rect>()); 470 InFlightBoundsChange new_change(window, new_bounds.To<gfx::Rect>());
445 if (ApplyServerChangeToExistingInFlightChange(new_change)) 471 if (ApplyServerChangeToExistingInFlightChange(new_change))
446 return; 472 return;
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 void WindowTreeClientImpl::OnActionCompleted(bool success) { 692 void WindowTreeClientImpl::OnActionCompleted(bool success) {
667 if (!change_acked_callback_.is_null()) 693 if (!change_acked_callback_.is_null())
668 change_acked_callback_.Run(); 694 change_acked_callback_.Run();
669 } 695 }
670 696
671 mojo::Callback<void(bool)> WindowTreeClientImpl::ActionCompletedCallback() { 697 mojo::Callback<void(bool)> WindowTreeClientImpl::ActionCompletedCallback() {
672 return [this](bool success) { OnActionCompleted(success); }; 698 return [this](bool success) { OnActionCompleted(success); };
673 } 699 }
674 700
675 } // namespace mus 701 } // namespace mus
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698