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/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 Loading... |
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()->OnWindowPredefinedCursorChanged(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 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
851 host->SetFocusedWindow(window); | 860 host->SetFocusedWindow(window); |
852 } | 861 } |
853 } | 862 } |
854 | 863 |
855 void WindowTreeImpl::SetCanFocus(uint32_t window_id, bool can_focus) { | 864 void WindowTreeImpl::SetCanFocus(uint32_t window_id, bool can_focus) { |
856 ServerWindow* window = GetWindow(WindowIdFromTransportId(window_id)); | 865 ServerWindow* window = GetWindow(WindowIdFromTransportId(window_id)); |
857 if (window && ShouldRouteToWindowManager(window)) | 866 if (window && ShouldRouteToWindowManager(window)) |
858 window->set_can_focus(can_focus); | 867 window->set_can_focus(can_focus); |
859 } | 868 } |
860 | 869 |
| 870 void WindowTreeImpl::SetPredefinedCursor(uint32_t change_id, |
| 871 uint32_t window_id, |
| 872 mus::mojom::Cursor cursor_id) { |
| 873 ServerWindow* window = GetWindow(WindowIdFromTransportId(window_id)); |
| 874 |
| 875 // Only the owner of the window can change the bounds. |
| 876 bool success = window && access_policy_->CanSetCursorProperties(window); |
| 877 if (success) { |
| 878 Operation op(this, connection_manager_, |
| 879 OperationType::SET_WINDOW_PREDEFINED_CURSOR); |
| 880 window->SetPredefinedCursor(cursor_id); |
| 881 } |
| 882 client_->OnChangeCompleted(change_id, success); |
| 883 } |
| 884 |
861 void WindowTreeImpl::WmResponse(uint32 change_id, bool response) { | 885 void WindowTreeImpl::WmResponse(uint32 change_id, bool response) { |
862 if (GetHost() && GetHost()->GetWindowTree() == this) | 886 if (GetHost() && GetHost()->GetWindowTree() == this) |
863 connection_manager_->WindowManagerChangeCompleted(change_id, response); | 887 connection_manager_->WindowManagerChangeCompleted(change_id, response); |
864 } | 888 } |
865 | 889 |
866 bool WindowTreeImpl::IsRootForAccessPolicy(const WindowId& id) const { | 890 bool WindowTreeImpl::IsRootForAccessPolicy(const WindowId& id) const { |
867 return IsRoot(id); | 891 return IsRoot(id); |
868 } | 892 } |
869 | 893 |
870 bool WindowTreeImpl::IsWindowKnownForAccessPolicy( | 894 bool WindowTreeImpl::IsWindowKnownForAccessPolicy( |
871 const ServerWindow* window) const { | 895 const ServerWindow* window) const { |
872 return IsWindowKnown(window); | 896 return IsWindowKnown(window); |
873 } | 897 } |
874 | 898 |
875 bool WindowTreeImpl::IsWindowRootOfAnotherConnectionForAccessPolicy( | 899 bool WindowTreeImpl::IsWindowRootOfAnotherConnectionForAccessPolicy( |
876 const ServerWindow* window) const { | 900 const ServerWindow* window) const { |
877 WindowTreeImpl* connection = | 901 WindowTreeImpl* connection = |
878 connection_manager_->GetConnectionWithRoot(window->id()); | 902 connection_manager_->GetConnectionWithRoot(window->id()); |
879 return connection && connection != this; | 903 return connection && connection != this; |
880 } | 904 } |
881 | 905 |
882 bool WindowTreeImpl::IsDescendantOfEmbedRoot(const ServerWindow* window) { | 906 bool WindowTreeImpl::IsDescendantOfEmbedRoot(const ServerWindow* window) { |
883 return is_embed_root_ && root_ && GetWindow(*root_)->Contains(window); | 907 return is_embed_root_ && root_ && GetWindow(*root_)->Contains(window); |
884 } | 908 } |
885 | 909 |
886 } // namespace ws | 910 } // namespace ws |
887 | 911 |
888 } // namespace mus | 912 } // namespace mus |
OLD | NEW |