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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 } | 90 } |
91 } | 91 } |
92 return event_target; | 92 return event_target; |
93 } | 93 } |
94 | 94 |
95 // If |target| has capture all events go to it, even if the mouse is | 95 // If |target| has capture all events go to it, even if the mouse is |
96 // really over another window. Find the real window the mouse is over. | 96 // really over another window. Find the real window the mouse is over. |
97 gfx::Point screen_loc(event.location()); | 97 gfx::Point screen_loc(event.location()); |
98 aura::client::GetScreenPositionClient(event_target->GetRootWindow())-> | 98 aura::client::GetScreenPositionClient(event_target->GetRootWindow())-> |
99 ConvertPointToScreen(event_target, &screen_loc); | 99 ConvertPointToScreen(event_target, &screen_loc); |
100 gfx::Screen* screen = gfx::Screen::GetScreenFor(event_target); | 100 gfx::Screen* screen = gfx::Screen::GetScreen(); |
101 aura::Window* target = screen->GetWindowAtScreenPoint(screen_loc); | 101 aura::Window* target = screen->GetWindowAtScreenPoint(screen_loc); |
102 if (!target) | 102 if (!target) |
103 return NULL; | 103 return NULL; |
104 gfx::Point target_loc(screen_loc); | 104 gfx::Point target_loc(screen_loc); |
105 aura::client::GetScreenPositionClient(target->GetRootWindow())-> | 105 aura::client::GetScreenPositionClient(target->GetRootWindow())-> |
106 ConvertPointFromScreen(target, &target_loc); | 106 ConvertPointFromScreen(target, &target_loc); |
107 aura::Window* screen_target = target->GetEventHandlerForPoint(target_loc); | 107 aura::Window* screen_target = target->GetEventHandlerForPoint(target_loc); |
108 if (!IsValidTarget(event_target, screen_target)) | 108 if (!IsValidTarget(event_target, screen_target)) |
109 return NULL; | 109 return NULL; |
110 | 110 |
(...skipping 22 matching lines...) Expand all Loading... |
133 tooltip_timer_.Start(FROM_HERE, | 133 tooltip_timer_.Start(FROM_HERE, |
134 base::TimeDelta::FromMilliseconds(kTooltipTimeoutMs), | 134 base::TimeDelta::FromMilliseconds(kTooltipTimeoutMs), |
135 this, &TooltipController::TooltipTimerFired); | 135 this, &TooltipController::TooltipTimerFired); |
136 } | 136 } |
137 | 137 |
138 TooltipController::~TooltipController() { | 138 TooltipController::~TooltipController() { |
139 if (tooltip_window_) | 139 if (tooltip_window_) |
140 tooltip_window_->RemoveObserver(this); | 140 tooltip_window_->RemoveObserver(this); |
141 } | 141 } |
142 | 142 |
143 int TooltipController::GetMaxWidth(const gfx::Point& location, | 143 int TooltipController::GetMaxWidth(const gfx::Point& location) const { |
144 gfx::NativeView context) const { | 144 return tooltip_->GetMaxWidth(location); |
145 return tooltip_->GetMaxWidth(location, context); | |
146 } | 145 } |
147 | 146 |
148 void TooltipController::UpdateTooltip(aura::Window* target) { | 147 void TooltipController::UpdateTooltip(aura::Window* target) { |
149 // If tooltip is visible, we may want to hide it. If it is not, we are ok. | 148 // If tooltip is visible, we may want to hide it. If it is not, we are ok. |
150 if (tooltip_window_ == target && tooltip_->IsVisible()) | 149 if (tooltip_window_ == target && tooltip_->IsVisible()) |
151 UpdateIfRequired(); | 150 UpdateIfRequired(); |
152 | 151 |
153 // Reset |tooltip_window_at_mouse_press_| if the moving within the same window | 152 // Reset |tooltip_window_at_mouse_press_| if the moving within the same window |
154 // but over a region that has different tooltip text. By resetting | 153 // but over a region that has different tooltip text. By resetting |
155 // |tooltip_window_at_mouse_press_| we ensure the next time the timer fires | 154 // |tooltip_window_at_mouse_press_| we ensure the next time the timer fires |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 return; | 374 return; |
376 if (tooltip_window_) | 375 if (tooltip_window_) |
377 tooltip_window_->RemoveObserver(this); | 376 tooltip_window_->RemoveObserver(this); |
378 tooltip_window_ = target; | 377 tooltip_window_ = target; |
379 if (tooltip_window_) | 378 if (tooltip_window_) |
380 tooltip_window_->AddObserver(this); | 379 tooltip_window_->AddObserver(this); |
381 } | 380 } |
382 | 381 |
383 } // namespace corewm | 382 } // namespace corewm |
384 } // namespace views | 383 } // namespace views |
OLD | NEW |