Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc

Issue 1679393002: Multiple DPI Tracking for ScreenWin (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR Feedback EXCEPT rect_util Rename Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/desktop_aura/desktop_window_tree_host_win.h" 5 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_win.h"
6 6
7 #include "third_party/skia/include/core/SkPath.h" 7 #include "third_party/skia/include/core/SkPath.h"
8 #include "third_party/skia/include/core/SkRegion.h" 8 #include "third_party/skia/include/core/SkRegion.h"
9 #include "ui/aura/client/aura_constants.h" 9 #include "ui/aura/client/aura_constants.h"
10 #include "ui/aura/client/cursor_client.h" 10 #include "ui/aura/client/cursor_client.h"
11 #include "ui/aura/client/focus_client.h" 11 #include "ui/aura/client/focus_client.h"
12 #include "ui/aura/window_event_dispatcher.h" 12 #include "ui/aura/window_event_dispatcher.h"
13 #include "ui/aura/window_property.h" 13 #include "ui/aura/window_property.h"
14 #include "ui/base/cursor/cursor_loader_win.h" 14 #include "ui/base/cursor/cursor_loader_win.h"
15 #include "ui/base/ime/input_method.h" 15 #include "ui/base/ime/input_method.h"
16 #include "ui/base/win/shell.h" 16 #include "ui/base/win/shell.h"
17 #include "ui/compositor/compositor_constants.h" 17 #include "ui/compositor/compositor_constants.h"
18 #include "ui/compositor/paint_context.h" 18 #include "ui/compositor/paint_context.h"
19 #include "ui/gfx/geometry/insets.h" 19 #include "ui/gfx/geometry/insets.h"
20 #include "ui/gfx/geometry/vector2d.h" 20 #include "ui/gfx/geometry/vector2d.h"
21 #include "ui/gfx/native_widget_types.h" 21 #include "ui/gfx/native_widget_types.h"
22 #include "ui/gfx/path.h" 22 #include "ui/gfx/path.h"
23 #include "ui/gfx/path_win.h" 23 #include "ui/gfx/path_win.h"
24 #include "ui/gfx/screen_win.h"
24 #include "ui/gfx/win/dpi.h" 25 #include "ui/gfx/win/dpi.h"
25 #include "ui/native_theme/native_theme_aura.h" 26 #include "ui/native_theme/native_theme_aura.h"
26 #include "ui/native_theme/native_theme_win.h" 27 #include "ui/native_theme/native_theme_win.h"
27 #include "ui/views/corewm/tooltip_win.h" 28 #include "ui/views/corewm/tooltip_win.h"
28 #include "ui/views/widget/desktop_aura/desktop_cursor_loader_updater.h" 29 #include "ui/views/widget/desktop_aura/desktop_cursor_loader_updater.h"
29 #include "ui/views/widget/desktop_aura/desktop_drag_drop_client_win.h" 30 #include "ui/views/widget/desktop_aura/desktop_drag_drop_client_win.h"
30 #include "ui/views/widget/desktop_aura/desktop_native_cursor_manager.h" 31 #include "ui/views/widget/desktop_aura/desktop_native_cursor_manager.h"
31 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" 32 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
32 #include "ui/views/widget/root_view.h" 33 #include "ui/views/widget/root_view.h"
33 #include "ui/views/widget/widget_delegate.h" 34 #include "ui/views/widget/widget_delegate.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 native_widget_delegate_); 135 native_widget_delegate_);
135 136
136 HWND parent_hwnd = NULL; 137 HWND parent_hwnd = NULL;
137 if (params.parent && params.parent->GetHost()) 138 if (params.parent && params.parent->GetHost())
138 parent_hwnd = params.parent->GetHost()->GetAcceleratedWidget(); 139 parent_hwnd = params.parent->GetHost()->GetAcceleratedWidget();
139 140
140 message_handler_->set_remove_standard_frame(params.remove_standard_frame); 141 message_handler_->set_remove_standard_frame(params.remove_standard_frame);
141 142
142 has_non_client_view_ = Widget::RequiresNonClientView(params.type); 143 has_non_client_view_ = Widget::RequiresNonClientView(params.type);
143 144
144 gfx::Rect pixel_bounds = gfx::win::DIPToScreenRect(params.bounds); 145 // We don't have an HWND yet, so scale relative to the nearest screen.
146 gfx::Rect pixel_bounds = gfx::ScreenWin::DIPToScreenRect(nullptr,
147 params.bounds);
145 message_handler_->Init(parent_hwnd, pixel_bounds); 148 message_handler_->Init(parent_hwnd, pixel_bounds);
146 if (params.force_software_compositing) { 149 if (params.force_software_compositing) {
147 ::SetProp(GetAcceleratedWidget(), 150 ::SetProp(GetAcceleratedWidget(),
148 kForceSoftwareCompositor, 151 kForceSoftwareCompositor,
149 reinterpret_cast<HANDLE>(true)); 152 reinterpret_cast<HANDLE>(true));
150 } 153 }
151 CreateCompositor(); 154 CreateCompositor();
152 OnAcceleratedWidgetAvailable(); 155 OnAcceleratedWidgetAvailable();
153 } 156 }
154 157
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 ui::WindowShowState show_state) { 215 ui::WindowShowState show_state) {
213 if (compositor()) 216 if (compositor())
214 compositor()->SetVisible(true); 217 compositor()->SetVisible(true);
215 message_handler_->ShowWindowWithState(show_state); 218 message_handler_->ShowWindowWithState(show_state);
216 } 219 }
217 220
218 void DesktopWindowTreeHostWin::ShowMaximizedWithBounds( 221 void DesktopWindowTreeHostWin::ShowMaximizedWithBounds(
219 const gfx::Rect& restored_bounds) { 222 const gfx::Rect& restored_bounds) {
220 if (compositor()) 223 if (compositor())
221 compositor()->SetVisible(true); 224 compositor()->SetVisible(true);
222 gfx::Rect pixel_bounds = gfx::win::DIPToScreenRect(restored_bounds); 225 gfx::Rect pixel_bounds = gfx::ScreenWin::DIPToScreenRect(GetHWND(),
226 restored_bounds);
223 message_handler_->ShowMaximizedWithBounds(pixel_bounds); 227 message_handler_->ShowMaximizedWithBounds(pixel_bounds);
224 } 228 }
225 229
226 bool DesktopWindowTreeHostWin::IsVisible() const { 230 bool DesktopWindowTreeHostWin::IsVisible() const {
227 return message_handler_->IsVisible(); 231 return message_handler_->IsVisible();
228 } 232 }
229 233
230 void DesktopWindowTreeHostWin::SetSize(const gfx::Size& size) { 234 void DesktopWindowTreeHostWin::SetSize(const gfx::Size& size) {
231 gfx::Size size_in_pixels = gfx::win::DIPToScreenSize(size); 235 gfx::Size size_in_pixels = gfx::ScreenWin::DIPToScreenSize(GetHWND(), size);
232 gfx::Size expanded = GetExpandedWindowSize( 236 gfx::Size expanded = GetExpandedWindowSize(
233 message_handler_->window_ex_style(), size_in_pixels); 237 message_handler_->window_ex_style(), size_in_pixels);
234 window_enlargement_ = 238 window_enlargement_ =
235 gfx::Vector2d(expanded.width() - size_in_pixels.width(), 239 gfx::Vector2d(expanded.width() - size_in_pixels.width(),
236 expanded.height() - size_in_pixels.height()); 240 expanded.height() - size_in_pixels.height());
237 message_handler_->SetSize(expanded); 241 message_handler_->SetSize(expanded);
238 } 242 }
239 243
240 void DesktopWindowTreeHostWin::StackAbove(aura::Window* window) { 244 void DesktopWindowTreeHostWin::StackAbove(aura::Window* window) {
241 HWND hwnd = HWNDForNativeView(window); 245 HWND hwnd = HWNDForNativeView(window);
242 if (hwnd) 246 if (hwnd)
243 message_handler_->StackAbove(hwnd); 247 message_handler_->StackAbove(hwnd);
244 } 248 }
245 249
246 void DesktopWindowTreeHostWin::StackAtTop() { 250 void DesktopWindowTreeHostWin::StackAtTop() {
247 message_handler_->StackAtTop(); 251 message_handler_->StackAtTop();
248 } 252 }
249 253
250 void DesktopWindowTreeHostWin::CenterWindow(const gfx::Size& size) { 254 void DesktopWindowTreeHostWin::CenterWindow(const gfx::Size& size) {
251 gfx::Size size_in_pixels = gfx::win::DIPToScreenSize(size); 255 gfx::Size size_in_pixels = gfx::ScreenWin::DIPToScreenSize(GetHWND(), size);
252 gfx::Size expanded_size; 256 gfx::Size expanded_size;
253 expanded_size = GetExpandedWindowSize(message_handler_->window_ex_style(), 257 expanded_size = GetExpandedWindowSize(message_handler_->window_ex_style(),
254 size_in_pixels); 258 size_in_pixels);
255 window_enlargement_ = 259 window_enlargement_ =
256 gfx::Vector2d(expanded_size.width() - size_in_pixels.width(), 260 gfx::Vector2d(expanded_size.width() - size_in_pixels.width(),
257 expanded_size.height() - size_in_pixels.height()); 261 expanded_size.height() - size_in_pixels.height());
258 message_handler_->CenterWindow(expanded_size); 262 message_handler_->CenterWindow(expanded_size);
259 } 263 }
260 264
261 void DesktopWindowTreeHostWin::GetWindowPlacement( 265 void DesktopWindowTreeHostWin::GetWindowPlacement(
262 gfx::Rect* bounds, 266 gfx::Rect* bounds,
263 ui::WindowShowState* show_state) const { 267 ui::WindowShowState* show_state) const {
264 message_handler_->GetWindowPlacement(bounds, show_state); 268 message_handler_->GetWindowPlacement(bounds, show_state);
265 InsetBottomRight(bounds, window_enlargement_); 269 InsetBottomRight(bounds, window_enlargement_);
266 *bounds = gfx::win::ScreenToDIPRect(*bounds); 270 *bounds = gfx::ScreenWin::ScreenToDIPRect(GetHWND(), *bounds);
267 } 271 }
268 272
269 gfx::Rect DesktopWindowTreeHostWin::GetWindowBoundsInScreen() const { 273 gfx::Rect DesktopWindowTreeHostWin::GetWindowBoundsInScreen() const {
270 gfx::Rect pixel_bounds = message_handler_->GetWindowBoundsInScreen(); 274 gfx::Rect pixel_bounds = message_handler_->GetWindowBoundsInScreen();
271 InsetBottomRight(&pixel_bounds, window_enlargement_); 275 InsetBottomRight(&pixel_bounds, window_enlargement_);
272 return gfx::win::ScreenToDIPRect(pixel_bounds); 276 return gfx::ScreenWin::ScreenToDIPRect(GetHWND(), pixel_bounds);
273 } 277 }
274 278
275 gfx::Rect DesktopWindowTreeHostWin::GetClientAreaBoundsInScreen() const { 279 gfx::Rect DesktopWindowTreeHostWin::GetClientAreaBoundsInScreen() const {
276 gfx::Rect pixel_bounds = message_handler_->GetClientAreaBoundsInScreen(); 280 gfx::Rect pixel_bounds = message_handler_->GetClientAreaBoundsInScreen();
277 InsetBottomRight(&pixel_bounds, window_enlargement_); 281 InsetBottomRight(&pixel_bounds, window_enlargement_);
278 return gfx::win::ScreenToDIPRect(pixel_bounds); 282 return gfx::ScreenWin::ScreenToDIPRect(GetHWND(), pixel_bounds);
279 } 283 }
280 284
281 gfx::Rect DesktopWindowTreeHostWin::GetRestoredBounds() const { 285 gfx::Rect DesktopWindowTreeHostWin::GetRestoredBounds() const {
282 gfx::Rect pixel_bounds = message_handler_->GetRestoredBounds(); 286 gfx::Rect pixel_bounds = message_handler_->GetRestoredBounds();
283 InsetBottomRight(&pixel_bounds, window_enlargement_); 287 InsetBottomRight(&pixel_bounds, window_enlargement_);
284 return gfx::win::ScreenToDIPRect(pixel_bounds); 288 return gfx::ScreenWin::ScreenToDIPRect(GetHWND(), pixel_bounds);
285 } 289 }
286 290
287 gfx::Rect DesktopWindowTreeHostWin::GetWorkAreaBoundsInScreen() const { 291 gfx::Rect DesktopWindowTreeHostWin::GetWorkAreaBoundsInScreen() const {
288 MONITORINFO monitor_info; 292 MONITORINFO monitor_info;
289 monitor_info.cbSize = sizeof(monitor_info); 293 monitor_info.cbSize = sizeof(monitor_info);
290 GetMonitorInfo(MonitorFromWindow(message_handler_->hwnd(), 294 GetMonitorInfo(MonitorFromWindow(message_handler_->hwnd(),
291 MONITOR_DEFAULTTONEAREST), 295 MONITOR_DEFAULTTONEAREST),
292 &monitor_info); 296 &monitor_info);
293 gfx::Rect pixel_bounds = gfx::Rect(monitor_info.rcWork); 297 gfx::Rect pixel_bounds = gfx::Rect(monitor_info.rcWork);
294 return gfx::win::ScreenToDIPRect(pixel_bounds); 298 return gfx::ScreenWin::ScreenToDIPRect(GetHWND(), pixel_bounds);
295 } 299 }
296 300
297 void DesktopWindowTreeHostWin::SetShape(SkRegion* native_region) { 301 void DesktopWindowTreeHostWin::SetShape(SkRegion* native_region) {
298 if (native_region) { 302 if (native_region) {
299 // TODO(wez): This would be a lot simpler if we were passed an SkPath. 303 // TODO(wez): This would be a lot simpler if we were passed an SkPath.
300 // See crbug.com/410593. 304 // See crbug.com/410593.
301 SkRegion* shape = native_region; 305 SkRegion* shape = native_region;
302 SkRegion device_region; 306 SkRegion device_region;
303 if (gfx::GetDPIScale() > 1.0) { 307 if (gfx::GetDPIScale() > 1.0) {
304 shape = &device_region; 308 shape = &device_region;
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 int DesktopWindowTreeHostWin::GetInitialShowState() const { 646 int DesktopWindowTreeHostWin::GetInitialShowState() const {
643 return CanActivate() ? SW_SHOWNORMAL : SW_SHOWNOACTIVATE; 647 return CanActivate() ? SW_SHOWNORMAL : SW_SHOWNOACTIVATE;
644 } 648 }
645 649
646 bool DesktopWindowTreeHostWin::WillProcessWorkAreaChange() const { 650 bool DesktopWindowTreeHostWin::WillProcessWorkAreaChange() const {
647 return GetWidget()->widget_delegate()->WillProcessWorkAreaChange(); 651 return GetWidget()->widget_delegate()->WillProcessWorkAreaChange();
648 } 652 }
649 653
650 int DesktopWindowTreeHostWin::GetNonClientComponent( 654 int DesktopWindowTreeHostWin::GetNonClientComponent(
651 const gfx::Point& point) const { 655 const gfx::Point& point) const {
652 gfx::Point dip_position = gfx::win::ScreenToDIPPoint(point); 656 gfx::Point dip_position = gfx::ScreenWin::ClientToDIPPoint(GetHWND(), point);
653 return native_widget_delegate_->GetNonClientComponent(dip_position); 657 return native_widget_delegate_->GetNonClientComponent(dip_position);
654 } 658 }
655 659
656 void DesktopWindowTreeHostWin::GetWindowMask(const gfx::Size& size, 660 void DesktopWindowTreeHostWin::GetWindowMask(const gfx::Size& size,
657 gfx::Path* path) { 661 gfx::Path* path) {
658 if (GetWidget()->non_client_view()) { 662 if (GetWidget()->non_client_view()) {
659 GetWidget()->non_client_view()->GetWindowMask(size, path); 663 GetWidget()->non_client_view()->GetWindowMask(size, path);
660 } else if (!window_enlargement_.IsZero()) { 664 } else if (!window_enlargement_.IsZero()) {
661 gfx::Rect bounds(WidgetSizeIsClientSize() 665 gfx::Rect bounds(WidgetSizeIsClientSize()
662 ? message_handler_->GetClientAreaBoundsInScreen() 666 ? message_handler_->GetClientAreaBoundsInScreen()
(...skipping 10 matching lines...) Expand all
673 void DesktopWindowTreeHostWin::GetMinMaxSize(gfx::Size* min_size, 677 void DesktopWindowTreeHostWin::GetMinMaxSize(gfx::Size* min_size,
674 gfx::Size* max_size) const { 678 gfx::Size* max_size) const {
675 *min_size = native_widget_delegate_->GetMinimumSize(); 679 *min_size = native_widget_delegate_->GetMinimumSize();
676 *max_size = native_widget_delegate_->GetMaximumSize(); 680 *max_size = native_widget_delegate_->GetMaximumSize();
677 } 681 }
678 682
679 gfx::Size DesktopWindowTreeHostWin::GetRootViewSize() const { 683 gfx::Size DesktopWindowTreeHostWin::GetRootViewSize() const {
680 return GetWidget()->GetRootView()->size(); 684 return GetWidget()->GetRootView()->size();
681 } 685 }
682 686
687 gfx::Size DesktopWindowTreeHostWin::DIPToScreenSize(
688 const gfx::Size& dip_size) const {
689 return gfx::ScreenWin::DIPToScreenSize(GetHWND(), dip_size);
690 }
691
683 void DesktopWindowTreeHostWin::ResetWindowControls() { 692 void DesktopWindowTreeHostWin::ResetWindowControls() {
684 GetWidget()->non_client_view()->ResetWindowControls(); 693 GetWidget()->non_client_view()->ResetWindowControls();
685 } 694 }
686 695
687 gfx::NativeViewAccessible DesktopWindowTreeHostWin::GetNativeViewAccessible() { 696 gfx::NativeViewAccessible DesktopWindowTreeHostWin::GetNativeViewAccessible() {
688 return GetWidget()->GetRootView()->GetNativeViewAccessible(); 697 return GetWidget()->GetRootView()->GetNativeViewAccessible();
689 } 698 }
690 699
691 bool DesktopWindowTreeHostWin::ShouldHandleSystemCommands() const { 700 bool DesktopWindowTreeHostWin::ShouldHandleSystemCommands() const {
692 return GetWidget()->widget_delegate()->ShouldHandleSystemCommands(); 701 return GetWidget()->widget_delegate()->ShouldHandleSystemCommands();
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 970
962 // static 971 // static
963 DesktopWindowTreeHost* DesktopWindowTreeHost::Create( 972 DesktopWindowTreeHost* DesktopWindowTreeHost::Create(
964 internal::NativeWidgetDelegate* native_widget_delegate, 973 internal::NativeWidgetDelegate* native_widget_delegate,
965 DesktopNativeWidgetAura* desktop_native_widget_aura) { 974 DesktopNativeWidgetAura* desktop_native_widget_aura) {
966 return new DesktopWindowTreeHostWin(native_widget_delegate, 975 return new DesktopWindowTreeHostWin(native_widget_delegate,
967 desktop_native_widget_aura); 976 desktop_native_widget_aura);
968 } 977 }
969 978
970 } // namespace views 979 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/desktop_aura/desktop_window_tree_host_win.h ('k') | ui/views/win/hwnd_message_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698