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 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 reinterpret_cast<LPARAM>(&keyboard_toolinfo)); | 359 reinterpret_cast<LPARAM>(&keyboard_toolinfo)); |
360 if (!tooltip_height_) | 360 if (!tooltip_height_) |
361 tooltip_height_ = CalcTooltipHeight(); | 361 tooltip_height_ = CalcTooltipHeight(); |
362 RECT rect_bounds = {screen_point.x(), | 362 RECT rect_bounds = {screen_point.x(), |
363 screen_point.y() + focused_bounds.height(), | 363 screen_point.y() + focused_bounds.height(), |
364 screen_point.x() + tooltip_width, | 364 screen_point.x() + tooltip_width, |
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 rect_bounds = gfx::Rect(rect_bounds).AdjustToFit(monitor_bounds).ToRECT(); | 369 gfx::Rect fitted_bounds = gfx::Rect(rect_bounds); |
| 370 fitted_bounds.AdjustToFit(monitor_bounds); |
| 371 rect_bounds = fitted_bounds.ToRECT(); |
370 ::SetWindowPos(keyboard_tooltip_hwnd_, NULL, rect_bounds.left, | 372 ::SetWindowPos(keyboard_tooltip_hwnd_, NULL, rect_bounds.left, |
371 rect_bounds.top, 0, 0, | 373 rect_bounds.top, 0, 0, |
372 SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE); | 374 SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE); |
373 MessageLoop::current()->PostDelayedTask( | 375 MessageLoop::current()->PostDelayedTask( |
374 FROM_HERE, | 376 FROM_HERE, |
375 base::Bind(&TooltipManagerWin::DestroyKeyboardTooltipWindow, | 377 base::Bind(&TooltipManagerWin::DestroyKeyboardTooltipWindow, |
376 keyboard_tooltip_factory_.GetWeakPtr(), | 378 keyboard_tooltip_factory_.GetWeakPtr(), |
377 keyboard_tooltip_hwnd_), | 379 keyboard_tooltip_hwnd_), |
378 base::TimeDelta::FromMilliseconds(kDefaultTimeout)); | 380 base::TimeDelta::FromMilliseconds(kDefaultTimeout)); |
379 } | 381 } |
380 | 382 |
381 void TooltipManagerWin::HideKeyboardTooltip() { | 383 void TooltipManagerWin::HideKeyboardTooltip() { |
382 if (keyboard_tooltip_hwnd_ != NULL) { | 384 if (keyboard_tooltip_hwnd_ != NULL) { |
383 SendMessage(keyboard_tooltip_hwnd_, WM_CLOSE, 0, 0); | 385 SendMessage(keyboard_tooltip_hwnd_, WM_CLOSE, 0, 0); |
384 keyboard_tooltip_hwnd_ = NULL; | 386 keyboard_tooltip_hwnd_ = NULL; |
385 } | 387 } |
386 } | 388 } |
387 | 389 |
388 void TooltipManagerWin::DestroyKeyboardTooltipWindow(HWND window_to_destroy) { | 390 void TooltipManagerWin::DestroyKeyboardTooltipWindow(HWND window_to_destroy) { |
389 if (keyboard_tooltip_hwnd_ == window_to_destroy) | 391 if (keyboard_tooltip_hwnd_ == window_to_destroy) |
390 HideKeyboardTooltip(); | 392 HideKeyboardTooltip(); |
391 } | 393 } |
392 | 394 |
393 } // namespace views | 395 } // namespace views |
OLD | NEW |