| 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 "services/ui/ws/window_tree.h" | 5 #include "services/ui/ws/window_tree.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
| 14 #include "services/ui/ws/default_access_policy.h" | 14 #include "services/ui/ws/default_access_policy.h" |
| 15 #include "services/ui/ws/display.h" | 15 #include "services/ui/ws/display.h" |
| 16 #include "services/ui/ws/display_manager.h" | 16 #include "services/ui/ws/display_manager.h" |
| 17 #include "services/ui/ws/event_matcher.h" | 17 #include "services/ui/ws/event_matcher.h" |
| 18 #include "services/ui/ws/focus_controller.h" | 18 #include "services/ui/ws/focus_controller.h" |
| 19 #include "services/ui/ws/operation.h" | 19 #include "services/ui/ws/operation.h" |
| 20 #include "services/ui/ws/platform_display.h" | 20 #include "services/ui/ws/platform_display.h" |
| 21 #include "services/ui/ws/server_window.h" | 21 #include "services/ui/ws/server_window.h" |
| 22 #include "services/ui/ws/server_window_observer.h" | 22 #include "services/ui/ws/server_window_observer.h" |
| 23 #include "services/ui/ws/server_window_surface_manager.h" |
| 23 #include "services/ui/ws/user_display_manager.h" | 24 #include "services/ui/ws/user_display_manager.h" |
| 24 #include "services/ui/ws/window_manager_display_root.h" | 25 #include "services/ui/ws/window_manager_display_root.h" |
| 25 #include "services/ui/ws/window_manager_state.h" | 26 #include "services/ui/ws/window_manager_state.h" |
| 26 #include "services/ui/ws/window_server.h" | 27 #include "services/ui/ws/window_server.h" |
| 27 #include "services/ui/ws/window_tree_binding.h" | 28 #include "services/ui/ws/window_tree_binding.h" |
| 28 #include "ui/display/display.h" | 29 #include "ui/display/display.h" |
| 29 #include "ui/platform_window/mojo/ime_type_converters.h" | 30 #include "ui/platform_window/mojo/ime_type_converters.h" |
| 30 #include "ui/platform_window/text_input_state.h" | 31 #include "ui/platform_window/text_input_state.h" |
| 31 | 32 |
| 32 using mojo::Array; | 33 using mojo::Array; |
| (...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 return; | 750 return; |
| 750 ClientWindowId client_window_id, transient_client_window_id; | 751 ClientWindowId client_window_id, transient_client_window_id; |
| 751 if (!IsWindowKnown(window, &client_window_id) || | 752 if (!IsWindowKnown(window, &client_window_id) || |
| 752 !IsWindowKnown(transient_window, &transient_client_window_id)) { | 753 !IsWindowKnown(transient_window, &transient_client_window_id)) { |
| 753 return; | 754 return; |
| 754 } | 755 } |
| 755 client()->OnTransientWindowRemoved(client_window_id.id, | 756 client()->OnTransientWindowRemoved(client_window_id.id, |
| 756 transient_client_window_id.id); | 757 transient_client_window_id.id); |
| 757 } | 758 } |
| 758 | 759 |
| 760 void WindowTree::ProcessWindowSurfaceCreated(ServerWindow* window, |
| 761 const cc::SurfaceId& surface_id, |
| 762 const gfx::Size& frame_size, |
| 763 float device_scale_factor) { |
| 764 ServerWindow* parent_window = window->parent(); |
| 765 ClientWindowId client_window_id, parent_client_window_id; |
| 766 if (!IsWindowKnown(window, &client_window_id) || |
| 767 !IsWindowKnown(parent_window, &parent_client_window_id)) |
| 768 return; |
| 769 |
| 770 ServerWindowSurfaceManager* surface_manager = |
| 771 window->GetOrCreateSurfaceManager(); |
| 772 ServerWindowSurface* surface = surface_manager->GetDefaultSurface(); |
| 773 cc::SurfaceSequence sequence = surface->CreateSurfaceSequence(); |
| 774 client()->OnWindowSurfaceCreated(client_window_id.id, surface_id, sequence, |
| 775 frame_size, device_scale_factor); |
| 776 } |
| 777 |
| 759 void WindowTree::SendToPointerWatcher(const ui::Event& event, | 778 void WindowTree::SendToPointerWatcher(const ui::Event& event, |
| 760 ServerWindow* target_window) { | 779 ServerWindow* target_window) { |
| 761 if (!EventMatchesPointerWatcher(event)) | 780 if (!EventMatchesPointerWatcher(event)) |
| 762 return; | 781 return; |
| 763 | 782 |
| 764 ClientWindowId client_window_id; | 783 ClientWindowId client_window_id; |
| 765 // Ignore the return value from IsWindowKnown() as in the case of the client | 784 // Ignore the return value from IsWindowKnown() as in the case of the client |
| 766 // not knowing the window we'll send 0, which corresponds to no window. | 785 // not knowing the window we'll send 0, which corresponds to no window. |
| 767 IsWindowKnown(target_window, &client_window_id); | 786 IsWindowKnown(target_window, &client_window_id); |
| 768 client()->OnPointerEventObserved(ui::Event::Clone(event), | 787 client()->OnPointerEventObserved(ui::Event::Clone(event), |
| (...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1332 GetWindowByClientId(ClientWindowId(transport_window_id)); | 1351 GetWindowByClientId(ClientWindowId(transport_window_id)); |
| 1333 const bool success = | 1352 const bool success = |
| 1334 window && access_policy_->CanSetWindowSurface(window, type); | 1353 window && access_policy_->CanSetWindowSurface(window, type); |
| 1335 if (!success) { | 1354 if (!success) { |
| 1336 DVLOG(1) << "request to AttachSurface failed"; | 1355 DVLOG(1) << "request to AttachSurface failed"; |
| 1337 return; | 1356 return; |
| 1338 } | 1357 } |
| 1339 window->CreateSurface(type, std::move(surface), std::move(client)); | 1358 window->CreateSurface(type, std::move(surface), std::move(client)); |
| 1340 } | 1359 } |
| 1341 | 1360 |
| 1361 void WindowTree::ReturnSurfaceReference(Id transport_window_id, |
| 1362 const cc::SurfaceSequence& sequence) { |
| 1363 ServerWindow* window = |
| 1364 GetWindowByClientId(ClientWindowId(transport_window_id)); |
| 1365 if (!window) |
| 1366 return; |
| 1367 window_server_->GetDisplayCompositor()->ReturnSurfaceReference(sequence); |
| 1368 } |
| 1369 |
| 1342 void WindowTree::SetWindowTextInputState(Id transport_window_id, | 1370 void WindowTree::SetWindowTextInputState(Id transport_window_id, |
| 1343 mojo::TextInputStatePtr state) { | 1371 mojo::TextInputStatePtr state) { |
| 1344 ServerWindow* window = | 1372 ServerWindow* window = |
| 1345 GetWindowByClientId(ClientWindowId(transport_window_id)); | 1373 GetWindowByClientId(ClientWindowId(transport_window_id)); |
| 1346 bool success = window && access_policy_->CanSetWindowTextInputState(window); | 1374 bool success = window && access_policy_->CanSetWindowTextInputState(window); |
| 1347 if (success) | 1375 if (success) |
| 1348 window->SetTextInputState(state.To<ui::TextInputState>()); | 1376 window->SetTextInputState(state.To<ui::TextInputState>()); |
| 1349 } | 1377 } |
| 1350 | 1378 |
| 1351 void WindowTree::SetImeVisibility(Id transport_window_id, | 1379 void WindowTree::SetImeVisibility(Id transport_window_id, |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1906 client()->OnCompleteDrop(client_window_id.id, event_flags, cursor_offset, | 1934 client()->OnCompleteDrop(client_window_id.id, event_flags, cursor_offset, |
| 1907 effect_bitmask, callback); | 1935 effect_bitmask, callback); |
| 1908 } | 1936 } |
| 1909 | 1937 |
| 1910 void WindowTree::PerformOnDragDropDone() { | 1938 void WindowTree::PerformOnDragDropDone() { |
| 1911 client()->OnDragDropDone(); | 1939 client()->OnDragDropDone(); |
| 1912 } | 1940 } |
| 1913 | 1941 |
| 1914 } // namespace ws | 1942 } // namespace ws |
| 1915 } // namespace ui | 1943 } // namespace ui |
| OLD | NEW |