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 |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "services/ui/ws/operation.h" | 23 #include "services/ui/ws/operation.h" |
24 #include "services/ui/ws/platform_display.h" | 24 #include "services/ui/ws/platform_display.h" |
25 #include "services/ui/ws/server_window.h" | 25 #include "services/ui/ws/server_window.h" |
26 #include "services/ui/ws/server_window_compositor_frame_sink_manager.h" | 26 #include "services/ui/ws/server_window_compositor_frame_sink_manager.h" |
27 #include "services/ui/ws/server_window_observer.h" | 27 #include "services/ui/ws/server_window_observer.h" |
28 #include "services/ui/ws/user_display_manager.h" | 28 #include "services/ui/ws/user_display_manager.h" |
29 #include "services/ui/ws/window_manager_display_root.h" | 29 #include "services/ui/ws/window_manager_display_root.h" |
30 #include "services/ui/ws/window_manager_state.h" | 30 #include "services/ui/ws/window_manager_state.h" |
31 #include "services/ui/ws/window_server.h" | 31 #include "services/ui/ws/window_server.h" |
32 #include "services/ui/ws/window_tree_binding.h" | 32 #include "services/ui/ws/window_tree_binding.h" |
| 33 #include "ui/base/cursor/cursor.h" |
33 #include "ui/display/display.h" | 34 #include "ui/display/display.h" |
34 #include "ui/display/display_list.h" | 35 #include "ui/display/display_list.h" |
35 #include "ui/display/screen_base.h" | 36 #include "ui/display/screen_base.h" |
36 #include "ui/display/types/display_constants.h" | 37 #include "ui/display/types/display_constants.h" |
37 #include "ui/platform_window/mojo/ime_type_converters.h" | 38 #include "ui/platform_window/mojo/ime_type_converters.h" |
38 #include "ui/platform_window/text_input_state.h" | 39 #include "ui/platform_window/text_input_state.h" |
39 | 40 |
40 using mojo::InterfaceRequest; | 41 using mojo::InterfaceRequest; |
41 | 42 |
42 using EventProperties = std::unordered_map<std::string, std::vector<uint8_t>>; | 43 using EventProperties = std::unordered_map<std::string, std::vector<uint8_t>>; |
(...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
891 return; | 892 return; |
892 | 893 |
893 ClientWindowId client_window_id; | 894 ClientWindowId client_window_id; |
894 if (IsWindowKnown(window, &client_window_id)) { | 895 if (IsWindowKnown(window, &client_window_id)) { |
895 client()->OnWindowOpacityChanged(client_window_id.id, old_opacity, | 896 client()->OnWindowOpacityChanged(client_window_id.id, old_opacity, |
896 new_opacity); | 897 new_opacity); |
897 } | 898 } |
898 } | 899 } |
899 | 900 |
900 void WindowTree::ProcessCursorChanged(const ServerWindow* window, | 901 void WindowTree::ProcessCursorChanged(const ServerWindow* window, |
901 mojom::CursorType cursor_id, | 902 const ui::CursorData& cursor, |
902 bool originated_change) { | 903 bool originated_change) { |
903 if (originated_change) | 904 if (originated_change) |
904 return; | 905 return; |
905 ClientWindowId client_window_id; | 906 ClientWindowId client_window_id; |
906 if (!IsWindowKnown(window, &client_window_id)) | 907 if (!IsWindowKnown(window, &client_window_id)) |
907 return; | 908 return; |
908 | 909 |
909 client()->OnWindowPredefinedCursorChanged(client_window_id.id, cursor_id); | 910 client()->OnWindowCursorChanged(client_window_id.id, cursor); |
910 } | 911 } |
911 | 912 |
912 void WindowTree::ProcessFocusChanged(const ServerWindow* old_focused_window, | 913 void WindowTree::ProcessFocusChanged(const ServerWindow* old_focused_window, |
913 const ServerWindow* new_focused_window) { | 914 const ServerWindow* new_focused_window) { |
914 if (window_server_->current_operation_type() == OperationType::SET_FOCUS && | 915 if (window_server_->current_operation_type() == OperationType::SET_FOCUS && |
915 window_server_->IsOperationSource(id_)) { | 916 window_server_->IsOperationSource(id_)) { |
916 return; | 917 return; |
917 } | 918 } |
918 const ServerWindow* window = | 919 const ServerWindow* window = |
919 new_focused_window | 920 new_focused_window |
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1766 | 1767 |
1767 void WindowTree::SetEventTargetingPolicy(Id transport_window_id, | 1768 void WindowTree::SetEventTargetingPolicy(Id transport_window_id, |
1768 mojom::EventTargetingPolicy policy) { | 1769 mojom::EventTargetingPolicy policy) { |
1769 ServerWindow* window = | 1770 ServerWindow* window = |
1770 GetWindowByClientId(ClientWindowId(transport_window_id)); | 1771 GetWindowByClientId(ClientWindowId(transport_window_id)); |
1771 // TODO(riajiang): check |event_queue_| is empty for |window|. | 1772 // TODO(riajiang): check |event_queue_| is empty for |window|. |
1772 if (window && access_policy_->CanSetEventTargetingPolicy(window)) | 1773 if (window && access_policy_->CanSetEventTargetingPolicy(window)) |
1773 window->set_event_targeting_policy(policy); | 1774 window->set_event_targeting_policy(policy); |
1774 } | 1775 } |
1775 | 1776 |
1776 void WindowTree::SetPredefinedCursor(uint32_t change_id, | 1777 void WindowTree::SetCursor(uint32_t change_id, |
1777 Id transport_window_id, | 1778 Id transport_window_id, |
1778 ui::mojom::CursorType cursor_id) { | 1779 ui::CursorData cursor) { |
1779 ServerWindow* window = | 1780 ServerWindow* window = |
1780 GetWindowByClientId(ClientWindowId(transport_window_id)); | 1781 GetWindowByClientId(ClientWindowId(transport_window_id)); |
| 1782 if (!window) { |
| 1783 DVLOG(1) << "SetCursor failed (invalid id)"; |
| 1784 client()->OnChangeCompleted(change_id, false); |
| 1785 return; |
| 1786 } |
1781 | 1787 |
1782 // Only the owner of the window can change the bounds. | 1788 // Only the owner of the window can change the bounds. |
1783 bool success = window && access_policy_->CanSetCursorProperties(window); | 1789 bool success = access_policy_->CanSetCursorProperties(window); |
1784 if (success) { | 1790 if (!success) { |
1785 Operation op(this, window_server_, | 1791 DVLOG(1) << "SetCursor failed (access denied)"; |
1786 OperationType::SET_WINDOW_PREDEFINED_CURSOR); | 1792 client()->OnChangeCompleted(change_id, false); |
1787 window->SetPredefinedCursor(cursor_id); | 1793 return; |
1788 } | 1794 } |
| 1795 |
| 1796 // If the cursor is custom, it must have valid frames. |
| 1797 if (cursor.cursor_type() == ui::CursorType::kCustom) { |
| 1798 if (cursor.cursor_frames().empty()) { |
| 1799 DVLOG(1) << "SetCursor failed (no frames with custom cursor)"; |
| 1800 client()->OnChangeCompleted(change_id, false); |
| 1801 return; |
| 1802 } |
| 1803 |
| 1804 for (const SkBitmap& bitmap : cursor.cursor_frames()) { |
| 1805 if (bitmap.drawsNothing()) { |
| 1806 DVLOG(1) << "SetCursor failed (cursor frame draws nothing)"; |
| 1807 client()->OnChangeCompleted(change_id, false); |
| 1808 return; |
| 1809 } |
| 1810 } |
| 1811 } |
| 1812 |
| 1813 Operation op(this, window_server_, |
| 1814 OperationType::SET_WINDOW_PREDEFINED_CURSOR); |
| 1815 window->SetCursor(std::move(cursor)); |
1789 client()->OnChangeCompleted(change_id, success); | 1816 client()->OnChangeCompleted(change_id, success); |
1790 } | 1817 } |
1791 | 1818 |
1792 void WindowTree::DeactivateWindow(Id window_id) { | 1819 void WindowTree::DeactivateWindow(Id window_id) { |
1793 ServerWindow* window = | 1820 ServerWindow* window = |
1794 GetWindowByClientId(ClientWindowId(window_id)); | 1821 GetWindowByClientId(ClientWindowId(window_id)); |
1795 if (!window) { | 1822 if (!window) { |
1796 DVLOG(1) << "DeactivateWindow failed (invalid id)"; | 1823 DVLOG(1) << "DeactivateWindow failed (invalid id)"; |
1797 return; | 1824 return; |
1798 } | 1825 } |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2225 // TODO(sky): think about what else case means. | 2252 // TODO(sky): think about what else case means. |
2226 } | 2253 } |
2227 | 2254 |
2228 void WindowTree::WmSetFrameDecorationValues( | 2255 void WindowTree::WmSetFrameDecorationValues( |
2229 mojom::FrameDecorationValuesPtr values) { | 2256 mojom::FrameDecorationValuesPtr values) { |
2230 DCHECK(window_manager_state_); | 2257 DCHECK(window_manager_state_); |
2231 window_manager_state_->SetFrameDecorationValues(std::move(values)); | 2258 window_manager_state_->SetFrameDecorationValues(std::move(values)); |
2232 } | 2259 } |
2233 | 2260 |
2234 void WindowTree::WmSetNonClientCursor(uint32_t window_id, | 2261 void WindowTree::WmSetNonClientCursor(uint32_t window_id, |
2235 mojom::CursorType cursor_id) { | 2262 ui::CursorData cursor) { |
2236 DCHECK(window_manager_state_); | 2263 DCHECK(window_manager_state_); |
2237 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); | 2264 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); |
2238 if (window) { | 2265 if (window) { |
2239 window->SetNonClientCursor(cursor_id); | 2266 window->SetNonClientCursor(std::move(cursor)); |
2240 } else { | 2267 } else { |
2241 DVLOG(1) << "trying to update non-client cursor of invalid window"; | 2268 DVLOG(1) << "trying to update non-client cursor of invalid window"; |
2242 } | 2269 } |
2243 } | 2270 } |
2244 | 2271 |
2245 void WindowTree::OnWmCreatedTopLevelWindow(uint32_t change_id, | 2272 void WindowTree::OnWmCreatedTopLevelWindow(uint32_t change_id, |
2246 Id transport_window_id) { | 2273 Id transport_window_id) { |
2247 ServerWindow* window = | 2274 ServerWindow* window = |
2248 GetWindowByClientId(ClientWindowId(transport_window_id)); | 2275 GetWindowByClientId(ClientWindowId(transport_window_id)); |
2249 if (window && window->id().client_id != id_) { | 2276 if (window && window->id().client_id != id_) { |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2418 client()->OnCompleteDrop(client_window_id.id, event_flags, cursor_offset, | 2445 client()->OnCompleteDrop(client_window_id.id, event_flags, cursor_offset, |
2419 effect_bitmask, callback); | 2446 effect_bitmask, callback); |
2420 } | 2447 } |
2421 | 2448 |
2422 void WindowTree::PerformOnDragDropDone() { | 2449 void WindowTree::PerformOnDragDropDone() { |
2423 client()->OnDragDropDone(); | 2450 client()->OnDragDropDone(); |
2424 } | 2451 } |
2425 | 2452 |
2426 } // namespace ws | 2453 } // namespace ws |
2427 } // namespace ui | 2454 } // namespace ui |
OLD | NEW |