Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: chrome/browser/chromeos/input_method/input_method_engine_ibus.cc

Issue 11447007: Fix unexpected auxiliary text appearance. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/input_method_engine_ibus.h" 5 #include "chrome/browser/chromeos/input_method/input_method_engine_ibus.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 context_id_(0), 44 context_id_(0),
45 next_context_id_(1), 45 next_context_id_(1),
46 current_object_path_(0), 46 current_object_path_(0),
47 aux_text_(new ibus::IBusText()), 47 aux_text_(new ibus::IBusText()),
48 aux_text_visible_(false), 48 aux_text_visible_(false),
49 observer_(NULL), 49 observer_(NULL),
50 preedit_text_(new ibus::IBusText()), 50 preedit_text_(new ibus::IBusText()),
51 preedit_cursor_(0), 51 preedit_cursor_(0),
52 component_(new ibus::IBusComponent()), 52 component_(new ibus::IBusComponent()),
53 table_(new ibus::IBusLookupTable()), 53 table_(new ibus::IBusLookupTable()),
54 table_visible_(false), 54 window_visible_(false),
55 weak_ptr_factory_(this) { 55 weak_ptr_factory_(this) {
56 } 56 }
57 57
58 InputMethodEngineIBus::~InputMethodEngineIBus() { 58 InputMethodEngineIBus::~InputMethodEngineIBus() {
59 GetCurrentService()->UnsetEngine(); 59 GetCurrentService()->UnsetEngine();
60 input_method::InputMethodManager::GetInstance()-> 60 input_method::InputMethodManager::GetInstance()->
61 RemoveInputMethodExtension(ibus_id_); 61 RemoveInputMethodExtension(ibus_id_);
62 } 62 }
63 63
64 void InputMethodEngineIBus::Initialize( 64 void InputMethodEngineIBus::Initialize(
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 return true; 204 return true;
205 } 205 }
206 206
207 bool InputMethodEngineIBus::SetCandidateWindowVisible(bool visible, 207 bool InputMethodEngineIBus::SetCandidateWindowVisible(bool visible,
208 std::string* error) { 208 std::string* error) {
209 if (!active_) { 209 if (!active_) {
210 *error = kErrorNotActive; 210 *error = kErrorNotActive;
211 return false; 211 return false;
212 } 212 }
213 213
214 table_visible_ = visible; 214 window_visible_ = visible;
215 GetCurrentService()->UpdateLookupTable(*table_.get(), table_visible_); 215 GetCurrentService()->UpdateLookupTable(*table_.get(), window_visible_);
216 return true; 216 return true;
217 } 217 }
218 218
219 void InputMethodEngineIBus::SetCandidateWindowCursorVisible(bool visible) { 219 void InputMethodEngineIBus::SetCandidateWindowCursorVisible(bool visible) {
220 if (!active_)
221 return;
222 table_->set_is_cursor_visible(visible); 220 table_->set_is_cursor_visible(visible);
223 GetCurrentService()->UpdateLookupTable(*table_.get(), table_visible_); 221 if (active_)
222 GetCurrentService()->UpdateLookupTable(*table_.get(), window_visible_);
224 } 223 }
225 224
226 void InputMethodEngineIBus::SetCandidateWindowVertical(bool vertical) { 225 void InputMethodEngineIBus::SetCandidateWindowVertical(bool vertical) {
227 if (!active_)
228 return;
229 table_->set_orientation( 226 table_->set_orientation(
230 vertical ? ibus::IBusLookupTable::IBUS_LOOKUP_TABLE_ORIENTATION_VERTICAL : 227 vertical ? ibus::IBusLookupTable::IBUS_LOOKUP_TABLE_ORIENTATION_VERTICAL :
231 ibus::IBusLookupTable::IBUS_LOOKUP_TABLE_ORIENTATION_HORIZONTAL); 228 ibus::IBusLookupTable::IBUS_LOOKUP_TABLE_ORIENTATION_HORIZONTAL);
232 GetCurrentService()->UpdateLookupTable(*table_.get(), table_visible_); 229 if (active_)
230 GetCurrentService()->UpdateLookupTable(*table_.get(), window_visible_);
233 } 231 }
234 232
235 void InputMethodEngineIBus::SetCandidateWindowPageSize(int size) { 233 void InputMethodEngineIBus::SetCandidateWindowPageSize(int size) {
236 if (!active_)
237 return;
238 table_->set_page_size(size); 234 table_->set_page_size(size);
239 GetCurrentService()->UpdateLookupTable(*table_.get(), table_visible_); 235 if (active_)
236 GetCurrentService()->UpdateLookupTable(*table_.get(), window_visible_);
240 } 237 }
241 238
242 void InputMethodEngineIBus::SetCandidateWindowAuxText(const char* text) { 239 void InputMethodEngineIBus::SetCandidateWindowAuxText(const char* text) {
243 if (!active_)
244 return;
245 aux_text_->set_text(text); 240 aux_text_->set_text(text);
246 GetCurrentService()->UpdateAuxiliaryText(*aux_text_.get(), aux_text_visible_); 241 if (active_) {
242 // Should not show auxiliary text if the whole window visibility is false.
243 GetCurrentService()->UpdateAuxiliaryText(
244 *aux_text_.get(),
245 window_visible_ && aux_text_visible_);
246 }
247 } 247 }
248 248
249 void InputMethodEngineIBus::SetCandidateWindowAuxTextVisible(bool visible) { 249 void InputMethodEngineIBus::SetCandidateWindowAuxTextVisible(bool visible) {
250 if (!active_)
251 return;
252 aux_text_visible_ = visible; 250 aux_text_visible_ = visible;
253 GetCurrentService()->UpdateAuxiliaryText(*aux_text_.get(), aux_text_visible_); 251 if (active_) {
252 // Should not show auxiliary text if the whole window visibility is false.
253 GetCurrentService()->UpdateAuxiliaryText(
254 *aux_text_.get(),
255 window_visible_ && aux_text_visible_);
256 }
254 } 257 }
255 258
256 bool InputMethodEngineIBus::SetCandidates( 259 bool InputMethodEngineIBus::SetCandidates(
257 int context_id, 260 int context_id,
258 const std::vector<Candidate>& candidates, 261 const std::vector<Candidate>& candidates,
259 std::string* error) { 262 std::string* error) {
260 if (!active_) { 263 if (!active_) {
261 *error = kErrorNotActive; 264 *error = kErrorNotActive;
262 return false; 265 return false;
263 } 266 }
(...skipping 14 matching lines...) Expand all
278 entry.annotation = ix->annotation; 281 entry.annotation = ix->annotation;
279 entry.description_title = ix->usage.title; 282 entry.description_title = ix->usage.title;
280 entry.description_body = ix->usage.body; 283 entry.description_body = ix->usage.body;
281 284
282 // Store a mapping from the user defined ID to the candidate index. 285 // Store a mapping from the user defined ID to the candidate index.
283 candidate_indexes_[ix->id] = candidate_ids_.size(); 286 candidate_indexes_[ix->id] = candidate_ids_.size();
284 candidate_ids_.push_back(ix->id); 287 candidate_ids_.push_back(ix->id);
285 288
286 table_->mutable_candidates()->push_back(entry); 289 table_->mutable_candidates()->push_back(entry);
287 } 290 }
288 GetCurrentService()->UpdateLookupTable(*table_.get(), table_visible_); 291 GetCurrentService()->UpdateLookupTable(*table_.get(), window_visible_);
289 return true; 292 return true;
290 } 293 }
291 294
292 bool InputMethodEngineIBus::SetCursorPosition(int context_id, int candidate_id, 295 bool InputMethodEngineIBus::SetCursorPosition(int context_id, int candidate_id,
293 std::string* error) { 296 std::string* error) {
294 if (!active_) { 297 if (!active_) {
295 *error = kErrorNotActive; 298 *error = kErrorNotActive;
296 return false; 299 return false;
297 } 300 }
298 if (context_id != context_id_ || context_id_ == -1) { 301 if (context_id != context_id_ || context_id_ == -1) {
299 *error = kErrorWrongContext; 302 *error = kErrorWrongContext;
300 return false; 303 return false;
301 } 304 }
302 305
303 std::map<int, int>::const_iterator position = 306 std::map<int, int>::const_iterator position =
304 candidate_indexes_.find(candidate_id); 307 candidate_indexes_.find(candidate_id);
305 if (position == candidate_indexes_.end()) { 308 if (position == candidate_indexes_.end()) {
306 *error = kCandidateNotFound; 309 *error = kCandidateNotFound;
307 return false; 310 return false;
308 } 311 }
309 312
310 table_->set_cursor_position(position->second); 313 table_->set_cursor_position(position->second);
311 GetCurrentService()->UpdateLookupTable(*table_.get(), table_visible_); 314 GetCurrentService()->UpdateLookupTable(*table_.get(), window_visible_);
312 return true; 315 return true;
313 } 316 }
314 317
315 bool InputMethodEngineIBus::SetMenuItems(const std::vector<MenuItem>& items) { 318 bool InputMethodEngineIBus::SetMenuItems(const std::vector<MenuItem>& items) {
316 if (!active_) 319 if (!active_)
317 return false; 320 return false;
318 321
319 ibus::IBusPropertyList properties; 322 ibus::IBusPropertyList properties;
320 for (std::vector<MenuItem>::const_iterator item = items.begin(); 323 for (std::vector<MenuItem>::const_iterator item = items.begin();
321 item != items.end(); ++item) { 324 item != items.end(); ++item) {
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 DBusThreadManager::Get()->RemoveIBusEngineService(object_path_); 577 DBusThreadManager::Get()->RemoveIBusEngineService(object_path_);
575 578
576 current_object_path_++; 579 current_object_path_++;
577 object_path_ = dbus::ObjectPath(kObjectPathPrefix + 580 object_path_ = dbus::ObjectPath(kObjectPathPrefix +
578 base::IntToString(current_object_path_)); 581 base::IntToString(current_object_path_));
579 GetCurrentService()->SetEngine(this); 582 GetCurrentService()->SetEngine(this);
580 sender.Run(object_path_); 583 sender.Run(object_path_);
581 } 584 }
582 585
583 } // namespace chromeos 586 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698