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/widget/tooltip_manager_win.h" | 5 #include "ui/views/widget/tooltip_manager_win.h" |
6 | 6 |
7 #include <windowsx.h> | 7 #include <windowsx.h> |
8 | 8 |
9 #include <limits> | 9 #include <limits> |
10 | 10 |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 screen_point.y() + focused_bounds.height() + | 365 screen_point.y() + focused_bounds.height() + |
366 line_count * tooltip_height_ }; | 366 line_count * tooltip_height_ }; |
367 gfx::Rect monitor_bounds = | 367 gfx::Rect monitor_bounds = |
368 views::GetMonitorBoundsForRect(gfx::Rect(rect_bounds)); | 368 views::GetMonitorBoundsForRect(gfx::Rect(rect_bounds)); |
369 gfx::Rect fitted_bounds = gfx::Rect(rect_bounds); | 369 gfx::Rect fitted_bounds = gfx::Rect(rect_bounds); |
370 fitted_bounds.AdjustToFit(monitor_bounds); | 370 fitted_bounds.AdjustToFit(monitor_bounds); |
371 rect_bounds = fitted_bounds.ToRECT(); | 371 rect_bounds = fitted_bounds.ToRECT(); |
372 ::SetWindowPos(keyboard_tooltip_hwnd_, NULL, rect_bounds.left, | 372 ::SetWindowPos(keyboard_tooltip_hwnd_, NULL, rect_bounds.left, |
373 rect_bounds.top, 0, 0, | 373 rect_bounds.top, 0, 0, |
374 SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE); | 374 SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE); |
375 MessageLoop::current()->PostDelayedTask( | 375 base::MessageLoop::current()->PostDelayedTask( |
376 FROM_HERE, | 376 FROM_HERE, |
377 base::Bind(&TooltipManagerWin::DestroyKeyboardTooltipWindow, | 377 base::Bind(&TooltipManagerWin::DestroyKeyboardTooltipWindow, |
378 keyboard_tooltip_factory_.GetWeakPtr(), | 378 keyboard_tooltip_factory_.GetWeakPtr(), |
379 keyboard_tooltip_hwnd_), | 379 keyboard_tooltip_hwnd_), |
380 base::TimeDelta::FromMilliseconds(kDefaultTimeout)); | 380 base::TimeDelta::FromMilliseconds(kDefaultTimeout)); |
381 } | 381 } |
382 | 382 |
383 void TooltipManagerWin::HideKeyboardTooltip() { | 383 void TooltipManagerWin::HideKeyboardTooltip() { |
384 if (keyboard_tooltip_hwnd_ != NULL) { | 384 if (keyboard_tooltip_hwnd_ != NULL) { |
385 SendMessage(keyboard_tooltip_hwnd_, WM_CLOSE, 0, 0); | 385 SendMessage(keyboard_tooltip_hwnd_, WM_CLOSE, 0, 0); |
386 keyboard_tooltip_hwnd_ = NULL; | 386 keyboard_tooltip_hwnd_ = NULL; |
387 } | 387 } |
388 } | 388 } |
389 | 389 |
390 void TooltipManagerWin::DestroyKeyboardTooltipWindow(HWND window_to_destroy) { | 390 void TooltipManagerWin::DestroyKeyboardTooltipWindow(HWND window_to_destroy) { |
391 if (keyboard_tooltip_hwnd_ == window_to_destroy) | 391 if (keyboard_tooltip_hwnd_ == window_to_destroy) |
392 HideKeyboardTooltip(); | 392 HideKeyboardTooltip(); |
393 } | 393 } |
394 | 394 |
395 } // namespace views | 395 } // namespace views |
OLD | NEW |