Chromium Code Reviews| 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.h" | 5 #include "ui/base/events/event.h" |
| 6 | 6 |
| 7 #if defined(USE_X11) | 7 #if defined(USE_X11) |
| 8 #include <X11/Xlib.h> | 8 #include <X11/Xlib.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 97 CASE_TYPE(ET_SCROLL_FLING_CANCEL); | 97 CASE_TYPE(ET_SCROLL_FLING_CANCEL); |
| 98 case ui::ET_LAST: NOTREACHED(); return std::string(); | 98 case ui::ET_LAST: NOTREACHED(); return std::string(); |
| 99 // Don't include default, so that we get an error when new type is added. | 99 // Don't include default, so that we get an error when new type is added. |
| 100 } | 100 } |
| 101 #undef CASE_TYPE | 101 #undef CASE_TYPE |
| 102 | 102 |
| 103 NOTREACHED(); | 103 NOTREACHED(); |
| 104 return std::string(); | 104 return std::string(); |
| 105 } | 105 } |
| 106 | 106 |
| 107 bool IsX11SendEventTrue(const base::NativeEvent& event) { | |
| 108 #if defined(USE_X11) | |
| 109 if (event && event->xany.send_event) | |
| 110 return true; | |
| 111 #endif | |
| 112 return false; | |
| 113 } | |
| 114 | |
| 107 } // namespace | 115 } // namespace |
| 108 | 116 |
| 109 namespace ui { | 117 namespace ui { |
| 110 | 118 |
| 111 //////////////////////////////////////////////////////////////////////////////// | 119 //////////////////////////////////////////////////////////////////////////////// |
| 112 // Event | 120 // Event |
| 113 | 121 |
| 114 Event::~Event() { | 122 Event::~Event() { |
| 115 #if defined(USE_X11) | 123 #if defined(USE_X11) |
| 116 if (delete_native_event_) | 124 if (delete_native_event_) |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 292 | 300 |
| 293 if (event1.type() != ET_MOUSE_PRESSED || | 301 if (event1.type() != ET_MOUSE_PRESSED || |
| 294 event2.type() != ET_MOUSE_PRESSED) | 302 event2.type() != ET_MOUSE_PRESSED) |
| 295 return false; | 303 return false; |
| 296 | 304 |
| 297 // Compare flags, but ignore EF_IS_DOUBLE_CLICK to allow triple clicks. | 305 // Compare flags, but ignore EF_IS_DOUBLE_CLICK to allow triple clicks. |
| 298 if ((event1.flags() & ~EF_IS_DOUBLE_CLICK) != | 306 if ((event1.flags() & ~EF_IS_DOUBLE_CLICK) != |
| 299 (event2.flags() & ~EF_IS_DOUBLE_CLICK)) | 307 (event2.flags() & ~EF_IS_DOUBLE_CLICK)) |
| 300 return false; | 308 return false; |
| 301 | 309 |
| 310 if (IsX11SendEventTrue(event2.native_event())) | |
| 311 return false; | |
| 312 | |
| 302 base::TimeDelta time_difference = event2.time_stamp() - event1.time_stamp(); | 313 base::TimeDelta time_difference = event2.time_stamp() - event1.time_stamp(); |
| 303 | 314 |
| 304 if (time_difference.InMilliseconds() > kDoubleClickTimeMS) | 315 if (time_difference.InMilliseconds() > kDoubleClickTimeMS) |
| 305 return false; | 316 return false; |
| 306 | 317 |
| 307 if (abs(event2.x() - event1.x()) > kDoubleClickWidth / 2) | 318 if (abs(event2.x() - event1.x()) > kDoubleClickWidth / 2) |
| 308 return false; | 319 return false; |
| 309 | 320 |
| 310 if (abs(event2.y() - event1.y()) > kDoubleClickHeight / 2) | 321 if (abs(event2.y() - event1.y()) > kDoubleClickHeight / 2) |
| 311 return false; | 322 return false; |
| 312 | 323 |
| 313 return true; | 324 return true; |
| 314 } | 325 } |
| 315 | 326 |
| 316 // static | 327 // static |
| 317 int MouseEvent::GetRepeatCount(const MouseEvent& event) { | 328 int MouseEvent::GetRepeatCount(const MouseEvent& event) { |
|
oshima
2013/01/08 20:01:51
It's better to check if it's synthesized event her
sschmitz
2013/01/08 22:48:57
Done.
| |
| 318 int click_count = 1; | 329 int click_count = 1; |
| 319 if (last_click_event_) { | 330 if (last_click_event_) { |
| 320 if (IsRepeatedClickEvent(*last_click_event_, event)) | 331 if (IsRepeatedClickEvent(*last_click_event_, event)) |
| 321 click_count = last_click_event_->GetClickCount() + 1; | 332 click_count = last_click_event_->GetClickCount() + 1; |
| 322 delete last_click_event_; | 333 delete last_click_event_; |
| 323 } | 334 } |
| 324 last_click_event_ = new MouseEvent(event); | 335 last_click_event_ = new MouseEvent(event); |
| 325 if (click_count > 3) | 336 if (click_count > 3) |
| 326 click_count = 3; | 337 click_count = 3; |
| 327 last_click_event_->SetClickCount(click_count); | 338 last_click_event_->SetClickCount(click_count); |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 660 int GestureEvent::GetLowestTouchId() const { | 671 int GestureEvent::GetLowestTouchId() const { |
| 661 if (touch_ids_bitfield_ == 0) | 672 if (touch_ids_bitfield_ == 0) |
| 662 return -1; | 673 return -1; |
| 663 int i = -1; | 674 int i = -1; |
| 664 // Find the index of the least significant 1 bit | 675 // Find the index of the least significant 1 bit |
| 665 while (!(1 << ++i & touch_ids_bitfield_)); | 676 while (!(1 << ++i & touch_ids_bitfield_)); |
| 666 return i; | 677 return i; |
| 667 } | 678 } |
| 668 | 679 |
| 669 } // namespace ui | 680 } // namespace ui |
| OLD | NEW |