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/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/Xlib.h> | 9 #include <X11/Xlib.h> |
10 #endif | 10 #endif |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
310 if (std::abs(event2.y() - event1.y()) > kDoubleClickHeight / 2) | 310 if (std::abs(event2.y() - event1.y()) > kDoubleClickHeight / 2) |
311 return false; | 311 return false; |
312 | 312 |
313 return true; | 313 return true; |
314 } | 314 } |
315 | 315 |
316 // static | 316 // static |
317 int MouseEvent::GetRepeatCount(const MouseEvent& event) { | 317 int MouseEvent::GetRepeatCount(const MouseEvent& event) { |
318 int click_count = 1; | 318 int click_count = 1; |
319 if (last_click_event_) { | 319 if (last_click_event_) { |
320 if (event.type() == ui::ET_MOUSE_RELEASED) | 320 if (event.type() == ui::ET_MOUSE_RELEASED) { |
321 return last_click_event_->GetClickCount(); | 321 if (event.changed_button_flags() == |
322 if (IsX11SendEventTrue(event.native_event())) | 322 last_click_event_->changed_button_flags()) { |
323 last_click_complete_ = true; | |
324 return last_click_event_->GetClickCount(); | |
325 } else { | |
326 // If last_click_event_ has changed since this button was pressed | |
327 // return a click count of 1. | |
328 return click_count; | |
329 } | |
330 } | |
331 if (event.time_stamp() != last_click_event_->time_stamp()) | |
332 last_click_complete_ = true; | |
333 if (!last_click_complete_ || | |
334 IsX11SendEventTrue(event.native_event())) { | |
323 click_count = last_click_event_->GetClickCount(); | 335 click_count = last_click_event_->GetClickCount(); |
324 else if (IsRepeatedClickEvent(*last_click_event_, event)) | 336 } else if (IsRepeatedClickEvent(*last_click_event_, event)) { |
325 click_count = last_click_event_->GetClickCount() + 1; | 337 click_count = last_click_event_->GetClickCount() + 1; |
338 } | |
326 delete last_click_event_; | 339 delete last_click_event_; |
327 } | 340 } |
328 last_click_event_ = new MouseEvent(event); | 341 last_click_event_ = new MouseEvent(event); |
342 last_click_complete_ = false; | |
sky
2014/07/18 22:42:51
Do we need both last_click_complete_ and last_clic
flackr
2014/07/19 12:55:11
It's marked complete when another pressed event sh
| |
329 if (click_count > 3) | 343 if (click_count > 3) |
330 click_count = 3; | 344 click_count = 3; |
331 last_click_event_->SetClickCount(click_count); | 345 last_click_event_->SetClickCount(click_count); |
332 return click_count; | 346 return click_count; |
333 } | 347 } |
334 | 348 |
349 void MouseEvent::ResetLastClickForTest() { | |
350 if (last_click_event_) { | |
351 delete last_click_event_; | |
352 last_click_event_ = NULL; | |
353 last_click_complete_ = false; | |
354 } | |
355 } | |
356 | |
335 // static | 357 // static |
336 MouseEvent* MouseEvent::last_click_event_ = NULL; | 358 MouseEvent* MouseEvent::last_click_event_ = NULL; |
359 bool MouseEvent::last_click_complete_ = false; | |
337 | 360 |
338 int MouseEvent::GetClickCount() const { | 361 int MouseEvent::GetClickCount() const { |
339 if (type() != ET_MOUSE_PRESSED && type() != ET_MOUSE_RELEASED) | 362 if (type() != ET_MOUSE_PRESSED && type() != ET_MOUSE_RELEASED) |
340 return 0; | 363 return 0; |
341 | 364 |
342 if (flags() & EF_IS_TRIPLE_CLICK) | 365 if (flags() & EF_IS_TRIPLE_CLICK) |
343 return 3; | 366 return 3; |
344 else if (flags() & EF_IS_DOUBLE_CLICK) | 367 else if (flags() & EF_IS_DOUBLE_CLICK) |
345 return 2; | 368 return 2; |
346 else | 369 else |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
749 gfx::PointF(x, y), | 772 gfx::PointF(x, y), |
750 time_stamp, | 773 time_stamp, |
751 flags | EF_FROM_TOUCH), | 774 flags | EF_FROM_TOUCH), |
752 details_(details) { | 775 details_(details) { |
753 } | 776 } |
754 | 777 |
755 GestureEvent::~GestureEvent() { | 778 GestureEvent::~GestureEvent() { |
756 } | 779 } |
757 | 780 |
758 } // namespace ui | 781 } // namespace ui |
OLD | NEW |