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

Side by Side Diff: components/mus/ws/window_tree_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/ws/window_tree_impl.h" 5 #include "components/mus/ws/window_tree_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "components/mus/ws/connection_manager.h" 9 #include "components/mus/ws/connection_manager.h"
10 #include "components/mus/ws/default_access_policy.h" 10 #include "components/mus/ws/default_access_policy.h"
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 // Window is being hidden, won't be drawn. 357 // Window is being hidden, won't be drawn.
358 window_target_drawn_state = false; 358 window_target_drawn_state = false;
359 } else { 359 } else {
360 // Window is being shown. Window will be drawn if its parent is drawn. 360 // Window is being shown. Window will be drawn if its parent is drawn.
361 window_target_drawn_state = window->parent() && window->parent()->IsDrawn(); 361 window_target_drawn_state = window->parent() && window->parent()->IsDrawn();
362 } 362 }
363 363
364 NotifyDrawnStateChanged(window, window_target_drawn_state); 364 NotifyDrawnStateChanged(window, window_target_drawn_state);
365 } 365 }
366 366
367 void WindowTreeImpl::ProcessCursorChanged(const ServerWindow* window,
368 int32_t cursor_id,
369 bool originated_change) {
370 if (originated_change)
371 return;
372 client()->OnWindowSetPredefinedCursor(WindowIdToTransportId(window->id()),
373 mojom::Cursor(cursor_id));
374 }
375
367 void WindowTreeImpl::ProcessFocusChanged( 376 void WindowTreeImpl::ProcessFocusChanged(
368 const ServerWindow* old_focused_window, 377 const ServerWindow* old_focused_window,
369 const ServerWindow* new_focused_window) { 378 const ServerWindow* new_focused_window) {
370 const ServerWindow* window = 379 const ServerWindow* window =
371 new_focused_window 380 new_focused_window
372 ? access_policy_->GetWindowForFocusChange(new_focused_window) 381 ? access_policy_->GetWindowForFocusChange(new_focused_window)
373 : nullptr; 382 : nullptr;
374 client()->OnWindowFocused(window ? WindowIdToTransportId(window->id()) 383 client()->OnWindowFocused(window ? WindowIdToTransportId(window->id())
375 : WindowIdToTransportId(WindowId())); 384 : WindowIdToTransportId(WindowId()));
376 } 385 }
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 host->SetFocusedWindow(window); 859 host->SetFocusedWindow(window);
851 } 860 }
852 } 861 }
853 862
854 void WindowTreeImpl::SetCanFocus(uint32_t window_id, bool can_focus) { 863 void WindowTreeImpl::SetCanFocus(uint32_t window_id, bool can_focus) {
855 ServerWindow* window = GetWindow(WindowIdFromTransportId(window_id)); 864 ServerWindow* window = GetWindow(WindowIdFromTransportId(window_id));
856 if (window && ShouldRouteToWindowManager(window)) 865 if (window && ShouldRouteToWindowManager(window))
857 window->set_can_focus(can_focus); 866 window->set_can_focus(can_focus);
858 } 867 }
859 868
869 void WindowTreeImpl::SetPredefinedCursor(uint32_t change_id,
870 uint32_t window_id,
871 mus::mojom::Cursor cursor_id) {
872 ServerWindow* window = GetWindow(WindowIdFromTransportId(window_id));
873
874 // Only the owner of the window can change the bounds.
875 bool success = window && access_policy_->CanSetCursorProperties(window);
876 if (success) {
877 Operation op(this, connection_manager_,
878 OperationType::SET_WINDOW_PREDEFINED_CURSOR);
879 window->SetPredefinedCursor(cursor_id);
880 }
881 client_->OnChangeCompleted(change_id, success);
882 }
883
860 void WindowTreeImpl::WmResponse(uint32 change_id, bool response) { 884 void WindowTreeImpl::WmResponse(uint32 change_id, bool response) {
861 if (GetHost() && GetHost()->GetWindowTree() == this) 885 if (GetHost() && GetHost()->GetWindowTree() == this)
862 connection_manager_->WindowManagerChangeCompleted(change_id, response); 886 connection_manager_->WindowManagerChangeCompleted(change_id, response);
863 } 887 }
864 888
865 bool WindowTreeImpl::IsRootForAccessPolicy(const WindowId& id) const { 889 bool WindowTreeImpl::IsRootForAccessPolicy(const WindowId& id) const {
866 return IsRoot(id); 890 return IsRoot(id);
867 } 891 }
868 892
869 bool WindowTreeImpl::IsWindowKnownForAccessPolicy( 893 bool WindowTreeImpl::IsWindowKnownForAccessPolicy(
870 const ServerWindow* window) const { 894 const ServerWindow* window) const {
871 return IsWindowKnown(window); 895 return IsWindowKnown(window);
872 } 896 }
873 897
874 bool WindowTreeImpl::IsWindowRootOfAnotherConnectionForAccessPolicy( 898 bool WindowTreeImpl::IsWindowRootOfAnotherConnectionForAccessPolicy(
875 const ServerWindow* window) const { 899 const ServerWindow* window) const {
876 WindowTreeImpl* connection = 900 WindowTreeImpl* connection =
877 connection_manager_->GetConnectionWithRoot(window->id()); 901 connection_manager_->GetConnectionWithRoot(window->id());
878 return connection && connection != this; 902 return connection && connection != this;
879 } 903 }
880 904
881 bool WindowTreeImpl::IsDescendantOfEmbedRoot(const ServerWindow* window) { 905 bool WindowTreeImpl::IsDescendantOfEmbedRoot(const ServerWindow* window) {
882 return is_embed_root_ && root_ && GetWindow(*root_)->Contains(window); 906 return is_embed_root_ && root_ && GetWindow(*root_)->Contains(window);
883 } 907 }
884 908
885 } // namespace ws 909 } // namespace ws
886 910
887 } // namespace mus 911 } // namespace mus
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698