OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ash/display/display_util.h" | 5 #include "ash/display/display_util.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "ash/common/system/system_notifier.h" | 10 #include "ash/common/system/system_notifier.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 // Private destructor since NotificationDelegate is ref-counted. | 60 // Private destructor since NotificationDelegate is ref-counted. |
61 ~DisplayErrorNotificationDelegate() override = default; | 61 ~DisplayErrorNotificationDelegate() override = default; |
62 | 62 |
63 DISALLOW_COPY_AND_ASSIGN(DisplayErrorNotificationDelegate); | 63 DISALLOW_COPY_AND_ASSIGN(DisplayErrorNotificationDelegate); |
64 }; | 64 }; |
65 | 65 |
66 | 66 |
67 void ConvertPointFromScreenToNative(aura::WindowTreeHost* host, | 67 void ConvertPointFromScreenToNative(aura::WindowTreeHost* host, |
68 gfx::Point* point) { | 68 gfx::Point* point) { |
69 ::wm::ConvertPointFromScreen(host->window(), point); | 69 ::wm::ConvertPointFromScreen(host->window(), point); |
70 host->ConvertPointToNativeScreen(point); | 70 host->ConvertDIPToScreenInPixels(point); |
71 } | 71 } |
72 | 72 |
73 } // namespace | 73 } // namespace |
74 | 74 |
75 std::unique_ptr<MouseWarpController> CreateMouseWarpController( | 75 std::unique_ptr<MouseWarpController> CreateMouseWarpController( |
76 display::DisplayManager* manager, | 76 display::DisplayManager* manager, |
77 aura::Window* drag_source) { | 77 aura::Window* drag_source) { |
78 if (manager->IsInUnifiedMode() && manager->num_connected_displays() >= 2) | 78 if (manager->IsInUnifiedMode() && manager->num_connected_displays() >= 2) |
79 return base::MakeUnique<UnifiedMouseWarpController>(); | 79 return base::MakeUnique<UnifiedMouseWarpController>(); |
80 // Extra check for |num_connected_displays()| is for SystemDisplayApiTest | 80 // Extra check for |num_connected_displays()| is for SystemDisplayApiTest |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 } | 116 } |
117 | 117 |
118 // Moves the cursor to the point inside the root that is closest to | 118 // Moves the cursor to the point inside the root that is closest to |
119 // the point_in_screen, which is outside of the root window. | 119 // the point_in_screen, which is outside of the root window. |
120 void MoveCursorTo(AshWindowTreeHost* ash_host, | 120 void MoveCursorTo(AshWindowTreeHost* ash_host, |
121 const gfx::Point& point_in_screen, | 121 const gfx::Point& point_in_screen, |
122 bool update_last_location_now) { | 122 bool update_last_location_now) { |
123 aura::WindowTreeHost* host = ash_host->AsWindowTreeHost(); | 123 aura::WindowTreeHost* host = ash_host->AsWindowTreeHost(); |
124 gfx::Point point_in_native = point_in_screen; | 124 gfx::Point point_in_native = point_in_screen; |
125 ::wm::ConvertPointFromScreen(host->window(), &point_in_native); | 125 ::wm::ConvertPointFromScreen(host->window(), &point_in_native); |
126 host->ConvertPointToNativeScreen(&point_in_native); | 126 host->ConvertDIPToScreenInPixels(&point_in_native); |
127 | 127 |
128 // now fit the point inside the native bounds. | 128 // now fit the point inside the native bounds. |
129 gfx::Rect native_bounds = host->GetBoundsInPixels(); | 129 gfx::Rect native_bounds = host->GetBoundsInPixels(); |
130 gfx::Point native_origin = native_bounds.origin(); | 130 gfx::Point native_origin = native_bounds.origin(); |
131 native_bounds.Inset(ash_host->GetHostInsets()); | 131 native_bounds.Inset(ash_host->GetHostInsets()); |
132 // Shrink further so that the mouse doesn't warp on the | 132 // Shrink further so that the mouse doesn't warp on the |
133 // edge. The right/bottom needs to be shrink by 2 to subtract | 133 // edge. The right/bottom needs to be shrink by 2 to subtract |
134 // the 1 px from width/height value. | 134 // the 1 px from width/height value. |
135 native_bounds.Inset(1, 1, 2, 2); | 135 native_bounds.Inset(1, 1, 2, 2); |
136 | 136 |
137 // Ensure that |point_in_native| is inside the |native_bounds|. | 137 // Ensure that |point_in_native| is inside the |native_bounds|. |
138 point_in_native.SetToMax(native_bounds.origin()); | 138 point_in_native.SetToMax(native_bounds.origin()); |
139 point_in_native.SetToMin(native_bounds.bottom_right()); | 139 point_in_native.SetToMin(native_bounds.bottom_right()); |
140 | 140 |
141 gfx::Point point_in_host = point_in_native; | 141 gfx::Point point_in_host = point_in_native; |
142 | 142 |
143 point_in_host.Offset(-native_origin.x(), -native_origin.y()); | 143 point_in_host.Offset(-native_origin.x(), -native_origin.y()); |
144 host->MoveCursorToHostLocation(point_in_host); | 144 host->MoveCursorToLocationInPixels(point_in_host); |
145 | 145 |
146 if (update_last_location_now) { | 146 if (update_last_location_now) { |
147 gfx::Point new_point_in_screen; | 147 gfx::Point new_point_in_screen; |
148 if (Shell::GetInstance()->display_manager()->IsInUnifiedMode()) { | 148 if (Shell::GetInstance()->display_manager()->IsInUnifiedMode()) { |
149 new_point_in_screen = point_in_host; | 149 new_point_in_screen = point_in_host; |
150 // First convert to the unified host. | 150 // First convert to the unified host. |
151 host->ConvertPointFromHost(&new_point_in_screen); | 151 host->ConvertPixelsToDIP(&new_point_in_screen); |
152 // Then convert to the unified screen. | 152 // Then convert to the unified screen. |
153 Shell::GetPrimaryRootWindow()->GetHost()->ConvertPointFromHost( | 153 Shell::GetPrimaryRootWindow()->GetHost()->ConvertPixelsToDIP( |
154 &new_point_in_screen); | 154 &new_point_in_screen); |
155 } else { | 155 } else { |
156 new_point_in_screen = point_in_native; | 156 new_point_in_screen = point_in_native; |
157 host->ConvertPointFromNativeScreen(&new_point_in_screen); | 157 host->ConvertScreenInPixelsToDIP(&new_point_in_screen); |
158 ::wm::ConvertPointToScreen(host->window(), &new_point_in_screen); | 158 ::wm::ConvertPointToScreen(host->window(), &new_point_in_screen); |
159 } | 159 } |
160 aura::Env::GetInstance()->set_last_mouse_location(new_point_in_screen); | 160 aura::Env::GetInstance()->set_last_mouse_location(new_point_in_screen); |
161 } | 161 } |
162 } | 162 } |
163 | 163 |
164 | 164 |
165 #if defined(OS_CHROMEOS) | 165 #if defined(OS_CHROMEOS) |
166 void ShowDisplayErrorNotification(int message_id) { | 166 void ShowDisplayErrorNotification(int message_id) { |
167 // Always remove the notification to make sure the notification appears | 167 // Always remove the notification to make sure the notification appears |
(...skipping 23 matching lines...) Expand all Loading... |
191 message_center::NotificationList::Notifications notifications = | 191 message_center::NotificationList::Notifications notifications = |
192 message_center::MessageCenter::Get()->GetVisibleNotifications(); | 192 message_center::MessageCenter::Get()->GetVisibleNotifications(); |
193 for (auto* const notification : notifications) { | 193 for (auto* const notification : notifications) { |
194 if (notification->id() == kDisplayErrorNotificationId) | 194 if (notification->id() == kDisplayErrorNotificationId) |
195 return notification->message(); | 195 return notification->message(); |
196 } | 196 } |
197 return base::string16(); | 197 return base::string16(); |
198 } | 198 } |
199 | 199 |
200 } // namespace ash | 200 } // namespace ash |
OLD | NEW |