summaryrefslogtreecommitdiffstats
path: root/ui/views/widget
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-29 23:40:04 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-29 23:40:04 +0000
commite2ebe33202fd6d03ec9766a914f45eae646924a5 (patch)
tree27f563f89a96f2bf55fa2cd5cbf0f60a4d14beca /ui/views/widget
parentbe0fff6dceca7a2c6d7ec18275e5d4f766e97059 (diff)
downloadchromium_src-e2ebe33202fd6d03ec9766a914f45eae646924a5.zip
chromium_src-e2ebe33202fd6d03ec9766a914f45eae646924a5.tar.gz
chromium_src-e2ebe33202fd6d03ec9766a914f45eae646924a5.tar.bz2
Two changes to desktop aura for tooltips:
. Makes tooltip hide on exit. This is necessary on windows else we can leave tooltips on screen after an exit. . Changes desktop aura to only create a single TooltipController. This isn't strictly necessary, but better matches what we're doing on ash. BUG=275488 TEST=covered by test. R=varunjain@chromium.org Review URL: https://chromiumcodereview.appspot.com/23477022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@220432 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/views/widget')
-rw-r--r--ui/views/widget/desktop_aura/desktop_native_widget_aura.cc15
-rw-r--r--ui/views/widget/desktop_aura/desktop_native_widget_aura.h4
-rw-r--r--ui/views/widget/desktop_aura/scoped_tooltip_client.cc37
-rw-r--r--ui/views/widget/desktop_aura/scoped_tooltip_client.h43
4 files changed, 86 insertions, 13 deletions
diff --git a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc
index e81a823..cf068755 100644
--- a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc
+++ b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc
@@ -29,13 +29,13 @@
#include "ui/views/corewm/input_method_event_filter.h"
#include "ui/views/corewm/shadow_controller.h"
#include "ui/views/corewm/shadow_types.h"
-#include "ui/views/corewm/tooltip_controller.h"
#include "ui/views/corewm/visibility_controller.h"
#include "ui/views/corewm/window_modality_controller.h"
#include "ui/views/drag_utils.h"
#include "ui/views/ime/input_method.h"
#include "ui/views/ime/input_method_bridge.h"
#include "ui/views/widget/desktop_aura/desktop_root_window_host.h"
+#include "ui/views/widget/desktop_aura/scoped_tooltip_client.h"
#include "ui/views/widget/drop_helper.h"
#include "ui/views/widget/native_widget_aura.h"
#include "ui/views/widget/native_widget_aura_window_observer.h"
@@ -260,11 +260,8 @@ void DesktopNativeWidgetAura::InitNativeWidget(
aura::client::SetDragDropDelegate(window_, this);
tooltip_manager_.reset(new views::TooltipManagerAura(window_, GetWidget()));
- tooltip_controller_.reset(
- new corewm::TooltipController(gfx::SCREEN_TYPE_NATIVE));
- aura::client::SetTooltipClient(root_window_.get(),
- tooltip_controller_.get());
- root_window_->AddPreTargetHandler(tooltip_controller_.get());
+
+ scoped_tooltip_client_.reset(new ScopedTooltipClient(root_window_.get()));
if (params.opacity == Widget::InitParams::TRANSLUCENT_WINDOW) {
visibility_controller_.reset(new views::corewm::VisibilityController);
@@ -720,11 +717,7 @@ void DesktopNativeWidgetAura::OnWindowDestroying() {
shadow_controller_.reset();
// The DesktopRootWindowHost implementation sends OnNativeWidgetDestroying().
tooltip_manager_.reset();
- if (tooltip_controller_.get()) {
- root_window_->RemovePreTargetHandler(tooltip_controller_.get());
- tooltip_controller_.reset();
- aura::client::SetTooltipClient(root_window_.get(), NULL);
- }
+ scoped_tooltip_client_.reset();
if (window_modality_controller_) {
root_window_->RemovePreTargetHandler(window_modality_controller_.get());
window_modality_controller_.reset();
diff --git a/ui/views/widget/desktop_aura/desktop_native_widget_aura.h b/ui/views/widget/desktop_aura/desktop_native_widget_aura.h
index ce95139..1b25199 100644
--- a/ui/views/widget/desktop_aura/desktop_native_widget_aura.h
+++ b/ui/views/widget/desktop_aura/desktop_native_widget_aura.h
@@ -29,7 +29,6 @@ class CompoundEventFilter;
class InputMethodEventFilter;
class ScopedCaptureClient;
class ShadowController;
-class TooltipController;
class VisibilityController;
class WindowModalityController;
}
@@ -37,6 +36,7 @@ class WindowModalityController;
class DesktopRootWindowHost;
class DropHelper;
class NativeWidgetAuraWindowObserver;
+class ScopedTooltipClient;
class TooltipManagerAura;
class WindowReorderer;
@@ -247,7 +247,7 @@ class VIEWS_EXPORT DesktopNativeWidgetAura
scoped_ptr<DropHelper> drop_helper_;
int last_drop_operation_;
- scoped_ptr<corewm::TooltipController> tooltip_controller_;
+ scoped_ptr<ScopedTooltipClient> scoped_tooltip_client_;
scoped_ptr<TooltipManagerAura> tooltip_manager_;
scoped_ptr<views::corewm::VisibilityController> visibility_controller_;
diff --git a/ui/views/widget/desktop_aura/scoped_tooltip_client.cc b/ui/views/widget/desktop_aura/scoped_tooltip_client.cc
new file mode 100644
index 0000000..cf13102
--- /dev/null
+++ b/ui/views/widget/desktop_aura/scoped_tooltip_client.cc
@@ -0,0 +1,37 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/views/widget/desktop_aura/scoped_tooltip_client.h"
+
+#include "ui/aura/root_window.h"
+#include "ui/views/corewm/tooltip_controller.h"
+
+namespace views {
+
+// static
+corewm::TooltipController* ScopedTooltipClient::tooltip_controller_ = NULL;
+
+// static
+int ScopedTooltipClient::scoped_tooltip_client_count_ = 0;
+
+ScopedTooltipClient::ScopedTooltipClient(aura::RootWindow* root_window)
+ : root_window_(root_window) {
+ if (scoped_tooltip_client_count_++ == 0) {
+ tooltip_controller_ =
+ new corewm::TooltipController(gfx::SCREEN_TYPE_NATIVE);
+ }
+ aura::client::SetTooltipClient(root_window_, tooltip_controller_);
+ root_window_->AddPreTargetHandler(tooltip_controller_);
+}
+
+ScopedTooltipClient::~ScopedTooltipClient() {
+ root_window_->RemovePreTargetHandler(tooltip_controller_);
+ aura::client::SetTooltipClient(root_window_, NULL);
+ if (--scoped_tooltip_client_count_ == 0) {
+ delete tooltip_controller_;
+ tooltip_controller_ = NULL;
+ }
+}
+
+} // namespace views
diff --git a/ui/views/widget/desktop_aura/scoped_tooltip_client.h b/ui/views/widget/desktop_aura/scoped_tooltip_client.h
new file mode 100644
index 0000000..bb3e57b
--- /dev/null
+++ b/ui/views/widget/desktop_aura/scoped_tooltip_client.h
@@ -0,0 +1,43 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_VIEWS_WIDGET_DESKTOP_AURA_SCOPED_TOOLTIP_CLIENT_H_
+#define UI_VIEWS_WIDGET_DESKTOP_AURA_SCOPED_TOOLTIP_CLIENT_H_
+
+#include "base/basictypes.h"
+
+namespace aura {
+class RootWindow;
+}
+
+namespace views {
+
+namespace corewm {
+class TooltipController;
+}
+
+// ScopedTooltipClient is responsible for installing a TooltipClient
+// implementation on a RootWindow. Additionally it ensures only one
+// TooltipController is only ever created. In this way all
+// DesktopNativeWidgetAuras share the same TooltipClient.
+class ScopedTooltipClient {
+ public:
+ explicit ScopedTooltipClient(aura::RootWindow* root_window);
+ ~ScopedTooltipClient();
+
+ private:
+ // Single TooltipController.
+ static corewm::TooltipController* tooltip_controller_;
+
+ // Number of ScopedTooltipClients created.
+ static int scoped_tooltip_client_count_;
+
+ aura::RootWindow* root_window_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScopedTooltipClient);
+};
+
+} // namespace views
+
+#endif // UI_VIEWS_WIDGET_DESKTOP_AURA_SCOPED_TOOLTIP_CLIENT_H_