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

Side by Side Diff: ui/views/corewm/tooltip_controller.cc

Issue 2829653002: Removed (spurious, touch-initiated) tooltips from nav buttons (Closed)
Patch Set: Unit test cleanup Created 3 years, 8 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
« no previous file with comments | « ui/views/corewm/tooltip_controller.h ('k') | ui/views/corewm/tooltip_controller_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/views/corewm/tooltip_controller.h" 5 #include "ui/views/corewm/tooltip_controller.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 // On key press, we want to hide the tooltip and not show it until change. 174 // On key press, we want to hide the tooltip and not show it until change.
175 // This is the same behavior as hiding tooltips on timeout. Hence, we can 175 // This is the same behavior as hiding tooltips on timeout. Hence, we can
176 // simply simulate a timeout. 176 // simply simulate a timeout.
177 if (tooltip_shown_timer_.IsRunning()) { 177 if (tooltip_shown_timer_.IsRunning()) {
178 tooltip_shown_timer_.Stop(); 178 tooltip_shown_timer_.Stop();
179 TooltipShownTimerFired(); 179 TooltipShownTimerFired();
180 } 180 }
181 } 181 }
182 182
183 void TooltipController::OnMouseEvent(ui::MouseEvent* event) { 183 void TooltipController::OnMouseEvent(ui::MouseEvent* event) {
184 // Ignore mouse events that coincide with the last touch event.
185 if (event->location() == last_touch_loc_) {
186 SetTooltipWindow(nullptr);
187
188 if (tooltip_->IsVisible())
189 UpdateIfRequired();
190 return;
191 }
184 switch (event->type()) { 192 switch (event->type()) {
185 case ui::ET_MOUSE_CAPTURE_CHANGED: 193 case ui::ET_MOUSE_CAPTURE_CHANGED:
186 case ui::ET_MOUSE_EXITED: 194 case ui::ET_MOUSE_EXITED:
187 case ui::ET_MOUSE_MOVED: 195 case ui::ET_MOUSE_MOVED:
188 case ui::ET_MOUSE_DRAGGED: { 196 case ui::ET_MOUSE_DRAGGED: {
189 curr_mouse_loc_ = event->location(); 197 curr_mouse_loc_ = event->location();
190 aura::Window* target = NULL; 198 aura::Window* target = NULL;
191 // Avoid a call to display::Screen::GetWindowAtScreenPoint() since it can 199 // Avoid a call to display::Screen::GetWindowAtScreenPoint() since it can
192 // be very expensive on X11 in cases when the tooltip is hidden anyway. 200 // be very expensive on X11 in cases when the tooltip is hidden anyway.
193 if (tooltips_enabled_ && 201 if (tooltips_enabled_ &&
(...skipping 23 matching lines...) Expand all
217 // Hide the tooltip for click, release, drag, wheel events. 225 // Hide the tooltip for click, release, drag, wheel events.
218 if (tooltip_->IsVisible()) 226 if (tooltip_->IsVisible())
219 tooltip_->Hide(); 227 tooltip_->Hide();
220 break; 228 break;
221 default: 229 default:
222 break; 230 break;
223 } 231 }
224 } 232 }
225 233
226 void TooltipController::OnTouchEvent(ui::TouchEvent* event) { 234 void TooltipController::OnTouchEvent(ui::TouchEvent* event) {
227 // TODO(varunjain): need to properly implement tooltips for
228 // touch events.
229 // Hide the tooltip for touch events. 235 // Hide the tooltip for touch events.
230 tooltip_->Hide(); 236 tooltip_->Hide();
231 SetTooltipWindow(NULL); 237 SetTooltipWindow(NULL);
238 last_touch_loc_ = event->location();
232 } 239 }
233 240
234 void TooltipController::OnCancelMode(ui::CancelModeEvent* event) { 241 void TooltipController::OnCancelMode(ui::CancelModeEvent* event) {
235 tooltip_->Hide(); 242 tooltip_->Hide();
236 SetTooltipWindow(NULL); 243 SetTooltipWindow(NULL);
237 } 244 }
238 245
239 void TooltipController::OnCursorVisibilityChanged(bool is_visible) { 246 void TooltipController::OnCursorVisibilityChanged(bool is_visible) {
240 UpdateIfRequired(); 247 UpdateIfRequired();
241 } 248 }
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 return; 387 return;
381 if (tooltip_window_) 388 if (tooltip_window_)
382 tooltip_window_->RemoveObserver(this); 389 tooltip_window_->RemoveObserver(this);
383 tooltip_window_ = target; 390 tooltip_window_ = target;
384 if (tooltip_window_) 391 if (tooltip_window_)
385 tooltip_window_->AddObserver(this); 392 tooltip_window_->AddObserver(this);
386 } 393 }
387 394
388 } // namespace corewm 395 } // namespace corewm
389 } // namespace views 396 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/corewm/tooltip_controller.h ('k') | ui/views/corewm/tooltip_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698