Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/chromeos/input_method/xkeyboard.h" | 5 #include "chrome/browser/chromeos/input_method/xkeyboard.h" |
| 6 | 6 |
| 7 #include <queue> | 7 #include <queue> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 152 XkbDescPtr xkb_desc = | 152 XkbDescPtr xkb_desc = |
| 153 XkbGetKeyboard(ui::GetXDisplay(), XkbAllComponentsMask, XkbUseCoreKbd); | 153 XkbGetKeyboard(ui::GetXDisplay(), XkbAllComponentsMask, XkbUseCoreKbd); |
| 154 if (!xkb_desc) { | 154 if (!xkb_desc) { |
| 155 return kBadMask; | 155 return kBadMask; |
| 156 } | 156 } |
| 157 | 157 |
| 158 if (xkb_desc->dpy && xkb_desc->names && xkb_desc->names->vmods) { | 158 if (xkb_desc->dpy && xkb_desc->names && xkb_desc->names->vmods) { |
| 159 const std::string string_to_find(kNumLockVirtualModifierString); | 159 const std::string string_to_find(kNumLockVirtualModifierString); |
| 160 for (size_t i = 0; i < XkbNumVirtualMods; ++i) { | 160 for (size_t i = 0; i < XkbNumVirtualMods; ++i) { |
| 161 const unsigned int virtual_mod_mask = 1U << i; | 161 const unsigned int virtual_mod_mask = 1U << i; |
| 162 const char* virtual_mod_str = | 162 char* virtual_mod_str = |
| 163 XGetAtomName(xkb_desc->dpy, xkb_desc->names->vmods[i]); | 163 XGetAtomName(xkb_desc->dpy, xkb_desc->names->vmods[i]); |
| 164 if (!virtual_mod_str) { | 164 if (!virtual_mod_str) { |
| 165 continue; | 165 continue; |
| 166 } | 166 } |
| 167 if (string_to_find == virtual_mod_str) { | 167 if (string_to_find == virtual_mod_str) { |
|
Daniel Kurtz
2011/11/14 08:44:50
Do you want to compare strings, or addresses?
Perh
Yusuke Sato
2011/11/14 08:56:45
I believe std::string does not have the problem si
| |
| 168 if (!XkbVirtualModsToReal(xkb_desc, virtual_mod_mask, &real_mask)) { | 168 if (!XkbVirtualModsToReal(xkb_desc, virtual_mod_mask, &real_mask)) { |
| 169 LOG(ERROR) << "XkbVirtualModsToReal failed"; | 169 LOG(ERROR) << "XkbVirtualModsToReal failed"; |
| 170 real_mask = kBadMask; // reset the return value, just in case. | 170 real_mask = kBadMask; // reset the return value, just in case. |
| 171 } | 171 } |
| 172 XFree(virtual_mod_str); | |
| 172 break; | 173 break; |
| 173 } | 174 } |
| 175 XFree(virtual_mod_str); | |
| 174 } | 176 } |
| 175 } | 177 } |
| 176 XkbFreeKeyboard(xkb_desc, 0, True /* free all components */); | 178 XkbFreeKeyboard(xkb_desc, 0, True /* free all components */); |
| 177 return real_mask; | 179 return real_mask; |
| 178 } | 180 } |
| 179 | 181 |
| 180 bool XKeyboard::SetLayoutInternal(const std::string& layout_name, | 182 bool XKeyboard::SetLayoutInternal(const std::string& layout_name, |
| 181 const ModifierMap& modifier_map, | 183 const ModifierMap& modifier_map, |
| 182 bool force) { | 184 bool force) { |
| 183 if (!is_running_on_chrome_os_) { | 185 if (!is_running_on_chrome_os_) { |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 516 case kCapsLockKey: | 518 case kCapsLockKey: |
| 517 return "capslock"; | 519 return "capslock"; |
| 518 case kNumModifierKeys: | 520 case kNumModifierKeys: |
| 519 break; | 521 break; |
| 520 } | 522 } |
| 521 return ""; | 523 return ""; |
| 522 } | 524 } |
| 523 | 525 |
| 524 } // namespace input_method | 526 } // namespace input_method |
| 525 } // namespace chromeos | 527 } // namespace chromeos |
| OLD | NEW |