| 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 #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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 // we got a connection. | 215 // we got a connection. |
| 216 DCHECK(tree_); | 216 DCHECK(tree_); |
| 217 tree_->SetFocus(window_id); | 217 tree_->SetFocus(window_id); |
| 218 } | 218 } |
| 219 | 219 |
| 220 void WindowTreeClientImpl::SetCanFocus(Id window_id, bool can_focus) { | 220 void WindowTreeClientImpl::SetCanFocus(Id window_id, bool can_focus) { |
| 221 DCHECK(tree_); | 221 DCHECK(tree_); |
| 222 tree_->SetCanFocus(window_id, can_focus); | 222 tree_->SetCanFocus(window_id, can_focus); |
| 223 } | 223 } |
| 224 | 224 |
| 225 void WindowTreeClientImpl::SetPredefinedCursor(Id window_id, |
| 226 mus::mojom::Cursor cursor_id) { |
| 227 DCHECK(tree_); |
| 228 |
| 229 Window* window = GetWindowById(window_id); |
| 230 if (!window) |
| 231 return; |
| 232 |
| 233 // We make an inflight change thing here. |
| 234 const uint32_t change_id = ScheduleInFlightChange(make_scoped_ptr( |
| 235 new InFlightPredefinedCursorChange(window, window->predefined_cursor()))); |
| 236 tree_->SetPredefinedCursor(change_id, window_id, cursor_id); |
| 237 } |
| 238 |
| 225 void WindowTreeClientImpl::SetVisible(Window* window, bool visible) { | 239 void WindowTreeClientImpl::SetVisible(Window* window, bool visible) { |
| 226 DCHECK(tree_); | 240 DCHECK(tree_); |
| 227 const uint32_t change_id = ScheduleInFlightChange( | 241 const uint32_t change_id = ScheduleInFlightChange( |
| 228 make_scoped_ptr(new InFlightVisibleChange(window, !visible))); | 242 make_scoped_ptr(new InFlightVisibleChange(window, !visible))); |
| 229 tree_->SetWindowVisibility(change_id, window->id(), visible); | 243 tree_->SetWindowVisibility(change_id, window->id(), visible); |
| 230 } | 244 } |
| 231 | 245 |
| 232 void WindowTreeClientImpl::SetProperty(Window* window, | 246 void WindowTreeClientImpl::SetProperty(Window* window, |
| 233 const std::string& name, | 247 const std::string& name, |
| 234 mojo::Array<uint8_t> data) { | 248 mojo::Array<uint8_t> data) { |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 if (blurred) { | 604 if (blurred) { |
| 591 FOR_EACH_OBSERVER(WindowObserver, *WindowPrivate(blurred).observers(), | 605 FOR_EACH_OBSERVER(WindowObserver, *WindowPrivate(blurred).observers(), |
| 592 OnWindowFocusChanged(focused, blurred)); | 606 OnWindowFocusChanged(focused, blurred)); |
| 593 } | 607 } |
| 594 if (focused) { | 608 if (focused) { |
| 595 FOR_EACH_OBSERVER(WindowObserver, *WindowPrivate(focused).observers(), | 609 FOR_EACH_OBSERVER(WindowObserver, *WindowPrivate(focused).observers(), |
| 596 OnWindowFocusChanged(focused, blurred)); | 610 OnWindowFocusChanged(focused, blurred)); |
| 597 } | 611 } |
| 598 } | 612 } |
| 599 | 613 |
| 614 void WindowTreeClientImpl::OnWindowPredefinedCursorChanged( |
| 615 Id window_id, |
| 616 mojom::Cursor cursor) { |
| 617 Window* window = GetWindowById(window_id); |
| 618 if (window) { |
| 619 FOR_EACH_OBSERVER(WindowObserver, *WindowPrivate(window).observers(), |
| 620 OnWindowPredefinedCursorChanged(window, cursor)); |
| 621 } |
| 622 } |
| 623 |
| 600 void WindowTreeClientImpl::OnChangeCompleted(uint32 change_id, bool success) { | 624 void WindowTreeClientImpl::OnChangeCompleted(uint32 change_id, bool success) { |
| 601 scoped_ptr<InFlightChange> change(std::move(in_flight_map_[change_id])); | 625 scoped_ptr<InFlightChange> change(std::move(in_flight_map_[change_id])); |
| 602 in_flight_map_.erase(change_id); | 626 in_flight_map_.erase(change_id); |
| 603 if (!change) | 627 if (!change) |
| 604 return; | 628 return; |
| 605 | 629 |
| 606 if (!success) | 630 if (!success) |
| 607 change->ChangeFailed(); | 631 change->ChangeFailed(); |
| 608 | 632 |
| 609 InFlightChange* next_change = GetOldestInFlightChangeMatching(*change); | 633 InFlightChange* next_change = GetOldestInFlightChangeMatching(*change); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 void WindowTreeClientImpl::OnActionCompleted(bool success) { | 687 void WindowTreeClientImpl::OnActionCompleted(bool success) { |
| 664 if (!change_acked_callback_.is_null()) | 688 if (!change_acked_callback_.is_null()) |
| 665 change_acked_callback_.Run(); | 689 change_acked_callback_.Run(); |
| 666 } | 690 } |
| 667 | 691 |
| 668 mojo::Callback<void(bool)> WindowTreeClientImpl::ActionCompletedCallback() { | 692 mojo::Callback<void(bool)> WindowTreeClientImpl::ActionCompletedCallback() { |
| 669 return [this](bool success) { OnActionCompleted(success); }; | 693 return [this](bool success) { OnActionCompleted(success); }; |
| 670 } | 694 } |
| 671 | 695 |
| 672 } // namespace mus | 696 } // namespace mus |
| OLD | NEW |