OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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.h" | 5 #include "chrome/browser/chromeos/input_method/candidate_window.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 // in libcros. |input_method_library| is a void pointer to this object. | 578 // in libcros. |input_method_library| is a void pointer to this object. |
579 static void OnUpdateAuxiliaryText(void* input_method_library, | 579 static void OnUpdateAuxiliaryText(void* input_method_library, |
580 const std::string& utf8_text, | 580 const std::string& utf8_text, |
581 bool visible); | 581 bool visible); |
582 | 582 |
583 // The function is called when |UpdateLookupTable| signal is received | 583 // The function is called when |UpdateLookupTable| signal is received |
584 // in libcros. |input_method_library| is a void pointer to this object. | 584 // in libcros. |input_method_library| is a void pointer to this object. |
585 static void OnUpdateLookupTable(void* input_method_library, | 585 static void OnUpdateLookupTable(void* input_method_library, |
586 const InputMethodLookupTable& lookup_table); | 586 const InputMethodLookupTable& lookup_table); |
587 | 587 |
| 588 // The function is called when |UpdatePreeditText| signal is received |
| 589 // in libcros. |input_method_library| is a void pointer to this object. |
| 590 static void OnUpdatePreeditText(void* input_method_library, |
| 591 const std::string& utf8_text, |
| 592 unsigned int cursor, bool visible); |
| 593 |
| 594 // The function is called when |HidePreeditText| signal is received |
| 595 // in libcros. |input_method_library| is a void pointer to this object. |
| 596 static void OnHidePreeditText(void* input_method_library); |
| 597 |
588 // This function is called by libcros when ibus connects or disconnects. | 598 // This function is called by libcros when ibus connects or disconnects. |
589 // |input_method_library| is a void pointer to this object. | 599 // |input_method_library| is a void pointer to this object. |
590 static void OnConnectionChange(void* input_method_library, bool connected); | 600 static void OnConnectionChange(void* input_method_library, bool connected); |
591 | 601 |
592 // The connection is used for communicating with input method UI logic | 602 // The connection is used for communicating with input method UI logic |
593 // in libcros. | 603 // in libcros. |
594 InputMethodUiStatusConnection* ui_status_connection_; | 604 InputMethodUiStatusConnection* ui_status_connection_; |
595 | 605 |
596 // The candidate window view. | 606 // The candidate window view. |
597 CandidateWindowView* candidate_window_; | 607 CandidateWindowView* candidate_window_; |
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1240 functions.update_lookup_table = | 1250 functions.update_lookup_table = |
1241 &CandidateWindowController::Impl::OnUpdateLookupTable; | 1251 &CandidateWindowController::Impl::OnUpdateLookupTable; |
1242 ui_status_connection_ = MonitorInputMethodUiStatus(functions, this); | 1252 ui_status_connection_ = MonitorInputMethodUiStatus(functions, this); |
1243 if (!ui_status_connection_) { | 1253 if (!ui_status_connection_) { |
1244 LOG(ERROR) << "MonitorInputMethodUiStatus() failed."; | 1254 LOG(ERROR) << "MonitorInputMethodUiStatus() failed."; |
1245 return false; | 1255 return false; |
1246 } | 1256 } |
1247 MonitorInputMethodConnection( | 1257 MonitorInputMethodConnection( |
1248 ui_status_connection_, | 1258 ui_status_connection_, |
1249 &CandidateWindowController::Impl::OnConnectionChange); | 1259 &CandidateWindowController::Impl::OnConnectionChange); |
| 1260 MonitorInputMethodPreeditText( |
| 1261 ui_status_connection_, |
| 1262 &CandidateWindowController::Impl::OnHidePreeditText, |
| 1263 &CandidateWindowController::Impl::OnUpdatePreeditText); |
1250 | 1264 |
1251 // Create the candidate window view. | 1265 // Create the candidate window view. |
1252 CreateView(); | 1266 CreateView(); |
1253 | 1267 |
1254 return true; | 1268 return true; |
1255 } | 1269 } |
1256 | 1270 |
1257 void CandidateWindowController::Impl::CreateView() { | 1271 void CandidateWindowController::Impl::CreateView() { |
1258 // Create a non-decorated frame. | 1272 // Create a non-decorated frame. |
1259 frame_.reset(new views::Widget); | 1273 frame_.reset(new views::Widget); |
(...skipping 29 matching lines...) Expand all Loading... |
1289 } | 1303 } |
1290 | 1304 |
1291 void CandidateWindowController::Impl::OnHideLookupTable( | 1305 void CandidateWindowController::Impl::OnHideLookupTable( |
1292 void* input_method_library) { | 1306 void* input_method_library) { |
1293 CandidateWindowController::Impl* controller = | 1307 CandidateWindowController::Impl* controller = |
1294 static_cast<CandidateWindowController::Impl*>(input_method_library); | 1308 static_cast<CandidateWindowController::Impl*>(input_method_library); |
1295 | 1309 |
1296 controller->candidate_window_->HideLookupTable(); | 1310 controller->candidate_window_->HideLookupTable(); |
1297 } | 1311 } |
1298 | 1312 |
| 1313 void CandidateWindowController::Impl::OnHidePreeditText( |
| 1314 void* input_method_library) { |
| 1315 } |
| 1316 |
1299 void CandidateWindowController::Impl::OnSetCursorLocation( | 1317 void CandidateWindowController::Impl::OnSetCursorLocation( |
1300 void* input_method_library, | 1318 void* input_method_library, |
1301 int x, | 1319 int x, |
1302 int y, | 1320 int y, |
1303 int width, | 1321 int width, |
1304 int height) { | 1322 int height) { |
1305 CandidateWindowController::Impl* controller = | 1323 CandidateWindowController::Impl* controller = |
1306 static_cast<CandidateWindowController::Impl*>(input_method_library); | 1324 static_cast<CandidateWindowController::Impl*>(input_method_library); |
1307 | 1325 |
1308 // A workaround for http://crosbug.com/6460. We should ignore very short Y | 1326 // A workaround for http://crosbug.com/6460. We should ignore very short Y |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1349 if (!lookup_table.visible) { | 1367 if (!lookup_table.visible) { |
1350 controller->candidate_window_->HideLookupTable(); | 1368 controller->candidate_window_->HideLookupTable(); |
1351 return; | 1369 return; |
1352 } | 1370 } |
1353 | 1371 |
1354 controller->candidate_window_->UpdateCandidates(lookup_table); | 1372 controller->candidate_window_->UpdateCandidates(lookup_table); |
1355 controller->candidate_window_->ResizeAndMoveParentFrame(); | 1373 controller->candidate_window_->ResizeAndMoveParentFrame(); |
1356 controller->frame_->Show(); | 1374 controller->frame_->Show(); |
1357 } | 1375 } |
1358 | 1376 |
| 1377 void CandidateWindowController::Impl::OnUpdatePreeditText( |
| 1378 void* input_method_library, |
| 1379 const std::string& utf8_text, unsigned int cursor, bool visible) { |
| 1380 } |
| 1381 |
1359 void CandidateWindowController::Impl::OnCandidateCommitted(int index, | 1382 void CandidateWindowController::Impl::OnCandidateCommitted(int index, |
1360 int button, | 1383 int button, |
1361 int flags) { | 1384 int flags) { |
1362 NotifyCandidateClicked(ui_status_connection_, index, button, flags); | 1385 NotifyCandidateClicked(ui_status_connection_, index, button, flags); |
1363 } | 1386 } |
1364 | 1387 |
1365 void CandidateWindowController::Impl::OnConnectionChange( | 1388 void CandidateWindowController::Impl::OnConnectionChange( |
1366 void* input_method_library, | 1389 void* input_method_library, |
1367 bool connected) { | 1390 bool connected) { |
1368 if (!connected) { | 1391 if (!connected) { |
1369 CandidateWindowController::Impl* controller = | 1392 CandidateWindowController::Impl* controller = |
1370 static_cast<CandidateWindowController::Impl*>(input_method_library); | 1393 static_cast<CandidateWindowController::Impl*>(input_method_library); |
1371 controller->candidate_window_->HideLookupTable(); | 1394 controller->candidate_window_->HideLookupTable(); |
1372 } | 1395 } |
1373 } | 1396 } |
1374 | 1397 |
1375 CandidateWindowController::CandidateWindowController() | 1398 CandidateWindowController::CandidateWindowController() |
1376 : impl_(new CandidateWindowController::Impl) { | 1399 : impl_(new CandidateWindowController::Impl) { |
1377 } | 1400 } |
1378 | 1401 |
1379 CandidateWindowController::~CandidateWindowController() { | 1402 CandidateWindowController::~CandidateWindowController() { |
1380 delete impl_; | 1403 delete impl_; |
1381 } | 1404 } |
1382 | 1405 |
1383 bool CandidateWindowController::Init() { | 1406 bool CandidateWindowController::Init() { |
1384 return impl_->Init(); | 1407 return impl_->Init(); |
1385 } | 1408 } |
1386 | 1409 |
1387 } // namespace chromeos | 1410 } // namespace chromeos |
OLD | NEW |