Chromium Code Reviews| 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 "chrome/browser/chromeos/input_method/ibus_ui_controller.h" | 5 #include "chrome/browser/chromeos/input_method/ibus_ui_controller.h" |
| 6 | 6 |
| 7 #if defined(HAVE_IBUS) | 7 #if defined(HAVE_IBUS) |
| 8 #include <ibus.h> | 8 #include <ibus.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 288 } | 288 } |
| 289 | 289 |
| 290 // ui::IBusClient override. | 290 // ui::IBusClient override. |
| 291 virtual InputMethodType GetInputMethodType() OVERRIDE { | 291 virtual InputMethodType GetInputMethodType() OVERRIDE { |
| 292 const std::string current_input_method_id = GetCurrentInputMethodId(); | 292 const std::string current_input_method_id = GetCurrentInputMethodId(); |
| 293 return InputMethodUtil::IsKeyboardLayout(current_input_method_id) ? | 293 return InputMethodUtil::IsKeyboardLayout(current_input_method_id) ? |
| 294 INPUT_METHOD_XKB_LAYOUT : INPUT_METHOD_NORMAL; | 294 INPUT_METHOD_XKB_LAYOUT : INPUT_METHOD_NORMAL; |
| 295 } | 295 } |
| 296 | 296 |
| 297 virtual void SetCursorLocation(IBusInputContext* context, | 297 virtual void SetCursorLocation(IBusInputContext* context, |
| 298 int32 x, | 298 int32 x, |
|
Yusuke Sato
2012/06/13 14:31:26
line 298-301: const gfx::Rect&
Seigo Nonaka
2012/06/13 15:07:18
Done.
| |
| 299 int32 y, | 299 int32 y, |
| 300 int32 w, | 300 int32 w, |
| 301 int32 h) OVERRIDE { | 301 int32 h, |
| 302 // The list of input method IDs for Mozc Japanese IMEs. | 302 const gfx::Rect& composition_head) OVERRIDE { |
|
Yusuke Sato
2012/06/13 14:31:26
super-nice :)
I'm very happy to see the hack will
| |
| 303 const char* kMozcJaInputMethodIds[] = { "mozc", "mozc-jp", "mozc-dv" }; | |
| 304 | |
| 305 if (!ui_) | 303 if (!ui_) |
| 306 return; | 304 return; |
| 307 | |
| 308 scoped_ptr<InputMethodDescriptors> input_methods( | |
| 309 InputMethodManager::GetInstance()->GetSupportedInputMethods()); | |
| 310 for (size_t i = 0; i < arraysize(kMozcJaInputMethodIds); ++i) { | |
| 311 if (IsActive(kMozcJaInputMethodIds[i], input_methods.get())) { | |
| 312 // Mozc Japanese IMEs require cursor location information to show the | |
| 313 // suggestion window in a correct position. | |
| 314 ui::internal::IBusClientImpl::SetCursorLocation(context, x, y, w, h); | |
| 315 break; // call IBusUiControllerImpl::SetCursorLocation() as well. | |
| 316 } | |
| 317 } | |
| 318 | |
| 319 // We don't have to call ibus_input_context_set_cursor_location() on | 305 // We don't have to call ibus_input_context_set_cursor_location() on |
| 320 // Chrome OS because the candidate window for IBus is integrated with | 306 // Chrome OS because the candidate window for IBus is integrated with |
| 321 // Chrome. | 307 // Chrome. |
| 322 ui_->SetCursorLocation(NULL, x, y, w, h); | 308 ui_->SetCursorLocation(NULL, x, y, w, h, composition_head); |
| 323 } | 309 } |
| 324 | 310 |
| 325 void set_ui(IBusUiControllerImpl* ui) { | 311 void set_ui(IBusUiControllerImpl* ui) { |
| 326 ui_ = ui; | 312 ui_ = ui; |
| 327 } | 313 } |
| 328 | 314 |
| 329 private: | 315 private: |
| 330 std::string GetCurrentInputMethodId() { | 316 std::string GetCurrentInputMethodId() { |
| 331 InputMethodManager* manager = InputMethodManager::GetInstance(); | 317 InputMethodManager* manager = InputMethodManager::GetInstance(); |
| 332 return manager->GetCurrentInputMethod().id(); | 318 return manager->GetCurrentInputMethod().id(); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 376 static void UpdateAuxiliaryTextThunk(IBusPanelService* sender, | 362 static void UpdateAuxiliaryTextThunk(IBusPanelService* sender, |
| 377 IBusText* text, gboolean visible, | 363 IBusText* text, gboolean visible, |
| 378 gpointer userdata) { | 364 gpointer userdata) { |
| 379 return reinterpret_cast<IBusUiControllerImpl*>(userdata) | 365 return reinterpret_cast<IBusUiControllerImpl*>(userdata) |
| 380 ->UpdateAuxiliaryText(sender, text, visible); | 366 ->UpdateAuxiliaryText(sender, text, visible); |
| 381 } | 367 } |
| 382 static void SetCursorLocationThunk(IBusPanelService* sender, | 368 static void SetCursorLocationThunk(IBusPanelService* sender, |
| 383 gint x, gint y, gint width, gint height, | 369 gint x, gint y, gint width, gint height, |
| 384 gpointer userdata) { | 370 gpointer userdata) { |
| 385 return reinterpret_cast<IBusUiControllerImpl*>(userdata) | 371 return reinterpret_cast<IBusUiControllerImpl*>(userdata) |
| 386 ->SetCursorLocation(sender, x, y, width, height); | 372 ->SetCursorLocation(sender, x, y, width, height, gfx::Rect()); |
| 387 } | 373 } |
| 388 static void UpdateLookupTableThunk(IBusPanelService* sender, | 374 static void UpdateLookupTableThunk(IBusPanelService* sender, |
| 389 IBusLookupTable* table, gboolean visible, | 375 IBusLookupTable* table, gboolean visible, |
| 390 gpointer userdata) { | 376 gpointer userdata) { |
| 391 return reinterpret_cast<IBusUiControllerImpl*>(userdata) | 377 return reinterpret_cast<IBusUiControllerImpl*>(userdata) |
| 392 ->UpdateLookupTable(sender, table, visible); | 378 ->UpdateLookupTable(sender, table, visible); |
| 393 } | 379 } |
| 394 static void UpdatePreeditTextThunk(IBusPanelService* sender, | 380 static void UpdatePreeditTextThunk(IBusPanelService* sender, |
| 395 IBusText* text, | 381 IBusText* text, |
| 396 guint cursor_pos, | 382 guint cursor_pos, |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 563 const std::string simple_text = text->text; | 549 const std::string simple_text = text->text; |
| 564 FOR_EACH_OBSERVER(Observer, observers_, | 550 FOR_EACH_OBSERVER(Observer, observers_, |
| 565 OnUpdateAuxiliaryText(simple_text, visible == TRUE)); | 551 OnUpdateAuxiliaryText(simple_text, visible == TRUE)); |
| 566 } | 552 } |
| 567 | 553 |
| 568 // Handles IBusPanelService's |SetCursorLocation| method call. | 554 // Handles IBusPanelService's |SetCursorLocation| method call. |
| 569 void SetCursorLocation(IBusPanelService *panel, | 555 void SetCursorLocation(IBusPanelService *panel, |
| 570 gint x, | 556 gint x, |
| 571 gint y, | 557 gint y, |
| 572 gint width, | 558 gint width, |
| 573 gint height) { | 559 gint height, |
| 560 const gfx::Rect& composition_head) { | |
| 574 // Note: |panel| might be NULL. See IBusChromeOSClientImpl above. | 561 // Note: |panel| might be NULL. See IBusChromeOSClientImpl above. |
| 575 FOR_EACH_OBSERVER(Observer, observers_, | 562 FOR_EACH_OBSERVER(Observer, observers_, |
| 576 OnSetCursorLocation(x, y, width, height)); | 563 OnSetCursorLocation(x, y, width, height, |
| 564 composition_head)); | |
| 577 } | 565 } |
| 578 | 566 |
| 579 // Handles IBusPanelService's |UpdatePreeditText| method call. | 567 // Handles IBusPanelService's |UpdatePreeditText| method call. |
| 580 void UpdatePreeditText(IBusPanelService *panel, | 568 void UpdatePreeditText(IBusPanelService *panel, |
| 581 IBusText *text, | 569 IBusText *text, |
| 582 guint cursor_pos, | 570 guint cursor_pos, |
| 583 gboolean visible) { | 571 gboolean visible) { |
| 584 FOR_EACH_OBSERVER(Observer, observers_, | 572 FOR_EACH_OBSERVER(Observer, observers_, |
| 585 OnUpdatePreeditText(text->text, cursor_pos, visible)); | 573 OnUpdatePreeditText(text->text, cursor_pos, visible)); |
| 586 } | 574 } |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 751 IBusUiController::~IBusUiController() { | 739 IBusUiController::~IBusUiController() { |
| 752 } | 740 } |
| 753 | 741 |
| 754 bool IsActiveForTesting(const std::string& input_method_id, | 742 bool IsActiveForTesting(const std::string& input_method_id, |
| 755 const InputMethodDescriptors* descriptors) { | 743 const InputMethodDescriptors* descriptors) { |
| 756 return IsActive(input_method_id, descriptors); | 744 return IsActive(input_method_id, descriptors); |
| 757 } | 745 } |
| 758 | 746 |
| 759 } // namespace input_method | 747 } // namespace input_method |
| 760 } // namespace chromeos | 748 } // namespace chromeos |
| OLD | NEW |