diff options
author | dhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-17 22:32:22 +0000 |
---|---|---|
committer | dhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-17 22:32:22 +0000 |
commit | 539ee3e4239962f775f0c7e42bc4816642eae671 (patch) | |
tree | 77d808fe49bb044678c0bb068b7c6cd1fcd8bd06 /ui/aura | |
parent | 8056bc2f83c10247fd6f076b45fa0a02ceaab766 (diff) | |
download | chromium_src-539ee3e4239962f775f0c7e42bc4816642eae671.zip chromium_src-539ee3e4239962f775f0c7e42bc4816642eae671.tar.gz chromium_src-539ee3e4239962f775f0c7e42bc4816642eae671.tar.bz2 |
Mac Native Event copying missing under Aura
Implements native event copying for NativeEvent/NSEvent under Mac/Aura.
BUG=109946
TEST=Compiles and links under Mac/Aura.
R=ben@chromium.org
Review URL: https://chromiumcodereview.appspot.com/9244009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@117981 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/aura')
-rw-r--r-- | ui/aura/aura.gyp | 3 | ||||
-rw-r--r-- | ui/aura/event.cc | 39 | ||||
-rw-r--r-- | ui/aura/event_mac.h | 19 | ||||
-rw-r--r-- | ui/aura/event_mac.mm | 15 |
4 files changed, 61 insertions, 15 deletions
diff --git a/ui/aura/aura.gyp b/ui/aura/aura.gyp index 2348f02..90a5007 100644 --- a/ui/aura/aura.gyp +++ b/ui/aura/aura.gyp @@ -53,6 +53,8 @@ 'event.h', 'event_filter.cc', 'event_filter.h', + 'event_mac.cc', + 'event_mac.h', 'focus_manager.h', 'layout_manager.cc', 'layout_manager.h', @@ -155,6 +157,7 @@ ], # osmesa GL implementation is used on linux. 'conditions': [ + # osmesa GL implementation is used on linux. ['OS=="linux"', { 'dependencies': [ '<(DEPTH)/third_party/mesa/mesa.gyp:osmesa', diff --git a/ui/aura/event.cc b/ui/aura/event.cc index 9008744..57a0f31 100644 --- a/ui/aura/event.cc +++ b/ui/aura/event.cc @@ -15,10 +15,33 @@ #include "ui/gfx/point3.h" #include "ui/gfx/transform.h" +#if defined(OS_MACOSX) +#include "ui/aura/event_mac.h" +#endif + #if defined(USE_X11) #include "ui/base/keycodes/keyboard_code_conversion_x.h" #endif +namespace { + +base::NativeEvent CopyNativeEvent(const base::NativeEvent& event) { +#if defined(USE_X11) + XEvent* copy = new XEvent; + *copy = *event; + return copy; +#elif defined(OS_WIN) + return event; +#elif defined(OS_MACOSX) + return aura::CopyNativeEvent(event); +#else + NOTREACHED() << + "Don't know how to copy base::NativeEvent for this platform"; +#endif +} + +} // namespace + namespace aura { Event::~Event() { @@ -316,22 +339,8 @@ uint16 KeyEvent::GetUnmodifiedCharacter() const { #endif } -base::NativeEvent CopyNativeEvent(const base::NativeEvent& event) { -#if defined(USE_X11) - XEvent* copy = new XEvent; - *copy = *event; - return copy; -#elif defined(OS_WIN) - return event; -#else - NOTREACHED() << - "Don't know how to copy base::NativeEvent for this platform"; -#endif -} - KeyEvent* KeyEvent::Copy() { - KeyEvent* copy = new KeyEvent(CopyNativeEvent(native_event()), - is_char()); + KeyEvent* copy = new KeyEvent(::CopyNativeEvent(native_event()), is_char()); #if defined(USE_X11) copy->set_delete_native_event(true); #endif diff --git a/ui/aura/event_mac.h b/ui/aura/event_mac.h new file mode 100644 index 0000000..d170380 --- /dev/null +++ b/ui/aura/event_mac.h @@ -0,0 +1,19 @@ +// Copyright (c) 2012 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 UI_AURA_EVENT_MAC_H_ +#define UI_AURA_EVENT_MAC_H_ +#pragma once + +#include "base/event_types.h" + +namespace aura { + +// Returns a deep copy of the native |event|. On Mac the returned value is +// autoreleased. +base::NativeEvent CopyNativeEvent(const base::NativeEvent& event); + +} // namespace aura + +#endif // UI_AURA_EVENT_MAC_H_ diff --git a/ui/aura/event_mac.mm b/ui/aura/event_mac.mm new file mode 100644 index 0000000..d68a011 --- /dev/null +++ b/ui/aura/event_mac.mm @@ -0,0 +1,15 @@ +// Copyright (c) 2012 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. + +#import <AppKit/NSEvent.h> + +#include "ui/aura/event_mac.h" + +namespace aura { + +base::NativeEvent CopyNativeEvent(const base::NativeEvent& event) { + return [NSEvent eventWithCGEvent:[event CGEvent]]; +} + +} // namespace aura |