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

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

Issue 2125883003: Adds ability for pre-target accelerators to not consume events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments Created 4 years, 5 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 "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
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,
sadrul 2016/07/08 15:40:44 Use event_ack_id_ instead?
sky 2016/07/08 16:23:51 Done.
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
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);
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 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
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. event_id=" << event_id 1305 NOTIMPLEMENTED() << ": Wrong event acked. event_id=" << event_id
1300 << ", event_ack_id_=" << event_ack_id_; 1306 << ", event_ack_id_=" << event_ack_id_;
1307 DVLOG(1) << "OnAcceleratorAck supplied unexpected event_id";
sadrul 2016/07/08 15:40:44 This is the wrong place?
sky 2016/07/08 16:23:51 Done.
1301 } 1308 }
1302 event_ack_id_ = 0; 1309 event_ack_id_ = 0;
1303 1310
1304 if (janky_) 1311 if (janky_)
1305 event_source_wms_->window_tree()->ClientJankinessChanged(this); 1312 event_source_wms_->window_tree()->ClientJankinessChanged(this);
1306 1313
1307 WindowManagerState* event_source_wms = event_source_wms_; 1314 WindowManagerState* event_source_wms = event_source_wms_;
1308 event_source_wms_ = nullptr; 1315 event_source_wms_ = nullptr;
1309 if (event_source_wms) 1316 if (event_source_wms)
1310 event_source_wms->OnEventAck(this, result); 1317 event_source_wms->OnEventAck(this, result);
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
1604 ServerWindow* window = 1611 ServerWindow* window =
1605 GetWindowByClientId(ClientWindowId(transport_window_id)); 1612 GetWindowByClientId(ClientWindowId(transport_window_id));
1606 if (window && window->id().client_id != id_) { 1613 if (window && window->id().client_id != id_) {
1607 DVLOG(1) << "OnWmCreatedTopLevelWindow supplied invalid window id"; 1614 DVLOG(1) << "OnWmCreatedTopLevelWindow supplied invalid window id";
1608 window_server_->WindowManagerSentBogusMessage(); 1615 window_server_->WindowManagerSentBogusMessage();
1609 window = nullptr; 1616 window = nullptr;
1610 } 1617 }
1611 window_server_->WindowManagerCreatedTopLevelWindow(this, change_id, window); 1618 window_server_->WindowManagerCreatedTopLevelWindow(this, change_id, window);
1612 } 1619 }
1613 1620
1621 void WindowTree::OnAcceleratorAck(uint32_t event_id,
1622 mojom::EventResult result) {
1623 if (event_ack_id_ == 0 || event_id != event_ack_id_) {
1624 DVLOG(1) << "OnAcceleratorAck supplied invalid event_id";
1625 window_server_->WindowManagerSentBogusMessage();
1626 return;
1627 }
1628 event_ack_id_ = 0;
1629 DCHECK(window_manager_state_);
1630 window_manager_state_->OnAcceleratorAck(result);
1631 }
1632
1614 bool WindowTree::HasRootForAccessPolicy(const ServerWindow* window) const { 1633 bool WindowTree::HasRootForAccessPolicy(const ServerWindow* window) const {
1615 return HasRoot(window); 1634 return HasRoot(window);
1616 } 1635 }
1617 1636
1618 bool WindowTree::IsWindowKnownForAccessPolicy( 1637 bool WindowTree::IsWindowKnownForAccessPolicy(
1619 const ServerWindow* window) const { 1638 const ServerWindow* window) const {
1620 return IsWindowKnown(window); 1639 return IsWindowKnown(window);
1621 } 1640 }
1622 1641
1623 bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy( 1642 bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy(
1624 const ServerWindow* window) const { 1643 const ServerWindow* window) const {
1625 WindowTree* tree = window_server_->GetTreeWithRoot(window); 1644 WindowTree* tree = window_server_->GetTreeWithRoot(window);
1626 return tree && tree != this; 1645 return tree && tree != this;
1627 } 1646 }
1628 1647
1629 } // namespace ws 1648 } // namespace ws
1630 } // namespace ui 1649 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698