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 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
424 } else { | 424 } else { |
425 DVLOG(1) << "AddActivationParent supplied invalid window id"; | 425 DVLOG(1) << "AddActivationParent supplied invalid window id"; |
426 } | 426 } |
427 } | 427 } |
428 | 428 |
429 void WindowTree::OnChangeCompleted(uint32_t change_id, bool success) { | 429 void WindowTree::OnChangeCompleted(uint32_t change_id, bool success) { |
430 client()->OnChangeCompleted(change_id, success); | 430 client()->OnChangeCompleted(change_id, success); |
431 } | 431 } |
432 | 432 |
433 void WindowTree::OnAccelerator(uint32_t accelerator_id, | 433 void WindowTree::OnAccelerator(uint32_t accelerator_id, |
434 const ui::Event& event) { | 434 const ui::Event& event, |
435 bool needs_ack) { | |
435 DCHECK(window_manager_internal_); | 436 DCHECK(window_manager_internal_); |
437 const uint32_t ack_id = needs_ack ? GenerateEventAckId() : 0u; | |
436 // TODO(moshayedi): crbug.com/617167. Don't clone even once we map | 438 // TODO(moshayedi): crbug.com/617167. Don't clone even once we map |
437 // mojom::Event directly to ui::Event. | 439 // mojom::Event directly to ui::Event. |
438 window_manager_internal_->OnAccelerator(accelerator_id, | 440 window_manager_internal_->OnAccelerator(ack_id, accelerator_id, |
439 ui::Event::Clone(event)); | 441 ui::Event::Clone(event)); |
440 } | 442 } |
441 | 443 |
442 void WindowTree::ClientJankinessChanged(WindowTree* tree) { | 444 void WindowTree::ClientJankinessChanged(WindowTree* tree) { |
443 tree->janky_ = !tree->janky_; | 445 tree->janky_ = !tree->janky_; |
444 if (window_manager_internal_) { | 446 if (window_manager_internal_) { |
445 window_manager_internal_->WmClientJankinessChanged( | 447 window_manager_internal_->WmClientJankinessChanged( |
446 tree->id(), tree->janky()); | 448 tree->id(), tree->janky()); |
447 } | 449 } |
448 } | 450 } |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
953 } | 955 } |
954 } | 956 } |
955 | 957 |
956 void WindowTree::RemoveChildrenAsPartOfEmbed(ServerWindow* window) { | 958 void WindowTree::RemoveChildrenAsPartOfEmbed(ServerWindow* window) { |
957 CHECK(window); | 959 CHECK(window); |
958 std::vector<ServerWindow*> children = window->GetChildren(); | 960 std::vector<ServerWindow*> children = window->GetChildren(); |
959 for (size_t i = 0; i < children.size(); ++i) | 961 for (size_t i = 0; i < children.size(); ++i) |
960 window->Remove(children[i]); | 962 window->Remove(children[i]); |
961 } | 963 } |
962 | 964 |
965 uint32_t WindowTree::GenerateEventAckId() { | |
966 DCHECK(!event_ack_id_); | |
967 // We do not want to create a sequential id for each event, because that can | |
968 // leak some information to the client. So instead, manufacture the id | |
969 // randomly. | |
970 event_ack_id_ = 0x1000000 | (rand() & 0xffffff); | |
dcheng
2016/07/07 04:04:21
Out of curiosity, are there/should there be any re
sky
2016/07/07 13:38:38
I don't think it's been given much thought. If the
| |
971 return event_ack_id_; | |
972 } | |
973 | |
963 void WindowTree::DispatchInputEventImpl(ServerWindow* target, | 974 void WindowTree::DispatchInputEventImpl(ServerWindow* target, |
964 const ui::Event& event) { | 975 const ui::Event& event) { |
965 DCHECK(!event_ack_id_); | 976 GenerateEventAckId(); |
966 // We do not want to create a sequential id for each event, because that can | |
967 // leak some information to the client. So instead, manufacture the id | |
968 // randomly. | |
969 // TODO(moshayedi): Find a faster way to generate ids. | |
970 event_ack_id_ = 0x1000000 | (rand() & 0xffffff); | |
971 WindowManagerDisplayRoot* display_root = GetWindowManagerDisplayRoot(target); | 977 WindowManagerDisplayRoot* display_root = GetWindowManagerDisplayRoot(target); |
972 DCHECK(display_root); | 978 DCHECK(display_root); |
973 event_source_wms_ = display_root->window_manager_state(); | 979 event_source_wms_ = display_root->window_manager_state(); |
974 // Should only get events from windows attached to a host. | 980 // Should only get events from windows attached to a host. |
975 DCHECK(event_source_wms_); | 981 DCHECK(event_source_wms_); |
976 bool matched_observer = | 982 bool matched_observer = |
977 event_observer_matcher_ && event_observer_matcher_->MatchesEvent(event); | 983 event_observer_matcher_ && event_observer_matcher_->MatchesEvent(event); |
978 client()->OnWindowInputEvent( | 984 client()->OnWindowInputEvent( |
979 event_ack_id_, ClientWindowIdForWindow(target).id, | 985 event_ack_id_, ClientWindowIdForWindow(target).id, |
980 ui::Event::Clone(event), matched_observer ? event_observer_id_ : 0); | 986 ui::Event::Clone(event), matched_observer ? event_observer_id_ : 0); |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1290 if (display) | 1296 if (display) |
1291 display->SetImeVisibility(window, visible); | 1297 display->SetImeVisibility(window, visible); |
1292 } | 1298 } |
1293 } | 1299 } |
1294 | 1300 |
1295 void WindowTree::OnWindowInputEventAck(uint32_t event_id, | 1301 void WindowTree::OnWindowInputEventAck(uint32_t event_id, |
1296 mojom::EventResult result) { | 1302 mojom::EventResult result) { |
1297 if (event_ack_id_ == 0 || event_id != event_ack_id_) { | 1303 if (event_ack_id_ == 0 || event_id != event_ack_id_) { |
1298 // TODO(sad): Something bad happened. Kill the client? | 1304 // TODO(sad): Something bad happened. Kill the client? |
1299 NOTIMPLEMENTED() << "Wrong event acked."; | 1305 NOTIMPLEMENTED() << "Wrong event acked."; |
1306 DVLOG(1) << "OnAcceleratorAck supplied unexpected event_id"; | |
1300 } | 1307 } |
1301 event_ack_id_ = 0; | 1308 event_ack_id_ = 0; |
1302 | 1309 |
1303 if (janky_) | 1310 if (janky_) |
1304 event_source_wms_->window_tree()->ClientJankinessChanged(this); | 1311 event_source_wms_->window_tree()->ClientJankinessChanged(this); |
1305 | 1312 |
1306 WindowManagerState* event_source_wms = event_source_wms_; | 1313 WindowManagerState* event_source_wms = event_source_wms_; |
1307 event_source_wms_ = nullptr; | 1314 event_source_wms_ = nullptr; |
1308 if (event_source_wms) | 1315 if (event_source_wms) |
1309 event_source_wms->OnEventAck(this, result); | 1316 event_source_wms->OnEventAck(this, result); |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1513 ServerWindow* window = | 1520 ServerWindow* window = |
1514 GetWindowByClientId(ClientWindowId(transport_window_id)); | 1521 GetWindowByClientId(ClientWindowId(transport_window_id)); |
1515 if (window && window->id().client_id != id_) { | 1522 if (window && window->id().client_id != id_) { |
1516 DVLOG(1) << "OnWmCreatedTopLevelWindow supplied invalid window id"; | 1523 DVLOG(1) << "OnWmCreatedTopLevelWindow supplied invalid window id"; |
1517 window_server_->WindowManagerSentBogusMessage(); | 1524 window_server_->WindowManagerSentBogusMessage(); |
1518 window = nullptr; | 1525 window = nullptr; |
1519 } | 1526 } |
1520 window_server_->WindowManagerCreatedTopLevelWindow(this, change_id, window); | 1527 window_server_->WindowManagerCreatedTopLevelWindow(this, change_id, window); |
1521 } | 1528 } |
1522 | 1529 |
1530 void WindowTree::OnAcceleratorAck(uint32_t event_id, | |
1531 mojom::EventResult result) { | |
1532 if (event_ack_id_ == 0 || event_id != event_ack_id_) { | |
1533 DVLOG(1) << "OnAcceleratorAck supplied invalid event_id"; | |
1534 window_server_->WindowManagerSentBogusMessage(); | |
1535 return; | |
1536 } | |
1537 event_ack_id_ = 0; | |
1538 DCHECK(window_manager_state_); | |
1539 window_manager_state_->OnAcceleratorAck(result); | |
1540 } | |
1541 | |
1523 bool WindowTree::HasRootForAccessPolicy(const ServerWindow* window) const { | 1542 bool WindowTree::HasRootForAccessPolicy(const ServerWindow* window) const { |
1524 return HasRoot(window); | 1543 return HasRoot(window); |
1525 } | 1544 } |
1526 | 1545 |
1527 bool WindowTree::IsWindowKnownForAccessPolicy( | 1546 bool WindowTree::IsWindowKnownForAccessPolicy( |
1528 const ServerWindow* window) const { | 1547 const ServerWindow* window) const { |
1529 return IsWindowKnown(window); | 1548 return IsWindowKnown(window); |
1530 } | 1549 } |
1531 | 1550 |
1532 bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy( | 1551 bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy( |
1533 const ServerWindow* window) const { | 1552 const ServerWindow* window) const { |
1534 WindowTree* tree = window_server_->GetTreeWithRoot(window); | 1553 WindowTree* tree = window_server_->GetTreeWithRoot(window); |
1535 return tree && tree != this; | 1554 return tree && tree != this; |
1536 } | 1555 } |
1537 | 1556 |
1538 } // namespace ws | 1557 } // namespace ws |
1539 } // namespace ui | 1558 } // namespace ui |
OLD | NEW |