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

Side by Side Diff: ui/events/test/events_test_utils_x11.cc

Issue 336403005: Use XInput2 events for keyboard events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments (sadrul) 3 Created 6 years, 5 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/test/events_test_utils_x11.h ('k') | ui/events/x/events_x.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/test/events_test_utils_x11.h" 5 #include "ui/events/test/events_test_utils_x11.h"
6 6
7 #include <X11/extensions/XI2.h> 7 #include <X11/extensions/XI2.h>
8 #include <X11/keysym.h> 8 #include <X11/keysym.h>
9 #include <X11/X.h> 9 #include <X11/X.h>
10 #include <X11/Xlib.h> 10 #include <X11/Xlib.h>
(...skipping 27 matching lines...) Expand all
38 switch (type) { 38 switch (type) {
39 case ui::ET_KEY_PRESSED: 39 case ui::ET_KEY_PRESSED:
40 return KeyPress; 40 return KeyPress;
41 case ui::ET_KEY_RELEASED: 41 case ui::ET_KEY_RELEASED:
42 return KeyRelease; 42 return KeyRelease;
43 default: 43 default:
44 return 0; 44 return 0;
45 } 45 }
46 } 46 }
47 47
48 // Converts EventType to XI2 event type.
49 int XIKeyEventType(ui::EventType type) {
50 switch (type) {
51 case ui::ET_KEY_PRESSED:
52 return XI_KeyPress;
53 case ui::ET_KEY_RELEASED:
54 return XI_KeyRelease;
55 default:
56 return 0;
57 }
58 }
59
48 int XIButtonEventType(ui::EventType type) { 60 int XIButtonEventType(ui::EventType type) {
49 switch (type) { 61 switch (type) {
50 case ui::ET_MOUSEWHEEL: 62 case ui::ET_MOUSEWHEEL:
51 case ui::ET_MOUSE_PRESSED: 63 case ui::ET_MOUSE_PRESSED:
52 // The button release X events for mouse wheels are dropped by Aura. 64 // The button release X events for mouse wheels are dropped by Aura.
53 return XI_ButtonPress; 65 return XI_ButtonPress;
54 case ui::ET_MOUSE_RELEASED: 66 case ui::ET_MOUSE_RELEASED:
55 return XI_ButtonRelease; 67 return XI_ButtonRelease;
56 default: 68 default:
57 NOTREACHED(); 69 NOTREACHED();
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 event_->xkey.subwindow = 0; 174 event_->xkey.subwindow = 0;
163 event_->xkey.x = 0; 175 event_->xkey.x = 0;
164 event_->xkey.y = 0; 176 event_->xkey.y = 0;
165 event_->xkey.x_root = 0; 177 event_->xkey.x_root = 0;
166 event_->xkey.y_root = 0; 178 event_->xkey.y_root = 0;
167 event_->xkey.state = XEventState(flags); 179 event_->xkey.state = XEventState(flags);
168 event_->xkey.keycode = XKeyEventKeyCode(key_code, flags, display); 180 event_->xkey.keycode = XKeyEventKeyCode(key_code, flags, display);
169 event_->xkey.same_screen = 1; 181 event_->xkey.same_screen = 1;
170 } 182 }
171 183
184 void ScopedXI2Event::InitGenericKeyEvent(int deviceid,
185 EventType type,
186 KeyboardCode key_code,
187 int flags) {
188 event_.reset(
189 CreateXInput2Event(deviceid, XIKeyEventType(type), 0, gfx::Point()));
190 XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(event_->xcookie.data);
191 CHECK_NE(0, xievent->evtype);
192 XDisplay* display = gfx::GetXDisplay();
193 event_->xgeneric.display = display;
194 xievent->display = display;
195 xievent->mods.effective = XEventState(flags);
196 xievent->detail = XKeyEventKeyCode(key_code, flags, display);
197 }
198
172 void ScopedXI2Event::InitGenericButtonEvent(int deviceid, 199 void ScopedXI2Event::InitGenericButtonEvent(int deviceid,
173 EventType type, 200 EventType type,
174 const gfx::Point& location, 201 const gfx::Point& location,
175 int flags) { 202 int flags) {
176 event_.reset(CreateXInput2Event(deviceid, 203 event_.reset(CreateXInput2Event(deviceid,
177 XIButtonEventType(type), 0, gfx::Point())); 204 XIButtonEventType(type), 0, gfx::Point()));
178 XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(event_->xcookie.data); 205 XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(event_->xcookie.data);
179 xievent->mods.effective = XEventState(flags); 206 xievent->mods.effective = XEventState(flags);
180 xievent->detail = XButtonEventButton(type, flags); 207 xievent->detail = XButtonEventButton(type, flags);
181 xievent->event_x = location.x(); 208 xievent->event_x = location.x();
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 manager->SetDeviceListForTest(std::vector<unsigned int>(), device_list); 304 manager->SetDeviceListForTest(std::vector<unsigned int>(), device_list);
278 } 305 }
279 306
280 void SetUpTouchDevicesForTest(const std::vector<unsigned int>& devices) { 307 void SetUpTouchDevicesForTest(const std::vector<unsigned int>& devices) {
281 TouchFactory::GetInstance()->SetTouchDeviceForTest(devices); 308 TouchFactory::GetInstance()->SetTouchDeviceForTest(devices);
282 ui::DeviceDataManagerX11* manager = ui::DeviceDataManagerX11::GetInstance(); 309 ui::DeviceDataManagerX11* manager = ui::DeviceDataManagerX11::GetInstance();
283 manager->SetDeviceListForTest(devices, std::vector<unsigned int>()); 310 manager->SetDeviceListForTest(devices, std::vector<unsigned int>());
284 } 311 }
285 312
286 } // namespace ui 313 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/test/events_test_utils_x11.h ('k') | ui/events/x/events_x.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698