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

Side by Side Diff: ui/events/ozone/evdev/libgestures_glue/gesture_interpreter_libevdev_cros.cc

Issue 1017473002: [Merge] Make mouse buttons 8 - 11 navigate forward and back in history (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2311
Patch Set: Created 5 years, 9 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
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/libgestures_glue/gesture_interpreter_libevdev_cr os.h" 5 #include "ui/events/ozone/evdev/libgestures_glue/gesture_interpreter_libevdev_cr os.h"
6 6
7 #include <gestures/gestures.h> 7 #include <gestures/gestures.h>
8 #include <libevdev/libevdev.h> 8 #include <libevdev/libevdev.h>
9 #include <linux/input.h> 9 #include <linux/input.h>
10 10
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 hwstate.finger_cnt = current_finger; 194 hwstate.finger_cnt = current_finger;
195 hwstate.fingers = fingers; 195 hwstate.fingers = fingers;
196 196
197 // Buttons. 197 // Buttons.
198 if (Event_Get_Button_Left(evdev)) 198 if (Event_Get_Button_Left(evdev))
199 hwstate.buttons_down |= GESTURES_BUTTON_LEFT; 199 hwstate.buttons_down |= GESTURES_BUTTON_LEFT;
200 if (Event_Get_Button_Middle(evdev)) 200 if (Event_Get_Button_Middle(evdev))
201 hwstate.buttons_down |= GESTURES_BUTTON_MIDDLE; 201 hwstate.buttons_down |= GESTURES_BUTTON_MIDDLE;
202 if (Event_Get_Button_Right(evdev)) 202 if (Event_Get_Button_Right(evdev))
203 hwstate.buttons_down |= GESTURES_BUTTON_RIGHT; 203 hwstate.buttons_down |= GESTURES_BUTTON_RIGHT;
204 if (Event_Get_Button(evdev, BTN_SIDE) ||
205 Event_Get_Button(evdev, BTN_BACK)) {
206 hwstate.buttons_down |= GESTURES_BUTTON_BACK;
207 }
208 if (Event_Get_Button(evdev, BTN_EXTRA) ||
209 Event_Get_Button(evdev, BTN_FORWARD)) {
210 hwstate.buttons_down |= GESTURES_BUTTON_FORWARD;
211 }
204 212
205 GestureInterpreterPushHardwareState(interpreter_, &hwstate); 213 GestureInterpreterPushHardwareState(interpreter_, &hwstate);
206 } 214 }
207 215
208 void GestureInterpreterLibevdevCros::OnLibEvdevCrosStopped( 216 void GestureInterpreterLibevdevCros::OnLibEvdevCrosStopped(
209 Evdev* evdev, 217 Evdev* evdev,
210 EventStateRec* state) { 218 EventStateRec* state) {
211 stime_t timestamp = StimeNow(); 219 stime_t timestamp = StimeNow();
212 220
213 ReleaseKeys(timestamp); 221 ReleaseKeys(timestamp);
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 void GestureInterpreterLibevdevCros::OnGestureButtonsChange( 320 void GestureInterpreterLibevdevCros::OnGestureButtonsChange(
313 const Gesture* gesture, 321 const Gesture* gesture,
314 const GestureButtonsChange* buttons) { 322 const GestureButtonsChange* buttons) {
315 DVLOG(3) << base::StringPrintf("Gesture Button Change: down=0x%02x up=0x%02x", 323 DVLOG(3) << base::StringPrintf("Gesture Button Change: down=0x%02x up=0x%02x",
316 buttons->down, 324 buttons->down,
317 buttons->up); 325 buttons->up);
318 326
319 if (!cursor_) 327 if (!cursor_)
320 return; // No cursor! 328 return; // No cursor!
321 329
322 if (buttons->down & GESTURES_BUTTON_LEFT) 330 DispatchChangedMouseButtons(buttons->down, true, gesture->end_time);
323 DispatchMouseButton(BTN_LEFT, true, gesture->end_time); 331 DispatchChangedMouseButtons(buttons->up, false, gesture->end_time);
324 if (buttons->down & GESTURES_BUTTON_MIDDLE)
325 DispatchMouseButton(BTN_MIDDLE, true, gesture->end_time);
326 if (buttons->down & GESTURES_BUTTON_RIGHT)
327 DispatchMouseButton(BTN_RIGHT, true, gesture->end_time);
328 if (buttons->up & GESTURES_BUTTON_LEFT)
329 DispatchMouseButton(BTN_LEFT, false, gesture->end_time);
330 if (buttons->up & GESTURES_BUTTON_MIDDLE)
331 DispatchMouseButton(BTN_MIDDLE, false, gesture->end_time);
332 if (buttons->up & GESTURES_BUTTON_RIGHT)
333 DispatchMouseButton(BTN_RIGHT, false, gesture->end_time);
334 } 332 }
335 333
336 void GestureInterpreterLibevdevCros::OnGestureContactInitiated( 334 void GestureInterpreterLibevdevCros::OnGestureContactInitiated(
337 const Gesture* gesture) { 335 const Gesture* gesture) {
338 // TODO(spang): handle contact initiated. 336 // TODO(spang): handle contact initiated.
339 } 337 }
340 338
341 void GestureInterpreterLibevdevCros::OnGestureFling(const Gesture* gesture, 339 void GestureInterpreterLibevdevCros::OnGestureFling(const Gesture* gesture,
342 const GestureFling* fling) { 340 const GestureFling* fling) {
343 DVLOG(3) << base::StringPrintf( 341 DVLOG(3) << base::StringPrintf(
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 void GestureInterpreterLibevdevCros::OnGestureMetrics( 410 void GestureInterpreterLibevdevCros::OnGestureMetrics(
413 const Gesture* gesture, 411 const Gesture* gesture,
414 const GestureMetrics* metrics) { 412 const GestureMetrics* metrics) {
415 DVLOG(3) << base::StringPrintf("Gesture Metrics: [%f, %f] type=%d", 413 DVLOG(3) << base::StringPrintf("Gesture Metrics: [%f, %f] type=%d",
416 metrics->data[0], 414 metrics->data[0],
417 metrics->data[1], 415 metrics->data[1],
418 metrics->type); 416 metrics->type);
419 NOTIMPLEMENTED(); 417 NOTIMPLEMENTED();
420 } 418 }
421 419
420 void GestureInterpreterLibevdevCros::DispatchChangedMouseButtons(
421 unsigned int changed_buttons, bool down, stime_t time) {
422 if (changed_buttons & GESTURES_BUTTON_LEFT)
423 DispatchMouseButton(BTN_LEFT, down, time);
424 if (changed_buttons & GESTURES_BUTTON_MIDDLE)
425 DispatchMouseButton(BTN_MIDDLE, down, time);
426 if (changed_buttons & GESTURES_BUTTON_RIGHT)
427 DispatchMouseButton(BTN_RIGHT, down, time);
428 if (changed_buttons & GESTURES_BUTTON_BACK)
429 DispatchMouseButton(BTN_BACK, down, time);
430 if (changed_buttons & GESTURES_BUTTON_FORWARD)
431 DispatchMouseButton(BTN_FORWARD, down, time);
432 }
433
422 void GestureInterpreterLibevdevCros::DispatchMouseButton(unsigned int button, 434 void GestureInterpreterLibevdevCros::DispatchMouseButton(unsigned int button,
423 bool down, 435 bool down,
424 stime_t time) { 436 stime_t time) {
425 if (!SetMouseButtonState(button, down)) 437 if (!SetMouseButtonState(button, down))
426 return; // No change. 438 return; // No change.
427 439
428 bool allow_remap = is_mouse_; 440 bool allow_remap = is_mouse_;
429 dispatcher_->DispatchMouseButtonEvent( 441 dispatcher_->DispatchMouseButtonEvent(
430 MouseButtonEventParams(id_, cursor_->GetLocation(), button, down, 442 MouseButtonEventParams(id_, cursor_->GetLocation(), button, down,
431 allow_remap, StimeToTimedelta(time))); 443 allow_remap, StimeToTimedelta(time)));
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 488
477 bool GestureInterpreterLibevdevCros::SetMouseButtonState(unsigned int button, 489 bool GestureInterpreterLibevdevCros::SetMouseButtonState(unsigned int button,
478 bool down) { 490 bool down) {
479 DCHECK(BTN_MOUSE <= button && button < BTN_JOYSTICK); 491 DCHECK(BTN_MOUSE <= button && button < BTN_JOYSTICK);
480 int button_offset = button - BTN_MOUSE; 492 int button_offset = button - BTN_MOUSE;
481 493
482 if (mouse_button_state_.test(button_offset) == down) 494 if (mouse_button_state_.test(button_offset) == down)
483 return false; 495 return false;
484 496
485 // State transition: !(down) -> (down) 497 // State transition: !(down) -> (down)
486 if (down) 498 mouse_button_state_.set(button_offset, down);
487 mouse_button_state_.set(button_offset);
488 else
489 mouse_button_state_.reset(button_offset);
490 499
491 return true; 500 return true;
492 } 501 }
493 502
494 void GestureInterpreterLibevdevCros::ReleaseMouseButtons(stime_t timestamp) { 503 void GestureInterpreterLibevdevCros::ReleaseMouseButtons(stime_t timestamp) {
495 DispatchMouseButton(BTN_LEFT, false /* down */, timestamp); 504 DispatchMouseButton(BTN_LEFT, false /* down */, timestamp);
496 DispatchMouseButton(BTN_MIDDLE, false /* down */, timestamp); 505 DispatchMouseButton(BTN_MIDDLE, false /* down */, timestamp);
497 DispatchMouseButton(BTN_RIGHT, false /* down */, timestamp); 506 DispatchMouseButton(BTN_RIGHT, false /* down */, timestamp);
507 DispatchMouseButton(BTN_BACK, false /* down */, timestamp);
508 DispatchMouseButton(BTN_FORWARD, false /* down */, timestamp);
498 } 509 }
499 510
500 } // namespace ui 511 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/ozone/evdev/libgestures_glue/gesture_interpreter_libevdev_cros.h ('k') | ui/events/x/events_x.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698