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