Commit e2664490 authored by azurewei's avatar azurewei Committed by Commit bot

Hide keyboard before showing IME menu.

BUG=677087
TEST=Verified on local build.

Review-Url: https://codereview.chromium.org/2607493002
Cr-Commit-Position: refs/heads/master@{#440911}
parent 857d7966
...@@ -342,7 +342,8 @@ ImeMenuTray::ImeMenuTray(WmShelf* wm_shelf) ...@@ -342,7 +342,8 @@ ImeMenuTray::ImeMenuTray(WmShelf* wm_shelf)
show_keyboard_(false), show_keyboard_(false),
force_show_keyboard_(false), force_show_keyboard_(false),
should_block_shelf_auto_hide_(false), should_block_shelf_auto_hide_(false),
keyboard_suppressed_(false) { keyboard_suppressed_(false),
show_bubble_after_keyboard_hidden_(false) {
if (MaterialDesignController::IsShelfMaterial()) { if (MaterialDesignController::IsShelfMaterial()) {
SetInkDropMode(InkDropMode::ON); SetInkDropMode(InkDropMode::ON);
SetContentsBackground(false); SetContentsBackground(false);
...@@ -365,6 +366,19 @@ ImeMenuTray::~ImeMenuTray() { ...@@ -365,6 +366,19 @@ ImeMenuTray::~ImeMenuTray() {
} }
void ImeMenuTray::ShowImeMenuBubble() { void ImeMenuTray::ShowImeMenuBubble() {
keyboard::KeyboardController* keyboard_controller =
keyboard::KeyboardController::GetInstance();
if (keyboard_controller && keyboard_controller->keyboard_visible()) {
show_bubble_after_keyboard_hidden_ = true;
keyboard_controller->AddObserver(this);
keyboard_controller->HideKeyboard(
keyboard::KeyboardController::HIDE_REASON_AUTOMATIC);
} else {
ShowImeMenuBubbleInternal();
}
}
void ImeMenuTray::ShowImeMenuBubbleInternal() {
int minimum_menu_width = GetMinimumMenuWidth(); int minimum_menu_width = GetMinimumMenuWidth();
should_block_shelf_auto_hide_ = true; should_block_shelf_auto_hide_ = true;
views::TrayBubbleView::InitParams init_params( views::TrayBubbleView::InitParams init_params(
...@@ -554,6 +568,17 @@ void ImeMenuTray::OnKeyboardClosed() { ...@@ -554,6 +568,17 @@ void ImeMenuTray::OnKeyboardClosed() {
} }
void ImeMenuTray::OnKeyboardHidden() { void ImeMenuTray::OnKeyboardHidden() {
if (show_bubble_after_keyboard_hidden_) {
show_bubble_after_keyboard_hidden_ = false;
keyboard::KeyboardController* keyboard_controller =
keyboard::KeyboardController::GetInstance();
if (keyboard_controller)
keyboard_controller->RemoveObserver(this);
ShowImeMenuBubbleInternal();
return;
}
if (!show_keyboard_) if (!show_keyboard_)
return; return;
......
...@@ -92,6 +92,9 @@ class ASH_EXPORT ImeMenuTray : public TrayBackgroundView, ...@@ -92,6 +92,9 @@ class ASH_EXPORT ImeMenuTray : public TrayBackgroundView,
// To allow the test class to access |label_|. // To allow the test class to access |label_|.
friend class ImeMenuTrayTest; friend class ImeMenuTrayTest;
// Show the IME menu bubble immediately.
void ShowImeMenuBubbleInternal();
// Updates the text of the label on the tray. // Updates the text of the label on the tray.
void UpdateTrayLabel(); void UpdateTrayLabel();
...@@ -105,6 +108,7 @@ class ASH_EXPORT ImeMenuTray : public TrayBackgroundView, ...@@ -105,6 +108,7 @@ class ASH_EXPORT ImeMenuTray : public TrayBackgroundView,
bool force_show_keyboard_; bool force_show_keyboard_;
bool should_block_shelf_auto_hide_; bool should_block_shelf_auto_hide_;
bool keyboard_suppressed_; bool keyboard_suppressed_;
bool show_bubble_after_keyboard_hidden_;
DISALLOW_COPY_AND_ASSIGN(ImeMenuTray); DISALLOW_COPY_AND_ASSIGN(ImeMenuTray);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment