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

Unified 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: merge 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « services/ui/ws/window_tree.h ('k') | services/ui/ws/window_tree_client_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/ui/ws/window_tree.cc
diff --git a/services/ui/ws/window_tree.cc b/services/ui/ws/window_tree.cc
index 7b677590017f2841d671284be29e16e733644c25..8a62bdd534534c4c4b111647511e306071068afe 100644
--- a/services/ui/ws/window_tree.cc
+++ b/services/ui/ws/window_tree.cc
@@ -431,11 +431,16 @@ 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_);
+ if (needs_ack)
+ GenerateEventAckId();
+ else
+ DCHECK_EQ(0u, event_ack_id_);
// 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(event_ack_id_, accelerator_id,
ui::Event::Clone(event));
}
@@ -959,14 +964,18 @@ void WindowTree::RemoveChildrenAsPartOfEmbed(ServerWindow* window) {
window->Remove(window->children().front());
}
-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();
@@ -1297,6 +1306,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) << "OnWindowInputEventAck supplied unexpected event_id";
}
event_ack_id_ = 0;
@@ -1610,6 +1620,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);
}
« no previous file with comments | « services/ui/ws/window_tree.h ('k') | services/ui/ws/window_tree_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698