OLD | NEW |
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 <X11/Xlib.h> | 7 #include <X11/Xlib.h> |
8 | 8 |
9 #undef RootWindow | 9 #undef RootWindow |
10 #undef Status | 10 #undef Status |
11 | 11 |
12 #include "ash/shell.h" | 12 #include "ash/shell.h" |
13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
14 #include "ui/aura/window_tracker.h" | 14 #include "ui/aura/window_tracker.h" |
15 #include "ui/aura/window_tree_host.h" | 15 #include "ui/aura/window_tree_host.h" |
16 #include "ui/events/event_dispatcher.h" | 16 #include "ui/events/event_dispatcher.h" |
17 #include "ui/events/event_processor.h" | 17 #include "ui/events/event_processor.h" |
18 | 18 |
19 namespace ash { | 19 namespace ash { |
20 namespace { | 20 namespace { |
21 | 21 |
22 void DispatchPressedEvent(XEvent native_event, | 22 void DispatchPressedEvent(XEvent native_event, |
23 scoped_ptr<aura::WindowTracker> tracker) { | 23 scoped_ptr<aura::WindowTracker> tracker) { |
24 // The target window may be gone. | 24 // The target window may be gone. |
25 if (tracker->windows().empty()) | 25 if (tracker->windows().empty()) |
26 return; | 26 return; |
27 aura::Window* target = *(tracker->windows().begin()); | 27 aura::Window* target = *(tracker->windows().begin()); |
28 ui::KeyEvent event(&native_event, false); | 28 ui::KeyEvent event(&native_event); |
29 event.set_flags(event.flags() | ui::EF_IS_SYNTHESIZED); | 29 event.set_flags(event.flags() | ui::EF_IS_SYNTHESIZED); |
30 ui::EventDispatchDetails result ALLOW_UNUSED = | 30 ui::EventDispatchDetails result ALLOW_UNUSED = |
31 target->GetHost()->event_processor()->OnEventFromSource(&event); | 31 target->GetHost()->event_processor()->OnEventFromSource(&event); |
32 } | 32 } |
33 | 33 |
34 void PostPressedEvent(ui::KeyEvent* event) { | 34 void PostPressedEvent(ui::KeyEvent* event) { |
35 // Modify RELEASED event to PRESSED event. | 35 // Modify RELEASED event to PRESSED event. |
36 XEvent xkey = *(event->native_event()); | 36 XEvent xkey = *(event->native_event()); |
37 xkey.xkey.type = KeyPress; | 37 xkey.xkey.type = KeyPress; |
38 xkey.xkey.state |= ShiftMask; | 38 xkey.xkey.state |= ShiftMask; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 delegate_->OnKeyUnhold(event); | 90 delegate_->OnKeyUnhold(event); |
91 event->StopPropagation(); | 91 event->StopPropagation(); |
92 break; | 92 break; |
93 } | 93 } |
94 } | 94 } |
95 state_ = INITIAL; | 95 state_ = INITIAL; |
96 } | 96 } |
97 } | 97 } |
98 | 98 |
99 } // namespace ash | 99 } // namespace ash |
OLD | NEW |