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

Side by Side Diff: chrome/browser/chromeos/events/event_rewriter.h

Issue 2731283004: Do not use ash in chromeos::EventRewriter. (Closed)
Patch Set: Address review 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 #ifndef CHROME_BROWSER_CHROMEOS_EVENTS_EVENT_REWRITER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_EVENTS_EVENT_REWRITER_H_
6 #define CHROME_BROWSER_CHROMEOS_EVENTS_EVENT_REWRITER_H_ 6 #define CHROME_BROWSER_CHROMEOS_EVENTS_EVENT_REWRITER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <set> 10 #include <set>
11 #include <string> 11 #include <string>
12 12
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/containers/hash_tables.h" 14 #include "base/containers/hash_tables.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "ui/events/event.h" 16 #include "ui/events/event.h"
17 #include "ui/events/event_rewriter.h" 17 #include "ui/events/event_rewriter.h"
18 #include "ui/events/keycodes/dom/dom_key.h" 18 #include "ui/events/keycodes/dom/dom_key.h"
19 19
20 class PrefService; 20 class PrefService;
21 21
22 namespace ash {
23 class StickyKeysController;
24 }
25
26 namespace ui { 22 namespace ui {
27 enum class DomCode; 23 enum class DomCode;
28 }; 24 };
29 25
30 namespace chromeos { 26 namespace chromeos {
31 namespace input_method { 27 namespace input_method {
32 class ImeKeyboard; 28 class ImeKeyboard;
33 } 29 }
34 30
35 // EventRewriter makes various changes to keyboard-related events, 31 // EventRewriter makes various changes to keyboard-related events,
(...skipping 19 matching lines...) Expand all
55 struct MutableKeyState { 51 struct MutableKeyState {
56 int flags; 52 int flags;
57 ui::DomCode code; 53 ui::DomCode code;
58 ui::DomKey::Base key; 54 ui::DomKey::Base key;
59 ui::KeyboardCode key_code; 55 ui::KeyboardCode key_code;
60 }; 56 };
61 57
62 // Does not take ownership of the |sticky_keys_controller|, which may also 58 // Does not take ownership of the |sticky_keys_controller|, which may also
63 // be NULL (for testing without ash), in which case sticky key operations 59 // be NULL (for testing without ash), in which case sticky key operations
64 // don't happen. 60 // don't happen.
65 explicit EventRewriter(ash::StickyKeysController* sticky_keys_controller); 61 explicit EventRewriter(ui::EventRewriter* sticky_keys_controller);
66 ~EventRewriter() override; 62 ~EventRewriter() override;
67 63
68 // Calls KeyboardDeviceAddedInternal. 64 // Calls KeyboardDeviceAddedInternal.
69 DeviceType KeyboardDeviceAddedForTesting(int device_id, 65 DeviceType KeyboardDeviceAddedForTesting(int device_id,
70 const std::string& device_name); 66 const std::string& device_name);
71 67
72 // Calls RewriteMouseEvent(). 68 // Calls RewriteMouseEvent().
73 void RewriteMouseButtonEventForTesting( 69 void RewriteMouseButtonEventForTesting(
74 const ui::MouseEvent& event, 70 const ui::MouseEvent& event,
75 std::unique_ptr<ui::Event>* rewritten_event); 71 std::unique_ptr<ui::Event>* rewritten_event);
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 168
173 // The |source_device_id()| of the most recent keyboard event, 169 // The |source_device_id()| of the most recent keyboard event,
174 // used to interpret modifiers on pointer events. 170 // used to interpret modifiers on pointer events.
175 int last_keyboard_device_id_; 171 int last_keyboard_device_id_;
176 172
177 chromeos::input_method::ImeKeyboard* ime_keyboard_for_testing_; 173 chromeos::input_method::ImeKeyboard* ime_keyboard_for_testing_;
178 const PrefService* pref_service_for_testing_; 174 const PrefService* pref_service_for_testing_;
179 175
180 // The sticky keys controller is not owned here; 176 // The sticky keys controller is not owned here;
181 // at time of writing it is a singleton in ash::Shell. 177 // at time of writing it is a singleton in ash::Shell.
182 ash::StickyKeysController* sticky_keys_controller_; 178 ui::EventRewriter* const sticky_keys_controller_;
183 179
184 // Some keyboard layouts have 'latching' keys, which either apply 180 // Some keyboard layouts have 'latching' keys, which either apply
185 // a modifier while held down (like normal modifiers), or, if no 181 // a modifier while held down (like normal modifiers), or, if no
186 // non-modifier is pressed while the latching key is down, apply the 182 // non-modifier is pressed while the latching key is down, apply the
187 // modifier to the next non-modifier keypress. Under Ozone the stateless 183 // modifier to the next non-modifier keypress. Under Ozone the stateless
188 // layout model requires this to be handled explicitly. See crbug.com/518237 184 // layout model requires this to be handled explicitly. See crbug.com/518237
189 // Pragmatically this, like the Diamond key, is handled here in 185 // Pragmatically this, like the Diamond key, is handled here in
190 // EventRewriter, but modifier state management is scattered between 186 // EventRewriter, but modifier state management is scattered between
191 // here, sticky keys, and the system layer (X11 or Ozone), and could 187 // here, sticky keys, and the system layer (X11 or Ozone), and could
192 // do with refactoring. 188 // do with refactoring.
193 // - |pressed_modifier_latches_| records the latching keys currently pressed. 189 // - |pressed_modifier_latches_| records the latching keys currently pressed.
194 // It also records the active modifier flags for non-modifier keys that are 190 // It also records the active modifier flags for non-modifier keys that are
195 // remapped to modifiers, e.g. Diamond/F15. 191 // remapped to modifiers, e.g. Diamond/F15.
196 // - |latched_modifier_latches_| records the latching keys just released, 192 // - |latched_modifier_latches_| records the latching keys just released,
197 // to be applied to the next non-modifier key. 193 // to be applied to the next non-modifier key.
198 // - |used_modifier_latches_| records the latching keys applied to a non- 194 // - |used_modifier_latches_| records the latching keys applied to a non-
199 // modifier while pressed, so that they do not get applied after release. 195 // modifier while pressed, so that they do not get applied after release.
200 int pressed_modifier_latches_; 196 int pressed_modifier_latches_;
201 int latched_modifier_latches_; 197 int latched_modifier_latches_;
202 int used_modifier_latches_; 198 int used_modifier_latches_;
203 199
204 DISALLOW_COPY_AND_ASSIGN(EventRewriter); 200 DISALLOW_COPY_AND_ASSIGN(EventRewriter);
205 }; 201 };
206 202
207 } // namespace chromeos 203 } // namespace chromeos
208 204
209 #endif // CHROME_BROWSER_CHROMEOS_EVENTS_EVENT_REWRITER_H_ 205 #endif // CHROME_BROWSER_CHROMEOS_EVENTS_EVENT_REWRITER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698