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

Side by Side Diff: services/ui/ws/window_tree.cc

Issue 2511883006: Mojo C++ bindings: switch services/ui/public/interfaces mojom target to use STL types. (Closed)
Patch Set: . Created 4 years, 1 month 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
« no previous file with comments | « services/ui/ws/window_tree.h ('k') | services/ui/ws/window_tree_client_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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 "mojo/public/cpp/bindings/stl_converters.h"
14 #include "services/ui/ws/default_access_policy.h" 15 #include "services/ui/ws/default_access_policy.h"
15 #include "services/ui/ws/display.h" 16 #include "services/ui/ws/display.h"
16 #include "services/ui/ws/display_manager.h" 17 #include "services/ui/ws/display_manager.h"
17 #include "services/ui/ws/event_matcher.h" 18 #include "services/ui/ws/event_matcher.h"
18 #include "services/ui/ws/focus_controller.h" 19 #include "services/ui/ws/focus_controller.h"
19 #include "services/ui/ws/operation.h" 20 #include "services/ui/ws/operation.h"
20 #include "services/ui/ws/platform_display.h" 21 #include "services/ui/ws/platform_display.h"
21 #include "services/ui/ws/server_window.h" 22 #include "services/ui/ws/server_window.h"
22 #include "services/ui/ws/server_window_compositor_frame_sink_manager.h" 23 #include "services/ui/ws/server_window_compositor_frame_sink_manager.h"
23 #include "services/ui/ws/server_window_observer.h" 24 #include "services/ui/ws/server_window_observer.h"
24 #include "services/ui/ws/user_display_manager.h" 25 #include "services/ui/ws/user_display_manager.h"
25 #include "services/ui/ws/window_manager_display_root.h" 26 #include "services/ui/ws/window_manager_display_root.h"
26 #include "services/ui/ws/window_manager_state.h" 27 #include "services/ui/ws/window_manager_state.h"
27 #include "services/ui/ws/window_server.h" 28 #include "services/ui/ws/window_server.h"
28 #include "services/ui/ws/window_tree_binding.h" 29 #include "services/ui/ws/window_tree_binding.h"
29 #include "ui/display/display.h" 30 #include "ui/display/display.h"
30 #include "ui/platform_window/mojo/ime_type_converters.h" 31 #include "ui/platform_window/mojo/ime_type_converters.h"
31 #include "ui/platform_window/text_input_state.h" 32 #include "ui/platform_window/text_input_state.h"
32 33
33 using mojo::Array;
34 using mojo::InterfaceRequest; 34 using mojo::InterfaceRequest;
35 using mojo::String;
36 35
37 namespace ui { 36 namespace ui {
38 namespace ws { 37 namespace ws {
39 38
40 class TargetedEvent : public ServerWindowObserver { 39 class TargetedEvent : public ServerWindowObserver {
41 public: 40 public:
42 TargetedEvent(ServerWindow* target, const ui::Event& event) 41 TargetedEvent(ServerWindow* target, const ui::Event& event)
43 : target_(target), event_(ui::Event::Clone(event)) { 42 : target_(target), event_(ui::Event::Clone(event)) {
44 target_->AddObserver(this); 43 target_->AddObserver(this);
45 } 44 }
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 const std::string& name, 564 const std::string& name,
566 const std::vector<uint8_t>* new_data, 565 const std::vector<uint8_t>* new_data,
567 bool originated_change) { 566 bool originated_change) {
568 if (originated_change) 567 if (originated_change)
569 return; 568 return;
570 569
571 ClientWindowId client_window_id; 570 ClientWindowId client_window_id;
572 if (!IsWindowKnown(window, &client_window_id)) 571 if (!IsWindowKnown(window, &client_window_id))
573 return; 572 return;
574 573
575 Array<uint8_t> data(nullptr); 574 base::Optional<std::vector<uint8_t>> data;
576 if (new_data) 575 if (new_data)
577 data = Array<uint8_t>::From(*new_data); 576 data.emplace(*new_data);
578 577
579 client()->OnWindowSharedPropertyChanged(client_window_id.id, String(name), 578 client()->OnWindowSharedPropertyChanged(client_window_id.id, name, data);
580 std::move(data));
581 } 579 }
582 580
583 void WindowTree::ProcessWindowHierarchyChanged(const ServerWindow* window, 581 void WindowTree::ProcessWindowHierarchyChanged(const ServerWindow* window,
584 const ServerWindow* new_parent, 582 const ServerWindow* new_parent,
585 const ServerWindow* old_parent, 583 const ServerWindow* old_parent,
586 bool originated_change) { 584 bool originated_change) {
587 const bool knows_new = new_parent && IsWindowKnown(new_parent); 585 const bool knows_new = new_parent && IsWindowKnown(new_parent);
588 if (originated_change || (window_server_->current_operation_type() == 586 if (originated_change || (window_server_->current_operation_type() ==
589 OperationType::DELETE_WINDOW) || 587 OperationType::DELETE_WINDOW) ||
590 (window_server_->current_operation_type() == OperationType::EMBED) || 588 (window_server_->current_operation_type() == OperationType::EMBED) ||
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
975 if (owning_tree) { 973 if (owning_tree) {
976 DCHECK(owning_tree && owning_tree != this); 974 DCHECK(owning_tree && owning_tree != this);
977 owning_tree->client()->OnEmbeddedAppDisconnected( 975 owning_tree->client()->OnEmbeddedAppDisconnected(
978 owning_tree->ClientWindowIdForWindow(window).id); 976 owning_tree->ClientWindowIdForWindow(window).id);
979 } 977 }
980 978
981 window->OnEmbeddedAppDisconnected(); 979 window->OnEmbeddedAppDisconnected();
982 } 980 }
983 } 981 }
984 982
985 Array<mojom::WindowDataPtr> WindowTree::WindowsToWindowDatas( 983 std::vector<mojom::WindowDataPtr> WindowTree::WindowsToWindowDatas(
986 const std::vector<const ServerWindow*>& windows) { 984 const std::vector<const ServerWindow*>& windows) {
987 Array<mojom::WindowDataPtr> array(windows.size()); 985 std::vector<mojom::WindowDataPtr> array(windows.size());
988 for (size_t i = 0; i < windows.size(); ++i) 986 for (size_t i = 0; i < windows.size(); ++i)
989 array[i] = WindowToWindowData(windows[i]); 987 array[i] = WindowToWindowData(windows[i]);
990 return array; 988 return array;
991 } 989 }
992 990
993 mojom::WindowDataPtr WindowTree::WindowToWindowData( 991 mojom::WindowDataPtr WindowTree::WindowToWindowData(
994 const ServerWindow* window) { 992 const ServerWindow* window) {
995 DCHECK(IsWindowKnown(window)); 993 DCHECK(IsWindowKnown(window));
996 const ServerWindow* parent = window->parent(); 994 const ServerWindow* parent = window->parent();
997 // If the parent isn't known, it means the parent is not visible to us (not 995 // If the parent isn't known, it means the parent is not visible to us (not
998 // in roots), and should not be sent over. 996 // in roots), and should not be sent over.
999 if (parent && !IsWindowKnown(parent)) 997 if (parent && !IsWindowKnown(parent))
1000 parent = nullptr; 998 parent = nullptr;
1001 mojom::WindowDataPtr window_data(mojom::WindowData::New()); 999 mojom::WindowDataPtr window_data(mojom::WindowData::New());
1002 window_data->parent_id = 1000 window_data->parent_id =
1003 parent ? ClientWindowIdForWindow(parent).id : ClientWindowId().id; 1001 parent ? ClientWindowIdForWindow(parent).id : ClientWindowId().id;
1004 window_data->window_id = 1002 window_data->window_id =
1005 window ? ClientWindowIdForWindow(window).id : ClientWindowId().id; 1003 window ? ClientWindowIdForWindow(window).id : ClientWindowId().id;
1006 window_data->bounds = window->bounds(); 1004 window_data->bounds = window->bounds();
1007 window_data->properties = 1005 window_data->properties = mojo::MapToUnorderedMap(window->properties());
1008 mojo::Map<String, Array<uint8_t>>::From(window->properties());
1009 window_data->visible = window->visible(); 1006 window_data->visible = window->visible();
1010 return window_data; 1007 return window_data;
1011 } 1008 }
1012 1009
1013 void WindowTree::GetWindowTreeImpl( 1010 void WindowTree::GetWindowTreeImpl(
1014 const ServerWindow* window, 1011 const ServerWindow* window,
1015 std::vector<const ServerWindow*>* windows) const { 1012 std::vector<const ServerWindow*>* windows) const {
1016 DCHECK(window); 1013 DCHECK(window);
1017 1014
1018 if (!access_policy_->CanGetWindowTree(window)) 1015 if (!access_policy_->CanGetWindowTree(window))
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1123 if (pointer_watcher_want_moves_ && event.type() == ui::ET_POINTER_MOVED) 1120 if (pointer_watcher_want_moves_ && event.type() == ui::ET_POINTER_MOVED)
1124 return true; 1121 return true;
1125 return event.type() == ui::ET_POINTER_DOWN || 1122 return event.type() == ui::ET_POINTER_DOWN ||
1126 event.type() == ui::ET_POINTER_UP || 1123 event.type() == ui::ET_POINTER_UP ||
1127 event.type() == ui::ET_POINTER_WHEEL_CHANGED; 1124 event.type() == ui::ET_POINTER_WHEEL_CHANGED;
1128 } 1125 }
1129 1126
1130 void WindowTree::NewWindow( 1127 void WindowTree::NewWindow(
1131 uint32_t change_id, 1128 uint32_t change_id,
1132 Id transport_window_id, 1129 Id transport_window_id,
1133 mojo::Map<mojo::String, mojo::Array<uint8_t>> transport_properties) { 1130 const base::Optional<std::unordered_map<std::string, std::vector<uint8_t>>>&
1131 transport_properties) {
1134 std::map<std::string, std::vector<uint8_t>> properties; 1132 std::map<std::string, std::vector<uint8_t>> properties;
1135 if (!transport_properties.is_null()) { 1133 if (transport_properties.has_value())
1136 properties = 1134 properties = mojo::UnorderedMapToMap(transport_properties.value());
1137 transport_properties.To<std::map<std::string, std::vector<uint8_t>>>(); 1135
1138 }
1139 client()->OnChangeCompleted( 1136 client()->OnChangeCompleted(
1140 change_id, NewWindow(ClientWindowId(transport_window_id), properties)); 1137 change_id, NewWindow(ClientWindowId(transport_window_id), properties));
1141 } 1138 }
1142 1139
1143 void WindowTree::NewTopLevelWindow( 1140 void WindowTree::NewTopLevelWindow(
1144 uint32_t change_id, 1141 uint32_t change_id,
1145 Id transport_window_id, 1142 Id transport_window_id,
1146 mojo::Map<mojo::String, mojo::Array<uint8_t>> transport_properties) { 1143 const std::unordered_map<std::string, std::vector<uint8_t>>&
1144 transport_properties) {
1147 // TODO(sky): rather than DCHECK, have this kill connection. 1145 // TODO(sky): rather than DCHECK, have this kill connection.
1148 DCHECK(!window_manager_internal_); // Not valid for the windowmanager. 1146 DCHECK(!window_manager_internal_); // Not valid for the windowmanager.
1149 DCHECK(!waiting_for_top_level_window_info_); 1147 DCHECK(!waiting_for_top_level_window_info_);
1150 const ClientWindowId client_window_id(transport_window_id); 1148 const ClientWindowId client_window_id(transport_window_id);
1151 // TODO(sky): need a way for client to provide context to figure out display. 1149 // TODO(sky): need a way for client to provide context to figure out display.
1152 Display* display = display_manager()->displays().empty() 1150 Display* display = display_manager()->displays().empty()
1153 ? nullptr 1151 ? nullptr
1154 : *(display_manager()->displays().begin()); 1152 : *(display_manager()->displays().begin());
1155 // TODO(sky): move checks to accesspolicy. 1153 // TODO(sky): move checks to accesspolicy.
1156 WindowManagerDisplayRoot* display_root = 1154 WindowManagerDisplayRoot* display_root =
(...skipping 14 matching lines...) Expand all
1171 binding_->SetIncomingMethodCallProcessingPaused(true); 1169 binding_->SetIncomingMethodCallProcessingPaused(true);
1172 1170
1173 const uint32_t wm_change_id = 1171 const uint32_t wm_change_id =
1174 window_server_->GenerateWindowManagerChangeId(this, change_id); 1172 window_server_->GenerateWindowManagerChangeId(this, change_id);
1175 1173
1176 waiting_for_top_level_window_info_.reset( 1174 waiting_for_top_level_window_info_.reset(
1177 new WaitingForTopLevelWindowInfo(client_window_id, wm_change_id)); 1175 new WaitingForTopLevelWindowInfo(client_window_id, wm_change_id));
1178 1176
1179 display_root->window_manager_state() 1177 display_root->window_manager_state()
1180 ->window_tree() 1178 ->window_tree()
1181 ->window_manager_internal_->WmCreateTopLevelWindow( 1179 ->window_manager_internal_->WmCreateTopLevelWindow(wm_change_id, id_,
1182 wm_change_id, id_, std::move(transport_properties)); 1180 transport_properties);
1183 } 1181 }
1184 1182
1185 void WindowTree::DeleteWindow(uint32_t change_id, Id transport_window_id) { 1183 void WindowTree::DeleteWindow(uint32_t change_id, Id transport_window_id) {
1186 client()->OnChangeCompleted( 1184 client()->OnChangeCompleted(
1187 change_id, DeleteWindow(ClientWindowId(transport_window_id))); 1185 change_id, DeleteWindow(ClientWindowId(transport_window_id)));
1188 } 1186 }
1189 1187
1190 void WindowTree::AddWindow(uint32_t change_id, Id parent_id, Id child_id) { 1188 void WindowTree::AddWindow(uint32_t change_id, Id parent_id, Id child_id) {
1191 client()->OnChangeCompleted(change_id, AddWindow(ClientWindowId(parent_id), 1189 client()->OnChangeCompleted(change_id, AddWindow(ClientWindowId(parent_id),
1192 ClientWindowId(child_id))); 1190 ClientWindowId(child_id)));
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1245 success = true; 1243 success = true;
1246 Operation op(this, window_server_, OperationType::REORDER_WINDOW); 1244 Operation op(this, window_server_, OperationType::REORDER_WINDOW);
1247 window->Reorder(relative_window, direction); 1245 window->Reorder(relative_window, direction);
1248 window_server_->ProcessWindowReorder(window, relative_window, direction); 1246 window_server_->ProcessWindowReorder(window, relative_window, direction);
1249 } 1247 }
1250 client()->OnChangeCompleted(change_id, success); 1248 client()->OnChangeCompleted(change_id, success);
1251 } 1249 }
1252 1250
1253 void WindowTree::GetWindowTree( 1251 void WindowTree::GetWindowTree(
1254 Id window_id, 1252 Id window_id,
1255 const base::Callback<void(Array<mojom::WindowDataPtr>)>& callback) { 1253 const base::Callback<void(std::vector<mojom::WindowDataPtr>)>& callback) {
1256 std::vector<const ServerWindow*> windows( 1254 std::vector<const ServerWindow*> windows(
1257 GetWindowTree(ClientWindowId(window_id))); 1255 GetWindowTree(ClientWindowId(window_id)));
1258 callback.Run(WindowsToWindowDatas(windows)); 1256 callback.Run(WindowsToWindowDatas(windows));
1259 } 1257 }
1260 1258
1261 void WindowTree::SetCapture(uint32_t change_id, Id window_id) { 1259 void WindowTree::SetCapture(uint32_t change_id, Id window_id) {
1262 client()->OnChangeCompleted(change_id, SetCapture(ClientWindowId(window_id))); 1260 client()->OnChangeCompleted(change_id, SetCapture(ClientWindowId(window_id)));
1263 } 1261 }
1264 1262
1265 void WindowTree::ReleaseCapture(uint32_t change_id, Id window_id) { 1263 void WindowTree::ReleaseCapture(uint32_t change_id, Id window_id) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1305 } 1303 }
1306 1304
1307 void WindowTree::SetWindowVisibility(uint32_t change_id, 1305 void WindowTree::SetWindowVisibility(uint32_t change_id,
1308 Id transport_window_id, 1306 Id transport_window_id,
1309 bool visible) { 1307 bool visible) {
1310 client()->OnChangeCompleted( 1308 client()->OnChangeCompleted(
1311 change_id, 1309 change_id,
1312 SetWindowVisibility(ClientWindowId(transport_window_id), visible)); 1310 SetWindowVisibility(ClientWindowId(transport_window_id), visible));
1313 } 1311 }
1314 1312
1315 void WindowTree::SetWindowProperty(uint32_t change_id, 1313 void WindowTree::SetWindowProperty(
1316 Id transport_window_id, 1314 uint32_t change_id,
1317 const mojo::String& name, 1315 Id transport_window_id,
1318 mojo::Array<uint8_t> value) { 1316 const std::string& name,
1317 const base::Optional<std::vector<uint8_t>>& value) {
1319 ServerWindow* window = 1318 ServerWindow* window =
1320 GetWindowByClientId(ClientWindowId(transport_window_id)); 1319 GetWindowByClientId(ClientWindowId(transport_window_id));
1321 if (window && ShouldRouteToWindowManager(window)) { 1320 if (window && ShouldRouteToWindowManager(window)) {
1322 const uint32_t wm_change_id = 1321 const uint32_t wm_change_id =
1323 window_server_->GenerateWindowManagerChangeId(this, change_id); 1322 window_server_->GenerateWindowManagerChangeId(this, change_id);
1324 WindowManagerDisplayRoot* display_root = 1323 WindowManagerDisplayRoot* display_root =
1325 GetWindowManagerDisplayRoot(window); 1324 GetWindowManagerDisplayRoot(window);
1326 WindowTree* wm_tree = display_root->window_manager_state()->window_tree(); 1325 WindowTree* wm_tree = display_root->window_manager_state()->window_tree();
1327 wm_tree->window_manager_internal_->WmSetProperty( 1326 wm_tree->window_manager_internal_->WmSetProperty(
1328 wm_change_id, wm_tree->ClientWindowIdForWindow(window).id, name, 1327 wm_change_id, wm_tree->ClientWindowIdForWindow(window).id, name, value);
1329 std::move(value));
1330 return; 1328 return;
1331 } 1329 }
1332 const bool success = window && access_policy_->CanSetWindowProperties(window); 1330 const bool success = window && access_policy_->CanSetWindowProperties(window);
1333 if (success) { 1331 if (success) {
1334 Operation op(this, window_server_, OperationType::SET_WINDOW_PROPERTY); 1332 Operation op(this, window_server_, OperationType::SET_WINDOW_PROPERTY);
1335 if (value.is_null()) { 1333 if (!value.has_value()) {
1336 window->SetProperty(name, nullptr); 1334 window->SetProperty(name, nullptr);
1337 } else { 1335 } else {
1338 std::vector<uint8_t> data = value.To<std::vector<uint8_t>>(); 1336 window->SetProperty(name, &value.value());
1339 window->SetProperty(name, &data);
1340 } 1337 }
1341 } 1338 }
1342 client()->OnChangeCompleted(change_id, success); 1339 client()->OnChangeCompleted(change_id, success);
1343 } 1340 }
1344 1341
1345 void WindowTree::SetWindowOpacity(uint32_t change_id, 1342 void WindowTree::SetWindowOpacity(uint32_t change_id,
1346 Id window_id, 1343 Id window_id,
1347 float opacity) { 1344 float opacity) {
1348 client()->OnChangeCompleted( 1345 client()->OnChangeCompleted(
1349 change_id, SetWindowOpacity(ClientWindowId(window_id), opacity)); 1346 change_id, SetWindowOpacity(ClientWindowId(window_id), opacity));
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1419 std::move(event_queue_.front()); 1416 std::move(event_queue_.front());
1420 event_queue_.pop(); 1417 event_queue_.pop();
1421 target = targeted_event->target(); 1418 target = targeted_event->target();
1422 event = targeted_event->TakeEvent(); 1419 event = targeted_event->TakeEvent();
1423 } while (!event_queue_.empty() && !GetDisplay(target)); 1420 } while (!event_queue_.empty() && !GetDisplay(target));
1424 if (target) 1421 if (target)
1425 DispatchInputEventImpl(target, *event); 1422 DispatchInputEventImpl(target, *event);
1426 } 1423 }
1427 } 1424 }
1428 1425
1429 void WindowTree::SetClientArea( 1426 void WindowTree::SetClientArea(Id transport_window_id,
1430 Id transport_window_id, 1427 const gfx::Insets& insets,
1431 const gfx::Insets& insets, 1428 const base::Optional<std::vector<gfx::Rect>>&
1432 mojo::Array<gfx::Rect> transport_additional_client_areas) { 1429 transport_additional_client_areas) {
1433 ServerWindow* window = 1430 ServerWindow* window =
1434 GetWindowByClientId(ClientWindowId(transport_window_id)); 1431 GetWindowByClientId(ClientWindowId(transport_window_id));
1435 if (!window || !access_policy_->CanSetClientArea(window)) 1432 if (!window || !access_policy_->CanSetClientArea(window))
1436 return; 1433 return;
1437 1434
1438 std::vector<gfx::Rect> additional_client_areas = 1435 window->SetClientArea(insets, transport_additional_client_areas.value_or(
1439 transport_additional_client_areas.To<std::vector<gfx::Rect>>(); 1436 std::vector<gfx::Rect>()));
1440 window->SetClientArea(insets, additional_client_areas);
1441 } 1437 }
1442 1438
1443 void WindowTree::SetHitTestMask(Id transport_window_id, 1439 void WindowTree::SetHitTestMask(Id transport_window_id,
1444 const base::Optional<gfx::Rect>& mask) { 1440 const base::Optional<gfx::Rect>& mask) {
1445 ServerWindow* window = 1441 ServerWindow* window =
1446 GetWindowByClientId(ClientWindowId(transport_window_id)); 1442 GetWindowByClientId(ClientWindowId(transport_window_id));
1447 if (!window || !access_policy_->CanSetHitTestMask(window)) { 1443 if (!window || !access_policy_->CanSetHitTestMask(window)) {
1448 DVLOG(1) << "SetHitTestMask failed"; 1444 DVLOG(1) << "SetHitTestMask failed";
1449 return; 1445 return;
1450 } 1446 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1526 void WindowTree::GetCursorLocationMemory( 1522 void WindowTree::GetCursorLocationMemory(
1527 const GetCursorLocationMemoryCallback& callback) { 1523 const GetCursorLocationMemoryCallback& callback) {
1528 callback.Run( 1524 callback.Run(
1529 window_server_->display_manager()->GetUserDisplayManager(user_id_)-> 1525 window_server_->display_manager()->GetUserDisplayManager(user_id_)->
1530 GetCursorLocationMemory()); 1526 GetCursorLocationMemory());
1531 } 1527 }
1532 1528
1533 void WindowTree::PerformDragDrop( 1529 void WindowTree::PerformDragDrop(
1534 uint32_t change_id, 1530 uint32_t change_id,
1535 Id source_window_id, 1531 Id source_window_id,
1536 mojo::Map<mojo::String, mojo::Array<uint8_t>> drag_data, 1532 const std::unordered_map<std::string, std::vector<uint8_t>>& drag_data,
1537 uint32_t drag_operation) { 1533 uint32_t drag_operation) {
1538 ServerWindow* window = GetWindowByClientId(ClientWindowId(source_window_id)); 1534 ServerWindow* window = GetWindowByClientId(ClientWindowId(source_window_id));
1539 bool success = window && access_policy_->CanInitiateDragLoop(window); 1535 bool success = window && access_policy_->CanInitiateDragLoop(window);
1540 if (!success || !ShouldRouteToWindowManager(window)) { 1536 if (!success || !ShouldRouteToWindowManager(window)) {
1541 // We need to fail this move loop change, otherwise the client will just be 1537 // We need to fail this move loop change, otherwise the client will just be
1542 // waiting for |change_id|. 1538 // waiting for |change_id|.
1543 DVLOG(1) << "PerformDragDrop failed (access denied)."; 1539 DVLOG(1) << "PerformDragDrop failed (access denied).";
1544 OnChangeCompleted(change_id, false); 1540 OnChangeCompleted(change_id, false);
1545 return; 1541 return;
1546 } 1542 }
(...skipping 15 matching lines...) Expand all
1562 } 1558 }
1563 1559
1564 // TODO(erg): Dealing with |drag_representation| is hard, so we're going to 1560 // TODO(erg): Dealing with |drag_representation| is hard, so we're going to
1565 // deal with that later. 1561 // deal with that later.
1566 1562
1567 // Here, we need to dramatically change how the mouse pointer works. Once 1563 // Here, we need to dramatically change how the mouse pointer works. Once
1568 // we've started a drag drop operation, cursor events don't go to windows as 1564 // we've started a drag drop operation, cursor events don't go to windows as
1569 // normal. 1565 // normal.
1570 WindowManagerState* wms = display_root->window_manager_state(); 1566 WindowManagerState* wms = display_root->window_manager_state();
1571 window_server_->StartDragLoop(change_id, window, this); 1567 window_server_->StartDragLoop(change_id, window, this);
1572 wms->SetDragDropSourceWindow(this, window, this, std::move(drag_data), 1568 wms->SetDragDropSourceWindow(
1573 drag_operation); 1569 this, window, this, mojo::WrapSTLType(mojo::UnorderedMapToMap(drag_data)),
1570 drag_operation);
1574 } 1571 }
1575 1572
1576 void WindowTree::CancelDragDrop(Id window_id) { 1573 void WindowTree::CancelDragDrop(Id window_id) {
1577 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); 1574 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id));
1578 if (!window) { 1575 if (!window) {
1579 DVLOG(1) << "CancelDragDrop failed (no window)"; 1576 DVLOG(1) << "CancelDragDrop failed (no window)";
1580 return; 1577 return;
1581 } 1578 }
1582 1579
1583 if (window != window_server_->GetCurrentDragLoopWindow()) { 1580 if (window != window_server_->GetCurrentDragLoopWindow()) {
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
1868 if (!window) 1865 if (!window)
1869 return nullptr; 1866 return nullptr;
1870 DragTargetConnection* connection = window_server_->GetTreeWithRoot(window); 1867 DragTargetConnection* connection = window_server_->GetTreeWithRoot(window);
1871 if (connection) 1868 if (connection)
1872 return connection; 1869 return connection;
1873 return window_server_->GetTreeWithId(window->id().client_id); 1870 return window_server_->GetTreeWithId(window->id().client_id);
1874 } 1871 }
1875 1872
1876 void WindowTree::PerformOnDragDropStart( 1873 void WindowTree::PerformOnDragDropStart(
1877 mojo::Map<mojo::String, mojo::Array<uint8_t>> mime_data) { 1874 mojo::Map<mojo::String, mojo::Array<uint8_t>> mime_data) {
1878 client()->OnDragDropStart(std::move(mime_data)); 1875 client()->OnDragDropStart(
1876 mojo::MapToUnorderedMap(mojo::UnwrapToSTLType(std::move(mime_data))));
1879 } 1877 }
1880 1878
1881 void WindowTree::PerformOnDragEnter( 1879 void WindowTree::PerformOnDragEnter(
1882 const ServerWindow* window, 1880 const ServerWindow* window,
1883 uint32_t event_flags, 1881 uint32_t event_flags,
1884 const gfx::Point& cursor_offset, 1882 const gfx::Point& cursor_offset,
1885 uint32_t effect_bitmask, 1883 uint32_t effect_bitmask,
1886 const base::Callback<void(uint32_t)>& callback) { 1884 const base::Callback<void(uint32_t)>& callback) {
1887 ClientWindowId client_window_id; 1885 ClientWindowId client_window_id;
1888 if (!IsWindowKnown(window, &client_window_id)) { 1886 if (!IsWindowKnown(window, &client_window_id)) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1934 client()->OnCompleteDrop(client_window_id.id, event_flags, cursor_offset, 1932 client()->OnCompleteDrop(client_window_id.id, event_flags, cursor_offset,
1935 effect_bitmask, callback); 1933 effect_bitmask, callback);
1936 } 1934 }
1937 1935
1938 void WindowTree::PerformOnDragDropDone() { 1936 void WindowTree::PerformOnDragDropDone() {
1939 client()->OnDragDropDone(); 1937 client()->OnDragDropDone();
1940 } 1938 }
1941 1939
1942 } // namespace ws 1940 } // namespace ws
1943 } // namespace ui 1941 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/window_tree.h ('k') | services/ui/ws/window_tree_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698