Chromium Code Reviews| Index: services/ui/ws/window_tree.cc |
| diff --git a/services/ui/ws/window_tree.cc b/services/ui/ws/window_tree.cc |
| index a32eec9bcd3393b4b683a8d93e3ce6d0960e448a..b951af85a19f9090e7f4f661c4d5b599cd25841d 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); |
|
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
|
| + 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(); |
| @@ -1297,6 +1303,7 @@ void WindowTree::OnWindowInputEventAck(uint32_t event_id, |
| if (event_ack_id_ == 0 || event_id != event_ack_id_) { |
| // TODO(sad): Something bad happened. Kill the client? |
| NOTIMPLEMENTED() << "Wrong event acked."; |
| + DVLOG(1) << "OnAcceleratorAck supplied unexpected event_id"; |
| } |
| event_ack_id_ = 0; |
| @@ -1520,6 +1527,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); |
| } |