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

Side by Side Diff: views/events/event_x.cc

Issue 7792094: touchui: support XInput2 MT (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 3 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 | Annotate | Revision Log
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 "views/events/event.h" 5 #include "views/events/event.h"
6 6
7 #include <gdk/gdk.h> 7 #include <gdk/gdk.h>
8 #include <gdk/gdkx.h> 8 #include <gdk/gdkx.h>
9 #include <X11/extensions/XInput2.h> 9 #include <X11/extensions/XInput2.h>
10 #include <X11/Xlib.h> 10 #include <X11/Xlib.h>
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 69
70 for (int i = 0; i < 8 * xievent->buttons.mask_len; i++) { 70 for (int i = 0; i < 8 * xievent->buttons.mask_len; i++) {
71 if (XIMaskIsSet(xievent->buttons.mask, i)) { 71 if (XIMaskIsSet(xievent->buttons.mask, i)) {
72 buttonflags |= GetEventFlagsForButton(i); 72 buttonflags |= GetEventFlagsForButton(i);
73 } 73 }
74 } 74 }
75 75
76 return buttonflags; 76 return buttonflags;
77 } 77 }
78 78
79 int GetTouchIDFromXEvent(XEvent* xev) {
80 float id = 0;
81 if (!TouchFactory::GetInstance()->ExtractTouchParam(
82 *xev, TouchFactory::TP_TRACKING_ID, &id))
sadrul 2011/09/06 14:35:21 Are TRACKING_ID's recycled by XInput2.1? As far as
ningxin.hu 2011/09/07 08:49:58 With XI2.1, TRACKING_ID is increased for each new
83 LOG(ERROR) << "Could not get the touch ID for the event. Using 0.";
84 return id;
85 }
86
79 ui::EventType GetTouchEventType(XEvent* xev) { 87 ui::EventType GetTouchEventType(XEvent* xev) {
80 XGenericEventCookie* cookie = &xev->xcookie; 88 XIEvent* event = static_cast<XIEvent*>(xev->xcookie.data);
81 DCHECK_EQ(cookie->evtype, XI_Motion);
82
83 // Note: We will not generate a _STATIONARY event here. It will be created, 89 // Note: We will not generate a _STATIONARY event here. It will be created,
84 // when necessary, by a RWHVV. 90 // when necessary, by a RWHVV.
85 // TODO(sad): When should _CANCELLED be generated? 91 // TODO(sad): When should _CANCELLED be generated?
86 92
87 TouchFactory* factory = TouchFactory::GetInstance(); 93 switch(event->evtype) {
88 float slot; 94 case XI_TouchBegin:
89 if (!factory->ExtractTouchParam(*xev, TouchFactory::TP_SLOT_ID, &slot)) 95 return ui::ET_TOUCH_PRESSED;
90 return ui::ET_UNKNOWN; 96 case XI_TouchUpdate:
91 97 return ui::ET_TOUCH_MOVED;
92 if (!factory->IsSlotUsed(slot)) { 98 case XI_TouchEnd:
93 // This is a new touch point. 99 return ui::ET_TOUCH_RELEASED;
94 return ui::ET_TOUCH_PRESSED;
95 } 100 }
96 101
97 float tracking; 102 return ui::ET_UNKNOWN;
98 if (!factory->ExtractTouchParam(*xev, TouchFactory::TP_TRACKING_ID,
99 &tracking))
100 return ui::ET_UNKNOWN;
101
102 if (tracking == 0l) {
103 // The touch point has been released.
104 return ui::ET_TOUCH_RELEASED;
105 }
106
107 return ui::ET_TOUCH_MOVED;
108 }
109
110 int GetTouchIDFromXEvent(XEvent* xev) {
111 float slot = 0;
112 if (!TouchFactory::GetInstance()->ExtractTouchParam(
113 *xev, TouchFactory::TP_SLOT_ID, &slot))
114 LOG(ERROR) << "Could not get the slot ID for the event. Using 0.";
115 return slot;
116 } 103 }
117 104
118 ui::EventType EventTypeFromNative(NativeEvent2 native_event) { 105 ui::EventType EventTypeFromNative(NativeEvent2 native_event) {
119 switch (native_event->type) { 106 switch (native_event->type) {
120 case KeyPress: 107 case KeyPress:
121 return ui::ET_KEY_PRESSED; 108 return ui::ET_KEY_PRESSED;
122 case KeyRelease: 109 case KeyRelease:
123 return ui::ET_KEY_RELEASED; 110 return ui::ET_KEY_RELEASED;
124 case ButtonPress: 111 case ButtonPress:
125 if (native_event->xbutton.button == 4 || 112 if (native_event->xbutton.button == 4 ||
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 radius_x_(GetTouchParamFromXEvent(native_event_2, 383 radius_x_(GetTouchParamFromXEvent(native_event_2,
397 TouchFactory::TP_TOUCH_MAJOR, 384 TouchFactory::TP_TOUCH_MAJOR,
398 2.0) / 2.0), 385 2.0) / 2.0),
399 radius_y_(GetTouchParamFromXEvent(native_event_2, 386 radius_y_(GetTouchParamFromXEvent(native_event_2,
400 TouchFactory::TP_TOUCH_MINOR, 387 TouchFactory::TP_TOUCH_MINOR,
401 2.0) / 2.0), 388 2.0) / 2.0),
402 rotation_angle_(GetTouchParamFromXEvent(native_event_2, 389 rotation_angle_(GetTouchParamFromXEvent(native_event_2,
403 TouchFactory::TP_ORIENTATION, 390 TouchFactory::TP_ORIENTATION,
404 0.0)), 391 0.0)),
405 force_(GetTouchForceFromXEvent(native_event_2)) { 392 force_(GetTouchForceFromXEvent(native_event_2)) {
406 if (type() == ui::ET_TOUCH_PRESSED || type() == ui::ET_TOUCH_RELEASED) {
407 TouchFactory* factory = TouchFactory::GetInstance();
408 float slot;
409 if (factory->ExtractTouchParam(*native_event_2,
410 TouchFactory::TP_SLOT_ID, &slot)) {
411 factory->SetSlotUsed(slot, type() == ui::ET_TOUCH_PRESSED);
412 }
413 }
414 } 393 }
415 394
416 } // namespace views 395 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698