| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/event_constants.h" | 5 #include "ui/base/events/event_constants.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 #include <X11/extensions/XInput.h> | 8 #include <X11/extensions/XInput.h> |
| 9 #include <X11/extensions/XInput2.h> | 9 #include <X11/extensions/XInput2.h> |
| 10 #include <X11/Xlib.h> | 10 #include <X11/Xlib.h> |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #include "ui/gfx/screen.h" | 29 #include "ui/gfx/screen.h" |
| 30 | 30 |
| 31 // Copied from xserver-properties.h | 31 // Copied from xserver-properties.h |
| 32 #define AXIS_LABEL_PROP_REL_HWHEEL "Rel Horiz Wheel" | 32 #define AXIS_LABEL_PROP_REL_HWHEEL "Rel Horiz Wheel" |
| 33 #define AXIS_LABEL_PROP_REL_WHEEL "Rel Vert Wheel" | 33 #define AXIS_LABEL_PROP_REL_WHEEL "Rel Vert Wheel" |
| 34 | 34 |
| 35 // CMT specific timings | 35 // CMT specific timings |
| 36 #define AXIS_LABEL_PROP_ABS_START_TIME "Abs Start Timestamp" | 36 #define AXIS_LABEL_PROP_ABS_START_TIME "Abs Start Timestamp" |
| 37 #define AXIS_LABEL_PROP_ABS_END_TIME "Abs End Timestamp" | 37 #define AXIS_LABEL_PROP_ABS_END_TIME "Abs End Timestamp" |
| 38 | 38 |
| 39 // Ordinal values |
| 40 #define AXIS_LABEL_PROP_ABS_DBL_ORDINAL_X "Abs Dbl Ordinal X" |
| 41 #define AXIS_LABEL_PROP_ABS_DBL_ORDINAL_Y "Abs Dbl Ordinal Y" |
| 42 |
| 39 // Fling properties | 43 // Fling properties |
| 40 #define AXIS_LABEL_PROP_ABS_FLING_X "Abs Fling X Velocity" | 44 #define AXIS_LABEL_PROP_ABS_FLING_X "Abs Fling X Velocity" |
| 41 #define AXIS_LABEL_PROP_ABS_FLING_Y "Abs Fling Y Velocity" | 45 #define AXIS_LABEL_PROP_ABS_FLING_Y "Abs Fling Y Velocity" |
| 42 #define AXIS_LABEL_PROP_ABS_FLING_STATE "Abs Fling State" | 46 #define AXIS_LABEL_PROP_ABS_FLING_STATE "Abs Fling State" |
| 43 | 47 |
| 44 #define AXIS_LABEL_PROP_ABS_FINGER_COUNT "Abs Finger Count" | 48 #define AXIS_LABEL_PROP_ABS_FINGER_COUNT "Abs Finger Count" |
| 45 | 49 |
| 46 // New versions of the valuators, with double values instead of fixed point. | 50 // New versions of the valuators, with double values instead of fixed point. |
| 47 #define AXIS_LABEL_PROP_ABS_DBL_START_TIME "Abs Dbl Start Timestamp" | 51 #define AXIS_LABEL_PROP_ABS_DBL_START_TIME "Abs Dbl Start Timestamp" |
| 48 #define AXIS_LABEL_PROP_ABS_DBL_END_TIME "Abs Dbl End Timestamp" | 52 #define AXIS_LABEL_PROP_ABS_DBL_END_TIME "Abs Dbl End Timestamp" |
| 49 #define AXIS_LABEL_PROP_ABS_DBL_FLING_VX "Abs Dbl Fling X Velocity" | 53 #define AXIS_LABEL_PROP_ABS_DBL_FLING_VX "Abs Dbl Fling X Velocity" |
| 50 #define AXIS_LABEL_PROP_ABS_DBL_FLING_VY "Abs Dbl Fling Y Velocity" | 54 #define AXIS_LABEL_PROP_ABS_DBL_FLING_VY "Abs Dbl Fling Y Velocity" |
| 51 | 55 |
| 52 namespace { | 56 namespace { |
| 53 | 57 |
| 54 // Scroll amount for each wheelscroll event. 53 is also the value used for GTK+. | 58 // Scroll amount for each wheelscroll event. 53 is also the value used for GTK+. |
| 55 const int kWheelScrollAmount = 53; | 59 const int kWheelScrollAmount = 53; |
| 56 | 60 |
| 57 const int kMinWheelButton = 4; | 61 const int kMinWheelButton = 4; |
| 58 const int kMaxWheelButton = 7; | 62 const int kMaxWheelButton = 7; |
| 59 | 63 |
| 60 const char* kCMTCachedAtoms[] = { | 64 const char* kCMTCachedAtoms[] = { |
| 65 AXIS_LABEL_PROP_ABS_DBL_ORDINAL_X, |
| 66 AXIS_LABEL_PROP_ABS_DBL_ORDINAL_Y, |
| 61 AXIS_LABEL_PROP_REL_HWHEEL, | 67 AXIS_LABEL_PROP_REL_HWHEEL, |
| 62 AXIS_LABEL_PROP_REL_WHEEL, | 68 AXIS_LABEL_PROP_REL_WHEEL, |
| 63 AXIS_LABEL_PROP_ABS_START_TIME, | 69 AXIS_LABEL_PROP_ABS_START_TIME, |
| 64 AXIS_LABEL_PROP_ABS_DBL_START_TIME, | 70 AXIS_LABEL_PROP_ABS_DBL_START_TIME, |
| 65 AXIS_LABEL_PROP_ABS_END_TIME, | 71 AXIS_LABEL_PROP_ABS_END_TIME, |
| 66 AXIS_LABEL_PROP_ABS_DBL_END_TIME, | 72 AXIS_LABEL_PROP_ABS_DBL_END_TIME, |
| 67 AXIS_LABEL_PROP_ABS_FLING_X, | 73 AXIS_LABEL_PROP_ABS_FLING_X, |
| 68 AXIS_LABEL_PROP_ABS_FLING_Y, | 74 AXIS_LABEL_PROP_ABS_FLING_Y, |
| 69 AXIS_LABEL_PROP_ABS_DBL_FLING_VX, | 75 AXIS_LABEL_PROP_ABS_DBL_FLING_VX, |
| 70 AXIS_LABEL_PROP_ABS_DBL_FLING_VY, | 76 AXIS_LABEL_PROP_ABS_DBL_FLING_VY, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 ui::DeviceListCacheX::GetInstance()->GetXDeviceList(display); | 110 ui::DeviceListCacheX::GetInstance()->GetXDeviceList(display); |
| 105 Atom xi_touchpad = XInternAtom(display, XI_TOUCHPAD, false); | 111 Atom xi_touchpad = XInternAtom(display, XI_TOUCHPAD, false); |
| 106 for (int i = 0; i < dev_list.count; ++i) | 112 for (int i = 0; i < dev_list.count; ++i) |
| 107 if (dev_list[i].type == xi_touchpad) | 113 if (dev_list[i].type == xi_touchpad) |
| 108 touchpads_[dev_list[i].id] = true; | 114 touchpads_[dev_list[i].id] = true; |
| 109 | 115 |
| 110 XIDeviceList info_list = | 116 XIDeviceList info_list = |
| 111 ui::DeviceListCacheX::GetInstance()->GetXI2DeviceList(display); | 117 ui::DeviceListCacheX::GetInstance()->GetXI2DeviceList(display); |
| 112 Atom x_axis = atom_cache_.GetAtom(AXIS_LABEL_PROP_REL_HWHEEL); | 118 Atom x_axis = atom_cache_.GetAtom(AXIS_LABEL_PROP_REL_HWHEEL); |
| 113 Atom y_axis = atom_cache_.GetAtom(AXIS_LABEL_PROP_REL_WHEEL); | 119 Atom y_axis = atom_cache_.GetAtom(AXIS_LABEL_PROP_REL_WHEEL); |
| 120 Atom x_ordinal = atom_cache_.GetAtom(AXIS_LABEL_PROP_ABS_DBL_ORDINAL_X); |
| 121 Atom y_ordinal = atom_cache_.GetAtom(AXIS_LABEL_PROP_ABS_DBL_ORDINAL_Y); |
| 114 Atom start_time = atom_cache_.GetAtom(AXIS_LABEL_PROP_ABS_START_TIME); | 122 Atom start_time = atom_cache_.GetAtom(AXIS_LABEL_PROP_ABS_START_TIME); |
| 115 Atom start_time_dbl = | 123 Atom start_time_dbl = |
| 116 atom_cache_.GetAtom(AXIS_LABEL_PROP_ABS_DBL_START_TIME); | 124 atom_cache_.GetAtom(AXIS_LABEL_PROP_ABS_DBL_START_TIME); |
| 117 Atom end_time = atom_cache_.GetAtom(AXIS_LABEL_PROP_ABS_END_TIME); | 125 Atom end_time = atom_cache_.GetAtom(AXIS_LABEL_PROP_ABS_END_TIME); |
| 118 Atom end_time_dbl = atom_cache_.GetAtom(AXIS_LABEL_PROP_ABS_DBL_END_TIME); | 126 Atom end_time_dbl = atom_cache_.GetAtom(AXIS_LABEL_PROP_ABS_DBL_END_TIME); |
| 119 Atom fling_vx = atom_cache_.GetAtom(AXIS_LABEL_PROP_ABS_FLING_X); | 127 Atom fling_vx = atom_cache_.GetAtom(AXIS_LABEL_PROP_ABS_FLING_X); |
| 120 Atom fling_vx_dbl = atom_cache_.GetAtom(AXIS_LABEL_PROP_ABS_DBL_FLING_VX); | 128 Atom fling_vx_dbl = atom_cache_.GetAtom(AXIS_LABEL_PROP_ABS_DBL_FLING_VX); |
| 121 Atom fling_vy = atom_cache_.GetAtom(AXIS_LABEL_PROP_ABS_FLING_Y); | 129 Atom fling_vy = atom_cache_.GetAtom(AXIS_LABEL_PROP_ABS_FLING_Y); |
| 122 Atom fling_vy_dbl = atom_cache_.GetAtom(AXIS_LABEL_PROP_ABS_DBL_FLING_VY); | 130 Atom fling_vy_dbl = atom_cache_.GetAtom(AXIS_LABEL_PROP_ABS_DBL_FLING_VY); |
| 123 Atom fling_state = atom_cache_.GetAtom(AXIS_LABEL_PROP_ABS_FLING_STATE); | 131 Atom fling_state = atom_cache_.GetAtom(AXIS_LABEL_PROP_ABS_FLING_STATE); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 143 reinterpret_cast<XIValuatorClassInfo*>(info->classes[j]); | 151 reinterpret_cast<XIValuatorClassInfo*>(info->classes[j]); |
| 144 int number = v->number; | 152 int number = v->number; |
| 145 if (number > valuators.max) | 153 if (number > valuators.max) |
| 146 valuators.max = number; | 154 valuators.max = number; |
| 147 if (v->label == x_axis) { | 155 if (v->label == x_axis) { |
| 148 valuators.scroll_x = number; | 156 valuators.scroll_x = number; |
| 149 is_cmt = true; | 157 is_cmt = true; |
| 150 } else if (v->label == y_axis) { | 158 } else if (v->label == y_axis) { |
| 151 valuators.scroll_y = number; | 159 valuators.scroll_y = number; |
| 152 is_cmt = true; | 160 is_cmt = true; |
| 161 } else if (v->label == x_ordinal) { |
| 162 valuators.ordinal_x = number; |
| 163 is_cmt = true; |
| 164 } else if (v->label == y_ordinal) { |
| 165 valuators.ordinal_y = number; |
| 166 is_cmt = true; |
| 153 } else if (v->label == finger_count) { | 167 } else if (v->label == finger_count) { |
| 154 valuators.finger_count = number; | 168 valuators.finger_count = number; |
| 155 is_cmt = true; | 169 is_cmt = true; |
| 156 } else if (v->label == start_time) { | 170 } else if (v->label == start_time) { |
| 157 valuators.start_time = number; | 171 valuators.start_time = number; |
| 158 is_cmt = true; | 172 is_cmt = true; |
| 159 } else if (v->label == start_time_dbl) { | 173 } else if (v->label == start_time_dbl) { |
| 160 valuators.start_time_dbl = number; | 174 valuators.start_time_dbl = number; |
| 161 is_cmt = true; | 175 is_cmt = true; |
| 162 } else if (v->label == end_time) { | 176 } else if (v->label == end_time) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 | 234 |
| 221 return natural_scroll_enabled_ ? 1.0f : -1.0f; | 235 return natural_scroll_enabled_ ? 1.0f : -1.0f; |
| 222 } | 236 } |
| 223 | 237 |
| 224 // Returns true if this is a scroll event (a motion event with the necessary | 238 // Returns true if this is a scroll event (a motion event with the necessary |
| 225 // valuators. Also returns the offsets. |x_offset| and |y_offset| can be | 239 // valuators. Also returns the offsets. |x_offset| and |y_offset| can be |
| 226 // NULL. | 240 // NULL. |
| 227 bool GetScrollOffsets(const XEvent& xev, | 241 bool GetScrollOffsets(const XEvent& xev, |
| 228 float* x_offset, | 242 float* x_offset, |
| 229 float* y_offset, | 243 float* y_offset, |
| 244 float* x_offset_ordinal, |
| 245 float* y_offset_ordinal, |
| 230 int* finger_count) { | 246 int* finger_count) { |
| 231 XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(xev.xcookie.data); | 247 XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(xev.xcookie.data); |
| 232 | 248 |
| 233 if (x_offset) | 249 if (x_offset) |
| 234 *x_offset = 0; | 250 *x_offset = 0; |
| 235 if (y_offset) | 251 if (y_offset) |
| 236 *y_offset = 0; | 252 *y_offset = 0; |
| 237 if (finger_count) | 253 if (x_offset_ordinal) |
| 254 *x_offset_ordinal = 0; |
| 255 if (y_offset_ordinal) |
| 256 *y_offset_ordinal = 0; |
| 257 if (finger_count) |
| 238 *finger_count = 2; | 258 *finger_count = 2; |
| 239 | 259 |
| 240 const int sourceid = xiev->sourceid; | 260 const int sourceid = xiev->sourceid; |
| 241 if (!cmt_devices_[sourceid]) | 261 if (!cmt_devices_[sourceid]) |
| 242 return false; | 262 return false; |
| 243 | 263 |
| 244 const float natural_scroll_factor = GetNaturalScrollFactor(sourceid); | 264 const float natural_scroll_factor = GetNaturalScrollFactor(sourceid); |
| 245 const Valuators v = device_to_valuators_[sourceid]; | 265 const Valuators v = device_to_valuators_[sourceid]; |
| 246 const bool has_x_offset = XIMaskIsSet(xiev->valuators.mask, v.scroll_x); | 266 const bool has_x_offset = XIMaskIsSet(xiev->valuators.mask, v.scroll_x); |
| 247 const bool has_y_offset = XIMaskIsSet(xiev->valuators.mask, v.scroll_y); | 267 const bool has_y_offset = XIMaskIsSet(xiev->valuators.mask, v.scroll_y); |
| 248 const bool is_scroll = has_x_offset || has_y_offset; | 268 const bool is_scroll = has_x_offset || has_y_offset; |
| 249 | 269 |
| 250 if (!is_scroll || (!x_offset && !y_offset)) | 270 if (!is_scroll || (!x_offset && !y_offset)) |
| 251 return is_scroll; | 271 return is_scroll; |
| 252 | 272 |
| 253 double* valuators = xiev->valuators.values; | 273 double* valuators = xiev->valuators.values; |
| 254 for (int i = 0; i <= v.max; ++i) { | 274 for (int i = 0; i <= v.max; ++i) { |
| 255 if (XIMaskIsSet(xiev->valuators.mask, i)) { | 275 if (XIMaskIsSet(xiev->valuators.mask, i)) { |
| 256 if (x_offset && v.scroll_x == i) | 276 if (x_offset && v.scroll_x == i) |
| 257 *x_offset = *valuators * natural_scroll_factor; | 277 *x_offset = *valuators * natural_scroll_factor; |
| 258 else if (y_offset && v.scroll_y == i) | 278 else if (y_offset && v.scroll_y == i) |
| 259 *y_offset = *valuators * natural_scroll_factor; | 279 *y_offset = *valuators * natural_scroll_factor; |
| 280 else if (x_offset_ordinal && v.ordinal_x == i) |
| 281 *x_offset_ordinal = *valuators * natural_scroll_factor; |
| 282 else if (y_offset_ordinal && v.ordinal_y == i) |
| 283 *y_offset_ordinal = *valuators * natural_scroll_factor; |
| 260 else if (finger_count && v.finger_count == i) | 284 else if (finger_count && v.finger_count == i) |
| 261 *finger_count = static_cast<int>(*valuators); | 285 *finger_count = static_cast<int>(*valuators); |
| 262 valuators++; | 286 valuators++; |
| 263 } | 287 } |
| 264 } | 288 } |
| 265 | 289 |
| 266 return true; | 290 return true; |
| 267 } | 291 } |
| 268 | 292 |
| 269 bool GetFlingData(const XEvent& xev, | 293 bool GetFlingData(const XEvent& xev, |
| 270 float* vx, float* vy, | 294 float* vx, float* vy, |
| 295 float* vx_ordinal, float* vy_ordinal, |
| 271 bool* is_cancel) { | 296 bool* is_cancel) { |
| 272 XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(xev.xcookie.data); | 297 XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(xev.xcookie.data); |
| 273 | 298 |
| 274 *vx = 0; | 299 if (vx) |
| 275 *vy = 0; | 300 *vx = 0; |
| 276 *is_cancel = false; | 301 if (vy) |
| 302 *vy = 0; |
| 303 if (vx_ordinal) |
| 304 *vx_ordinal = 0; |
| 305 if (vy_ordinal) |
| 306 *vy_ordinal = 0; |
| 307 if (is_cancel) |
| 308 *is_cancel = false; |
| 277 | 309 |
| 278 const int sourceid = xiev->sourceid; | 310 const int sourceid = xiev->sourceid; |
| 279 if (!cmt_devices_[sourceid]) | 311 if (!cmt_devices_[sourceid]) |
| 280 return false; | 312 return false; |
| 281 | 313 |
| 282 const float natural_scroll_factor = GetNaturalScrollFactor(sourceid); | 314 const float natural_scroll_factor = GetNaturalScrollFactor(sourceid); |
| 283 const Valuators v = device_to_valuators_[sourceid]; | 315 const Valuators v = device_to_valuators_[sourceid]; |
| 284 if ((!XIMaskIsSet(xiev->valuators.mask, v.fling_vx) && | 316 if ((!XIMaskIsSet(xiev->valuators.mask, v.fling_vx) && |
| 285 !XIMaskIsSet(xiev->valuators.mask, v.fling_vx_dbl)) || | 317 !XIMaskIsSet(xiev->valuators.mask, v.fling_vx_dbl)) || |
| 286 (!XIMaskIsSet(xiev->valuators.mask, v.fling_vy) && | 318 (!XIMaskIsSet(xiev->valuators.mask, v.fling_vy) && |
| 287 !XIMaskIsSet(xiev->valuators.mask, v.fling_vy_dbl)) || | 319 !XIMaskIsSet(xiev->valuators.mask, v.fling_vy_dbl)) || |
| 288 !XIMaskIsSet(xiev->valuators.mask, v.fling_state)) | 320 !XIMaskIsSet(xiev->valuators.mask, v.fling_state)) |
| 289 return false; | 321 return false; |
| 290 | 322 |
| 291 double* valuators = xiev->valuators.values; | 323 double* valuators = xiev->valuators.values; |
| 292 for (int i = 0; i <= v.max; ++i) { | 324 for (int i = 0; i <= v.max; ++i) { |
| 293 if (XIMaskIsSet(xiev->valuators.mask, i)) { | 325 if (XIMaskIsSet(xiev->valuators.mask, i)) { |
| 294 // Convert values to unsigned ints representing ms before storing them, | 326 // Convert values to unsigned ints representing ms before storing them, |
| 295 // as that is how they were encoded before conversion to doubles. | 327 // as that is how they were encoded before conversion to doubles. |
| 296 if (v.fling_vx_dbl == i) { | 328 if (vx && v.fling_vx_dbl == i) { |
| 297 *vx = natural_scroll_factor * *valuators; | 329 *vx = natural_scroll_factor * *valuators; |
| 298 } else if (v.fling_vx == i) { | 330 } else if (vx && v.fling_vx == i) { |
| 299 *vx = natural_scroll_factor * | 331 *vx = natural_scroll_factor * |
| 300 static_cast<double>(static_cast<int>(*valuators)) / 1000.0f; | 332 static_cast<double>(static_cast<int>(*valuators)) / 1000.0f; |
| 301 } else if (v.fling_vy_dbl == i) { | 333 } else if (vy && v.fling_vy_dbl == i) { |
| 302 *vy = natural_scroll_factor * *valuators; | 334 *vy = natural_scroll_factor * *valuators; |
| 303 } else if (v.fling_vy == i) { | 335 } else if (vy && v.fling_vy == i) { |
| 304 *vy = natural_scroll_factor * | 336 *vy = natural_scroll_factor * |
| 305 static_cast<double>(static_cast<int>(*valuators)) / 1000.0f; | 337 static_cast<double>(static_cast<int>(*valuators)) / 1000.0f; |
| 306 } else if (v.fling_state == i) { | 338 } else if (is_cancel && v.fling_state == i) { |
| 307 *is_cancel = !!static_cast<unsigned int>(*valuators); | 339 *is_cancel = !!static_cast<unsigned int>(*valuators); |
| 340 } else if (vx_ordinal && v.ordinal_x == i) { |
| 341 *vx_ordinal = *valuators * natural_scroll_factor; |
| 342 } else if (vy_ordinal && v.ordinal_y == i) { |
| 343 *vy_ordinal = *valuators * natural_scroll_factor; |
| 308 } | 344 } |
| 309 valuators++; | 345 valuators++; |
| 310 } | 346 } |
| 311 } | 347 } |
| 312 | 348 |
| 313 return true; | 349 return true; |
| 314 } | 350 } |
| 315 | 351 |
| 316 bool GetGestureTimes(const XEvent& xev, | 352 bool GetGestureTimes(const XEvent& xev, |
| 317 double* start_time, | 353 double* start_time, |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 } | 396 } |
| 361 | 397 |
| 362 private: | 398 private: |
| 363 // Requirement for Singleton | 399 // Requirement for Singleton |
| 364 friend struct DefaultSingletonTraits<CMTEventData>; | 400 friend struct DefaultSingletonTraits<CMTEventData>; |
| 365 | 401 |
| 366 struct Valuators { | 402 struct Valuators { |
| 367 int max; | 403 int max; |
| 368 int scroll_x; | 404 int scroll_x; |
| 369 int scroll_y; | 405 int scroll_y; |
| 406 int ordinal_x; |
| 407 int ordinal_y; |
| 370 int finger_count; | 408 int finger_count; |
| 371 int start_time; | 409 int start_time; |
| 372 int end_time; | 410 int end_time; |
| 373 int fling_vx; | 411 int fling_vx; |
| 374 int fling_vy; | 412 int fling_vy; |
| 375 int fling_state; | 413 int fling_state; |
| 376 // *_dbl valuators take precedence over the fixed precision versions. | 414 // *_dbl valuators take precedence over the fixed precision versions. |
| 377 int start_time_dbl; | 415 int start_time_dbl; |
| 378 int end_time_dbl; | 416 int end_time_dbl; |
| 379 int fling_vx_dbl; | 417 int fling_vx_dbl; |
| 380 int fling_vy_dbl; | 418 int fling_vy_dbl; |
| 381 | 419 |
| 382 Valuators() | 420 Valuators() |
| 383 : max(-1), | 421 : max(-1), |
| 384 scroll_x(-1), | 422 scroll_x(-1), |
| 385 scroll_y(-1), | 423 scroll_y(-1), |
| 424 ordinal_x(-1), |
| 425 ordinal_y(-1), |
| 386 finger_count(-1), | 426 finger_count(-1), |
| 387 start_time(-1), | 427 start_time(-1), |
| 388 end_time(-1), | 428 end_time(-1), |
| 389 fling_vx(-1), | 429 fling_vx(-1), |
| 390 fling_vy(-1), | 430 fling_vy(-1), |
| 391 fling_state(-1), | 431 fling_state(-1), |
| 392 start_time_dbl(-1), | 432 start_time_dbl(-1), |
| 393 end_time_dbl(-1), | 433 end_time_dbl(-1), |
| 394 fling_vx_dbl(-1), | 434 fling_vx_dbl(-1), |
| 395 fling_vy_dbl(-1) { | 435 fling_vy_dbl(-1) { |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 return ET_MOUSE_PRESSED; | 823 return ET_MOUSE_PRESSED; |
| 784 } | 824 } |
| 785 case XI_ButtonRelease: { | 825 case XI_ButtonRelease: { |
| 786 int button = EventButtonFromNative(native_event); | 826 int button = EventButtonFromNative(native_event); |
| 787 // Drop wheel events; we should've already scrolled on the press. | 827 // Drop wheel events; we should've already scrolled on the press. |
| 788 if (button >= kMinWheelButton && button <= kMaxWheelButton) | 828 if (button >= kMinWheelButton && button <= kMaxWheelButton) |
| 789 return ET_UNKNOWN; | 829 return ET_UNKNOWN; |
| 790 return ET_MOUSE_RELEASED; | 830 return ET_MOUSE_RELEASED; |
| 791 } | 831 } |
| 792 case XI_Motion: { | 832 case XI_Motion: { |
| 793 float vx, vy; | |
| 794 bool is_cancel; | 833 bool is_cancel; |
| 795 if (GetFlingData(native_event, &vx, &vy, &is_cancel)) { | 834 if (GetFlingData(native_event, NULL, NULL, NULL, NULL, &is_cancel)) { |
| 796 return is_cancel ? ET_SCROLL_FLING_CANCEL : ET_SCROLL_FLING_START; | 835 return is_cancel ? ET_SCROLL_FLING_CANCEL : ET_SCROLL_FLING_START; |
| 797 } else if (GetScrollOffsets(native_event, NULL, NULL, NULL)) { | 836 } else if (GetScrollOffsets( |
| 837 native_event, NULL, NULL, NULL, NULL, NULL)) { |
| 798 return ET_SCROLL; | 838 return ET_SCROLL; |
| 799 } else if (GetButtonMaskForX2Event(xievent)) { | 839 } else if (GetButtonMaskForX2Event(xievent)) { |
| 800 return ET_MOUSE_DRAGGED; | 840 return ET_MOUSE_DRAGGED; |
| 801 } else { | 841 } else { |
| 802 return ET_MOUSE_MOVED; | 842 return ET_MOUSE_MOVED; |
| 803 } | 843 } |
| 804 } | 844 } |
| 805 } | 845 } |
| 806 } | 846 } |
| 807 default: | 847 default: |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1105 // Force is normalized to fall into [0, 1] | 1145 // Force is normalized to fall into [0, 1] |
| 1106 if (!ui::ValuatorTracker::GetInstance()->NormalizeValuator( | 1146 if (!ui::ValuatorTracker::GetInstance()->NormalizeValuator( |
| 1107 deviceid, ui::ValuatorTracker::VAL_PRESSURE, &force)) | 1147 deviceid, ui::ValuatorTracker::VAL_PRESSURE, &force)) |
| 1108 force = 0.0; | 1148 force = 0.0; |
| 1109 return force; | 1149 return force; |
| 1110 } | 1150 } |
| 1111 | 1151 |
| 1112 bool GetScrollOffsets(const base::NativeEvent& native_event, | 1152 bool GetScrollOffsets(const base::NativeEvent& native_event, |
| 1113 float* x_offset, | 1153 float* x_offset, |
| 1114 float* y_offset, | 1154 float* y_offset, |
| 1155 float* x_offset_ordinal, |
| 1156 float* y_offset_ordinal, |
| 1115 int* finger_count) { | 1157 int* finger_count) { |
| 1116 return CMTEventData::GetInstance()->GetScrollOffsets( | 1158 return CMTEventData::GetInstance()->GetScrollOffsets( |
| 1117 *native_event, x_offset, y_offset, finger_count); | 1159 *native_event, |
| 1160 x_offset, y_offset, |
| 1161 x_offset_ordinal, y_offset_ordinal, |
| 1162 finger_count); |
| 1118 } | 1163 } |
| 1119 | 1164 |
| 1120 bool GetFlingData(const base::NativeEvent& native_event, | 1165 bool GetFlingData(const base::NativeEvent& native_event, |
| 1121 float* vx, | 1166 float* vx, |
| 1122 float* vy, | 1167 float* vy, |
| 1168 float* vx_ordinal, |
| 1169 float* vy_ordinal, |
| 1123 bool* is_cancel) { | 1170 bool* is_cancel) { |
| 1124 return CMTEventData::GetInstance()->GetFlingData( | 1171 return CMTEventData::GetInstance()->GetFlingData( |
| 1125 *native_event, vx, vy, is_cancel); | 1172 *native_event, vx, vy, vx_ordinal, vy_ordinal, is_cancel); |
| 1126 } | 1173 } |
| 1127 | 1174 |
| 1128 bool GetGestureTimes(const base::NativeEvent& native_event, | 1175 bool GetGestureTimes(const base::NativeEvent& native_event, |
| 1129 double* start_time, | 1176 double* start_time, |
| 1130 double* end_time) { | 1177 double* end_time) { |
| 1131 return CMTEventData::GetInstance()->GetGestureTimes( | 1178 return CMTEventData::GetInstance()->GetGestureTimes( |
| 1132 *native_event, start_time, end_time); | 1179 *native_event, start_time, end_time); |
| 1133 } | 1180 } |
| 1134 | 1181 |
| 1135 void SetNaturalScroll(bool enabled) { | 1182 void SetNaturalScroll(bool enabled) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1159 noop->xclient.format = 8; | 1206 noop->xclient.format = 8; |
| 1160 DCHECK(!noop->xclient.display); | 1207 DCHECK(!noop->xclient.display); |
| 1161 } | 1208 } |
| 1162 // Make sure we use atom from current xdisplay, which may | 1209 // Make sure we use atom from current xdisplay, which may |
| 1163 // change during the test. | 1210 // change during the test. |
| 1164 noop->xclient.message_type = GetNoopEventAtom(); | 1211 noop->xclient.message_type = GetNoopEventAtom(); |
| 1165 return noop; | 1212 return noop; |
| 1166 } | 1213 } |
| 1167 | 1214 |
| 1168 } // namespace ui | 1215 } // namespace ui |
| OLD | NEW |