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 |
| 23 void ScalePos(gfx::Point& pos) { |
| 24 float scale = ui::GetDPIScale(); |
| 25 pos.set_x(pos.x() / scale); |
| 26 pos.set_y(pos.y() / scale); |
| 27 } |
| 28 |
22 AeroTooltipManager::AeroTooltipManager(Widget* widget) | 29 AeroTooltipManager::AeroTooltipManager(Widget* widget) |
23 : TooltipManagerWin(widget), | 30 : TooltipManagerWin(widget), |
24 initial_delay_(0) { | 31 initial_delay_(0) { |
25 } | 32 } |
26 | 33 |
27 AeroTooltipManager::~AeroTooltipManager() { | 34 AeroTooltipManager::~AeroTooltipManager() { |
28 if (initial_timer_) | 35 if (initial_timer_) |
29 initial_timer_->Disown(); | 36 initial_timer_->Disown(); |
30 } | 37 } |
31 | 38 |
32 void AeroTooltipManager::OnMouse(UINT u_msg, WPARAM w_param, LPARAM l_param) { | 39 void AeroTooltipManager::OnMouse(UINT u_msg, WPARAM w_param, LPARAM l_param) { |
33 if (u_msg == WM_MOUSELEAVE) { | 40 if (u_msg == WM_MOUSELEAVE) { |
34 last_mouse_pos_.SetPoint(-1, -1); | 41 last_mouse_pos_.SetPoint(-1, -1); |
35 UpdateTooltip(); | 42 UpdateTooltip(); |
36 return; | 43 return; |
37 } | 44 } |
38 | 45 |
39 if (initial_timer_) | 46 if (initial_timer_) |
40 initial_timer_->Disown(); | 47 initial_timer_->Disown(); |
41 | 48 |
42 if (u_msg == WM_MOUSEMOVE || u_msg == WM_NCMOUSEMOVE) { | 49 if (u_msg == WM_MOUSEMOVE || u_msg == WM_NCMOUSEMOVE) { |
43 gfx::Point mouse_pos(l_param); | 50 gfx::Point mouse_pos(l_param); |
44 if (u_msg == WM_NCMOUSEMOVE) { | 51 if (u_msg == WM_NCMOUSEMOVE) { |
45 // NC message coordinates are in screen coordinates. | 52 // NC message coordinates are in screen coordinates. |
46 POINT temp = mouse_pos.ToPOINT(); | 53 POINT temp = mouse_pos.ToPOINT(); |
47 ::MapWindowPoints(HWND_DESKTOP, GetParent(), &temp, 1); | 54 ::MapWindowPoints(HWND_DESKTOP, GetParent(), &temp, 1); |
48 mouse_pos.SetPoint(temp.x, temp.y); | 55 mouse_pos.SetPoint(temp.x, temp.y); |
49 } | 56 } |
| 57 ScalePos( mouse_pos); |
50 if (last_mouse_pos_ != mouse_pos) { | 58 if (last_mouse_pos_ != mouse_pos) { |
51 last_mouse_pos_ = mouse_pos; | 59 last_mouse_pos_ = mouse_pos; |
52 HideKeyboardTooltip(); | 60 HideKeyboardTooltip(); |
53 UpdateTooltip(mouse_pos); | 61 UpdateTooltip(mouse_pos); |
54 } | 62 } |
55 | 63 |
56 // Delay opening of the tooltip just in case the user moves their | 64 // 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 | 65 // mouse to another control. We defer this from Init because we get |
58 // zero if we query it too soon. | 66 // zero if we query it too soon. |
59 if (!initial_delay_) { | 67 if (!initial_delay_) { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 void AeroTooltipManager::InitialTimer::Disown() { | 111 void AeroTooltipManager::InitialTimer::Disown() { |
104 manager_ = NULL; | 112 manager_ = NULL; |
105 } | 113 } |
106 | 114 |
107 void AeroTooltipManager::InitialTimer::Execute() { | 115 void AeroTooltipManager::InitialTimer::Execute() { |
108 if (manager_) | 116 if (manager_) |
109 manager_->OnTimer(); | 117 manager_->OnTimer(); |
110 } | 118 } |
111 | 119 |
112 } // namespace views | 120 } // namespace views |
OLD | NEW |