Commit c11b932f authored by Brian Liu Xu's avatar Brian Liu Xu Committed by Commit Bot

Dismiss open tooltips when window is minimized

Hides tooltips when windows are hidden or minimized on Windows.

Previously, when a browser window was minimized by the OS, tooltips
would stay open on top of other windows because they did not receive an
event that the mouse left the window. This was due to a race condition
between the minimize message and the WM_MOUSELEAVE message. Since Aura
first receives the minimize message and makes the Aura window not
"visible", the subsequent mouse exit event was thus rejected by the Aura
window. Consequently, tooltips would stick around indefinitely until the
window was restored and interacted with.

To fix this, we make the tooltip controller respond to the
WM_WINDOWPOSCHANGED message (which is also sent to us when the window is
minimizing) by explicitly hiding the tooltip.

Bug: 724538
Change-Id: I9e8a60e6de943230708b12f3a05b8ee03c27e54a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2241631Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Brian Liu Xu <brx@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#777994}
parent a4984459
......@@ -233,20 +233,24 @@ void TooltipController::OnMouseEvent(ui::MouseEvent* event) {
void TooltipController::OnTouchEvent(ui::TouchEvent* event) {
// Hide the tooltip for touch events.
tooltip_->Hide();
SetTooltipWindow(nullptr);
HideTooltipAndResetStates();
last_touch_loc_ = event->location();
}
void TooltipController::OnCancelMode(ui::CancelModeEvent* event) {
tooltip_->Hide();
SetTooltipWindow(nullptr);
HideTooltipAndResetStates();
}
void TooltipController::OnCursorVisibilityChanged(bool is_visible) {
UpdateIfRequired();
}
void TooltipController::OnWindowVisibilityChanged(aura::Window* window,
bool visible) {
if (!visible)
HideTooltipAndResetStates();
}
void TooltipController::OnWindowDestroyed(aura::Window* window) {
if (tooltip_window_ == window) {
tooltip_->Hide();
......@@ -350,6 +354,19 @@ void TooltipController::ShowTooltip() {
}
}
void TooltipController::HideTooltipAndResetStates() {
// Hide any open tooltips.
if (tooltip_shown_timer_.IsRunning())
tooltip_shown_timer_.Stop();
tooltip_->Hide();
// Cancel pending tooltips and reset controller states.
if (tooltip_defer_timer_.IsRunning())
tooltip_defer_timer_.Stop();
SetTooltipWindow(nullptr);
tooltip_id_ = nullptr;
}
bool TooltipController::IsTooltipVisible() {
return tooltip_->IsVisible();
}
......
......@@ -57,6 +57,7 @@ class VIEWS_EXPORT TooltipController
void OnCursorVisibilityChanged(bool is_visible) override;
// Overridden from aura::WindowObserver.
void OnWindowVisibilityChanged(aura::Window* window, bool visible) override;
void OnWindowDestroyed(aura::Window* window) override;
void OnWindowPropertyChanged(aura::Window* window,
const void* key,
......@@ -72,6 +73,9 @@ class VIEWS_EXPORT TooltipController
// Show the tooltip.
void ShowTooltip();
// Hide the tooltip, clear timers, and reset controller states.
void HideTooltipAndResetStates();
// Updates the tooltip if required (if there is any change in the tooltip
// text, tooltip id or the aura::Window).
void UpdateIfRequired();
......
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