diff options
author | nona@chromium.org <nona@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-30 16:39:13 +0000 |
---|---|---|
committer | nona@chromium.org <nona@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-30 16:39:13 +0000 |
commit | 5ae11343fb5e92de0e336b817039e4e5888d7381 (patch) | |
tree | b5ddc598d15d1731efb687337bc5eef1deedf560 /chrome/browser/chromeos/input_method/candidate_window_controller_impl.cc | |
parent | 5b9377557e92934f16d10f1cd225edd610dd91e5 (diff) | |
download | chromium_src-5ae11343fb5e92de0e336b817039e4e5888d7381.zip chromium_src-5ae11343fb5e92de0e336b817039e4e5888d7381.tar.gz chromium_src-5ae11343fb5e92de0e336b817039e4e5888d7381.tar.bz2 |
Move SetCursorLocation bypass code.
Current Chrome does not emit SetCursorLocation message to ibus-daemon because both candidate window and input context is in same process.
It was achieved by injecting IBusClient into ui::InputMethodIBus, but we are now able to bypass them only in chromeos/ directory.
With this refactoring, we can remove ui::internal::IBusClient, IBusChromeOSClientImpl and their injection code.
The concept of this refactoring is...
1) ui::InputMethodIBus should communicate with only chromeos::IBus*.
Do not bypass chromeos::IBus* even if bypassing ibus-daemon.
2) chrome/browser/chromeos/input_method should communicate with only chromeos::IBus*
current code handles SetCursorLocation as special case, but I think it shouldn't consider where the event is come from.
Such special logic should be in chromeos/.
With this patch, we can remove IBusUiController.
BUG=None
TEST=Manually done on lumpy.
Review URL: https://chromiumcodereview.appspot.com/11956008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@179644 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos/input_method/candidate_window_controller_impl.cc')
-rw-r--r-- | chrome/browser/chromeos/input_method/candidate_window_controller_impl.cc | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/chrome/browser/chromeos/input_method/candidate_window_controller_impl.cc b/chrome/browser/chromeos/input_method/candidate_window_controller_impl.cc index 2f91702..1fdf9a4 100644 --- a/chrome/browser/chromeos/input_method/candidate_window_controller_impl.cc +++ b/chrome/browser/chromeos/input_method/candidate_window_controller_impl.cc @@ -30,6 +30,11 @@ namespace { const int kInfolistShowDelayMilliSeconds = 500; // The milliseconds of the delay to hide the infolist window. const int kInfolistHideDelayMilliSeconds = 500; + +// Converts from ibus::Rect to gfx::Rect. +gfx::Rect IBusRectToGfxRect(const ibus::Rect& rect) { + return gfx::Rect(rect.x, rect.y, rect.width, rect.height); +} } // namespace bool CandidateWindowControllerImpl::Init(IBusController* controller) { @@ -124,23 +129,24 @@ void CandidateWindowControllerImpl::OnHidePreeditText() { } void CandidateWindowControllerImpl::OnSetCursorLocation( - const gfx::Rect& cursor_location, - const gfx::Rect& composition_head) { + const ibus::Rect& cursor_location, + const ibus::Rect& composition_head) { // A workaround for http://crosbug.com/6460. We should ignore very short Y // move to prevent the window from shaking up and down. const int kKeepPositionThreshold = 2; // px const gfx::Rect& last_location = candidate_window_->cursor_location(); - const int delta_y = abs(last_location.y() - cursor_location.y()); - if ((last_location.x() == cursor_location.x()) && + const int delta_y = abs(last_location.y() - cursor_location.y); + if ((last_location.x() == cursor_location.x) && (delta_y <= kKeepPositionThreshold)) { DVLOG(1) << "Ignored set_cursor_location signal to prevent window shake"; return; } // Remember the cursor location. - candidate_window_->set_cursor_location(cursor_location); - candidate_window_->set_composition_head_location(composition_head); + candidate_window_->set_cursor_location(IBusRectToGfxRect(cursor_location)); + candidate_window_->set_composition_head_location( + IBusRectToGfxRect(composition_head)); // Move the window per the cursor location. candidate_window_->ResizeAndMoveParentFrame(); UpdateInfolistBounds(); |