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

Side by Side Diff: ash/common/system/chromeos/ime_menu/ime_menu_tray.cc

Issue 2607493002: Hide keyboard before showing IME menu. (Closed)
Patch Set: Created 3 years, 12 months 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
« no previous file with comments | « ash/common/system/chromeos/ime_menu/ime_menu_tray.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "ash/common/system/chromeos/ime_menu/ime_menu_tray.h" 5 #include "ash/common/system/chromeos/ime_menu/ime_menu_tray.h"
6 6
7 #include "ash/common/accessibility_delegate.h" 7 #include "ash/common/accessibility_delegate.h"
8 #include "ash/common/ash_constants.h" 8 #include "ash/common/ash_constants.h"
9 #include "ash/common/material_design/material_design_controller.h" 9 #include "ash/common/material_design/material_design_controller.h"
10 #include "ash/common/session/session_state_delegate.h" 10 #include "ash/common/session/session_state_delegate.h"
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 }; 335 };
336 336
337 } // namespace 337 } // namespace
338 338
339 ImeMenuTray::ImeMenuTray(WmShelf* wm_shelf) 339 ImeMenuTray::ImeMenuTray(WmShelf* wm_shelf)
340 : TrayBackgroundView(wm_shelf), 340 : TrayBackgroundView(wm_shelf),
341 label_(new ImeMenuLabel()), 341 label_(new ImeMenuLabel()),
342 show_keyboard_(false), 342 show_keyboard_(false),
343 force_show_keyboard_(false), 343 force_show_keyboard_(false),
344 should_block_shelf_auto_hide_(false), 344 should_block_shelf_auto_hide_(false),
345 keyboard_suppressed_(false) { 345 keyboard_suppressed_(false),
346 show_bubble_after_keyboard_hidden_(false) {
346 if (MaterialDesignController::IsShelfMaterial()) { 347 if (MaterialDesignController::IsShelfMaterial()) {
347 SetInkDropMode(InkDropMode::ON); 348 SetInkDropMode(InkDropMode::ON);
348 SetContentsBackground(false); 349 SetContentsBackground(false);
349 } else { 350 } else {
350 SetContentsBackground(true); 351 SetContentsBackground(true);
351 } 352 }
352 SetupLabelForTray(label_); 353 SetupLabelForTray(label_);
353 tray_container()->AddChildView(label_); 354 tray_container()->AddChildView(label_);
354 SystemTrayNotifier* tray_notifier = WmShell::Get()->system_tray_notifier(); 355 SystemTrayNotifier* tray_notifier = WmShell::Get()->system_tray_notifier();
355 tray_notifier->AddIMEObserver(this); 356 tray_notifier->AddIMEObserver(this);
356 tray_notifier->AddVirtualKeyboardObserver(this); 357 tray_notifier->AddVirtualKeyboardObserver(this);
357 } 358 }
358 359
359 ImeMenuTray::~ImeMenuTray() { 360 ImeMenuTray::~ImeMenuTray() {
360 if (bubble_) 361 if (bubble_)
361 bubble_->bubble_view()->reset_delegate(); 362 bubble_->bubble_view()->reset_delegate();
362 SystemTrayNotifier* tray_notifier = WmShell::Get()->system_tray_notifier(); 363 SystemTrayNotifier* tray_notifier = WmShell::Get()->system_tray_notifier();
363 tray_notifier->RemoveIMEObserver(this); 364 tray_notifier->RemoveIMEObserver(this);
364 tray_notifier->RemoveVirtualKeyboardObserver(this); 365 tray_notifier->RemoveVirtualKeyboardObserver(this);
365 } 366 }
366 367
367 void ImeMenuTray::ShowImeMenuBubble() { 368 void ImeMenuTray::ShowImeMenuBubble() {
369 keyboard::KeyboardController* keyboard_controller =
370 keyboard::KeyboardController::GetInstance();
371 if (keyboard_controller && keyboard_controller->keyboard_visible()) {
372 show_bubble_after_keyboard_hidden_ = true;
373 keyboard_controller->AddObserver(this);
374 keyboard_controller->HideKeyboard(
375 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC);
376 } else {
377 ShowImeMenuBubbleInternal();
378 }
379 }
380
381 void ImeMenuTray::ShowImeMenuBubbleInternal() {
368 int minimum_menu_width = GetMinimumMenuWidth(); 382 int minimum_menu_width = GetMinimumMenuWidth();
369 should_block_shelf_auto_hide_ = true; 383 should_block_shelf_auto_hide_ = true;
370 views::TrayBubbleView::InitParams init_params( 384 views::TrayBubbleView::InitParams init_params(
371 GetAnchorAlignment(), minimum_menu_width, minimum_menu_width); 385 GetAnchorAlignment(), minimum_menu_width, minimum_menu_width);
372 init_params.can_activate = true; 386 init_params.can_activate = true;
373 init_params.close_on_deactivate = true; 387 init_params.close_on_deactivate = true;
374 388
375 views::TrayBubbleView* bubble_view = 389 views::TrayBubbleView* bubble_view =
376 views::TrayBubbleView::Create(GetBubbleAnchor(), this, &init_params); 390 views::TrayBubbleView::Create(GetBubbleAnchor(), this, &init_params);
377 bubble_view->set_anchor_view_insets(GetBubbleAnchorInsets()); 391 bubble_view->set_anchor_view_insets(GetBubbleAnchorInsets());
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 void ImeMenuTray::OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) {} 561 void ImeMenuTray::OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) {}
548 562
549 void ImeMenuTray::OnKeyboardClosed() { 563 void ImeMenuTray::OnKeyboardClosed() {
550 if (InputMethodManager::Get()) 564 if (InputMethodManager::Get())
551 InputMethodManager::Get()->OverrideKeyboardUrlRef(std::string()); 565 InputMethodManager::Get()->OverrideKeyboardUrlRef(std::string());
552 show_keyboard_ = false; 566 show_keyboard_ = false;
553 force_show_keyboard_ = false; 567 force_show_keyboard_ = false;
554 } 568 }
555 569
556 void ImeMenuTray::OnKeyboardHidden() { 570 void ImeMenuTray::OnKeyboardHidden() {
571 if (show_bubble_after_keyboard_hidden_) {
572 show_bubble_after_keyboard_hidden_ = false;
573 keyboard::KeyboardController* keyboard_controller =
574 keyboard::KeyboardController::GetInstance();
575 if (keyboard_controller)
576 keyboard_controller->RemoveObserver(this);
577
578 ShowImeMenuBubbleInternal();
579 return;
580 }
581
557 if (!show_keyboard_) 582 if (!show_keyboard_)
558 return; 583 return;
559 584
560 // If the the IME menu has overriding the input view url, we should write it 585 // If the the IME menu has overriding the input view url, we should write it
561 // back to normal keyboard when hiding the input view. 586 // back to normal keyboard when hiding the input view.
562 if (InputMethodManager::Get()) 587 if (InputMethodManager::Get())
563 InputMethodManager::Get()->OverrideKeyboardUrlRef(std::string()); 588 InputMethodManager::Get()->OverrideKeyboardUrlRef(std::string());
564 show_keyboard_ = false; 589 show_keyboard_ = false;
565 590
566 // If the keyboard is forced to be shown by IME menu for once, we need to 591 // If the keyboard is forced to be shown by IME menu for once, we need to
(...skipping 20 matching lines...) Expand all
587 WmShell::Get()->system_tray_delegate()->GetCurrentIME(&current_ime_); 612 WmShell::Get()->system_tray_delegate()->GetCurrentIME(&current_ime_);
588 613
589 // Updates the tray label based on the current input method. 614 // Updates the tray label based on the current input method.
590 if (current_ime_.third_party) 615 if (current_ime_.third_party)
591 label_->SetText(current_ime_.short_name + base::UTF8ToUTF16("*")); 616 label_->SetText(current_ime_.short_name + base::UTF8ToUTF16("*"));
592 else 617 else
593 label_->SetText(current_ime_.short_name); 618 label_->SetText(current_ime_.short_name);
594 } 619 }
595 620
596 } // namespace ash 621 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/chromeos/ime_menu/ime_menu_tray.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698