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

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: Sync and rebase; cleanup. 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..66ba5c791c5122359ec89ead9e8dda60276052e2 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,6 +173,18 @@ void ShelfTooltipManager::ShowTooltipWithDelay(views::View* view) {
}
}
+void ShelfTooltipManager::OnMousePressed(const ui::MouseEvent& event,
+ const gfx::Point& location_in_screen) {
+ // PointerWatcher supports tracking events outside the root window in mash.
James Cook 2016/05/04 19:17:49 nit: I might say something explicitly that any cli
msw 2016/05/04 20:07:49 Done.
+ Close();
+}
+
+void ShelfTooltipManager::OnTouchPressed(const ui::TouchEvent& event,
+ const gfx::Point& location_in_screen) {
+ // PointerWatcher supports tracking events outside the root window in mash.
+ Close();
+}
+
void ShelfTooltipManager::OnEvent(ui::Event* event) {
if (event->type() == ui::ET_MOUSE_PRESSED ||
James Cook 2016/05/04 19:17:49 Eliminate this one, as it's confusing that there a
msw 2016/05/04 20:07:49 Done. (Added early return for touch/mouse pressed)
event->type() == ui::ET_MOUSE_EXITED || !event->IsMouseEvent() ||
« 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