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

Side by Side Diff: ash/accelerators/key_hold_detector.cc

Issue 2712963003: mustash: Use ui::chromeos::EventRewriter in mus (Closed)
Patch Set: Fix build issues. 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ash/accelerators/key_hold_detector.h" 5 #include "ash/accelerators/key_hold_detector.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
11 #include "ui/aura/window_tracker.h" 11 #include "ui/aura/window_tracker.h"
12 #include "ui/aura/window_tree_host.h" 12 #include "ui/aura/window_tree_host.h"
13 #include "ui/events/event_dispatcher.h" 13 #include "ui/events/event_dispatcher.h"
14 #include "ui/events/event_processor.h" 14 #include "ui/events/event_sink.h"
15 15
16 namespace ash { 16 namespace ash {
17 namespace { 17 namespace {
18 18
19 void DispatchPressedEvent(const ui::KeyEvent& key_event, 19 void DispatchPressedEvent(const ui::KeyEvent& key_event,
20 std::unique_ptr<aura::WindowTracker> tracker) { 20 std::unique_ptr<aura::WindowTracker> tracker) {
21 // The target window may be gone. 21 // The target window may be gone.
22 if (tracker->windows().empty()) 22 if (tracker->windows().empty())
23 return; 23 return;
24 ui::KeyEvent event(key_event); 24 ui::KeyEvent event(key_event);
25 aura::Window* target = *(tracker->windows().begin()); 25 aura::Window* target = *(tracker->windows().begin());
26 ignore_result( 26 ignore_result(target->GetHost()->event_sink()->OnEventFromSource(&event));
27 target->GetHost()->event_processor()->OnEventFromSource(&event));
28 } 27 }
29 28
30 void PostPressedEvent(ui::KeyEvent* event) { 29 void PostPressedEvent(ui::KeyEvent* event) {
31 // Modify RELEASED event to PRESSED event. 30 // Modify RELEASED event to PRESSED event.
32 const ui::KeyEvent pressed_event( 31 const ui::KeyEvent pressed_event(
33 ui::ET_KEY_PRESSED, event->key_code(), event->code(), 32 ui::ET_KEY_PRESSED, event->key_code(), event->code(),
34 event->flags() | ui::EF_SHIFT_DOWN | ui::EF_IS_SYNTHESIZED); 33 event->flags() | ui::EF_SHIFT_DOWN | ui::EF_IS_SYNTHESIZED);
35 std::unique_ptr<aura::WindowTracker> tracker(new aura::WindowTracker); 34 std::unique_ptr<aura::WindowTracker> tracker(new aura::WindowTracker);
36 tracker->Add(static_cast<aura::Window*>(event->target())); 35 tracker->Add(static_cast<aura::Window*>(event->target()));
37 36
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 if (delegate_->ShouldStopEventPropagation()) 90 if (delegate_->ShouldStopEventPropagation())
92 event->StopPropagation(); 91 event->StopPropagation();
93 break; 92 break;
94 } 93 }
95 } 94 }
96 state_ = INITIAL; 95 state_ = INITIAL;
97 } 96 }
98 } 97 }
99 98
100 } // namespace ash 99 } // namespace ash
OLDNEW
« no previous file with comments | « ash/accelerators/accelerator_controller_unittest.cc ('k') | ash/autoclick/autoclick_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698