| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/chromeos/ime_keyboard_x11.h" | 5 #include "ui/base/ime/chromeos/ime_keyboard_x11.h" |
| 6 | 6 |
| 7 #include <X11/XKBlib.h> | 7 #include <X11/XKBlib.h> |
| 8 #include <X11/Xlib.h> | 8 #include <X11/Xlib.h> |
| 9 | 9 |
| 10 #include "ui/gfx/x/x11_types.h" | 10 #include "ui/gfx/x/x11_types.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 unsigned int real_mask = kBadMask; | 77 unsigned int real_mask = kBadMask; |
| 78 XkbDescPtr xkb_desc = | 78 XkbDescPtr xkb_desc = |
| 79 XkbGetKeyboard(gfx::GetXDisplay(), XkbAllComponentsMask, XkbUseCoreKbd); | 79 XkbGetKeyboard(gfx::GetXDisplay(), XkbAllComponentsMask, XkbUseCoreKbd); |
| 80 if (!xkb_desc) | 80 if (!xkb_desc) |
| 81 return kBadMask; | 81 return kBadMask; |
| 82 | 82 |
| 83 if (xkb_desc->dpy && xkb_desc->names) { | 83 if (xkb_desc->dpy && xkb_desc->names) { |
| 84 const std::string string_to_find(kNumLockVirtualModifierString); | 84 const std::string string_to_find(kNumLockVirtualModifierString); |
| 85 for (size_t i = 0; i < XkbNumVirtualMods; ++i) { | 85 for (size_t i = 0; i < XkbNumVirtualMods; ++i) { |
| 86 const unsigned int virtual_mod_mask = 1U << i; | 86 const unsigned int virtual_mod_mask = 1U << i; |
| 87 char* virtual_mod_str_raw_ptr = | 87 gfx::XScopedPtr<char> virtual_mod_str_raw_ptr( |
| 88 XGetAtomName(xkb_desc->dpy, xkb_desc->names->vmods[i]); | 88 XGetAtomName(xkb_desc->dpy, xkb_desc->names->vmods[i])); |
| 89 if (!virtual_mod_str_raw_ptr) | 89 if (!virtual_mod_str_raw_ptr) |
| 90 continue; | 90 continue; |
| 91 const std::string virtual_mod_str = virtual_mod_str_raw_ptr; | 91 const std::string virtual_mod_str = virtual_mod_str_raw_ptr.get(); |
| 92 XFree(virtual_mod_str_raw_ptr); | |
| 93 | 92 |
| 94 if (string_to_find == virtual_mod_str) { | 93 if (string_to_find == virtual_mod_str) { |
| 95 if (!XkbVirtualModsToReal(xkb_desc, virtual_mod_mask, &real_mask)) { | 94 if (!XkbVirtualModsToReal(xkb_desc, virtual_mod_mask, &real_mask)) { |
| 96 DVLOG(1) << "XkbVirtualModsToReal failed"; | 95 DVLOG(1) << "XkbVirtualModsToReal failed"; |
| 97 real_mask = kBadMask; // reset the return value, just in case. | 96 real_mask = kBadMask; // reset the return value, just in case. |
| 98 } | 97 } |
| 99 break; | 98 break; |
| 100 } | 99 } |
| 101 } | 100 } |
| 102 } | 101 } |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 return CheckLayoutName(layout_name); | 295 return CheckLayoutName(layout_name); |
| 297 } | 296 } |
| 298 | 297 |
| 299 // static | 298 // static |
| 300 ImeKeyboard* ImeKeyboard::Create() { | 299 ImeKeyboard* ImeKeyboard::Create() { |
| 301 return new ImeKeyboardX11(); | 300 return new ImeKeyboardX11(); |
| 302 } | 301 } |
| 303 | 302 |
| 304 } // namespace input_method | 303 } // namespace input_method |
| 305 } // namespace chromeos | 304 } // namespace chromeos |
| OLD | NEW |