Chromium Code Reviews| Index: views/events/event.h |
| =================================================================== |
| --- views/events/event.h (revision 74437) |
| +++ views/events/event.h (working copy) |
| @@ -1,9 +1,9 @@ |
| -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#ifndef VIEWS_EVENT_H_ |
| -#define VIEWS_EVENT_H_ |
| +#ifndef VIEWS_EVENTS_EVENT_H_ |
| +#define VIEWS_EVENTS_EVENT_H_ |
| #pragma once |
| #include "base/basictypes.h" |
| @@ -45,6 +45,7 @@ |
| class Event { |
| public: |
| const NativeEvent& native_event() const { return native_event_; } |
| + const NativeEvent2& native_event_2() const { return native_event_2_; } |
| ui::EventType type() const { return type_; } |
| const base::Time& time_stamp() const { return time_stamp_; } |
| int flags() const { return flags_; } |
| @@ -90,6 +91,11 @@ |
| protected: |
| Event(ui::EventType type, int flags); |
| + Event(NativeEvent native_event, ui::EventType type, int flags); |
| + // Because the world is complicated, sometimes we have two different kinds of |
| + // NativeEvent in play in the same executable. See native_types.h for the tale |
| + // of woe. |
|
rjkroege
2011/02/10 21:15:26
I'd a TODO here or in native_types.h that was a li
Ben Goodger (Google)
2011/02/10 21:22:37
I rewrote the comment in native_types.h as:
// O
|
| + Event(NativeEvent2 native_event, ui::EventType type, int flags); |
| Event(const Event& model) |
| : native_event_(model.native_event()), |
| @@ -102,6 +108,7 @@ |
| void operator=(const Event&); |
| NativeEvent native_event_; |
| + NativeEvent2 native_event_2_; |
| ui::EventType type_; |
| base::Time time_stamp_; |
| int flags_; |
| @@ -246,64 +253,28 @@ |
| #endif |
| //////////////////////////////////////////////////////////////////////////////// |
| -// |
| // KeyEvent class |
| // |
| -// A key event is used for any input event related to the keyboard. |
| -// Note: this event is about key pressed, not typed characters. |
| +// KeyEvent encapsulates keyboard input events - key press and release. |
| // |
| -//////////////////////////////////////////////////////////////////////////////// |
| class KeyEvent : public Event { |
| public: |
| - // Create a new key event |
| - KeyEvent(ui::EventType type, |
| - ui::KeyboardCode key_code, |
| - int event_flags, |
| - int repeat_count, |
| - int message_flags); |
| + explicit KeyEvent(NativeEvent native_event); |
| + explicit KeyEvent(NativeEvent2 native_event_2); |
| -#if defined(OS_WIN) |
| + // Creates a new KeyEvent synthetically (i.e. not in response to an input |
| + // event from the host environment). This is typically only used in testing as |
| + // some metadata obtainable from the underlying native event is not present. |
| + // TODO(beng): see if we can kill this. |
| KeyEvent(ui::EventType type, |
| ui::KeyboardCode key_code, |
| - int event_flags, |
| - int repeat_count, |
| - int message_flags, |
| - UINT message); |
| -#endif |
| -#if defined(OS_LINUX) |
| - explicit KeyEvent(const GdkEventKey* event); |
| + int event_flags); |
| - const GdkEventKey* native_event() const { return native_event_; } |
| -#endif |
| -#if defined(TOUCH_UI) |
| - // Create a key event from an X key event. |
| - explicit KeyEvent(XEvent* xevent); |
| -#endif |
| - |
| ui::KeyboardCode key_code() const { return key_code_; } |
| -#if defined(OS_WIN) |
| - bool IsExtendedKey() const; |
| - |
| - UINT message() const { return message_; } |
| -#endif |
| - |
| - int repeat_count() const { return repeat_count_; } |
| - |
| -#if defined(OS_WIN) |
| - static int GetKeyStateFlags(); |
| -#endif |
| - |
| private: |
| - |
| ui::KeyboardCode key_code_; |
| - int repeat_count_; |
| - int message_flags_; |
| -#if defined(OS_WIN) |
| - UINT message_; |
| -#elif defined(OS_LINUX) |
| - const GdkEventKey* native_event_; |
| -#endif |
| + |
| DISALLOW_COPY_AND_ASSIGN(KeyEvent); |
| }; |
| @@ -369,4 +340,4 @@ |
| } // namespace views |
| -#endif // VIEWS_EVENT_H_ |
| +#endif // VIEWS_EVENTS_EVENT_H_ |