| 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/event_types.h" | 16 #include "base/event_types.h" |
| 17 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
| 18 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| 19 #include "ui/base/ime/composition_text.h" | 19 #include "ui/base/ime/composition_text.h" |
| 20 #include "ui/base/ime/composition_text_util_pango.h" | 20 #include "ui/base/ime/composition_text_util_pango.h" |
| 21 #include "ui/base/ime/text_input_client.h" | 21 #include "ui/base/ime/text_input_client.h" |
| 22 #include "ui/events/event.h" | 22 #include "ui/events/event.h" |
| 23 #include "ui/gfx/x/x11_types.h" |
| 23 | 24 |
| 24 namespace { | 25 namespace { |
| 25 | 26 |
| 26 // Constructs a GdkEventKey from a XKeyEvent and returns it. Otherwise, | 27 // Constructs a GdkEventKey from a XKeyEvent and returns it. Otherwise, |
| 27 // returns NULL. The returned GdkEvent must be freed by gdk_event_free. | 28 // returns NULL. The returned GdkEvent must be freed by gdk_event_free. |
| 28 GdkEvent* GdkEventFromXKeyEvent(XKeyEvent& xkey, bool is_modifier) { | 29 GdkEvent* GdkEventFromXKeyEvent(XKeyEvent& xkey, bool is_modifier) { |
| 29 DCHECK(xkey.type == KeyPress || xkey.type == KeyRelease); | 30 DCHECK(xkey.type == KeyPress || xkey.type == KeyRelease); |
| 30 | 31 |
| 31 // Get a GdkDisplay. | 32 // Get a GdkDisplay. |
| 32 GdkDisplay* display = gdk_x11_lookup_xdisplay(xkey.display); | 33 GdkDisplay* display = gdk_x11_lookup_xdisplay(xkey.display); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 | 97 |
| 97 X11InputMethodContextImplGtk2::X11InputMethodContextImplGtk2( | 98 X11InputMethodContextImplGtk2::X11InputMethodContextImplGtk2( |
| 98 ui::LinuxInputMethodContextDelegate* delegate) | 99 ui::LinuxInputMethodContextDelegate* delegate) |
| 99 : delegate_(delegate), | 100 : delegate_(delegate), |
| 100 gtk_context_simple_(NULL), | 101 gtk_context_simple_(NULL), |
| 101 gtk_multicontext_(NULL), | 102 gtk_multicontext_(NULL), |
| 102 gtk_context_(NULL) { | 103 gtk_context_(NULL) { |
| 103 CHECK(delegate_); | 104 CHECK(delegate_); |
| 104 | 105 |
| 105 { | 106 { |
| 106 XModifierKeymap* keymap = XGetModifierMapping( | 107 XModifierKeymap* keymap = XGetModifierMapping(gfx::GetXDisplay()); |
| 107 base::MessagePumpForUI::GetDefaultXDisplay()); | |
| 108 for (int i = 0; i < 8 * keymap->max_keypermod; ++i) { | 108 for (int i = 0; i < 8 * keymap->max_keypermod; ++i) { |
| 109 if (keymap->modifiermap[i]) | 109 if (keymap->modifiermap[i]) |
| 110 modifier_keycodes_.insert(keymap->modifiermap[i]); | 110 modifier_keycodes_.insert(keymap->modifiermap[i]); |
| 111 } | 111 } |
| 112 XFreeModifiermap(keymap); | 112 XFreeModifiermap(keymap); |
| 113 } | 113 } |
| 114 | 114 |
| 115 gtk_context_simple_ = gtk_im_context_simple_new(); | 115 gtk_context_simple_ = gtk_im_context_simple_new(); |
| 116 gtk_multicontext_ = gtk_im_multicontext_new(); | 116 gtk_multicontext_ = gtk_im_multicontext_new(); |
| 117 | 117 |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 text.length() == 1 && | 302 text.length() == 1 && |
| 303 text[0] == gdk_keyval_to_unicode(gdk_event_key_keyval_)) { | 303 text[0] == gdk_keyval_to_unicode(gdk_event_key_keyval_)) { |
| 304 is_signal_caught_ = true; | 304 is_signal_caught_ = true; |
| 305 return true; | 305 return true; |
| 306 } else { | 306 } else { |
| 307 return false; | 307 return false; |
| 308 } | 308 } |
| 309 } | 309 } |
| 310 | 310 |
| 311 } // namespace libgtk2ui | 311 } // namespace libgtk2ui |
| OLD | NEW |