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/aero_tooltip_manager.h" | 5 #include "ui/views/widget/aero_tooltip_manager.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <commctrl.h> | 8 #include <commctrl.h> |
9 #include <shlobj.h> | 9 #include <shlobj.h> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
13 #include "ui/base/l10n/l10n_util_win.h" | 13 #include "ui/base/l10n/l10n_util_win.h" |
14 #include "ui/base/win/hwnd_util.h" | 14 #include "ui/base/win/hwnd_util.h" |
| 15 #include "ui/base/win/dpi.h" |
15 #include "ui/gfx/point.h" | 16 #include "ui/gfx/point.h" |
16 | 17 |
17 namespace views { | 18 namespace views { |
18 | 19 |
19 /////////////////////////////////////////////////////////////////////////////// | 20 /////////////////////////////////////////////////////////////////////////////// |
20 // AeroTooltipManager, public: | 21 // AeroTooltipManager, public: |
21 | 22 |
22 AeroTooltipManager::AeroTooltipManager(Widget* widget) | 23 AeroTooltipManager::AeroTooltipManager(Widget* widget) |
23 : TooltipManagerWin(widget), | 24 : TooltipManagerWin(widget), |
24 initial_delay_(0) { | 25 initial_delay_(0) { |
25 } | 26 } |
26 | 27 |
27 AeroTooltipManager::~AeroTooltipManager() { | 28 AeroTooltipManager::~AeroTooltipManager() { |
28 if (initial_timer_) | 29 if (initial_timer_) |
29 initial_timer_->Disown(); | 30 initial_timer_->Disown(); |
30 } | 31 } |
31 | 32 |
32 void AeroTooltipManager::OnMouse(UINT u_msg, WPARAM w_param, LPARAM l_param) { | 33 void AeroTooltipManager::OnMouse(UINT u_msg, WPARAM w_param, LPARAM l_param) { |
33 if (u_msg == WM_MOUSELEAVE) { | 34 if (u_msg == WM_MOUSELEAVE) { |
34 last_mouse_pos_.SetPoint(-1, -1); | 35 last_mouse_pos_.SetPoint(-1, -1); |
35 UpdateTooltip(); | 36 UpdateTooltip(); |
36 return; | 37 return; |
37 } | 38 } |
38 | 39 |
39 if (initial_timer_) | 40 if (initial_timer_) |
40 initial_timer_->Disown(); | 41 initial_timer_->Disown(); |
41 | 42 |
42 if (u_msg == WM_MOUSEMOVE || u_msg == WM_NCMOUSEMOVE) { | 43 if (u_msg == WM_MOUSEMOVE || u_msg == WM_NCMOUSEMOVE) { |
43 gfx::Point mouse_pos(l_param); | 44 gfx::Point mouse_pos_in_pixels(l_param); |
| 45 gfx::Point mouse_pos = ui::win::ScreenToDIPPoint(mouse_pos_in_pixels); |
44 if (u_msg == WM_NCMOUSEMOVE) { | 46 if (u_msg == WM_NCMOUSEMOVE) { |
45 // NC message coordinates are in screen coordinates. | 47 // NC message coordinates are in screen coordinates. |
46 POINT temp = mouse_pos.ToPOINT(); | 48 POINT temp = mouse_pos_in_pixels.ToPOINT(); |
47 ::MapWindowPoints(HWND_DESKTOP, GetParent(), &temp, 1); | 49 ::MapWindowPoints(HWND_DESKTOP, GetParent(), &temp, 1); |
48 mouse_pos.SetPoint(temp.x, temp.y); | 50 mouse_pos_in_pixels.SetPoint(temp.x, temp.y); |
| 51 mouse_pos = ui::win::ScreenToDIPPoint(mouse_pos_in_pixels); |
49 } | 52 } |
50 if (last_mouse_pos_ != mouse_pos) { | 53 if (last_mouse_pos_ != mouse_pos) { |
51 last_mouse_pos_ = mouse_pos; | 54 last_mouse_pos_ = mouse_pos; |
52 HideKeyboardTooltip(); | 55 HideKeyboardTooltip(); |
53 UpdateTooltip(mouse_pos); | 56 UpdateTooltip(mouse_pos); |
54 } | 57 } |
55 | 58 |
56 // Delay opening of the tooltip just in case the user moves their | 59 // Delay opening of the tooltip just in case the user moves their |
57 // mouse to another control. We defer this from Init because we get | 60 // mouse to another control. We defer this from Init because we get |
58 // zero if we query it too soon. | 61 // zero if we query it too soon. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 void AeroTooltipManager::InitialTimer::Disown() { | 107 void AeroTooltipManager::InitialTimer::Disown() { |
105 manager_ = NULL; | 108 manager_ = NULL; |
106 } | 109 } |
107 | 110 |
108 void AeroTooltipManager::InitialTimer::Execute() { | 111 void AeroTooltipManager::InitialTimer::Execute() { |
109 if (manager_) | 112 if (manager_) |
110 manager_->OnTimer(); | 113 manager_->OnTimer(); |
111 } | 114 } |
112 | 115 |
113 } // namespace views | 116 } // namespace views |
OLD | NEW |