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

Side by Side Diff: chrome/browser/ui/libgtk2ui/x11_input_method_context_impl_gtk2.cc

Issue 243143002: linux-aura: Supports Compose key with XIM. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Disabled EF_IME_FABRICATED_KEY flag on CrOS. Created 6 years, 8 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/ui/libgtk2ui/x11_input_method_context_impl_gtk2.h" 5 #include "chrome/browser/ui/libgtk2ui/x11_input_method_context_impl_gtk2.h"
6 6
7 #include <gdk/gdk.h> 7 #include <gdk/gdk.h>
8 #include <gdk/gdkkeysyms.h> 8 #include <gdk/gdkkeysyms.h>
9 #include <gdk/gdkx.h> 9 #include <gdk/gdkx.h>
10 10
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 93
94 } // namespace 94 } // namespace
95 95
96 namespace libgtk2ui { 96 namespace libgtk2ui {
97 97
98 X11InputMethodContextImplGtk2::X11InputMethodContextImplGtk2( 98 X11InputMethodContextImplGtk2::X11InputMethodContextImplGtk2(
99 ui::LinuxInputMethodContextDelegate* delegate) 99 ui::LinuxInputMethodContextDelegate* delegate)
100 : delegate_(delegate), 100 : delegate_(delegate),
101 gtk_context_simple_(NULL), 101 gtk_context_simple_(NULL),
102 gtk_multicontext_(NULL), 102 gtk_multicontext_(NULL),
103 gtk_context_(NULL) { 103 gtk_context_(NULL),
104 gdk_last_set_client_window_(NULL) {
104 CHECK(delegate_); 105 CHECK(delegate_);
105 106
106 { 107 {
107 XModifierKeymap* keymap = XGetModifierMapping(gfx::GetXDisplay()); 108 XModifierKeymap* keymap = XGetModifierMapping(gfx::GetXDisplay());
108 for (int i = 0; i < 8 * keymap->max_keypermod; ++i) { 109 for (int i = 0; i < 8 * keymap->max_keypermod; ++i) {
109 if (keymap->modifiermap[i]) 110 if (keymap->modifiermap[i])
110 modifier_keycodes_.insert(keymap->modifiermap[i]); 111 modifier_keycodes_.insert(keymap->modifiermap[i]);
111 } 112 }
112 XFreeModifiermap(keymap); 113 XFreeModifiermap(keymap);
113 } 114 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 const base::NativeEvent& native_key_event = key_event.native_event(); 159 const base::NativeEvent& native_key_event = key_event.native_event();
159 GdkEvent* event = GdkEventFromXKeyEvent( 160 GdkEvent* event = GdkEventFromXKeyEvent(
160 native_key_event->xkey, 161 native_key_event->xkey,
161 IsKeycodeModifierKey(native_key_event->xkey.keycode)); 162 IsKeycodeModifierKey(native_key_event->xkey.keycode));
162 if (!event) { 163 if (!event) {
163 LOG(ERROR) << "Cannot translate a XKeyEvent to a GdkEvent."; 164 LOG(ERROR) << "Cannot translate a XKeyEvent to a GdkEvent.";
164 return false; 165 return false;
165 } 166 }
166 167
167 // Set the client window and cursor location. 168 // Set the client window and cursor location.
168 gtk_im_context_set_client_window(gtk_context_, event->key.window); 169 if (event->key.window != gdk_last_set_client_window_) {
170 gtk_im_context_set_client_window(gtk_context_, event->key.window);
171 gdk_last_set_client_window_ = event->key.window;
172 }
169 // Convert the last known caret bounds relative to the screen coordinates 173 // Convert the last known caret bounds relative to the screen coordinates
170 // to a GdkRectangle relative to the client window. 174 // to a GdkRectangle relative to the client window.
171 gint x = 0; 175 gint x = 0;
172 gint y = 0; 176 gint y = 0;
173 gdk_window_get_origin(event->key.window, &x, &y); 177 gdk_window_get_origin(event->key.window, &x, &y);
174 GdkRectangle rect = {last_caret_bounds_.x() - x, 178 GdkRectangle rect = {last_caret_bounds_.x() - x,
175 last_caret_bounds_.y() - y, 179 last_caret_bounds_.y() - y,
176 last_caret_bounds_.width(), 180 last_caret_bounds_.width(),
177 last_caret_bounds_.height()}; 181 last_caret_bounds_.height()};
178 gtk_im_context_set_cursor_location(gtk_context_, &rect); 182 gtk_im_context_set_cursor_location(gtk_context_, &rect);
179 183
180 // Let an IME handle the key event. 184 // Let an IME handle the key event.
181 commit_signal_trap_.StartTrap(event->key.keyval); 185 commit_signal_trap_.StartTrap(event->key.keyval);
182 const gboolean handled = gtk_im_context_filter_keypress(gtk_context_, 186 const gboolean handled = gtk_im_context_filter_keypress(gtk_context_,
183 &event->key); 187 &event->key);
184 commit_signal_trap_.StopTrap(); 188 commit_signal_trap_.StopTrap();
185 gdk_event_free(event); 189 gdk_event_free(event);
186 190
187 return handled && !commit_signal_trap_.IsSignalCaught(); 191 return handled && !commit_signal_trap_.IsSignalCaught();
188 } 192 }
189 193
190 void X11InputMethodContextImplGtk2::Reset() { 194 void X11InputMethodContextImplGtk2::Reset() {
191 // Reset all the states of the context, not only preedit, caret but also 195 // Reset all the states of the context, not only preedit, caret but also
192 // focus. 196 // focus.
193 gtk_context_ = NULL; 197 gtk_context_ = NULL;
194 gtk_im_context_reset(gtk_context_simple_); 198 gtk_im_context_reset(gtk_context_simple_);
195 gtk_im_context_reset(gtk_multicontext_); 199 gtk_im_context_reset(gtk_multicontext_);
196 gtk_im_context_focus_out(gtk_context_simple_); 200 gtk_im_context_focus_out(gtk_context_simple_);
197 gtk_im_context_focus_out(gtk_multicontext_); 201 gtk_im_context_focus_out(gtk_multicontext_);
202 gdk_last_set_client_window_ = NULL;
198 } 203 }
199 204
200 void X11InputMethodContextImplGtk2::OnTextInputTypeChanged( 205 void X11InputMethodContextImplGtk2::OnTextInputTypeChanged(
201 ui::TextInputType text_input_type) { 206 ui::TextInputType text_input_type) {
202 switch (text_input_type) { 207 switch (text_input_type) {
203 case ui::TEXT_INPUT_TYPE_NONE: 208 case ui::TEXT_INPUT_TYPE_NONE:
204 case ui::TEXT_INPUT_TYPE_PASSWORD: 209 case ui::TEXT_INPUT_TYPE_PASSWORD:
205 gtk_context_ = gtk_context_simple_; 210 gtk_context_ = gtk_context_simple_;
206 break; 211 break;
207 default: 212 default:
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 text.length() == 1 && 307 text.length() == 1 &&
303 text[0] == gdk_keyval_to_unicode(gdk_event_key_keyval_)) { 308 text[0] == gdk_keyval_to_unicode(gdk_event_key_keyval_)) {
304 is_signal_caught_ = true; 309 is_signal_caught_ = true;
305 return true; 310 return true;
306 } else { 311 } else {
307 return false; 312 return false;
308 } 313 }
309 } 314 }
310 315
311 } // namespace libgtk2ui 316 } // namespace libgtk2ui
OLDNEW
« no previous file with comments | « chrome/browser/ui/libgtk2ui/x11_input_method_context_impl_gtk2.h ('k') | ui/aura/window_targeter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698