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

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

Issue 427003002: Merge 284479 "Require a mouse button release event before counti..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/2062/src/
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « ui/events/event.h ('k') | ui/events/event_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/Xlib.h> 9 #include <X11/Xlib.h>
10 #endif 10 #endif
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 if (std::abs(event2.y() - event1.y()) > kDoubleClickHeight / 2) 299 if (std::abs(event2.y() - event1.y()) > kDoubleClickHeight / 2)
300 return false; 300 return false;
301 301
302 return true; 302 return true;
303 } 303 }
304 304
305 // static 305 // static
306 int MouseEvent::GetRepeatCount(const MouseEvent& event) { 306 int MouseEvent::GetRepeatCount(const MouseEvent& event) {
307 int click_count = 1; 307 int click_count = 1;
308 if (last_click_event_) { 308 if (last_click_event_) {
309 if (event.type() == ui::ET_MOUSE_RELEASED) 309 if (event.type() == ui::ET_MOUSE_RELEASED) {
310 return last_click_event_->GetClickCount(); 310 if (event.changed_button_flags() ==
311 if (IsX11SendEventTrue(event.native_event())) 311 last_click_event_->changed_button_flags()) {
312 last_click_complete_ = true;
313 return last_click_event_->GetClickCount();
314 } else {
315 // If last_click_event_ has changed since this button was pressed
316 // return a click count of 1.
317 return click_count;
318 }
319 }
320 if (event.time_stamp() != last_click_event_->time_stamp())
321 last_click_complete_ = true;
322 if (!last_click_complete_ ||
323 IsX11SendEventTrue(event.native_event())) {
312 click_count = last_click_event_->GetClickCount(); 324 click_count = last_click_event_->GetClickCount();
313 else if (IsRepeatedClickEvent(*last_click_event_, event)) 325 } else if (IsRepeatedClickEvent(*last_click_event_, event)) {
314 click_count = last_click_event_->GetClickCount() + 1; 326 click_count = last_click_event_->GetClickCount() + 1;
327 }
315 delete last_click_event_; 328 delete last_click_event_;
316 } 329 }
317 last_click_event_ = new MouseEvent(event); 330 last_click_event_ = new MouseEvent(event);
331 last_click_complete_ = false;
318 if (click_count > 3) 332 if (click_count > 3)
319 click_count = 3; 333 click_count = 3;
320 last_click_event_->SetClickCount(click_count); 334 last_click_event_->SetClickCount(click_count);
321 return click_count; 335 return click_count;
322 } 336 }
323 337
338 void MouseEvent::ResetLastClickForTest() {
339 if (last_click_event_) {
340 delete last_click_event_;
341 last_click_event_ = NULL;
342 last_click_complete_ = false;
343 }
344 }
345
324 // static 346 // static
325 MouseEvent* MouseEvent::last_click_event_ = NULL; 347 MouseEvent* MouseEvent::last_click_event_ = NULL;
348 bool MouseEvent::last_click_complete_ = false;
326 349
327 int MouseEvent::GetClickCount() const { 350 int MouseEvent::GetClickCount() const {
328 if (type() != ET_MOUSE_PRESSED && type() != ET_MOUSE_RELEASED) 351 if (type() != ET_MOUSE_PRESSED && type() != ET_MOUSE_RELEASED)
329 return 0; 352 return 0;
330 353
331 if (flags() & EF_IS_TRIPLE_CLICK) 354 if (flags() & EF_IS_TRIPLE_CLICK)
332 return 3; 355 return 3;
333 else if (flags() & EF_IS_DOUBLE_CLICK) 356 else if (flags() & EF_IS_DOUBLE_CLICK)
334 return 2; 357 return 2;
335 else 358 else
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 int GestureEvent::GetLowestTouchId() const { 768 int GestureEvent::GetLowestTouchId() const {
746 if (touch_ids_bitfield_ == 0) 769 if (touch_ids_bitfield_ == 0)
747 return -1; 770 return -1;
748 int i = -1; 771 int i = -1;
749 // Find the index of the least significant 1 bit 772 // Find the index of the least significant 1 bit
750 while (!(1 << ++i & touch_ids_bitfield_)); 773 while (!(1 << ++i & touch_ids_bitfield_));
751 return i; 774 return i;
752 } 775 }
753 776
754 } // namespace ui 777 } // namespace ui
OLDNEW
« 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