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

Side by Side Diff: ui/base/ime/fake_input_method.cc

Issue 17265006: wayland patch for inspection Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 | « ui/base/events/event.cc ('k') | ui/base/keycodes/keyboard_code_conversion_wayland.h » ('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) 2012 The Chromium Authors. All rights reserved. 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 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 "ui/base/ime/fake_input_method.h" 5 #include "ui/base/ime/fake_input_method.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/string16.h" 8 #include "base/strings/string16.h"
9 #include "ui/base/events/event.h" 9 #include "ui/base/events/event.h"
10 #include "ui/base/events/event_constants.h" 10 #include "ui/base/events/event_constants.h"
11 #include "ui/base/events/event_utils.h" 11 #include "ui/base/events/event_utils.h"
12 #include "ui/base/glib/glib_integers.h" 12 #include "ui/base/glib/glib_integers.h"
13 #include "ui/base/ime/input_method_delegate.h" 13 #include "ui/base/ime/input_method_delegate.h"
14 #include "ui/base/ime/text_input_client.h" 14 #include "ui/base/ime/text_input_client.h"
15 #include "ui/base/keycodes/keyboard_code_conversion.h" 15 #include "ui/base/keycodes/keyboard_code_conversion.h"
16 16
17 #if defined(USE_X11) 17 #if defined(USE_WAYLAND)
18 #include "ui/base/keycodes/keyboard_code_conversion_wayland.h"
19 #elif defined(USE_X11)
18 #include <X11/X.h> 20 #include <X11/X.h>
19 #include <X11/Xlib.h> 21 #include <X11/Xlib.h>
20 #include <X11/Xutil.h> 22 #include <X11/Xutil.h>
21 #include "ui/base/keycodes/keyboard_code_conversion_x.h" 23 #include "ui/base/keycodes/keyboard_code_conversion_x.h"
22 #endif 24 #endif
23 25
24 namespace { 26 namespace {
25 27
26 #if defined(USE_X11) 28 #if defined(USE_WAYLAND)
29 #elif defined(USE_X11)
27 uint32 EventFlagsFromXFlags(unsigned int flags) { 30 uint32 EventFlagsFromXFlags(unsigned int flags) {
28 return (flags & LockMask ? ui::EF_CAPS_LOCK_DOWN : 0U) | 31 return (flags & LockMask ? ui::EF_CAPS_LOCK_DOWN : 0U) |
29 (flags & ControlMask ? ui::EF_CONTROL_DOWN : 0U) | 32 (flags & ControlMask ? ui::EF_CONTROL_DOWN : 0U) |
30 (flags & ShiftMask ? ui::EF_SHIFT_DOWN : 0U) | 33 (flags & ShiftMask ? ui::EF_SHIFT_DOWN : 0U) |
31 (flags & Mod1Mask ? ui::EF_ALT_DOWN : 0U); 34 (flags & Mod1Mask ? ui::EF_ALT_DOWN : 0U);
32 } 35 }
33 #endif 36 #endif
34 37
35 } // namespace 38 } // namespace
36 39
(...skipping 27 matching lines...) Expand all
64 #if defined(OS_WIN) 67 #if defined(OS_WIN)
65 if (native_event.message == WM_CHAR) { 68 if (native_event.message == WM_CHAR) {
66 if (text_input_client_) { 69 if (text_input_client_) {
67 text_input_client_->InsertChar(ui::KeyboardCodeFromNative(native_event), 70 text_input_client_->InsertChar(ui::KeyboardCodeFromNative(native_event),
68 ui::EventFlagsFromNative(native_event)); 71 ui::EventFlagsFromNative(native_event));
69 handled = true; 72 handled = true;
70 } 73 }
71 } else { 74 } else {
72 handled = delegate_->DispatchKeyEventPostIME(native_event); 75 handled = delegate_->DispatchKeyEventPostIME(native_event);
73 } 76 }
77 #elif defined(USE_WAYLAND)
78 DCHECK(native_event);
79 if (EventTypeFromNative(native_event) == ET_KEY_RELEASED) {
80 // On key release, just dispatch it.
81 delegate_->DispatchKeyEventPostIME(native_event);
82 } else {
83 const uint32 state = EventFlagsFromNative(native_event);
84 // Send a RawKeyDown event first,
85 delegate_->DispatchKeyEventPostIME(native_event);
86 if (text_input_client_) {
87 // then send a Char event via ui::TextInputClient.
88 const KeyboardCode key_code = ui::KeyboardCodeFromNative(native_event);
89 uint16 ch = 0;
90 if (!(state & ui::EF_CONTROL_DOWN))
91 ch = ui::GetCharacterFromWaylandEvent(native_event);
92 if (!ch)
93 ch = ui::GetCharacterFromKeyCode(key_code, state);
94 if (ch)
95 text_input_client_->InsertChar(ch, state);
96 }
97 }
74 #elif defined(USE_X11) 98 #elif defined(USE_X11)
75 DCHECK(native_event); 99 DCHECK(native_event);
76 if (native_event->type == KeyRelease) { 100 if (native_event->type == KeyRelease) {
77 // On key release, just dispatch it. 101 // On key release, just dispatch it.
78 handled = delegate_->DispatchKeyEventPostIME(native_event); 102 handled = delegate_->DispatchKeyEventPostIME(native_event);
79 } else { 103 } else {
80 const uint32 state = EventFlagsFromXFlags(native_event->xkey.state); 104 const uint32 state = EventFlagsFromXFlags(native_event->xkey.state);
81 // Send a RawKeyDown event first, 105 // Send a RawKeyDown event first,
82 handled = delegate_->DispatchKeyEventPostIME(native_event); 106 handled = delegate_->DispatchKeyEventPostIME(native_event);
83 if (text_input_client_) { 107 if (text_input_client_) {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 171
148 void FakeInputMethod::AddObserver(InputMethodObserver* observer) { 172 void FakeInputMethod::AddObserver(InputMethodObserver* observer) {
149 observers_.AddObserver(observer); 173 observers_.AddObserver(observer);
150 } 174 }
151 175
152 void FakeInputMethod::RemoveObserver(InputMethodObserver* observer) { 176 void FakeInputMethod::RemoveObserver(InputMethodObserver* observer) {
153 observers_.RemoveObserver(observer); 177 observers_.RemoveObserver(observer);
154 } 178 }
155 179
156 } // namespace ui 180 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/events/event.cc ('k') | ui/base/keycodes/keyboard_code_conversion_wayland.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698