Navigation Menu

Skip to content

Commit

Permalink
Merge pull request #11629 from brenca/tooltip-fix
Browse files Browse the repository at this point in the history
Explicitly hide tooltip when the window is deactivated (1-8-x)
  • Loading branch information
ckerr committed Jan 19, 2018
2 parents d0ca62b + 445781c commit 6efa330
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
23 changes: 23 additions & 0 deletions atom/browser/ui/win/atom_desktop_native_widget_aura.cc
Expand Up @@ -3,12 +3,16 @@
// found in the LICENSE file.

#include "atom/browser/ui/win/atom_desktop_native_widget_aura.h"
#include "ui/views/corewm/tooltip_controller.h"
#include "ui/wm/public/tooltip_client.h"

namespace atom {

AtomDesktopNativeWidgetAura::AtomDesktopNativeWidgetAura(
views::internal::NativeWidgetDelegate* delegate)
: views::DesktopNativeWidgetAura(delegate) {
// This is to enable the override of OnWindowActivated
aura::client::SetActivationChangeObserver(GetNativeWindow(), this);
}

void AtomDesktopNativeWidgetAura::Activate() {
Expand All @@ -19,4 +23,23 @@ void AtomDesktopNativeWidgetAura::Activate() {
views::DesktopNativeWidgetAura::Activate();
}

void AtomDesktopNativeWidgetAura::OnWindowActivated(
aura::client::ActivationChangeObserver::ActivationReason reason,
aura::Window* gained_active,
aura::Window* lost_active) {
views::DesktopNativeWidgetAura::OnWindowActivated(
reason, gained_active, lost_active);
if (lost_active != nullptr) {
auto* tooltip_controller = static_cast<views::corewm::TooltipController*>(
aura::client::GetTooltipClient(lost_active->GetRootWindow()));

// This will cause the tooltip to be hidden when a window is deactivated,
// as it should be.
// TODO(brenca): Remove this fix when the chromium issue is fixed.
// crbug.com/724538
if (tooltip_controller != nullptr)
tooltip_controller->OnCancelMode(nullptr);
}
}

} // namespace atom
4 changes: 4 additions & 0 deletions atom/browser/ui/win/atom_desktop_native_widget_aura.h
Expand Up @@ -19,6 +19,10 @@ class AtomDesktopNativeWidgetAura : public views::DesktopNativeWidgetAura {
void Activate() override;

private:
void OnWindowActivated(
aura::client::ActivationChangeObserver::ActivationReason reason,
aura::Window* gained_active,
aura::Window* lost_active) override;
DISALLOW_COPY_AND_ASSIGN(AtomDesktopNativeWidgetAura);
};

Expand Down

0 comments on commit 6efa330

Please sign in to comment.