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

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

Issue 479873002: Removing X11 native_event uses for key events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove web_input_event_aurax11.cc from Android license whitelist. Created 6 years, 3 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
« no previous file with comments | « content/browser/renderer_host/web_input_event_aura.cc ('k') | content/content_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 // Portions based heavily on:
6 // third_party/WebKit/public/web/gtk/WebInputEventFactory.cpp
7 //
8 /*
9 * Copyright (C) 2006-2011 Google Inc. All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions are
13 * met:
14 *
15 * * Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * * Redistributions in binary form must reproduce the above
18 * copyright notice, this list of conditions and the following disclaimer
19 * in the documentation and/or other materials provided with the
20 * distribution.
21 * * Neither the name of Google Inc. nor the names of its
22 * contributors may be used to endorse or promote products derived from
23 * this software without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 */
37
38 #include "content/browser/renderer_host/web_input_event_aura.h"
39
40 #include <X11/keysym.h>
41 #include <X11/Xlib.h>
42 #include <X11/Xutil.h>
43 #include <cstdlib>
44
45 #include "base/event_types.h"
46 #include "base/logging.h"
47 #include "content/browser/renderer_host/ui_events_helper.h"
48 #include "ui/events/event.h"
49 #include "ui/events/event_constants.h"
50 #include "ui/events/event_utils.h"
51 #include "ui/events/keycodes/keyboard_code_conversion_x.h"
52 #include "ui/events/keycodes/keyboard_codes.h"
53
54 namespace content {
55
56 // chromium WebKit does not provide a WebInputEventFactory for X11, so we have
57 // to do the work here ourselves.
58
59 blink::WebKeyboardEvent MakeWebKeyboardEventFromAuraEvent(
60 ui::KeyEvent* event) {
61 const base::NativeEvent& native_event = event->native_event();
62 blink::WebKeyboardEvent webkit_event;
63 XKeyEvent* native_key_event = &native_event->xkey;
64
65 webkit_event.timeStampSeconds = event->time_stamp().InSecondsF();
66 webkit_event.modifiers = EventFlagsToWebEventModifiers(event->flags());
67
68 switch (native_event->type) {
69 case KeyPress:
70 webkit_event.type = event->is_char() ? blink::WebInputEvent::Char :
71 blink::WebInputEvent::RawKeyDown;
72 break;
73 case KeyRelease:
74 webkit_event.type = blink::WebInputEvent::KeyUp;
75 break;
76 default:
77 NOTREACHED();
78 }
79
80 if (webkit_event.modifiers & blink::WebInputEvent::AltKey)
81 webkit_event.isSystemKey = true;
82
83 webkit_event.windowsKeyCode = ui::WindowsKeycodeFromNative(native_event);
84 webkit_event.nativeKeyCode = native_key_event->keycode;
85 webkit_event.unmodifiedText[0] =
86 ui::UnmodifiedTextFromNative(native_event);
87 webkit_event.text[0] = ui::TextFromNative(native_event);
88
89 webkit_event.setKeyIdentifierFromWindowsKeyCode();
90
91 // TODO: IsKeyPad?
92
93 return webkit_event;
94 }
95
96 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/web_input_event_aura.cc ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698