Chromium Code Reviews| 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() || |