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

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

Issue 2761233003: Adds ability for accelerators to add key/value pairs to KeyEvent (Closed)
Patch Set: feedback and compile Created 3 years, 9 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
« no previous file with comments | « services/ui/ws/window_manager_state.h ('k') | services/ui/ws/window_manager_state_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_manager_state.h" 5 #include "services/ui/ws/window_manager_state.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 post_target_accelerator_.reset(); 291 post_target_accelerator_.reset();
292 292
293 if (result == mojom::EventResult::UNHANDLED && post_target_accelerator) { 293 if (result == mojom::EventResult::UNHANDLED && post_target_accelerator) {
294 OnAccelerator(post_target_accelerator->id(), *details->event, 294 OnAccelerator(post_target_accelerator->id(), *details->event,
295 AcceleratorPhase::POST); 295 AcceleratorPhase::POST);
296 } 296 }
297 297
298 ProcessNextEventFromQueue(); 298 ProcessNextEventFromQueue();
299 } 299 }
300 300
301 void WindowManagerState::OnAcceleratorAck(mojom::EventResult result) { 301 void WindowManagerState::OnAcceleratorAck(
302 mojom::EventResult result,
303 const std::unordered_map<std::string, std::vector<uint8_t>>& properties) {
302 if (!in_flight_event_details_ || 304 if (!in_flight_event_details_ ||
303 in_flight_event_details_->phase != 305 in_flight_event_details_->phase !=
304 EventDispatchPhase::PRE_TARGET_ACCELERATOR) { 306 EventDispatchPhase::PRE_TARGET_ACCELERATOR) {
305 // TODO(sad): The ack must have arrived after the timeout. We should do 307 // TODO(sad): The ack must have arrived after the timeout. We should do
306 // something here, and in OnEventAckTimeout(). 308 // something here, and in OnEventAckTimeout().
307 return; 309 return;
308 } 310 }
309 311
310 std::unique_ptr<InFlightEventDetails> details = 312 std::unique_ptr<InFlightEventDetails> details =
311 std::move(in_flight_event_details_); 313 std::move(in_flight_event_details_);
312 314
313 if (result == mojom::EventResult::UNHANDLED) { 315 if (result == mojom::EventResult::UNHANDLED) {
316 DCHECK(details->event->IsKeyEvent());
317 if (!properties.empty())
318 details->event->AsKeyEvent()->SetProperties(properties);
314 event_processing_display_id_ = details->display_id; 319 event_processing_display_id_ = details->display_id;
315 event_dispatcher_.ProcessEvent( 320 event_dispatcher_.ProcessEvent(
316 *details->event, EventDispatcher::AcceleratorMatchPhase::POST_ONLY); 321 *details->event, EventDispatcher::AcceleratorMatchPhase::POST_ONLY);
317 } else { 322 } else {
318 // We're not going to process the event any further, notify event observers. 323 // We're not going to process the event any further, notify event observers.
319 // We don't do this first to ensure we don't send an event twice to clients. 324 // We don't do this first to ensure we don't send an event twice to clients.
320 window_server()->SendToPointerWatchers(*details->event, user_id(), nullptr, 325 window_server()->SendToPointerWatchers(*details->event, user_id(), nullptr,
321 nullptr, details->display_id); 326 nullptr, details->display_id);
322 ProcessNextEventFromQueue(); 327 ProcessNextEventFromQueue();
323 } 328 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 NOTREACHED(); 379 NOTREACHED();
375 return nullptr; 380 return nullptr;
376 } 381 }
377 382
378 void WindowManagerState::OnEventAckTimeout(ClientSpecificId client_id) { 383 void WindowManagerState::OnEventAckTimeout(ClientSpecificId client_id) {
379 WindowTree* hung_tree = window_server()->GetTreeWithId(client_id); 384 WindowTree* hung_tree = window_server()->GetTreeWithId(client_id);
380 if (hung_tree && !hung_tree->janky()) 385 if (hung_tree && !hung_tree->janky())
381 window_tree_->ClientJankinessChanged(hung_tree); 386 window_tree_->ClientJankinessChanged(hung_tree);
382 if (in_flight_event_details_->phase == 387 if (in_flight_event_details_->phase ==
383 EventDispatchPhase::PRE_TARGET_ACCELERATOR) { 388 EventDispatchPhase::PRE_TARGET_ACCELERATOR) {
384 OnAcceleratorAck(mojom::EventResult::UNHANDLED); 389 OnAcceleratorAck(mojom::EventResult::UNHANDLED, KeyEvent::Properties());
385 } else { 390 } else {
386 OnEventAck( 391 OnEventAck(
387 in_flight_event_details_ ? in_flight_event_details_->tree : nullptr, 392 in_flight_event_details_ ? in_flight_event_details_->tree : nullptr,
388 mojom::EventResult::UNHANDLED); 393 mojom::EventResult::UNHANDLED);
389 } 394 }
390 } 395 }
391 396
392 void WindowManagerState::ProcessEventImpl(const ui::Event& event, 397 void WindowManagerState::ProcessEventImpl(const ui::Event& event,
393 int64_t display_id) { 398 int64_t display_id) {
394 // Debug accelerators are always checked and don't interfere with processing. 399 // Debug accelerators are always checked and don't interfere with processing.
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 window->RemoveObserver(this); 676 window->RemoveObserver(this);
672 orphaned_window_manager_display_roots_.erase(iter); 677 orphaned_window_manager_display_roots_.erase(iter);
673 return; 678 return;
674 } 679 }
675 } 680 }
676 NOTREACHED(); 681 NOTREACHED();
677 } 682 }
678 683
679 } // namespace ws 684 } // namespace ws
680 } // namespace ui 685 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/window_manager_state.h ('k') | services/ui/ws/window_manager_state_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698