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

Side by Side Diff: mojo/views/input_method_mojo_linux.cc

Issue 851853002: It is time. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Trying to reup because the last upload failed. Created 5 years, 11 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 | « mojo/views/input_method_mojo_linux.h ('k') | mojo/views/native_widget_mojo.h » ('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 2014 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 #include "mojo/views/input_method_mojo_linux.h"
6
7 #include "ui/base/ime/text_input_client.h"
8 #include "ui/events/event.h"
9
10 namespace mojo {
11
12 InputMethodMojoLinux::InputMethodMojoLinux(
13 ui::internal::InputMethodDelegate* delegate)
14 : ui::InputMethodAuraLinux(delegate) {
15 }
16
17 InputMethodMojoLinux::~InputMethodMojoLinux() {}
18
19 bool InputMethodMojoLinux::DispatchKeyEvent(const ui::KeyEvent& event) {
20 DCHECK(event.type() == ui::ET_KEY_PRESSED ||
21 event.type() == ui::ET_KEY_RELEASED);
22 DCHECK(system_toplevel_window_focused());
23
24 // If no text input client, do nothing.
25 if (!GetTextInputClient())
26 return DispatchKeyEventPostIME(event);
27
28 // Here is where we change the differ from our base class's logic. Instead of
29 // always dispatching a key down event, and then sending a synthesized
30 // character event, we instead check to see if this is a character event and
31 // send out the key if it is. (We fallback to normal dispatch if it isn't.)
32 if (event.is_char()) {
33 const uint16 ch = event.GetCharacter();
34 if (GetTextInputClient())
35 GetTextInputClient()->InsertChar(ch, event.flags());
36
37 return false;
38 }
39
40 return DispatchKeyEventPostIME(event);
41 }
42
43 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/views/input_method_mojo_linux.h ('k') | mojo/views/native_widget_mojo.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698