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

Side by Side Diff: ui/base/x/events_x.cc

Issue 8634009: aura: Turn XInput2 back on. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years 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 | Annotate | Revision Log
« no previous file with comments | « ui/aura/desktop_host_linux.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/base/events.h" 5 #include "ui/base/events.h"
6 6
7 #include <X11/Xlib.h> 7 #include <X11/Xlib.h>
8 #include <X11/extensions/XInput2.h> 8 #include <X11/extensions/XInput2.h>
9 #include <string.h> 9 #include <string.h>
10 10
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 gfx::Point EventLocationFromNative(const base::NativeEvent& native_event) { 249 gfx::Point EventLocationFromNative(const base::NativeEvent& native_event) {
250 switch (native_event->type) { 250 switch (native_event->type) {
251 case ButtonPress: 251 case ButtonPress:
252 case ButtonRelease: 252 case ButtonRelease:
253 return gfx::Point(native_event->xbutton.x, native_event->xbutton.y); 253 return gfx::Point(native_event->xbutton.x, native_event->xbutton.y);
254 case MotionNotify: 254 case MotionNotify:
255 return gfx::Point(native_event->xmotion.x, native_event->xmotion.y); 255 return gfx::Point(native_event->xmotion.x, native_event->xmotion.y);
256 case GenericEvent: { 256 case GenericEvent: {
257 XIDeviceEvent* xievent = 257 XIDeviceEvent* xievent =
258 static_cast<XIDeviceEvent*>(native_event->xcookie.data); 258 static_cast<XIDeviceEvent*>(native_event->xcookie.data);
259 return gfx::Point(static_cast<int>(xievent->event_x), 259
260 static_cast<int>(xievent->event_y)); 260 // Read the position from the valuators, because the location reported in
261 // event_x/event_y seems to be different (and doesn't match for events
262 // coming from slave device and master device) from the values in the
263 // valuators. See more on crbug.com/103981. The position in the valuators
264 // is in the global screen coordinates. But it is necessary to convert it
265 // into the window's coordinates. If the valuator is not set, that means
266 // the value hasn't changed, and so we can use the value from
267 // event_x/event_y (which are in the window's coordinates).
268 double* valuators = xievent->valuators.values;
269
270 double x = xievent->event_x;
271 if (XIMaskIsSet(xievent->valuators.mask, 0))
272 x = *valuators++ - (xievent->root_x - xievent->event_x);
273
274 double y = xievent->event_y;
275 if (XIMaskIsSet(xievent->valuators.mask, 1))
276 y = *valuators++ - (xievent->root_y - xievent->event_y);
277
278 return gfx::Point(static_cast<int>(x), static_cast<int>(y));
261 } 279 }
262 } 280 }
263 return gfx::Point(); 281 return gfx::Point();
264 } 282 }
265 283
266 KeyboardCode KeyboardCodeFromNative(const base::NativeEvent& native_event) { 284 KeyboardCode KeyboardCodeFromNative(const base::NativeEvent& native_event) {
267 return KeyboardCodeFromXKeyEvent(native_event); 285 return KeyboardCodeFromXKeyEvent(native_event);
268 } 286 }
269 287
270 bool IsMouseEvent(const base::NativeEvent& native_event) { 288 bool IsMouseEvent(const base::NativeEvent& native_event) {
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 // Make sure we use atom from current xdisplay, which may 398 // Make sure we use atom from current xdisplay, which may
381 // change during the test. 399 // change during the test.
382 noop->xclient.message_type = XInternAtom( 400 noop->xclient.message_type = XInternAtom(
383 base::MessagePumpX::GetDefaultXDisplay(), 401 base::MessagePumpX::GetDefaultXDisplay(),
384 "noop", False); 402 "noop", False);
385 #endif 403 #endif
386 return noop; 404 return noop;
387 } 405 }
388 406
389 } // namespace ui 407 } // namespace ui
OLDNEW
« no previous file with comments | « ui/aura/desktop_host_linux.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698