OLD | NEW |
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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 // simply simulate a timeout. | 249 // simply simulate a timeout. |
250 if (tooltip_shown_timer_.IsRunning()) { | 250 if (tooltip_shown_timer_.IsRunning()) { |
251 tooltip_shown_timer_.Stop(); | 251 tooltip_shown_timer_.Stop(); |
252 TooltipShownTimerFired(); | 252 TooltipShownTimerFired(); |
253 } | 253 } |
254 } | 254 } |
255 | 255 |
256 void TooltipController::OnMouseEvent(ui::MouseEvent* event) { | 256 void TooltipController::OnMouseEvent(ui::MouseEvent* event) { |
257 aura::Window* target = static_cast<aura::Window*>(event->target()); | 257 aura::Window* target = static_cast<aura::Window*>(event->target()); |
258 switch (event->type()) { | 258 switch (event->type()) { |
| 259 case ui::ET_MOUSE_EXITED: |
| 260 target = NULL; |
| 261 // Fall through. |
259 case ui::ET_MOUSE_MOVED: | 262 case ui::ET_MOUSE_MOVED: |
260 case ui::ET_MOUSE_DRAGGED: | 263 case ui::ET_MOUSE_DRAGGED: |
261 if (tooltip_window_ != target) { | 264 if (tooltip_window_ != target) { |
262 if (tooltip_window_) | 265 if (tooltip_window_) |
263 tooltip_window_->RemoveObserver(this); | 266 tooltip_window_->RemoveObserver(this); |
264 tooltip_window_ = target; | 267 tooltip_window_ = target; |
265 tooltip_window_->AddObserver(this); | 268 if (tooltip_window_) |
| 269 tooltip_window_->AddObserver(this); |
266 } | 270 } |
267 curr_mouse_loc_ = event->location(); | 271 curr_mouse_loc_ = event->location(); |
268 if (tooltip_timer_.IsRunning()) | 272 if (tooltip_timer_.IsRunning()) |
269 tooltip_timer_.Reset(); | 273 tooltip_timer_.Reset(); |
270 | 274 |
271 if (GetTooltip()->IsVisible()) | 275 if (GetTooltip()->IsVisible()) |
272 UpdateIfRequired(); | 276 UpdateIfRequired(); |
273 break; | 277 break; |
274 case ui::ET_MOUSE_PRESSED: | 278 case ui::ET_MOUSE_PRESSED: |
275 if ((event->flags() & ui::EF_IS_NON_CLIENT) == 0) { | 279 if ((event->flags() & ui::EF_IS_NON_CLIENT) == 0) { |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 int TooltipController::GetTooltipShownTimeout() { | 532 int TooltipController::GetTooltipShownTimeout() { |
529 std::map<aura::Window*, int>::const_iterator it = | 533 std::map<aura::Window*, int>::const_iterator it = |
530 tooltip_shown_timeout_map_.find(tooltip_window_); | 534 tooltip_shown_timeout_map_.find(tooltip_window_); |
531 if (it == tooltip_shown_timeout_map_.end()) | 535 if (it == tooltip_shown_timeout_map_.end()) |
532 return kDefaultTooltipShownTimeoutMs; | 536 return kDefaultTooltipShownTimeoutMs; |
533 return it->second; | 537 return it->second; |
534 } | 538 } |
535 | 539 |
536 } // namespace corewm | 540 } // namespace corewm |
537 } // namespace views | 541 } // namespace views |
OLD | NEW |