OLD | NEW |
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/character_composer.h" | 5 #include "ui/base/ime/character_composer.h" |
6 | 6 |
7 #include <X11/Xlib.h> | 7 #include <X11/Xlib.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <iterator> | 10 #include <iterator> |
11 | 11 |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "base/third_party/icu/icu_utf.h" | 13 #include "base/third_party/icu/icu_utf.h" |
14 // Note for Gtk removal: gdkkeysyms.h only contains a set of | 14 // Note for Gtk removal: gdkkeysyms.h only contains a set of |
15 // '#define GDK_KeyName 0xNNNN' macros and does not #include any Gtk headers. | 15 // '#define GDK_KeyName 0xNNNN' macros and does not #include any Gtk headers. |
16 #include "third_party/gtk+/gdk/gdkkeysyms.h" | 16 #include "third_party/gtk+/gdk/gdkkeysyms.h" |
17 #include "ui/base/glib/glib_integers.h" | 17 #include "ui/base/glib/glib_integers.h" |
18 #include "ui/base/x/x11_util.h" | |
19 #include "ui/events/event_constants.h" | 18 #include "ui/events/event_constants.h" |
| 19 #include "ui/gfx/x/x11_types.h" |
20 | 20 |
21 // Note for Gtk removal: gtkimcontextsimpleseqs.h does not #include any Gtk | 21 // Note for Gtk removal: gtkimcontextsimpleseqs.h does not #include any Gtk |
22 // headers and only contains one big guint16 array |gtk_compose_seqs_compact| | 22 // headers and only contains one big guint16 array |gtk_compose_seqs_compact| |
23 // which defines the main compose table. The table has internal linkage. | 23 // which defines the main compose table. The table has internal linkage. |
24 // The order of header inclusion is out of order because | 24 // The order of header inclusion is out of order because |
25 // gtkimcontextsimpleseqs.h depends on guint16, which is defined in | 25 // gtkimcontextsimpleseqs.h depends on guint16, which is defined in |
26 // "ui/base/glib/glib_integers.h". | 26 // "ui/base/glib/glib_integers.h". |
27 #include "third_party/gtk+/gtk/gtkimcontextsimpleseqs.h" | 27 #include "third_party/gtk+/gtk/gtkimcontextsimpleseqs.h" |
28 | 28 |
29 namespace { | 29 namespace { |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 if (character) { | 364 if (character) { |
365 output->resize(CBU16_LENGTH(character)); | 365 output->resize(CBU16_LENGTH(character)); |
366 size_t i = 0; | 366 size_t i = 0; |
367 CBU16_APPEND_UNSAFE(&(*output)[0], i, character); | 367 CBU16_APPEND_UNSAFE(&(*output)[0], i, character); |
368 } | 368 } |
369 return true; | 369 return true; |
370 } | 370 } |
371 | 371 |
372 // Converts a X keycode to a X keysym with no modifiers. | 372 // Converts a X keycode to a X keysym with no modifiers. |
373 KeySym XKeyCodeToXKeySym(unsigned int keycode) { | 373 KeySym XKeyCodeToXKeySym(unsigned int keycode) { |
374 Display* display = ui::GetXDisplay(); | 374 XDisplay* display = gfx::GetXDisplay(); |
375 if (!display) | 375 if (!display) |
376 return NoSymbol; | 376 return NoSymbol; |
377 | 377 |
378 XKeyEvent x_key_event = {0}; | 378 XKeyEvent x_key_event = {0}; |
379 x_key_event.type = KeyPress; | 379 x_key_event.type = KeyPress; |
380 x_key_event.display = display; | 380 x_key_event.display = display; |
381 x_key_event.keycode = keycode; | 381 x_key_event.keycode = keycode; |
382 return ::XLookupKeysym(&x_key_event, 0); | 382 return ::XLookupKeysym(&x_key_event, 0); |
383 } | 383 } |
384 | 384 |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 std::string preedit_string_ascii("u"); | 543 std::string preedit_string_ascii("u"); |
544 for (size_t i = 0; i != compose_buffer_.size(); ++i) { | 544 for (size_t i = 0; i != compose_buffer_.size(); ++i) { |
545 const int digit = compose_buffer_[i]; | 545 const int digit = compose_buffer_[i]; |
546 DCHECK(0 <= digit && digit < 16); | 546 DCHECK(0 <= digit && digit < 16); |
547 preedit_string_ascii += digit <= 9 ? ('0' + digit) : ('a' + (digit - 10)); | 547 preedit_string_ascii += digit <= 9 ? ('0' + digit) : ('a' + (digit - 10)); |
548 } | 548 } |
549 preedit_string_ = ASCIIToUTF16(preedit_string_ascii); | 549 preedit_string_ = ASCIIToUTF16(preedit_string_ascii); |
550 } | 550 } |
551 | 551 |
552 } // namespace ui | 552 } // namespace ui |
OLD | NEW |