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

Side by Side Diff: ui/base/event.h

Issue 10830293: Fixes bug where Env/RootWindow would cache the wrong button (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to trunk Created 8 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/aura/root_window.cc ('k') | ui/base/event.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 #ifndef UI_BASE_EVENT_H_ 5 #ifndef UI_BASE_EVENT_H_
6 #define UI_BASE_EVENT_H_ 6 #define UI_BASE_EVENT_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/event_types.h" 10 #include "base/event_types.h"
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 class UI_EXPORT MouseEvent : public LocatedEvent { 180 class UI_EXPORT MouseEvent : public LocatedEvent {
181 public: 181 public:
182 explicit MouseEvent(const base::NativeEvent& native_event); 182 explicit MouseEvent(const base::NativeEvent& native_event);
183 183
184 // Create a new MouseEvent based on the provided model. 184 // Create a new MouseEvent based on the provided model.
185 // Uses the provided |type| and |flags| for the new event. 185 // Uses the provided |type| and |flags| for the new event.
186 // If source / target windows are provided, the model location will be 186 // If source / target windows are provided, the model location will be
187 // converted from |source| coordinate system to |target| coordinate system. 187 // converted from |source| coordinate system to |target| coordinate system.
188 template <class T> 188 template <class T>
189 MouseEvent(const MouseEvent& model, T* source, T* target) 189 MouseEvent(const MouseEvent& model, T* source, T* target)
190 : LocatedEvent(model, source, target) { 190 : LocatedEvent(model, source, target),
191 changed_button_flags_(model.changed_button_flags_) {
191 } 192 }
192 193
193 template <class T> 194 template <class T>
194 MouseEvent(const MouseEvent& model, 195 MouseEvent(const MouseEvent& model,
195 T* source, 196 T* source,
196 T* target, 197 T* target,
197 EventType type, 198 EventType type,
198 int flags) 199 int flags)
199 : LocatedEvent(model, source, target) { 200 : LocatedEvent(model, source, target),
201 changed_button_flags_(model.changed_button_flags_) {
200 set_type(type); 202 set_type(type);
201 set_flags(flags); 203 set_flags(flags);
202 } 204 }
203 205
204 // Used for synthetic events in testing and by the gesture recognizer. 206 // Used for synthetic events in testing and by the gesture recognizer.
205 MouseEvent(EventType type, 207 MouseEvent(EventType type,
206 const gfx::Point& location, 208 const gfx::Point& location,
207 const gfx::Point& root_location, 209 const gfx::Point& root_location,
208 int flags); 210 int flags);
209 211
(...skipping 30 matching lines...) Expand all
240 static bool IsRepeatedClickEvent( 242 static bool IsRepeatedClickEvent(
241 const MouseEvent& event1, 243 const MouseEvent& event1,
242 const MouseEvent& event2); 244 const MouseEvent& event2);
243 245
244 // Get the click count. Can be 1, 2 or 3 for mousedown messages, 0 otherwise. 246 // Get the click count. Can be 1, 2 or 3 for mousedown messages, 0 otherwise.
245 int GetClickCount() const; 247 int GetClickCount() const;
246 248
247 // Set the click count for a mousedown message. Can be 1, 2 or 3. 249 // Set the click count for a mousedown message. Can be 1, 2 or 3.
248 void SetClickCount(int click_count); 250 void SetClickCount(int click_count);
249 251
252 // Identifies the button that changed. During a press this corresponds to the
253 // button that was pressed and during a release this corresponds to the button
254 // that was released.
255 // NOTE: during a press and release flags() contains the complete set of
256 // flags. Use this to determine the button that was pressed or released.
257 int changed_button_flags() const { return changed_button_flags_; }
258
250 protected: 259 protected:
251 explicit MouseEvent(const MouseEvent& model); 260 explicit MouseEvent(const MouseEvent& model);
252 261
253 private: 262 private:
254 gfx::Point root_location_;
255
256 static MouseEvent* last_click_event_;
257 // Returns the repeat count based on the previous mouse click, if it is 263 // Returns the repeat count based on the previous mouse click, if it is
258 // recent enough and within a small enough distance. 264 // recent enough and within a small enough distance.
259 static int GetRepeatCount(const MouseEvent& click_event); 265 static int GetRepeatCount(const MouseEvent& click_event);
266
267 gfx::Point root_location_;
268
269 // See description above getter for details.
270 int changed_button_flags_;
271
272 static MouseEvent* last_click_event_;
260 }; 273 };
261 274
262 class UI_EXPORT TouchEvent : public LocatedEvent { 275 class UI_EXPORT TouchEvent : public LocatedEvent {
263 public: 276 public:
264 explicit TouchEvent(const base::NativeEvent& native_event); 277 explicit TouchEvent(const base::NativeEvent& native_event);
265 278
266 // Create a new TouchEvent which is identical to the provided model. 279 // Create a new TouchEvent which is identical to the provided model.
267 // If source / target windows are provided, the model location will be 280 // If source / target windows are provided, the model location will be
268 // converted from |source| coordinate system to |target| coordinate system. 281 // converted from |source| coordinate system to |target| coordinate system.
269 template <class T> 282 template <class T>
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 // This value is stored as a bitfield because the number of touch ids varies, 488 // This value is stored as a bitfield because the number of touch ids varies,
476 // but we currently don't need more than 32 touches at a time. 489 // but we currently don't need more than 32 touches at a time.
477 const unsigned int touch_ids_bitfield_; 490 const unsigned int touch_ids_bitfield_;
478 491
479 DISALLOW_COPY_AND_ASSIGN(GestureEvent); 492 DISALLOW_COPY_AND_ASSIGN(GestureEvent);
480 }; 493 };
481 494
482 } // namespace ui 495 } // namespace ui
483 496
484 #endif // UI_BASE_EVENT_H_ 497 #endif // UI_BASE_EVENT_H_
OLDNEW
« no previous file with comments | « ui/aura/root_window.cc ('k') | ui/base/event.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698