| OLD | NEW |
| 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 |
| 11 #include <gtk/gtk.h> | 11 #include <gtk/gtk.h> |
| 12 | 12 |
| 13 #include <X11/X.h> | 13 #include <X11/X.h> |
| 14 #include <X11/Xlib.h> | 14 #include <X11/Xlib.h> |
| 15 | 15 |
| 16 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 18 #include "ui/base/ime/composition_text.h" | 18 #include "ui/base/ime/composition_text.h" |
| 19 #include "ui/base/ime/composition_text_util_pango.h" | 19 #include "ui/base/ime/composition_text_util_pango.h" |
| 20 #include "ui/base/ime/text_input_client.h" | 20 #include "ui/base/ime/text_input_client.h" |
| 21 #include "ui/events/event.h" | 21 #include "ui/events/event.h" |
| 22 #include "ui/events/keycodes/keyboard_code_conversion_x.h" | |
| 23 #include "ui/gfx/x/x11_types.h" | 22 #include "ui/gfx/x/x11_types.h" |
| 24 | 23 |
| 25 namespace libgtk2ui { | 24 namespace libgtk2ui { |
| 26 | 25 |
| 27 X11InputMethodContextImplGtk2::X11InputMethodContextImplGtk2( | 26 X11InputMethodContextImplGtk2::X11InputMethodContextImplGtk2( |
| 28 ui::LinuxInputMethodContextDelegate* delegate) | 27 ui::LinuxInputMethodContextDelegate* delegate) |
| 29 : delegate_(delegate), | 28 : delegate_(delegate), |
| 30 gtk_context_simple_(NULL), | 29 gtk_context_simple_(NULL), |
| 31 gtk_multicontext_(NULL), | 30 gtk_multicontext_(NULL), |
| 32 gtk_context_(NULL), | 31 gtk_context_(NULL), |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 break; | 184 break; |
| 186 } | 185 } |
| 187 } | 186 } |
| 188 } | 187 } |
| 189 XFree(const_cast<KeySym*>(keysyms)); | 188 XFree(const_cast<KeySym*>(keysyms)); |
| 190 XFreeModifiermap(const_cast<XModifierKeymap*>(modmap)); | 189 XFreeModifiermap(const_cast<XModifierKeymap*>(modmap)); |
| 191 } | 190 } |
| 192 | 191 |
| 193 GdkEvent* X11InputMethodContextImplGtk2::GdkEventFromNativeEvent( | 192 GdkEvent* X11InputMethodContextImplGtk2::GdkEventFromNativeEvent( |
| 194 const base::NativeEvent& native_event) { | 193 const base::NativeEvent& native_event) { |
| 195 XEvent xkeyevent; | 194 const XKeyEvent& xkey = native_event->xkey; |
| 196 if (native_event->type == GenericEvent) { | 195 DCHECK(xkey.type == KeyPress || xkey.type == KeyRelease); |
| 197 // If this is an XI2 key event, build a matching core X event, to avoid | |
| 198 // having two cases for every use. | |
| 199 ui::InitXKeyEventFromXIDeviceEvent(*native_event, &xkeyevent); | |
| 200 } else { | |
| 201 DCHECK(native_event->type == KeyPress || native_event->type == KeyRelease); | |
| 202 xkeyevent.xkey = native_event->xkey; | |
| 203 } | |
| 204 const XKeyEvent& xkey = xkeyevent.xkey; | |
| 205 | 196 |
| 206 // Get a GdkDisplay. | 197 // Get a GdkDisplay. |
| 207 GdkDisplay* display = gdk_x11_lookup_xdisplay(xkey.display); | 198 GdkDisplay* display = gdk_x11_lookup_xdisplay(xkey.display); |
| 208 if (!display) { | 199 if (!display) { |
| 209 // Fall back to the default display. | 200 // Fall back to the default display. |
| 210 display = gdk_display_get_default(); | 201 display = gdk_display_get_default(); |
| 211 } | 202 } |
| 212 if (!display) { | 203 if (!display) { |
| 213 LOG(ERROR) << "Cannot get a GdkDisplay for a key event."; | 204 LOG(ERROR) << "Cannot get a GdkDisplay for a key event."; |
| 214 return NULL; | 205 return NULL; |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 text.length() == 1 && | 360 text.length() == 1 && |
| 370 text[0] == gdk_keyval_to_unicode(gdk_event_key_keyval_)) { | 361 text[0] == gdk_keyval_to_unicode(gdk_event_key_keyval_)) { |
| 371 is_signal_caught_ = true; | 362 is_signal_caught_ = true; |
| 372 return true; | 363 return true; |
| 373 } else { | 364 } else { |
| 374 return false; | 365 return false; |
| 375 } | 366 } |
| 376 } | 367 } |
| 377 | 368 |
| 378 } // namespace libgtk2ui | 369 } // namespace libgtk2ui |
| OLD | NEW |