| 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/chromeos/input_method/input_method_engine.h" | 5 #include "chrome/browser/chromeos/input_method/input_method_engine.h" |
| 6 | 6 |
| 7 #define XK_MISCELLANY | 7 #define XK_MISCELLANY |
| 8 #include <X11/keysymdef.h> | 8 #include <X11/keysymdef.h> |
| 9 #include <X11/X.h> | 9 #include <X11/X.h> |
| 10 #include <X11/Xlib.h> | 10 #include <X11/Xlib.h> |
| 11 #include <X11/Xutil.h> | 11 #include <X11/Xutil.h> |
| 12 #undef FocusIn | 12 #undef FocusIn |
| 13 #undef FocusOut | 13 #undef FocusOut |
| 14 #undef RootWindow | 14 #undef RootWindow |
| 15 #include <map> | 15 #include <map> |
| 16 | 16 |
| 17 #include "ash/ime/input_method_menu_item.h" |
| 18 #include "ash/ime/input_method_menu_manager.h" |
| 17 #include "ash/shell.h" | 19 #include "ash/shell.h" |
| 18 #include "base/logging.h" | 20 #include "base/logging.h" |
| 19 #include "base/memory/scoped_ptr.h" | 21 #include "base/memory/scoped_ptr.h" |
| 20 #include "base/strings/string_number_conversions.h" | 22 #include "base/strings/string_number_conversions.h" |
| 21 #include "base/strings/string_util.h" | 23 #include "base/strings/string_util.h" |
| 22 #include "base/strings/utf_string_conversions.h" | 24 #include "base/strings/utf_string_conversions.h" |
| 23 #include "chromeos/ime/component_extension_ime_manager.h" | 25 #include "chromeos/ime/component_extension_ime_manager.h" |
| 24 #include "chromeos/ime/composition_text.h" | 26 #include "chromeos/ime/composition_text.h" |
| 25 #include "chromeos/ime/extension_ime_util.h" | 27 #include "chromeos/ime/extension_ime_util.h" |
| 26 #include "chromeos/ime/ibus_keymap.h" | 28 #include "chromeos/ime/ibus_keymap.h" |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 | 370 |
| 369 bool InputMethodEngine::SetMenuItems(const std::vector<MenuItem>& items) { | 371 bool InputMethodEngine::SetMenuItems(const std::vector<MenuItem>& items) { |
| 370 return UpdateMenuItems(items); | 372 return UpdateMenuItems(items); |
| 371 } | 373 } |
| 372 | 374 |
| 373 bool InputMethodEngine::UpdateMenuItems( | 375 bool InputMethodEngine::UpdateMenuItems( |
| 374 const std::vector<MenuItem>& items) { | 376 const std::vector<MenuItem>& items) { |
| 375 if (!active_) | 377 if (!active_) |
| 376 return false; | 378 return false; |
| 377 | 379 |
| 378 input_method::InputMethodPropertyList property_list; | 380 ash::ime::InputMethodMenuItemList menu_item_list; |
| 379 for (std::vector<MenuItem>::const_iterator item = items.begin(); | 381 for (std::vector<MenuItem>::const_iterator item = items.begin(); |
| 380 item != items.end(); ++item) { | 382 item != items.end(); ++item) { |
| 381 input_method::InputMethodProperty property; | 383 ash::ime::InputMethodMenuItem property; |
| 382 MenuItemToProperty(*item, &property); | 384 MenuItemToProperty(*item, &property); |
| 383 property_list.push_back(property); | 385 menu_item_list.push_back(property); |
| 384 } | 386 } |
| 385 | 387 |
| 386 input_method::InputMethodManager* manager = | 388 ash::ime::InputMethodMenuManager::GetInstance()-> |
| 387 input_method::InputMethodManager::Get(); | 389 SetCurrentInputMethodMenuItemList( |
| 388 if (manager) | 390 menu_item_list); |
| 389 manager->SetCurrentInputMethodProperties(property_list); | |
| 390 | |
| 391 return true; | 391 return true; |
| 392 } | 392 } |
| 393 | 393 |
| 394 bool InputMethodEngine::IsActive() const { | 394 bool InputMethodEngine::IsActive() const { |
| 395 return active_; | 395 return active_; |
| 396 } | 396 } |
| 397 | 397 |
| 398 void InputMethodEngine::KeyEventDone(input_method::KeyEventHandle* key_data, | 398 void InputMethodEngine::KeyEventDone(input_method::KeyEventHandle* key_data, |
| 399 bool handled) { | 399 bool handled) { |
| 400 KeyEventDoneCallback* callback = | 400 KeyEventDoneCallback* callback = |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 | 588 |
| 589 void InputMethodEngine::SetSurroundingText(const std::string& text, | 589 void InputMethodEngine::SetSurroundingText(const std::string& text, |
| 590 uint32 cursor_pos, | 590 uint32 cursor_pos, |
| 591 uint32 anchor_pos) { | 591 uint32 anchor_pos) { |
| 592 observer_->OnSurroundingTextChanged(engine_id_, | 592 observer_->OnSurroundingTextChanged(engine_id_, |
| 593 text, | 593 text, |
| 594 static_cast<int>(cursor_pos), | 594 static_cast<int>(cursor_pos), |
| 595 static_cast<int>(anchor_pos)); | 595 static_cast<int>(anchor_pos)); |
| 596 } | 596 } |
| 597 | 597 |
| 598 // TODO(uekawa): rename this method to a more reasonable name. |
| 598 void InputMethodEngine::MenuItemToProperty( | 599 void InputMethodEngine::MenuItemToProperty( |
| 599 const MenuItem& item, | 600 const MenuItem& item, |
| 600 input_method::InputMethodProperty* property) { | 601 ash::ime::InputMethodMenuItem* property) { |
| 601 property->key = item.id; | 602 property->key = item.id; |
| 602 | 603 |
| 603 if (item.modified & MENU_ITEM_MODIFIED_LABEL) { | 604 if (item.modified & MENU_ITEM_MODIFIED_LABEL) { |
| 604 property->label = item.label; | 605 property->label = item.label; |
| 605 } | 606 } |
| 606 if (item.modified & MENU_ITEM_MODIFIED_VISIBLE) { | 607 if (item.modified & MENU_ITEM_MODIFIED_VISIBLE) { |
| 607 // TODO(nona): Implement it. | 608 // TODO(nona): Implement it. |
| 608 } | 609 } |
| 609 if (item.modified & MENU_ITEM_MODIFIED_CHECKED) { | 610 if (item.modified & MENU_ITEM_MODIFIED_CHECKED) { |
| 610 property->is_selection_item_checked = item.checked; | 611 property->is_selection_item_checked = item.checked; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 630 // TODO(nona): Implement it. | 631 // TODO(nona): Implement it. |
| 631 break; | 632 break; |
| 632 } | 633 } |
| 633 } | 634 } |
| 634 } | 635 } |
| 635 | 636 |
| 636 // TODO(nona): Support item.children. | 637 // TODO(nona): Support item.children. |
| 637 } | 638 } |
| 638 | 639 |
| 639 } // namespace chromeos | 640 } // namespace chromeos |
| OLD | NEW |