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

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

Issue 479873002: Removing X11 native_event uses for key events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
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 <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(ui::KeyEvent event,
sadrul 2014/08/19 03:46:19 const &
kpschoedel 2014/08/19 21:58:10 This gets passed to the non-const OnEventFromSourc
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);
29 event.set_flags(event.flags() | ui::EF_IS_SYNTHESIZED);
30 ui::EventDispatchDetails result ALLOW_UNUSED = 28 ui::EventDispatchDetails result ALLOW_UNUSED =
31 target->GetHost()->event_processor()->OnEventFromSource(&event); 29 target->GetHost()->event_processor()->OnEventFromSource(&event);
32 } 30 }
33 31
34 void PostPressedEvent(ui::KeyEvent* event) { 32 void PostPressedEvent(ui::KeyEvent* event) {
35 // Modify RELEASED event to PRESSED event. 33 // Modify RELEASED event to PRESSED event.
36 XEvent xkey = *(event->native_event()); 34 ui::KeyEvent pressed_event(
37 xkey.xkey.type = KeyPress; 35 ui::ET_KEY_PRESSED,
38 xkey.xkey.state |= ShiftMask; 36 event->key_code(),
37 event->code(),
38 event->flags() | ui::EF_SHIFT_DOWN | ui::EF_IS_SYNTHESIZED);
39
39 scoped_ptr<aura::WindowTracker> tracker(new aura::WindowTracker); 40 scoped_ptr<aura::WindowTracker> tracker(new aura::WindowTracker);
40 tracker->Add(static_cast<aura::Window*>(event->target())); 41 tracker->Add(static_cast<aura::Window*>(event->target()));
41 42
42 base::MessageLoopForUI::current()->PostTask( 43 base::MessageLoopForUI::current()->PostTask(
43 FROM_HERE, 44 FROM_HERE,
44 base::Bind(&DispatchPressedEvent, xkey, base::Passed(&tracker))); 45 base::Bind(&DispatchPressedEvent, pressed_event, base::Passed(&tracker)));
45 } 46 }
46 47
47 } // namespace 48 } // namespace
48 49
49 KeyHoldDetector::KeyHoldDetector(scoped_ptr<Delegate> delegate) 50 KeyHoldDetector::KeyHoldDetector(scoped_ptr<Delegate> delegate)
50 : state_(INITIAL), 51 : state_(INITIAL),
51 delegate_(delegate.Pass()) {} 52 delegate_(delegate.Pass()) {}
52 53
53 KeyHoldDetector::~KeyHoldDetector() {} 54 KeyHoldDetector::~KeyHoldDetector() {}
54 55
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 delegate_->OnKeyUnhold(event); 91 delegate_->OnKeyUnhold(event);
91 event->StopPropagation(); 92 event->StopPropagation();
92 break; 93 break;
93 } 94 }
94 } 95 }
95 state_ = INITIAL; 96 state_ = INITIAL;
96 } 97 }
97 } 98 }
98 99
99 } // namespace ash 100 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/web_input_event_aura.cc » ('j') | ui/events/event.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698