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 "ash/tooltips/tooltip_controller.h" | 5 #include "ash/tooltips/tooltip_controller.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "ash/ash_switches.h" | 9 #include "ash/ash_switches.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 if (tooltip_window_ != target) { | 257 if (tooltip_window_ != target) { |
258 if (tooltip_window_) | 258 if (tooltip_window_) |
259 tooltip_window_->RemoveObserver(this); | 259 tooltip_window_->RemoveObserver(this); |
260 tooltip_window_ = target; | 260 tooltip_window_ = target; |
261 tooltip_window_->AddObserver(this); | 261 tooltip_window_->AddObserver(this); |
262 } | 262 } |
263 curr_mouse_loc_ = event->location(); | 263 curr_mouse_loc_ = event->location(); |
264 if (tooltip_timer_.IsRunning()) | 264 if (tooltip_timer_.IsRunning()) |
265 tooltip_timer_.Reset(); | 265 tooltip_timer_.Reset(); |
266 | 266 |
267 // We update the tooltip if it is visible, or if we force-hid it due to a | 267 if (GetTooltip()->IsVisible()) |
268 // mouse press. | |
269 if (GetTooltip()->IsVisible() || tooltip_window_at_mouse_press_) | |
270 UpdateIfRequired(); | 268 UpdateIfRequired(); |
271 break; | 269 break; |
272 case ui::ET_MOUSE_PRESSED: | 270 case ui::ET_MOUSE_PRESSED: |
273 mouse_pressed_ = true; | 271 mouse_pressed_ = true; |
274 tooltip_window_at_mouse_press_ = target; | 272 tooltip_window_at_mouse_press_ = target; |
275 if (target) | 273 if (target) |
276 tooltip_text_at_mouse_press_ = aura::client::GetTooltipText(target); | 274 tooltip_text_at_mouse_press_ = aura::client::GetTooltipText(target); |
277 GetTooltip()->Hide(); | 275 GetTooltip()->Hide(); |
278 break; | 276 break; |
279 case ui::ET_MOUSE_RELEASED: | 277 case ui::ET_MOUSE_RELEASED: |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 } | 470 } |
473 | 471 |
474 TooltipController::Tooltip* TooltipController::GetTooltip() { | 472 TooltipController::Tooltip* TooltipController::GetTooltip() { |
475 if (!tooltip_.get()) | 473 if (!tooltip_.get()) |
476 tooltip_.reset(new Tooltip); | 474 tooltip_.reset(new Tooltip); |
477 return tooltip_.get(); | 475 return tooltip_.get(); |
478 } | 476 } |
479 | 477 |
480 } // namespace internal | 478 } // namespace internal |
481 } // namespace ash | 479 } // namespace ash |
OLD | NEW |