Chromium Code Reviews| 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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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(NULL); | |
|
sadrul
2017/04/19 18:31:16
nullptr
girard
2017/04/19 21:39:40
Acknowledged.
| |
| 187 | |
| 188 if (tooltip_->IsVisible() || | |
| 189 (tooltip_window_ && | |
|
sadrul
2017/04/19 18:31:16
Because you are calling SetTooltipWindow(nullptr)
girard
2017/04/19 21:39:40
Acknowledged.
| |
| 190 tooltip_text_ != aura::client::GetTooltipText(tooltip_window_))) | |
| 191 UpdateIfRequired(); | |
| 192 return; | |
| 193 } | |
| 184 switch (event->type()) { | 194 switch (event->type()) { |
| 185 case ui::ET_MOUSE_CAPTURE_CHANGED: | 195 case ui::ET_MOUSE_CAPTURE_CHANGED: |
| 186 case ui::ET_MOUSE_EXITED: | 196 case ui::ET_MOUSE_EXITED: |
| 187 case ui::ET_MOUSE_MOVED: | 197 case ui::ET_MOUSE_MOVED: |
| 188 case ui::ET_MOUSE_DRAGGED: { | 198 case ui::ET_MOUSE_DRAGGED: { |
| 189 curr_mouse_loc_ = event->location(); | 199 curr_mouse_loc_ = event->location(); |
| 190 aura::Window* target = NULL; | 200 aura::Window* target = NULL; |
| 191 // Avoid a call to display::Screen::GetWindowAtScreenPoint() since it can | 201 // Avoid a call to display::Screen::GetWindowAtScreenPoint() since it can |
| 192 // be very expensive on X11 in cases when the tooltip is hidden anyway. | 202 // be very expensive on X11 in cases when the tooltip is hidden anyway. |
| 193 if (tooltips_enabled_ && | 203 if (tooltips_enabled_ && |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 217 // Hide the tooltip for click, release, drag, wheel events. | 227 // Hide the tooltip for click, release, drag, wheel events. |
| 218 if (tooltip_->IsVisible()) | 228 if (tooltip_->IsVisible()) |
| 219 tooltip_->Hide(); | 229 tooltip_->Hide(); |
| 220 break; | 230 break; |
| 221 default: | 231 default: |
| 222 break; | 232 break; |
| 223 } | 233 } |
| 224 } | 234 } |
| 225 | 235 |
| 226 void TooltipController::OnTouchEvent(ui::TouchEvent* event) { | 236 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. | 237 // Hide the tooltip for touch events. |
| 230 tooltip_->Hide(); | 238 tooltip_->Hide(); |
| 231 SetTooltipWindow(NULL); | 239 SetTooltipWindow(NULL); |
| 240 last_touch_loc_ = event->location(); | |
| 232 } | 241 } |
| 233 | 242 |
| 234 void TooltipController::OnCancelMode(ui::CancelModeEvent* event) { | 243 void TooltipController::OnCancelMode(ui::CancelModeEvent* event) { |
| 235 tooltip_->Hide(); | 244 tooltip_->Hide(); |
| 236 SetTooltipWindow(NULL); | 245 SetTooltipWindow(NULL); |
| 237 } | 246 } |
| 238 | 247 |
| 239 void TooltipController::OnCursorVisibilityChanged(bool is_visible) { | 248 void TooltipController::OnCursorVisibilityChanged(bool is_visible) { |
| 240 UpdateIfRequired(); | 249 UpdateIfRequired(); |
| 241 } | 250 } |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 380 return; | 389 return; |
| 381 if (tooltip_window_) | 390 if (tooltip_window_) |
| 382 tooltip_window_->RemoveObserver(this); | 391 tooltip_window_->RemoveObserver(this); |
| 383 tooltip_window_ = target; | 392 tooltip_window_ = target; |
| 384 if (tooltip_window_) | 393 if (tooltip_window_) |
| 385 tooltip_window_->AddObserver(this); | 394 tooltip_window_->AddObserver(this); |
| 386 } | 395 } |
| 387 | 396 |
| 388 } // namespace corewm | 397 } // namespace corewm |
| 389 } // namespace views | 398 } // namespace views |
| OLD | NEW |