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

Side by Side 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: 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 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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 last_click_released_ = true;
sky 2014/07/17 21:37:55 If you get a capture change I'm not sure if you ar
flackr 2014/07/18 16:20:49 If the event is handled within chrome this is call
sky 2014/07/18 19:20:59 What I'm saying is that I'm not sure if we necessa
flackr 2014/07/18 19:45:23 Ah I see what you're saying. If I double click, an
321 return last_click_event_->GetClickCount(); 322 return last_click_event_->GetClickCount();
322 if (IsX11SendEventTrue(event.native_event())) 323 }
324 if (!last_click_released_ ||
325 IsX11SendEventTrue(event.native_event())) {
323 click_count = last_click_event_->GetClickCount(); 326 click_count = last_click_event_->GetClickCount();
324 else if (IsRepeatedClickEvent(*last_click_event_, event)) 327 } else if (IsRepeatedClickEvent(*last_click_event_, event)) {
325 click_count = last_click_event_->GetClickCount() + 1; 328 click_count = last_click_event_->GetClickCount() + 1;
329 }
326 delete last_click_event_; 330 delete last_click_event_;
327 } 331 }
328 last_click_event_ = new MouseEvent(event); 332 last_click_event_ = new MouseEvent(event);
333 last_click_released_ = false;
329 if (click_count > 3) 334 if (click_count > 3)
330 click_count = 3; 335 click_count = 3;
331 last_click_event_->SetClickCount(click_count); 336 last_click_event_->SetClickCount(click_count);
332 return click_count; 337 return click_count;
333 } 338 }
334 339
335 // static 340 // static
336 MouseEvent* MouseEvent::last_click_event_ = NULL; 341 MouseEvent* MouseEvent::last_click_event_ = NULL;
342 bool MouseEvent::last_click_released_ = false;
337 343
338 int MouseEvent::GetClickCount() const { 344 int MouseEvent::GetClickCount() const {
339 if (type() != ET_MOUSE_PRESSED && type() != ET_MOUSE_RELEASED) 345 if (type() != ET_MOUSE_PRESSED && type() != ET_MOUSE_RELEASED)
340 return 0; 346 return 0;
341 347
342 if (flags() & EF_IS_TRIPLE_CLICK) 348 if (flags() & EF_IS_TRIPLE_CLICK)
343 return 3; 349 return 3;
344 else if (flags() & EF_IS_DOUBLE_CLICK) 350 else if (flags() & EF_IS_DOUBLE_CLICK)
345 return 2; 351 return 2;
346 else 352 else
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 gfx::PointF(x, y), 755 gfx::PointF(x, y),
750 time_stamp, 756 time_stamp,
751 flags | EF_FROM_TOUCH), 757 flags | EF_FROM_TOUCH),
752 details_(details) { 758 details_(details) {
753 } 759 }
754 760
755 GestureEvent::~GestureEvent() { 761 GestureEvent::~GestureEvent() {
756 } 762 }
757 763
758 } // namespace ui 764 } // 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