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

Unified Diff: ash/shelf/shelf_tooltip_manager.cc

Issue 1937673002: Close mash shelf tooltips on touches outside the shelf. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/shelf/shelf_tooltip_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/shelf/shelf_tooltip_manager.cc
diff --git a/ash/shelf/shelf_tooltip_manager.cc b/ash/shelf/shelf_tooltip_manager.cc
index 8dda663349ac2b8e08601de2a90871e268143688..2aa93fde3d6b1869366ae4969f557c9c1b924ab7 100644
--- a/ash/shelf/shelf_tooltip_manager.cc
+++ b/ash/shelf/shelf_tooltip_manager.cc
@@ -11,6 +11,7 @@
#include "ash/shell_window_ids.h"
#include "ash/wm/window_animations.h"
#include "base/bind.h"
+#include "base/strings/string16.h"
#include "base/thread_task_runner_handle.h"
#include "base/time/time.h"
#include "ui/aura/window.h"
@@ -101,6 +102,9 @@ ShelfTooltipManager::ShelfTooltipManager(ShelfView* shelf_view)
ShelfTooltipManager::~ShelfTooltipManager() {
WillDeleteShelf();
+
+ Shell::GetInstance()->RemovePointerWatcher(this);
+
if (root_window_) {
root_window_->RemoveObserver(this);
root_window_->RemovePreTargetHandler(this);
@@ -112,10 +116,11 @@ void ShelfTooltipManager::Init() {
shelf_layout_manager_ = shelf_view_->shelf()->shelf_layout_manager();
shelf_layout_manager_->AddObserver(this);
- // TODO(msw): Observe events outside the shelf in mash, to close tooltips.
root_window_ = shelf_view_->GetWidget()->GetNativeWindow()->GetRootWindow();
root_window_->AddPreTargetHandler(this);
root_window_->AddObserver(this);
+
+ Shell::GetInstance()->AddPointerWatcher(this);
}
void ShelfTooltipManager::Close() {
@@ -168,9 +173,26 @@ void ShelfTooltipManager::ShowTooltipWithDelay(views::View* view) {
}
}
+void ShelfTooltipManager::OnMousePressed(const ui::MouseEvent& event,
+ const gfx::Point& location_in_screen) {
+ // Close on any mouse press events inside or outside the tooltip.
+ Close();
+}
+
+void ShelfTooltipManager::OnTouchPressed(const ui::TouchEvent& event,
+ const gfx::Point& location_in_screen) {
+ // Close on any touch press events inside or outside the tooltip.
+ Close();
+}
+
void ShelfTooltipManager::OnEvent(ui::Event* event) {
+ // Mouse and touch press events are handled via views::PointerWatcher.
if (event->type() == ui::ET_MOUSE_PRESSED ||
- event->type() == ui::ET_MOUSE_EXITED || !event->IsMouseEvent() ||
+ event->type() == ui::ET_TOUCH_PRESSED) {
+ return;
+ }
+
+ if (event->type() == ui::ET_MOUSE_EXITED || !event->IsMouseEvent() ||
event->target() != shelf_view_->GetWidget()->GetNativeWindow()) {
if (!event->IsKeyEvent())
Close();
« no previous file with comments | « ash/shelf/shelf_tooltip_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698