| 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/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 } | 179 } |
| 180 } | 180 } |
| 181 | 181 |
| 182 void TooltipController::OnMouseEvent(ui::MouseEvent* event) { | 182 void TooltipController::OnMouseEvent(ui::MouseEvent* event) { |
| 183 switch (event->type()) { | 183 switch (event->type()) { |
| 184 case ui::ET_MOUSE_CAPTURE_CHANGED: | 184 case ui::ET_MOUSE_CAPTURE_CHANGED: |
| 185 case ui::ET_MOUSE_EXITED: | 185 case ui::ET_MOUSE_EXITED: |
| 186 case ui::ET_MOUSE_MOVED: | 186 case ui::ET_MOUSE_MOVED: |
| 187 case ui::ET_MOUSE_DRAGGED: { | 187 case ui::ET_MOUSE_DRAGGED: { |
| 188 curr_mouse_loc_ = event->location(); | 188 curr_mouse_loc_ = event->location(); |
| 189 aura::Window* target = GetTooltipTarget(*event, &curr_mouse_loc_); | 189 aura::Window* target = NULL; |
| 190 // Avoid a call to gfx::Screen::GetWindowAtScreenPoint() since it can be |
| 191 // very expensive on X11 in cases when the tooltip is hidden anyway. |
| 192 if (tooltips_enabled_ && |
| 193 !aura::Env::GetInstance()->IsMouseButtonDown() && |
| 194 !IsDragDropInProgress()) { |
| 195 target = GetTooltipTarget(*event, &curr_mouse_loc_); |
| 196 } |
| 190 SetTooltipWindow(target); | 197 SetTooltipWindow(target); |
| 191 if (tooltip_timer_.IsRunning()) | 198 if (tooltip_timer_.IsRunning()) |
| 192 tooltip_timer_.Reset(); | 199 tooltip_timer_.Reset(); |
| 193 | 200 |
| 194 if (tooltip_->IsVisible()) | 201 if (tooltip_->IsVisible()) |
| 195 UpdateIfRequired(); | 202 UpdateIfRequired(); |
| 196 break; | 203 break; |
| 197 } | 204 } |
| 198 case ui::ET_MOUSE_PRESSED: | 205 case ui::ET_MOUSE_PRESSED: |
| 199 if ((event->flags() & ui::EF_IS_NON_CLIENT) == 0) { | 206 if ((event->flags() & ui::EF_IS_NON_CLIENT) == 0) { |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 return; | 351 return; |
| 345 if (tooltip_window_) | 352 if (tooltip_window_) |
| 346 tooltip_window_->RemoveObserver(this); | 353 tooltip_window_->RemoveObserver(this); |
| 347 tooltip_window_ = target; | 354 tooltip_window_ = target; |
| 348 if (tooltip_window_) | 355 if (tooltip_window_) |
| 349 tooltip_window_->AddObserver(this); | 356 tooltip_window_->AddObserver(this); |
| 350 } | 357 } |
| 351 | 358 |
| 352 } // namespace corewm | 359 } // namespace corewm |
| 353 } // namespace views | 360 } // namespace views |
| OLD | NEW |