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

Side by Side Diff: ui/events/event.cc

Issue 800163005: Fixed ui::TouchEvent rotation angle out-of-bound issue. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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 (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/events/event.h" 5 #include "ui/events/event.h"
6 6
7 #if defined(USE_X11) 7 #if defined(USE_X11)
8 #include <X11/extensions/XInput2.h> 8 #include <X11/extensions/XInput2.h>
9 #include <X11/keysym.h> 9 #include <X11/keysym.h>
10 #include <X11/Xlib.h> 10 #include <X11/Xlib.h>
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 force_(GetTouchForce(native_event)), 528 force_(GetTouchForce(native_event)),
529 may_cause_scrolling_(false) { 529 may_cause_scrolling_(false) {
530 latency()->AddLatencyNumberWithTimestamp( 530 latency()->AddLatencyNumberWithTimestamp(
531 INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 531 INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT,
532 0, 532 0,
533 0, 533 0,
534 base::TimeTicks::FromInternalValue(time_stamp().ToInternalValue()), 534 base::TimeTicks::FromInternalValue(time_stamp().ToInternalValue()),
535 1); 535 1);
536 536
537 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); 537 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
538 fixRotationAngle();
538 539
539 if (type() == ET_TOUCH_PRESSED) 540 if (type() == ET_TOUCH_PRESSED)
540 IncrementTouchIdRefCount(native_event); 541 IncrementTouchIdRefCount(native_event);
541 } 542 }
542 543
543 TouchEvent::TouchEvent(EventType type, 544 TouchEvent::TouchEvent(EventType type,
544 const gfx::PointF& location, 545 const gfx::PointF& location,
545 int touch_id, 546 int touch_id,
546 base::TimeDelta time_stamp) 547 base::TimeDelta time_stamp)
547 : LocatedEvent(type, location, location, time_stamp, 0), 548 : LocatedEvent(type, location, location, time_stamp, 0),
(...skipping 18 matching lines...) Expand all
566 float force) 567 float force)
567 : LocatedEvent(type, location, location, time_stamp, flags), 568 : LocatedEvent(type, location, location, time_stamp, flags),
568 touch_id_(touch_id), 569 touch_id_(touch_id),
569 unique_event_id_(get_next_touch_event_id()), 570 unique_event_id_(get_next_touch_event_id()),
570 radius_x_(radius_x), 571 radius_x_(radius_x),
571 radius_y_(radius_y), 572 radius_y_(radius_y),
572 rotation_angle_(angle), 573 rotation_angle_(angle),
573 force_(force), 574 force_(force),
574 may_cause_scrolling_(false) { 575 may_cause_scrolling_(false) {
575 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); 576 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
577 fixRotationAngle();
576 } 578 }
577 579
578 TouchEvent::~TouchEvent() { 580 TouchEvent::~TouchEvent() {
579 // In ctor TouchEvent(native_event) we call GetTouchId() which in X11 581 // In ctor TouchEvent(native_event) we call GetTouchId() which in X11
580 // platform setups the tracking_id to slot mapping. So in dtor here, 582 // platform setups the tracking_id to slot mapping. So in dtor here,
581 // if this touch event is a release event, we clear the mapping accordingly. 583 // if this touch event is a release event, we clear the mapping accordingly.
582 if (HasNativeEvent()) 584 if (HasNativeEvent())
583 ClearTouchIdIfReleased(native_event()); 585 ClearTouchIdIfReleased(native_event());
584 } 586 }
585 587
586 void TouchEvent::UpdateForRootTransform( 588 void TouchEvent::UpdateForRootTransform(
587 const gfx::Transform& inverted_root_transform) { 589 const gfx::Transform& inverted_root_transform) {
588 LocatedEvent::UpdateForRootTransform(inverted_root_transform); 590 LocatedEvent::UpdateForRootTransform(inverted_root_transform);
589 gfx::DecomposedTransform decomp; 591 gfx::DecomposedTransform decomp;
590 bool success = gfx::DecomposeTransform(&decomp, inverted_root_transform); 592 bool success = gfx::DecomposeTransform(&decomp, inverted_root_transform);
591 DCHECK(success); 593 DCHECK(success);
592 if (decomp.scale[0]) 594 if (decomp.scale[0])
593 radius_x_ *= decomp.scale[0]; 595 radius_x_ *= decomp.scale[0];
594 if (decomp.scale[1]) 596 if (decomp.scale[1])
595 radius_y_ *= decomp.scale[1]; 597 radius_y_ *= decomp.scale[1];
596 } 598 }
597 599
598 void TouchEvent::DisableSynchronousHandling() { 600 void TouchEvent::DisableSynchronousHandling() {
599 DispatcherApi dispatcher_api(this); 601 DispatcherApi dispatcher_api(this);
600 dispatcher_api.set_result( 602 dispatcher_api.set_result(
601 static_cast<EventResult>(result() | ER_DISABLE_SYNC_HANDLING)); 603 static_cast<EventResult>(result() | ER_DISABLE_SYNC_HANDLING));
602 } 604 }
603 605
606 void TouchEvent::fixRotationAngle() {
607 while (rotation_angle_ < 0)
608 rotation_angle_ += 180;
609 while (rotation_angle_ >= 180)
610 rotation_angle_ -= 180;
611 }
612
604 //////////////////////////////////////////////////////////////////////////////// 613 ////////////////////////////////////////////////////////////////////////////////
605 // KeyEvent 614 // KeyEvent
606 615
607 // static 616 // static
608 KeyEvent* KeyEvent::last_key_event_ = NULL; 617 KeyEvent* KeyEvent::last_key_event_ = NULL;
609 618
610 // static 619 // static
611 bool KeyEvent::IsRepeated(const KeyEvent& event) { 620 bool KeyEvent::IsRepeated(const KeyEvent& event) {
612 // A safe guard in case if there were continous key pressed events that are 621 // A safe guard in case if there were continous key pressed events that are
613 // not auto repeat. 622 // not auto repeat.
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 gfx::PointF(x, y), 973 gfx::PointF(x, y),
965 time_stamp, 974 time_stamp,
966 flags | EF_FROM_TOUCH), 975 flags | EF_FROM_TOUCH),
967 details_(details) { 976 details_(details) {
968 } 977 }
969 978
970 GestureEvent::~GestureEvent() { 979 GestureEvent::~GestureEvent() {
971 } 980 }
972 981
973 } // namespace ui 982 } // namespace ui
OLDNEW
« ui/events/event.h ('K') | « ui/events/event.h ('k') | ui/events/event_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698