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

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

Issue 2184613005: Fixes bug in accelerator handling in mus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 | « no previous file | 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 "base/memory/weak_ptr.h" 7 #include "base/memory/weak_ptr.h"
8 #include "services/shell/public/interfaces/connector.mojom.h" 8 #include "services/shell/public/interfaces/connector.mojom.h"
9 #include "services/ui/common/event_matcher_util.h" 9 #include "services/ui/common/event_matcher_util.h"
10 #include "services/ui/ws/accelerator.h" 10 #include "services/ui/ws/accelerator.h"
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 mojom::EventResult result) { 208 mojom::EventResult result) {
209 if (tree_awaiting_input_ack_ != tree || 209 if (tree_awaiting_input_ack_ != tree ||
210 event_dispatch_phase_ != EventDispatchPhase::TARGET) { 210 event_dispatch_phase_ != EventDispatchPhase::TARGET) {
211 // TODO(sad): The ack must have arrived after the timeout. We should do 211 // TODO(sad): The ack must have arrived after the timeout. We should do
212 // something here, and in OnEventAckTimeout(). 212 // something here, and in OnEventAckTimeout().
213 return; 213 return;
214 } 214 }
215 tree_awaiting_input_ack_ = nullptr; 215 tree_awaiting_input_ack_ = nullptr;
216 event_ack_timer_.Stop(); 216 event_ack_timer_.Stop();
217 217
218 if (result == mojom::EventResult::UNHANDLED && post_target_accelerator_) { 218 base::WeakPtr<Accelerator> post_target_accelerator = post_target_accelerator_;
219 OnAccelerator(post_target_accelerator_->id(), *event_awaiting_input_ack_, 219 post_target_accelerator_.reset();
220
221 if (result == mojom::EventResult::UNHANDLED && post_target_accelerator) {
222 std::unique_ptr<ui::Event> event = std::move(event_awaiting_input_ack_);
sadrul 2016/07/27 16:31:47 Should we always reset |event_awaiting_input_ack_|
sky 2016/07/27 16:34:49 Isn't that what the std::move does? Or did you mea
sadrul 2016/07/27 16:36:01 Yep. I mean, should we do that even if result != U
sky 2016/07/27 16:46:01 Ah, I got it. It doesn't matter because of Process
223 OnAccelerator(post_target_accelerator->id(), *event,
220 AcceleratorPhase::POST); 224 AcceleratorPhase::POST);
221 } 225 }
222 226
223 event_dispatch_phase_ = EventDispatchPhase::NONE; 227 event_dispatch_phase_ = EventDispatchPhase::NONE;
224 ProcessNextEventFromQueue(); 228 ProcessNextEventFromQueue();
225 } 229 }
226 230
227 void WindowManagerState::OnAcceleratorAck(mojom::EventResult result) { 231 void WindowManagerState::OnAcceleratorAck(mojom::EventResult result) {
228 if (event_dispatch_phase_ != EventDispatchPhase::PRE_TARGET_ACCELERATOR) { 232 if (event_dispatch_phase_ != EventDispatchPhase::PRE_TARGET_ACCELERATOR) {
229 // TODO(sad): The ack must have arrived after the timeout. We should do 233 // TODO(sad): The ack must have arrived after the timeout. We should do
230 // something here, and in OnEventAckTimeout(). 234 // something here, and in OnEventAckTimeout().
231 return; 235 return;
232 } 236 }
233 237
234 tree_awaiting_input_ack_ = nullptr; 238 tree_awaiting_input_ack_ = nullptr;
235 event_ack_timer_.Stop(); 239 event_ack_timer_.Stop();
236 event_dispatch_phase_ = EventDispatchPhase::NONE; 240 event_dispatch_phase_ = EventDispatchPhase::NONE;
237 241
238 if (result == mojom::EventResult::UNHANDLED) { 242 if (result == mojom::EventResult::UNHANDLED) {
243 std::unique_ptr<ui::Event> event = std::move(event_awaiting_input_ack_);
239 event_dispatcher_.ProcessEvent( 244 event_dispatcher_.ProcessEvent(
240 *event_awaiting_input_ack_, 245 *event, EventDispatcher::AcceleratorMatchPhase::POST_ONLY);
241 EventDispatcher::AcceleratorMatchPhase::POST_ONLY);
242 } else { 246 } else {
243 // We're not going to process the event any further, notify event observers. 247 // We're not going to process the event any further, notify event observers.
244 // We don't do this first to ensure we don't send an event twice to clients. 248 // We don't do this first to ensure we don't send an event twice to clients.
245 window_server()->SendToEventObservers(*event_awaiting_input_ack_, user_id(), 249 std::unique_ptr<ui::Event> event = std::move(event_awaiting_input_ack_);
246 nullptr); 250 window_server()->SendToEventObservers(*event, user_id(), nullptr);
247 ProcessNextEventFromQueue(); 251 ProcessNextEventFromQueue();
248 } 252 }
249 } 253 }
250 254
251 const WindowServer* WindowManagerState::window_server() const { 255 const WindowServer* WindowManagerState::window_server() const {
252 return window_tree_->window_server(); 256 return window_tree_->window_server();
253 } 257 }
254 258
255 WindowServer* WindowManagerState::window_server() { 259 WindowServer* WindowManagerState::window_server() {
256 return window_tree_->window_server(); 260 return window_tree_->window_server();
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 return display_root ? display_root->root() : nullptr; 530 return display_root ? display_root->root() : nullptr;
527 } 531 }
528 532
529 void WindowManagerState::OnEventTargetNotFound(const ui::Event& event) { 533 void WindowManagerState::OnEventTargetNotFound(const ui::Event& event) {
530 window_server()->SendToEventObservers(event, user_id(), 534 window_server()->SendToEventObservers(event, user_id(),
531 nullptr /* ignore_tree */); 535 nullptr /* ignore_tree */);
532 } 536 }
533 537
534 } // namespace ws 538 } // namespace ws
535 } // namespace ui 539 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | services/ui/ws/window_manager_state_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698