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

Side by Side Diff: ash/shelf/shelf_tooltip_manager.cc

Issue 2183163002: mus: Change PointerWatcher to observe all pointer events, with moves optional. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change to use PointerEvent. Created 4 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/shelf/shelf_tooltip_manager.h" 5 #include "ash/shelf/shelf_tooltip_manager.h"
6 6
7 #include "ash/common/shell_window_ids.h" 7 #include "ash/common/shell_window_ids.h"
8 #include "ash/shelf/shelf.h" 8 #include "ash/shelf/shelf.h"
9 #include "ash/shelf/shelf_layout_manager.h" 9 #include "ash/shelf/shelf_layout_manager.h"
10 #include "ash/shelf/shelf_view.h" 10 #include "ash/shelf/shelf_view.h"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 } 166 }
167 167
168 void ShelfTooltipManager::ShowTooltipWithDelay(views::View* view) { 168 void ShelfTooltipManager::ShowTooltipWithDelay(views::View* view) {
169 if (ShouldShowTooltipForView(view)) { 169 if (ShouldShowTooltipForView(view)) {
170 timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(timer_delay_), 170 timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(timer_delay_),
171 base::Bind(&ShelfTooltipManager::ShowTooltip, 171 base::Bind(&ShelfTooltipManager::ShowTooltip,
172 weak_factory_.GetWeakPtr(), view)); 172 weak_factory_.GetWeakPtr(), view));
173 } 173 }
174 } 174 }
175 175
176 void ShelfTooltipManager::OnMousePressed(const ui::MouseEvent& event, 176 void ShelfTooltipManager::OnPointerWatcherEvent(
177 const gfx::Point& location_in_screen, 177 const ui::PointerEvent& event,
178 views::Widget* target) { 178 const gfx::Point& location_in_screen,
179 // Close on any mouse press events inside or outside the tooltip. 179 views::Widget* target) {
180 Close(); 180 // Close on any press events inside or outside the tooltip.
181 } 181 if (event.type() == ui::ET_POINTER_DOWN)
182 182 Close();
183 void ShelfTooltipManager::OnTouchPressed(const ui::TouchEvent& event,
184 const gfx::Point& location_in_screen,
185 views::Widget* target) {
186 // Close on any touch press events inside or outside the tooltip.
187 Close();
188 } 183 }
189 184
190 void ShelfTooltipManager::OnEvent(ui::Event* event) { 185 void ShelfTooltipManager::OnEvent(ui::Event* event) {
191 // Mouse and touch press events are handled via views::PointerWatcher. 186 // Mouse and touch press events are handled via views::PointerWatcher.
192 if (event->type() == ui::ET_MOUSE_PRESSED || 187 if (event->type() == ui::ET_MOUSE_PRESSED ||
193 event->type() == ui::ET_TOUCH_PRESSED) { 188 event->type() == ui::ET_TOUCH_PRESSED) {
194 return; 189 return;
195 } 190 }
196 191
197 if (event->type() == ui::ET_MOUSE_EXITED || !event->IsMouseEvent() || 192 if (event->type() == ui::ET_MOUSE_EXITED || !event->IsMouseEvent() ||
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 base::Bind(&ShelfTooltipManager::Close, weak_factory_.GetWeakPtr())); 245 base::Bind(&ShelfTooltipManager::Close, weak_factory_.GetWeakPtr()));
251 } 246 }
252 } 247 }
253 248
254 bool ShelfTooltipManager::ShouldShowTooltipForView(views::View* view) { 249 bool ShelfTooltipManager::ShouldShowTooltipForView(views::View* view) {
255 return shelf_view_ && shelf_view_->ShouldShowTooltipForView(view) && 250 return shelf_view_ && shelf_view_->ShouldShowTooltipForView(view) &&
256 shelf_layout_manager_ && shelf_layout_manager_->IsVisible(); 251 shelf_layout_manager_ && shelf_layout_manager_->IsVisible();
257 } 252 }
258 253
259 } // namespace ash 254 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698