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

Side by Side Diff: content/browser/renderer_host/web_input_event_aura.cc

Issue 8353005: aura: Make keyevents for renderers work correctly in X11. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 2 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 | « no previous file | content/browser/renderer_host/web_input_event_aurax11.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "content/browser/renderer_host/web_input_event_aura.h" 5 #include "content/browser/renderer_host/web_input_event_aura.h"
6 6
7 #include "ui/aura/event.h" 7 #include "ui/aura/event.h"
8 8
9 namespace content { 9 namespace content {
10 10
11 WebKit::WebMouseEvent MakeUntranslatedWebMouseEventFromNativeEvent( 11 WebKit::WebMouseEvent MakeUntranslatedWebMouseEventFromNativeEvent(
12 base::NativeEvent native_event); 12 base::NativeEvent native_event);
13 WebKit::WebMouseEvent MakeWebMouseEventFromAuraEvent(aura::MouseEvent* event);
13 WebKit::WebKeyboardEvent MakeWebKeyboardEventFromNativeEvent( 14 WebKit::WebKeyboardEvent MakeWebKeyboardEventFromNativeEvent(
14 base::NativeEvent native_event); 15 base::NativeEvent native_event);
15 16
16 // General approach: 17 // General approach:
17 // 18 //
18 // aura::Event only carries a subset of possible event data provided to Aura by 19 // aura::Event only carries a subset of possible event data provided to Aura by
19 // the host platform. WebKit utilizes a larger subset of that information than 20 // the host platform. WebKit utilizes a larger subset of that information than
20 // Aura itself. WebKit includes some built in cracking functionality that we 21 // Aura itself. WebKit includes some built in cracking functionality that we
21 // rely on to obtain this information cleanly and consistently. 22 // rely on to obtain this information cleanly and consistently.
22 // 23 //
23 // The only place where an aura::Event's data differs from what the underlying 24 // The only place where an aura::Event's data differs from what the underlying
24 // base::NativeEvent would provide is position data, since we would like to 25 // base::NativeEvent would provide is position data, since we would like to
25 // provide coordinates relative to the aura::Window that is hosting the 26 // provide coordinates relative to the aura::Window that is hosting the
26 // renderer, not the top level platform window. 27 // renderer, not the top level platform window.
27 // 28 //
28 // The approach is to fully construct a WebKit::WebInputEvent from the 29 // The approach is to fully construct a WebKit::WebInputEvent from the
29 // aura::Event's base::NativeEvent, and then replace the coordinate fields with 30 // aura::Event's base::NativeEvent, and then replace the coordinate fields with
30 // the translated values from the aura::Event. 31 // the translated values from the aura::Event.
31 // 32 //
33 // The exception is mouse events on linux. The aura::MouseEvent contains enough
34 // necessary information to construct a WebMouseEvent. So instead of extracting
35 // the information from the XEvent, which can be tricky when supporting both
36 // XInput2 and XInput, the WebMouseEvent is constructed from the
37 // aura::MouseEvent. This will not be necessary once only XInput2 is supported.
38 //
32 39
33 WebKit::WebMouseEvent MakeWebMouseEvent(aura::MouseEvent* event) { 40 WebKit::WebMouseEvent MakeWebMouseEvent(aura::MouseEvent* event) {
41 #if defined(OS_WIN)
34 // Construct an untranslated event from the platform event data. 42 // Construct an untranslated event from the platform event data.
35 WebKit::WebMouseEvent webkit_event = 43 WebKit::WebMouseEvent webkit_event =
36 MakeUntranslatedWebMouseEventFromNativeEvent(event->native_event()); 44 MakeUntranslatedWebMouseEventFromNativeEvent(event->native_event());
45 #else
46 WebKit::WebMouseEvent webkit_event = MakeWebMouseEventFromAuraEvent(event);
47 #endif
37 48
38 // Replace the event's coordinate fields with translated position data from 49 // Replace the event's coordinate fields with translated position data from
39 // |event|. 50 // |event|.
40 webkit_event.windowX = webkit_event.x = event->x(); 51 webkit_event.windowX = webkit_event.x = event->x();
41 webkit_event.windowY = webkit_event.y = event->y(); 52 webkit_event.windowY = webkit_event.y = event->y();
42 53
43 // TODO(beng): map these to screen coordinates. 54 // TODO(beng): map these to screen coordinates.
44 webkit_event.globalX = event->x(); 55 webkit_event.globalX = event->x();
45 webkit_event.globalY = event->y(); 56 webkit_event.globalY = event->y();
46 57
47 return webkit_event; 58 return webkit_event;
48 } 59 }
49 60
50 WebKit::WebKeyboardEvent MakeWebKeyboardEvent(aura::KeyEvent* event) { 61 WebKit::WebKeyboardEvent MakeWebKeyboardEvent(aura::KeyEvent* event) {
51 // Key events require no translation by the aura system. 62 // Key events require no translation by the aura system.
52 return MakeWebKeyboardEventFromNativeEvent(event->native_event()); 63 return MakeWebKeyboardEventFromNativeEvent(event->native_event());
53 } 64 }
54 65
55 } // namespace content 66 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/web_input_event_aurax11.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698