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

Unified Diff: ui/events/event.cc

Issue 398393003: Require a mouse button release event before counting a press event as a new click. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Set last click complete if the incoming event has a different timestamp. Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/events/event.h ('k') | ui/events/event_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/event.cc
diff --git a/ui/events/event.cc b/ui/events/event.cc
index df38f38365ace7a3d8adbd89ea72bf7d493385ae..51379402fd8217b5e6d8c006e92195a8361732a6 100644
--- a/ui/events/event.cc
+++ b/ui/events/event.cc
@@ -317,23 +317,46 @@ bool MouseEvent::IsRepeatedClickEvent(
int MouseEvent::GetRepeatCount(const MouseEvent& event) {
int click_count = 1;
if (last_click_event_) {
- if (event.type() == ui::ET_MOUSE_RELEASED)
- return last_click_event_->GetClickCount();
- if (IsX11SendEventTrue(event.native_event()))
+ if (event.type() == ui::ET_MOUSE_RELEASED) {
+ if (event.changed_button_flags() ==
+ last_click_event_->changed_button_flags()) {
+ last_click_complete_ = true;
+ return last_click_event_->GetClickCount();
+ } else {
+ // If last_click_event_ has changed since this button was pressed
+ // return a click count of 1.
+ return click_count;
+ }
+ }
+ if (event.time_stamp() != last_click_event_->time_stamp())
+ last_click_complete_ = true;
+ if (!last_click_complete_ ||
+ IsX11SendEventTrue(event.native_event())) {
click_count = last_click_event_->GetClickCount();
- else if (IsRepeatedClickEvent(*last_click_event_, event))
+ } else if (IsRepeatedClickEvent(*last_click_event_, event)) {
click_count = last_click_event_->GetClickCount() + 1;
+ }
delete last_click_event_;
}
last_click_event_ = new MouseEvent(event);
+ 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
if (click_count > 3)
click_count = 3;
last_click_event_->SetClickCount(click_count);
return click_count;
}
+void MouseEvent::ResetLastClickForTest() {
+ if (last_click_event_) {
+ delete last_click_event_;
+ last_click_event_ = NULL;
+ last_click_complete_ = false;
+ }
+}
+
// static
MouseEvent* MouseEvent::last_click_event_ = NULL;
+bool MouseEvent::last_click_complete_ = false;
int MouseEvent::GetClickCount() const {
if (type() != ET_MOUSE_PRESSED && type() != ET_MOUSE_RELEASED)
« no previous file with comments | « 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