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/candidate_window_controller_impl. h" | 5 #include "chrome/browser/chromeos/input_method/candidate_window_controller_impl. h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 void CandidateWindowControllerImpl::OnHideLookupTable() { | 117 void CandidateWindowControllerImpl::OnHideLookupTable() { |
118 candidate_window_->HideLookupTable(); | 118 candidate_window_->HideLookupTable(); |
119 infolist_window_->Hide(); | 119 infolist_window_->Hide(); |
120 } | 120 } |
121 | 121 |
122 void CandidateWindowControllerImpl::OnHidePreeditText() { | 122 void CandidateWindowControllerImpl::OnHidePreeditText() { |
123 candidate_window_->HidePreeditText(); | 123 candidate_window_->HidePreeditText(); |
124 } | 124 } |
125 | 125 |
126 void CandidateWindowControllerImpl::OnSetCursorLocation( | 126 void CandidateWindowControllerImpl::OnSetCursorLocation( |
127 const gfx::Rect& cursor_location, | 127 const ibus::Rect& cursor_location, |
128 const gfx::Rect& composition_head) { | 128 const ibus::Rect& composition_head) { |
129 // A workaround for http://crosbug.com/6460. We should ignore very short Y | 129 // A workaround for http://crosbug.com/6460. We should ignore very short Y |
130 // move to prevent the window from shaking up and down. | 130 // move to prevent the window from shaking up and down. |
131 const int kKeepPositionThreshold = 2; // px | 131 const int kKeepPositionThreshold = 2; // px |
132 const gfx::Rect& last_location = | 132 const gfx::Rect& last_location = |
133 candidate_window_->cursor_location(); | 133 candidate_window_->cursor_location(); |
134 const int delta_y = abs(last_location.y() - cursor_location.y()); | 134 const int delta_y = abs(last_location.y() - cursor_location.y); |
135 if ((last_location.x() == cursor_location.x()) && | 135 if ((last_location.x() == cursor_location.x) && |
136 (delta_y <= kKeepPositionThreshold)) { | 136 (delta_y <= kKeepPositionThreshold)) { |
137 DVLOG(1) << "Ignored set_cursor_location signal to prevent window shake"; | 137 DVLOG(1) << "Ignored set_cursor_location signal to prevent window shake"; |
138 return; | 138 return; |
139 } | 139 } |
140 | 140 |
141 // Remember the cursor location. | 141 // Remember the cursor location. |
142 candidate_window_->set_cursor_location(cursor_location); | 142 candidate_window_->set_cursor_location( |
143 candidate_window_->set_composition_head_location(composition_head); | 143 gfx::Rect(cursor_location.x, |
144 cursor_location.y, | |
145 cursor_location.width, | |
146 cursor_location.height)); | |
satorux1
2013/01/29 05:16:08
Cannot we do something like:
candidate_window_->s
Seigo Nonaka
2013/01/30 06:00:07
We can't add member function into ibus::Rect struc
| |
147 candidate_window_->set_composition_head_location( | |
148 gfx::Rect(composition_head.x, | |
149 composition_head.y, | |
150 composition_head.width, | |
151 composition_head.height)); | |
144 // Move the window per the cursor location. | 152 // Move the window per the cursor location. |
145 candidate_window_->ResizeAndMoveParentFrame(); | 153 candidate_window_->ResizeAndMoveParentFrame(); |
146 UpdateInfolistBounds(); | 154 UpdateInfolistBounds(); |
147 } | 155 } |
148 | 156 |
149 void CandidateWindowControllerImpl::OnUpdateAuxiliaryText( | 157 void CandidateWindowControllerImpl::OnUpdateAuxiliaryText( |
150 const std::string& utf8_text, | 158 const std::string& utf8_text, |
151 bool visible) { | 159 bool visible) { |
152 // If it's not visible, hide the auxiliary text and return. | 160 // If it's not visible, hide the auxiliary text and return. |
153 if (!visible) { | 161 if (!visible) { |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
346 | 354 |
347 if (candidate_window_rect.y() + infolist_window_size.height() > | 355 if (candidate_window_rect.y() + infolist_window_size.height() > |
348 screen_rect.bottom()) | 356 screen_rect.bottom()) |
349 result.set_y(screen_rect.bottom() - infolist_window_size.height()); | 357 result.set_y(screen_rect.bottom() - infolist_window_size.height()); |
350 | 358 |
351 return result; | 359 return result; |
352 } | 360 } |
353 | 361 |
354 } // namespace input_method | 362 } // namespace input_method |
355 } // namespace chromeos | 363 } // namespace chromeos |
OLD | NEW |