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

Side by Side Diff: components/mus/ws/window_tree.cc

Issue 2008193002: Change mojo geometry structs from using type converters to StructTraits. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 months 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
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 "components/mus/ws/window_tree.h" 5 #include "components/mus/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 10 matching lines...) Expand all
21 #include "components/mus/ws/operation.h" 21 #include "components/mus/ws/operation.h"
22 #include "components/mus/ws/platform_display.h" 22 #include "components/mus/ws/platform_display.h"
23 #include "components/mus/ws/server_window.h" 23 #include "components/mus/ws/server_window.h"
24 #include "components/mus/ws/server_window_observer.h" 24 #include "components/mus/ws/server_window_observer.h"
25 #include "components/mus/ws/user_display_manager.h" 25 #include "components/mus/ws/user_display_manager.h"
26 #include "components/mus/ws/window_manager_state.h" 26 #include "components/mus/ws/window_manager_state.h"
27 #include "components/mus/ws/window_server.h" 27 #include "components/mus/ws/window_server.h"
28 #include "components/mus/ws/window_tree_binding.h" 28 #include "components/mus/ws/window_tree_binding.h"
29 #include "ui/display/display.h" 29 #include "ui/display/display.h"
30 #include "ui/events/mojo/input_events_type_converters.h" 30 #include "ui/events/mojo/input_events_type_converters.h"
31 #include "ui/gfx/geometry/mojo/geometry_type_converters.h"
32 #include "ui/platform_window/mojo/ime_type_converters.h" 31 #include "ui/platform_window/mojo/ime_type_converters.h"
33 #include "ui/platform_window/text_input_state.h" 32 #include "ui/platform_window/text_input_state.h"
34 33
35 using mojo::Array; 34 using mojo::Array;
36 using mojo::Callback; 35 using mojo::Callback;
37 using mojo::InterfaceRequest; 36 using mojo::InterfaceRequest;
38 using mojo::Rect;
39 using mojo::String; 37 using mojo::String;
40 38
41 namespace mus { 39 namespace mus {
42 namespace ws { 40 namespace ws {
43 41
44 class TargetedEvent : public ServerWindowObserver { 42 class TargetedEvent : public ServerWindowObserver {
45 public: 43 public:
46 TargetedEvent(ServerWindow* target, const ui::Event& event) 44 TargetedEvent(ServerWindow* target, const ui::Event& event)
47 : target_(target), event_(ui::Event::Clone(event)) { 45 : target_(target), event_(ui::Event::Clone(event)) {
48 target_->AddObserver(this); 46 target_->AddObserver(this);
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 } 411 }
414 } 412 }
415 413
416 void WindowTree::ProcessWindowBoundsChanged(const ServerWindow* window, 414 void WindowTree::ProcessWindowBoundsChanged(const ServerWindow* window,
417 const gfx::Rect& old_bounds, 415 const gfx::Rect& old_bounds,
418 const gfx::Rect& new_bounds, 416 const gfx::Rect& new_bounds,
419 bool originated_change) { 417 bool originated_change) {
420 ClientWindowId client_window_id; 418 ClientWindowId client_window_id;
421 if (originated_change || !IsWindowKnown(window, &client_window_id)) 419 if (originated_change || !IsWindowKnown(window, &client_window_id))
422 return; 420 return;
423 client()->OnWindowBoundsChanged(client_window_id.id, Rect::From(old_bounds), 421 client()->OnWindowBoundsChanged(client_window_id.id, old_bounds, new_bounds);
424 Rect::From(new_bounds));
425 } 422 }
426 423
427 void WindowTree::ProcessClientAreaChanged( 424 void WindowTree::ProcessClientAreaChanged(
428 const ServerWindow* window, 425 const ServerWindow* window,
429 const gfx::Insets& new_client_area, 426 const gfx::Insets& new_client_area,
430 const std::vector<gfx::Rect>& new_additional_client_areas, 427 const std::vector<gfx::Rect>& new_additional_client_areas,
431 bool originated_change) { 428 bool originated_change) {
432 ClientWindowId client_window_id; 429 ClientWindowId client_window_id;
433 if (originated_change || !IsWindowKnown(window, &client_window_id)) 430 if (originated_change || !IsWindowKnown(window, &client_window_id))
434 return; 431 return;
435 client()->OnClientAreaChanged( 432 client()->OnClientAreaChanged(
436 client_window_id.id, mojo::Insets::From(new_client_area), 433 client_window_id.id, new_client_area,
437 mojo::Array<mojo::RectPtr>::From(new_additional_client_areas)); 434 std::vector<gfx::Rect>(new_additional_client_areas));
438 } 435 }
439 436
440 void WindowTree::ProcessWillChangeWindowHierarchy( 437 void WindowTree::ProcessWillChangeWindowHierarchy(
441 const ServerWindow* window, 438 const ServerWindow* window,
442 const ServerWindow* new_parent, 439 const ServerWindow* new_parent,
443 const ServerWindow* old_parent, 440 const ServerWindow* old_parent,
444 bool originated_change) { 441 bool originated_change) {
445 if (originated_change) 442 if (originated_change)
446 return; 443 return;
447 444
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 const ServerWindow* parent = window->parent(); 855 const ServerWindow* parent = window->parent();
859 // If the parent isn't known, it means the parent is not visible to us (not 856 // If the parent isn't known, it means the parent is not visible to us (not
860 // in roots), and should not be sent over. 857 // in roots), and should not be sent over.
861 if (parent && !IsWindowKnown(parent)) 858 if (parent && !IsWindowKnown(parent))
862 parent = nullptr; 859 parent = nullptr;
863 mojom::WindowDataPtr window_data(mojom::WindowData::New()); 860 mojom::WindowDataPtr window_data(mojom::WindowData::New());
864 window_data->parent_id = 861 window_data->parent_id =
865 parent ? ClientWindowIdForWindow(parent).id : ClientWindowId().id; 862 parent ? ClientWindowIdForWindow(parent).id : ClientWindowId().id;
866 window_data->window_id = 863 window_data->window_id =
867 window ? ClientWindowIdForWindow(window).id : ClientWindowId().id; 864 window ? ClientWindowIdForWindow(window).id : ClientWindowId().id;
868 window_data->bounds = Rect::From(window->bounds()); 865 window_data->bounds = window->bounds();
869 window_data->properties = 866 window_data->properties =
870 mojo::Map<String, Array<uint8_t>>::From(window->properties()); 867 mojo::Map<String, Array<uint8_t>>::From(window->properties());
871 window_data->visible = window->visible(); 868 window_data->visible = window->visible();
872 return window_data; 869 return window_data;
873 } 870 }
874 871
875 void WindowTree::GetWindowTreeImpl( 872 void WindowTree::GetWindowTreeImpl(
876 const ServerWindow* window, 873 const ServerWindow* window,
877 std::vector<const ServerWindow*>* windows) const { 874 std::vector<const ServerWindow*>* windows) const {
878 DCHECK(window); 875 DCHECK(window);
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 DVLOG(1) << "SetEventObserver event type not allowed"; 1159 DVLOG(1) << "SetEventObserver event type not allowed";
1163 return; 1160 return;
1164 } 1161 }
1165 1162
1166 event_observer_matcher_.reset(new EventMatcher(*matcher)); 1163 event_observer_matcher_.reset(new EventMatcher(*matcher));
1167 event_observer_id_ = observer_id; 1164 event_observer_id_ = observer_id;
1168 } 1165 }
1169 1166
1170 void WindowTree::SetWindowBounds(uint32_t change_id, 1167 void WindowTree::SetWindowBounds(uint32_t change_id,
1171 Id window_id, 1168 Id window_id,
1172 mojo::RectPtr bounds) { 1169 const gfx::Rect& bounds) {
1173 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); 1170 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id));
1174 if (window && ShouldRouteToWindowManager(window)) { 1171 if (window && ShouldRouteToWindowManager(window)) {
1175 const uint32_t wm_change_id = 1172 const uint32_t wm_change_id =
1176 window_server_->GenerateWindowManagerChangeId(this, change_id); 1173 window_server_->GenerateWindowManagerChangeId(this, change_id);
1177 // |window_id| may be a client id, use the id from the window to ensure 1174 // |window_id| may be a client id, use the id from the window to ensure
1178 // the windowmanager doesn't get an id it doesn't know about. 1175 // the windowmanager doesn't get an id it doesn't know about.
1179 WindowManagerState* wms = display_manager() 1176 WindowManagerState* wms = display_manager()
1180 ->GetWindowManagerAndDisplay(window) 1177 ->GetWindowManagerAndDisplay(window)
1181 .window_manager_state; 1178 .window_manager_state;
1182 wms->tree()->window_manager_internal_->WmSetBounds( 1179 wms->tree()->window_manager_internal_->WmSetBounds(
1183 wm_change_id, wms->tree()->ClientWindowIdForWindow(window).id, 1180 wm_change_id, wms->tree()->ClientWindowIdForWindow(window).id,
1184 std::move(bounds)); 1181 std::move(bounds));
1185 return; 1182 return;
1186 } 1183 }
1187 1184
1188 // Only the owner of the window can change the bounds. 1185 // Only the owner of the window can change the bounds.
1189 bool success = window && access_policy_->CanSetWindowBounds(window); 1186 bool success = window && access_policy_->CanSetWindowBounds(window);
1190 if (success) { 1187 if (success) {
1191 Operation op(this, window_server_, OperationType::SET_WINDOW_BOUNDS); 1188 Operation op(this, window_server_, OperationType::SET_WINDOW_BOUNDS);
1192 window->SetBounds(bounds.To<gfx::Rect>()); 1189 window->SetBounds(bounds);
1193 } 1190 }
1194 client()->OnChangeCompleted(change_id, success); 1191 client()->OnChangeCompleted(change_id, success);
1195 } 1192 }
1196 1193
1197 void WindowTree::SetWindowVisibility(uint32_t change_id, 1194 void WindowTree::SetWindowVisibility(uint32_t change_id,
1198 Id transport_window_id, 1195 Id transport_window_id,
1199 bool visible) { 1196 bool visible) {
1200 client()->OnChangeCompleted( 1197 client()->OnChangeCompleted(
1201 change_id, 1198 change_id,
1202 SetWindowVisibility(ClientWindowId(transport_window_id), visible)); 1199 SetWindowVisibility(ClientWindowId(transport_window_id), visible));
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1304 target = targeted_event->target(); 1301 target = targeted_event->target();
1305 event = targeted_event->TakeEvent(); 1302 event = targeted_event->TakeEvent();
1306 } while (!event_queue_.empty() && !GetDisplay(target)); 1303 } while (!event_queue_.empty() && !GetDisplay(target));
1307 if (target) 1304 if (target)
1308 DispatchInputEventImpl(target, *event); 1305 DispatchInputEventImpl(target, *event);
1309 } 1306 }
1310 } 1307 }
1311 1308
1312 void WindowTree::SetClientArea( 1309 void WindowTree::SetClientArea(
1313 Id transport_window_id, 1310 Id transport_window_id,
1314 mojo::InsetsPtr insets, 1311 const gfx::Insets& insets,
1315 mojo::Array<mojo::RectPtr> transport_additional_client_areas) { 1312 mojo::Array<gfx::Rect> transport_additional_client_areas) {
1316 ServerWindow* window = 1313 ServerWindow* window =
1317 GetWindowByClientId(ClientWindowId(transport_window_id)); 1314 GetWindowByClientId(ClientWindowId(transport_window_id));
1318 if (!window || !access_policy_->CanSetClientArea(window)) 1315 if (!window || !access_policy_->CanSetClientArea(window))
1319 return; 1316 return;
1320 1317
1321 std::vector<gfx::Rect> additional_client_areas = 1318 std::vector<gfx::Rect> additional_client_areas =
1322 transport_additional_client_areas.To<std::vector<gfx::Rect>>(); 1319 transport_additional_client_areas.To<std::vector<gfx::Rect>>();
1323 window->SetClientArea(insets.To<gfx::Insets>(), additional_client_areas); 1320 window->SetClientArea(insets, additional_client_areas);
1324 } 1321 }
1325 1322
1326 void WindowTree::SetHitTestMask(Id transport_window_id, mojo::RectPtr mask) { 1323 void WindowTree::SetHitTestMask(Id transport_window_id, const gfx::Rect& mask) {
1327 ServerWindow* window = 1324 ServerWindow* window =
1328 GetWindowByClientId(ClientWindowId(transport_window_id)); 1325 GetWindowByClientId(ClientWindowId(transport_window_id));
1329 if (!window || !access_policy_->CanSetHitTestMask(window)) { 1326 if (!window || !access_policy_->CanSetHitTestMask(window)) {
1330 DVLOG(1) << "SetHitTestMask failed"; 1327 DVLOG(1) << "SetHitTestMask failed";
1331 return; 1328 return;
1332 } 1329 }
1333 1330
1334 if (mask) 1331 if (!mask.IsEmpty())
1335 window->SetHitTestMask(mask.To<gfx::Rect>()); 1332 window->SetHitTestMask(mask);
1336 else 1333 else
1337 window->ClearHitTestMask(); 1334 window->ClearHitTestMask();
1338 } 1335 }
1339 1336
1340 void WindowTree::Embed(Id transport_window_id, 1337 void WindowTree::Embed(Id transport_window_id,
1341 mojom::WindowTreeClientPtr client, 1338 mojom::WindowTreeClientPtr client,
1342 const EmbedCallback& callback) { 1339 const EmbedCallback& callback) {
1343 callback.Run(Embed(ClientWindowId(transport_window_id), std::move(client))); 1340 callback.Run(Embed(ClientWindowId(transport_window_id), std::move(client)));
1344 } 1341 }
1345 1342
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1423 Display* display = GetDisplayForWindowManager(); 1420 Display* display = GetDisplayForWindowManager();
1424 if (!display) 1421 if (!display)
1425 return; 1422 return;
1426 display->ActivateNextWindow(); 1423 display->ActivateNextWindow();
1427 } 1424 }
1428 1425
1429 void WindowTree::SetUnderlaySurfaceOffsetAndExtendedHitArea( 1426 void WindowTree::SetUnderlaySurfaceOffsetAndExtendedHitArea(
1430 Id window_id, 1427 Id window_id,
1431 int32_t x_offset, 1428 int32_t x_offset,
1432 int32_t y_offset, 1429 int32_t y_offset,
1433 mojo::InsetsPtr hit_area) { 1430 const gfx::Insets& hit_area) {
1434 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); 1431 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id));
1435 if (!window) 1432 if (!window)
1436 return; 1433 return;
1437 1434
1438 window->SetUnderlayOffset(gfx::Vector2d(x_offset, y_offset)); 1435 window->SetUnderlayOffset(gfx::Vector2d(x_offset, y_offset));
1439 window->set_extended_hit_test_region(hit_area.To<gfx::Insets>()); 1436 window->set_extended_hit_test_region(hit_area);
1440 } 1437 }
1441 1438
1442 void WindowTree::WmResponse(uint32_t change_id, bool response) { 1439 void WindowTree::WmResponse(uint32_t change_id, bool response) {
1443 // TODO(sky): think about what else case means. 1440 // TODO(sky): think about what else case means.
1444 if (GetDisplayForWindowManager()) 1441 if (GetDisplayForWindowManager())
1445 window_server_->WindowManagerChangeCompleted(change_id, response); 1442 window_server_->WindowManagerChangeCompleted(change_id, response);
1446 } 1443 }
1447 1444
1448 void WindowTree::WmRequestClose(Id transport_window_id) { 1445 void WindowTree::WmRequestClose(Id transport_window_id) {
1449 // Only the WindowManager should be using this. 1446 // Only the WindowManager should be using this.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1501 } 1498 }
1502 1499
1503 bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy( 1500 bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy(
1504 const ServerWindow* window) const { 1501 const ServerWindow* window) const {
1505 WindowTree* tree = window_server_->GetTreeWithRoot(window); 1502 WindowTree* tree = window_server_->GetTreeWithRoot(window);
1506 return tree && tree != this; 1503 return tree && tree != this;
1507 } 1504 }
1508 1505
1509 } // namespace ws 1506 } // namespace ws
1510 } // namespace mus 1507 } // namespace mus
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698