| Index: services/ui/ws/window_tree.cc
|
| diff --git a/services/ui/ws/window_tree.cc b/services/ui/ws/window_tree.cc
|
| index 4b5e7498f6b69c0d5f4cff8d3b71779087c0f6f0..09e29dd4577b6f0a7dfe4baa0b8e19fac5b50055 100644
|
| --- a/services/ui/ws/window_tree.cc
|
| +++ b/services/ui/ws/window_tree.cc
|
| @@ -431,11 +431,13 @@ void WindowTree::OnChangeCompleted(uint32_t change_id, bool success) {
|
| }
|
|
|
| void WindowTree::OnAccelerator(uint32_t accelerator_id,
|
| - const ui::Event& event) {
|
| + const ui::Event& event,
|
| + bool needs_ack) {
|
| DCHECK(window_manager_internal_);
|
| + const uint32_t ack_id = needs_ack ? GenerateEventAckId() : 0u;
|
| // TODO(moshayedi): crbug.com/617167. Don't clone even once we map
|
| // mojom::Event directly to ui::Event.
|
| - window_manager_internal_->OnAccelerator(accelerator_id,
|
| + window_manager_internal_->OnAccelerator(ack_id, accelerator_id,
|
| ui::Event::Clone(event));
|
| }
|
|
|
| @@ -960,14 +962,18 @@ void WindowTree::RemoveChildrenAsPartOfEmbed(ServerWindow* window) {
|
| window->Remove(children[i]);
|
| }
|
|
|
| -void WindowTree::DispatchInputEventImpl(ServerWindow* target,
|
| - const ui::Event& event) {
|
| +uint32_t WindowTree::GenerateEventAckId() {
|
| DCHECK(!event_ack_id_);
|
| // We do not want to create a sequential id for each event, because that can
|
| // leak some information to the client. So instead, manufacture the id
|
| // randomly.
|
| - // TODO(moshayedi): Find a faster way to generate ids.
|
| event_ack_id_ = 0x1000000 | (rand() & 0xffffff);
|
| + return event_ack_id_;
|
| +}
|
| +
|
| +void WindowTree::DispatchInputEventImpl(ServerWindow* target,
|
| + const ui::Event& event) {
|
| + GenerateEventAckId();
|
| WindowManagerDisplayRoot* display_root = GetWindowManagerDisplayRoot(target);
|
| DCHECK(display_root);
|
| event_source_wms_ = display_root->window_manager_state();
|
| @@ -1298,6 +1304,7 @@ void WindowTree::OnWindowInputEventAck(uint32_t event_id,
|
| // TODO(sad): Something bad happened. Kill the client?
|
| NOTIMPLEMENTED() << ": Wrong event acked. event_id=" << event_id
|
| << ", event_ack_id_=" << event_ack_id_;
|
| + DVLOG(1) << "OnAcceleratorAck supplied unexpected event_id";
|
| }
|
| event_ack_id_ = 0;
|
|
|
| @@ -1611,6 +1618,18 @@ void WindowTree::OnWmCreatedTopLevelWindow(uint32_t change_id,
|
| window_server_->WindowManagerCreatedTopLevelWindow(this, change_id, window);
|
| }
|
|
|
| +void WindowTree::OnAcceleratorAck(uint32_t event_id,
|
| + mojom::EventResult result) {
|
| + if (event_ack_id_ == 0 || event_id != event_ack_id_) {
|
| + DVLOG(1) << "OnAcceleratorAck supplied invalid event_id";
|
| + window_server_->WindowManagerSentBogusMessage();
|
| + return;
|
| + }
|
| + event_ack_id_ = 0;
|
| + DCHECK(window_manager_state_);
|
| + window_manager_state_->OnAcceleratorAck(result);
|
| +}
|
| +
|
| bool WindowTree::HasRootForAccessPolicy(const ServerWindow* window) const {
|
| return HasRoot(window);
|
| }
|
|
|