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

Side by Side Diff: ui/events/ozone/evdev/keyboard_evdev.cc

Issue 1559163002: Clean up event flags a bit: (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comment Created 4 years, 11 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 | « ui/events/ozone/evdev/event_modifiers_evdev.cc ('k') | ui/events/ozone/layout/layout_util.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 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 "ui/events/ozone/evdev/keyboard_evdev.h" 5 #include "ui/events/ozone/evdev/keyboard_evdev.h"
6 6
7 #include "base/single_thread_task_runner.h" 7 #include "base/single_thread_task_runner.h"
8 #include "base/thread_task_runner_handle.h" 8 #include "base/thread_task_runner_handle.h"
9 #include "ui/events/event.h" 9 #include "ui/events/event.h"
10 #include "ui/events/event_constants.h" 10 #include "ui/events/event_constants.h"
11 #include "ui/events/event_utils.h" 11 #include "ui/events/event_utils.h"
12 #include "ui/events/keycodes/dom/dom_code.h" 12 #include "ui/events/keycodes/dom/dom_code.h"
13 #include "ui/events/keycodes/dom/keycode_converter.h" 13 #include "ui/events/keycodes/dom/keycode_converter.h"
14 #include "ui/events/ozone/evdev/event_modifiers_evdev.h" 14 #include "ui/events/ozone/evdev/event_modifiers_evdev.h"
15 #include "ui/events/ozone/evdev/keyboard_util_evdev.h" 15 #include "ui/events/ozone/evdev/keyboard_util_evdev.h"
16 #include "ui/events/ozone/layout/keyboard_layout_engine.h" 16 #include "ui/events/ozone/layout/keyboard_layout_engine.h"
17 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" 17 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h"
18 #include "ui/events/ozone/layout/layout_util.h" 18 #include "ui/events/ozone/layout/layout_util.h"
19 19
20 namespace ui { 20 namespace ui {
21 21
22 namespace { 22 namespace {
23 23
24 const int kRepeatDelayMs = 500; 24 const int kRepeatDelayMs = 500;
25 const int kRepeatIntervalMs = 50; 25 const int kRepeatIntervalMs = 50;
26 26
27 int EventFlagToEvdevModifier(int flag) { 27 int EventFlagToEvdevModifier(int flag) {
28 switch (flag) { 28 switch (flag) {
29 case EF_CAPS_LOCK_DOWN:
30 return EVDEV_MODIFIER_CAPS_LOCK;
31 case EF_SHIFT_DOWN: 29 case EF_SHIFT_DOWN:
32 return EVDEV_MODIFIER_SHIFT; 30 return EVDEV_MODIFIER_SHIFT;
33 case EF_CONTROL_DOWN: 31 case EF_CONTROL_DOWN:
34 return EVDEV_MODIFIER_CONTROL; 32 return EVDEV_MODIFIER_CONTROL;
35 case EF_ALT_DOWN: 33 case EF_ALT_DOWN:
36 return EVDEV_MODIFIER_ALT; 34 return EVDEV_MODIFIER_ALT;
35 case EF_COMMAND_DOWN:
36 return EVDEV_MODIFIER_COMMAND;
37 case EF_ALTGR_DOWN: 37 case EF_ALTGR_DOWN:
38 return EVDEV_MODIFIER_ALTGR; 38 return EVDEV_MODIFIER_ALTGR;
39 case EF_MOD3_DOWN: 39 case EF_MOD3_DOWN:
40 return EVDEV_MODIFIER_MOD3; 40 return EVDEV_MODIFIER_MOD3;
41 case EF_CAPS_LOCK_ON:
42 return EVDEV_MODIFIER_CAPS_LOCK;
41 case EF_LEFT_MOUSE_BUTTON: 43 case EF_LEFT_MOUSE_BUTTON:
42 return EVDEV_MODIFIER_LEFT_MOUSE_BUTTON; 44 return EVDEV_MODIFIER_LEFT_MOUSE_BUTTON;
43 case EF_MIDDLE_MOUSE_BUTTON: 45 case EF_MIDDLE_MOUSE_BUTTON:
44 return EVDEV_MODIFIER_MIDDLE_MOUSE_BUTTON; 46 return EVDEV_MODIFIER_MIDDLE_MOUSE_BUTTON;
45 case EF_RIGHT_MOUSE_BUTTON: 47 case EF_RIGHT_MOUSE_BUTTON:
46 return EVDEV_MODIFIER_RIGHT_MOUSE_BUTTON; 48 return EVDEV_MODIFIER_RIGHT_MOUSE_BUTTON;
47 case EF_BACK_MOUSE_BUTTON: 49 case EF_BACK_MOUSE_BUTTON:
48 return EVDEV_MODIFIER_BACK_MOUSE_BUTTON; 50 return EVDEV_MODIFIER_BACK_MOUSE_BUTTON;
49 case EF_FORWARD_MOUSE_BUTTON: 51 case EF_FORWARD_MOUSE_BUTTON:
50 return EVDEV_MODIFIER_FORWARD_MOUSE_BUTTON; 52 return EVDEV_MODIFIER_FORWARD_MOUSE_BUTTON;
51 case EF_COMMAND_DOWN:
52 return EVDEV_MODIFIER_COMMAND;
53 default: 53 default:
54 return EVDEV_MODIFIER_NONE; 54 return EVDEV_MODIFIER_NONE;
55 } 55 }
56 } 56 }
57 57
58 } // namespace 58 } // namespace
59 59
60 KeyboardEvdev::KeyboardEvdev(EventModifiersEvdev* modifiers, 60 KeyboardEvdev::KeyboardEvdev(EventModifiersEvdev* modifiers,
61 KeyboardLayoutEngine* keyboard_layout_engine, 61 KeyboardLayoutEngine* keyboard_layout_engine,
62 const EventDispatchCallback& callback) 62 const EventDispatchCallback& callback)
(...skipping 24 matching lines...) Expand all
87 key_state_.set(key, down); 87 key_state_.set(key, down);
88 UpdateKeyRepeat(key, down, suppress_auto_repeat, device_id); 88 UpdateKeyRepeat(key, down, suppress_auto_repeat, device_id);
89 DispatchKey(key, down, is_repeat, timestamp, device_id); 89 DispatchKey(key, down, is_repeat, timestamp, device_id);
90 } 90 }
91 91
92 void KeyboardEvdev::SetCapsLockEnabled(bool enabled) { 92 void KeyboardEvdev::SetCapsLockEnabled(bool enabled) {
93 modifiers_->SetModifierLock(EVDEV_MODIFIER_CAPS_LOCK, enabled); 93 modifiers_->SetModifierLock(EVDEV_MODIFIER_CAPS_LOCK, enabled);
94 } 94 }
95 95
96 bool KeyboardEvdev::IsCapsLockEnabled() { 96 bool KeyboardEvdev::IsCapsLockEnabled() {
97 return (modifiers_->GetModifierFlags() & EF_CAPS_LOCK_DOWN) != 0; 97 return (modifiers_->GetModifierFlags() & EF_CAPS_LOCK_ON) != 0;
98 } 98 }
99 99
100 bool KeyboardEvdev::IsAutoRepeatEnabled() { 100 bool KeyboardEvdev::IsAutoRepeatEnabled() {
101 return auto_repeat_enabled_; 101 return auto_repeat_enabled_;
102 } 102 }
103 103
104 void KeyboardEvdev::SetAutoRepeatEnabled(bool enabled) { 104 void KeyboardEvdev::SetAutoRepeatEnabled(bool enabled) {
105 auto_repeat_enabled_ = enabled; 105 auto_repeat_enabled_ = enabled;
106 } 106 }
107 107
(...skipping 18 matching lines...) Expand all
126 void KeyboardEvdev::UpdateModifier(int modifier_flag, bool down) { 126 void KeyboardEvdev::UpdateModifier(int modifier_flag, bool down) {
127 if (modifier_flag == EF_NONE) 127 if (modifier_flag == EF_NONE)
128 return; 128 return;
129 129
130 int modifier = EventFlagToEvdevModifier(modifier_flag); 130 int modifier = EventFlagToEvdevModifier(modifier_flag);
131 if (modifier == EVDEV_MODIFIER_NONE) 131 if (modifier == EVDEV_MODIFIER_NONE)
132 return; 132 return;
133 133
134 // TODO post-X11: Revise remapping to not use EF_MOD3_DOWN. 134 // TODO post-X11: Revise remapping to not use EF_MOD3_DOWN.
135 // Currently EF_MOD3_DOWN means that the CapsLock key is currently down, 135 // Currently EF_MOD3_DOWN means that the CapsLock key is currently down,
136 // and EF_CAPS_LOCK_DOWN means the caps lock state is enabled (and the 136 // and EF_CAPS_LOCK_ON means the caps lock state is enabled (and the
137 // key may or may not be down, but usually isn't). There does need to 137 // key may or may not be down, but usually isn't). There does need to
138 // to be two different flags, since the physical CapsLock key is subject 138 // to be two different flags, since the physical CapsLock key is subject
139 // to remapping, but the caps lock state (which can be triggered in a 139 // to remapping, but the caps lock state (which can be triggered in a
140 // variety of ways) is not. 140 // variety of ways) is not.
141 if (modifier == EVDEV_MODIFIER_CAPS_LOCK) 141 if (modifier == EVDEV_MODIFIER_CAPS_LOCK)
142 modifiers_->UpdateModifier(EVDEV_MODIFIER_MOD3, down); 142 modifiers_->UpdateModifier(EVDEV_MODIFIER_MOD3, down);
143 else 143 else
144 modifiers_->UpdateModifier(modifier, down); 144 modifiers_->UpdateModifier(modifier, down);
145 } 145 }
146 146
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 UpdateModifier(flag, down); 239 UpdateModifier(flag, down);
240 } 240 }
241 241
242 KeyEvent event(down ? ET_KEY_PRESSED : ET_KEY_RELEASED, key_code, dom_code, 242 KeyEvent event(down ? ET_KEY_PRESSED : ET_KEY_RELEASED, key_code, dom_code,
243 modifiers_->GetModifierFlags(), dom_key, timestamp); 243 modifiers_->GetModifierFlags(), dom_key, timestamp);
244 event.set_source_device_id(device_id); 244 event.set_source_device_id(device_id);
245 callback_.Run(&event); 245 callback_.Run(&event);
246 } 246 }
247 247
248 } // namespace ui 248 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/ozone/evdev/event_modifiers_evdev.cc ('k') | ui/events/ozone/layout/layout_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698