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

Side by Side Diff: components/mus/public/cpp/lib/window_tree_client_impl.cc

Issue 1465803003: mus: Let clients set the cursor of their window. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix WindowTreeAppTest.SetCursor. Created 5 years 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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(Id window_id, bool visible) { 239 void WindowTreeClientImpl::SetVisible(Id window_id, bool visible) {
226 DCHECK(tree_); 240 DCHECK(tree_);
227 tree_->SetWindowVisibility(window_id, visible, ActionCompletedCallback()); 241 tree_->SetWindowVisibility(window_id, visible, ActionCompletedCallback());
228 } 242 }
229 243
230 void WindowTreeClientImpl::SetProperty(Window* window, 244 void WindowTreeClientImpl::SetProperty(Window* window,
231 const std::string& name, 245 const std::string& name,
232 mojo::Array<uint8_t> data) { 246 mojo::Array<uint8_t> data) {
233 DCHECK(tree_); 247 DCHECK(tree_);
234 248
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 if (blurred) { 599 if (blurred) {
586 FOR_EACH_OBSERVER(WindowObserver, *WindowPrivate(blurred).observers(), 600 FOR_EACH_OBSERVER(WindowObserver, *WindowPrivate(blurred).observers(),
587 OnWindowFocusChanged(focused, blurred)); 601 OnWindowFocusChanged(focused, blurred));
588 } 602 }
589 if (focused) { 603 if (focused) {
590 FOR_EACH_OBSERVER(WindowObserver, *WindowPrivate(focused).observers(), 604 FOR_EACH_OBSERVER(WindowObserver, *WindowPrivate(focused).observers(),
591 OnWindowFocusChanged(focused, blurred)); 605 OnWindowFocusChanged(focused, blurred));
592 } 606 }
593 } 607 }
594 608
609 void WindowTreeClientImpl::OnWindowSetPredefinedCursor(Id window_id,
610 mojom::Cursor cursor) {
611 Window* window = GetWindowById(window_id);
612 if (window) {
613 FOR_EACH_OBSERVER(WindowObserver, *WindowPrivate(window).observers(),
614 OnWindowSetPredefinedCursor(window, cursor));
615 }
616 }
617
595 void WindowTreeClientImpl::OnChangeCompleted(uint32 change_id, bool success) { 618 void WindowTreeClientImpl::OnChangeCompleted(uint32 change_id, bool success) {
596 scoped_ptr<InFlightChange> change(std::move(in_flight_map_[change_id])); 619 scoped_ptr<InFlightChange> change(std::move(in_flight_map_[change_id]));
597 in_flight_map_.erase(change_id); 620 in_flight_map_.erase(change_id);
598 if (!change) 621 if (!change)
599 return; 622 return;
600 623
601 if (!success) 624 if (!success)
602 change->ChangeFailed(); 625 change->ChangeFailed();
603 626
604 InFlightChange* next_change = GetOldestInFlightChangeMatching(*change); 627 InFlightChange* next_change = GetOldestInFlightChangeMatching(*change);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 void WindowTreeClientImpl::OnActionCompleted(bool success) { 681 void WindowTreeClientImpl::OnActionCompleted(bool success) {
659 if (!change_acked_callback_.is_null()) 682 if (!change_acked_callback_.is_null())
660 change_acked_callback_.Run(); 683 change_acked_callback_.Run();
661 } 684 }
662 685
663 mojo::Callback<void(bool)> WindowTreeClientImpl::ActionCompletedCallback() { 686 mojo::Callback<void(bool)> WindowTreeClientImpl::ActionCompletedCallback() {
664 return [this](bool success) { OnActionCompleted(success); }; 687 return [this](bool success) { OnActionCompleted(success); };
665 } 688 }
666 689
667 } // namespace mus 690 } // namespace mus
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698