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 return; |
| 620 |
| 621 InFlightPredefinedCursorChange new_change(window, cursor); |
| 622 if (ApplyServerChangeToExistingInFlightChange(new_change)) |
| 623 return; |
| 624 |
| 625 WindowPrivate(window).LocalSetPredefinedCursor(cursor); |
| 626 } |
| 627 |
600 void WindowTreeClientImpl::OnChangeCompleted(uint32 change_id, bool success) { | 628 void WindowTreeClientImpl::OnChangeCompleted(uint32 change_id, bool success) { |
601 scoped_ptr<InFlightChange> change(std::move(in_flight_map_[change_id])); | 629 scoped_ptr<InFlightChange> change(std::move(in_flight_map_[change_id])); |
602 in_flight_map_.erase(change_id); | 630 in_flight_map_.erase(change_id); |
603 if (!change) | 631 if (!change) |
604 return; | 632 return; |
605 | 633 |
606 if (!success) | 634 if (!success) |
607 change->ChangeFailed(); | 635 change->ChangeFailed(); |
608 | 636 |
609 InFlightChange* next_change = GetOldestInFlightChangeMatching(*change); | 637 InFlightChange* next_change = GetOldestInFlightChangeMatching(*change); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 } | 686 } |
659 | 687 |
660 //////////////////////////////////////////////////////////////////////////////// | 688 //////////////////////////////////////////////////////////////////////////////// |
661 // WindowTreeClientImpl, private: | 689 // WindowTreeClientImpl, private: |
662 | 690 |
663 mojo::Callback<void(bool)> WindowTreeClientImpl::ActionCompletedCallback() { | 691 mojo::Callback<void(bool)> WindowTreeClientImpl::ActionCompletedCallback() { |
664 return [this](bool success) {}; | 692 return [this](bool success) {}; |
665 } | 693 } |
666 | 694 |
667 } // namespace mus | 695 } // namespace mus |
OLD | NEW |