Index: ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc |
diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc |
index c354154a542c87f0dbdcdc46a9d6820d12215356..16aa5cc913331829b3a903c679b61db2fae8104b 100644 |
--- a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc |
+++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc |
@@ -21,6 +21,7 @@ |
#include "ui/gfx/native_widget_types.h" |
#include "ui/gfx/path.h" |
#include "ui/gfx/path_win.h" |
+#include "ui/gfx/screen_win.h" |
#include "ui/gfx/win/dpi.h" |
#include "ui/native_theme/native_theme_aura.h" |
#include "ui/native_theme/native_theme_win.h" |
@@ -140,7 +141,9 @@ void DesktopWindowTreeHostWin::Init(aura::Window* content_window, |
has_non_client_view_ = Widget::RequiresNonClientView(params.type); |
- gfx::Rect pixel_bounds = gfx::win::DIPToScreenRect(params.bounds); |
+ // We don't have an HWND yet, so scale relative to the nearest screen. |
+ gfx::Rect pixel_bounds = gfx::ScreenWin::DIPToScreenRect(nullptr, |
+ params.bounds); |
message_handler_->Init(parent_hwnd, pixel_bounds); |
if (params.force_software_compositing) { |
::SetProp(GetAcceleratedWidget(), |
@@ -218,7 +221,8 @@ void DesktopWindowTreeHostWin::ShowMaximizedWithBounds( |
const gfx::Rect& restored_bounds) { |
if (compositor()) |
compositor()->SetVisible(true); |
- gfx::Rect pixel_bounds = gfx::win::DIPToScreenRect(restored_bounds); |
+ gfx::Rect pixel_bounds = gfx::ScreenWin::DIPToScreenRect(GetHWND(), |
+ restored_bounds); |
message_handler_->ShowMaximizedWithBounds(pixel_bounds); |
} |
@@ -227,7 +231,7 @@ bool DesktopWindowTreeHostWin::IsVisible() const { |
} |
void DesktopWindowTreeHostWin::SetSize(const gfx::Size& size) { |
- gfx::Size size_in_pixels = gfx::win::DIPToScreenSize(size); |
+ gfx::Size size_in_pixels = gfx::ScreenWin::DIPToScreenSize(GetHWND(), size); |
gfx::Size expanded = GetExpandedWindowSize( |
message_handler_->window_ex_style(), size_in_pixels); |
window_enlargement_ = |
@@ -247,7 +251,7 @@ void DesktopWindowTreeHostWin::StackAtTop() { |
} |
void DesktopWindowTreeHostWin::CenterWindow(const gfx::Size& size) { |
- gfx::Size size_in_pixels = gfx::win::DIPToScreenSize(size); |
+ gfx::Size size_in_pixels = gfx::ScreenWin::DIPToScreenSize(GetHWND(), size); |
gfx::Size expanded_size; |
expanded_size = GetExpandedWindowSize(message_handler_->window_ex_style(), |
size_in_pixels); |
@@ -262,25 +266,25 @@ void DesktopWindowTreeHostWin::GetWindowPlacement( |
ui::WindowShowState* show_state) const { |
message_handler_->GetWindowPlacement(bounds, show_state); |
InsetBottomRight(bounds, window_enlargement_); |
- *bounds = gfx::win::ScreenToDIPRect(*bounds); |
+ *bounds = gfx::ScreenWin::ScreenToDIPRect(GetHWND(), *bounds); |
} |
gfx::Rect DesktopWindowTreeHostWin::GetWindowBoundsInScreen() const { |
gfx::Rect pixel_bounds = message_handler_->GetWindowBoundsInScreen(); |
InsetBottomRight(&pixel_bounds, window_enlargement_); |
- return gfx::win::ScreenToDIPRect(pixel_bounds); |
+ return gfx::ScreenWin::ScreenToDIPRect(GetHWND(), pixel_bounds); |
} |
gfx::Rect DesktopWindowTreeHostWin::GetClientAreaBoundsInScreen() const { |
gfx::Rect pixel_bounds = message_handler_->GetClientAreaBoundsInScreen(); |
InsetBottomRight(&pixel_bounds, window_enlargement_); |
- return gfx::win::ScreenToDIPRect(pixel_bounds); |
+ return gfx::ScreenWin::ScreenToDIPRect(GetHWND(), pixel_bounds); |
} |
gfx::Rect DesktopWindowTreeHostWin::GetRestoredBounds() const { |
gfx::Rect pixel_bounds = message_handler_->GetRestoredBounds(); |
InsetBottomRight(&pixel_bounds, window_enlargement_); |
- return gfx::win::ScreenToDIPRect(pixel_bounds); |
+ return gfx::ScreenWin::ScreenToDIPRect(GetHWND(), pixel_bounds); |
} |
gfx::Rect DesktopWindowTreeHostWin::GetWorkAreaBoundsInScreen() const { |
@@ -290,7 +294,7 @@ gfx::Rect DesktopWindowTreeHostWin::GetWorkAreaBoundsInScreen() const { |
MONITOR_DEFAULTTONEAREST), |
&monitor_info); |
gfx::Rect pixel_bounds = gfx::Rect(monitor_info.rcWork); |
- return gfx::win::ScreenToDIPRect(pixel_bounds); |
+ return gfx::ScreenWin::ScreenToDIPRect(GetHWND(), pixel_bounds); |
} |
void DesktopWindowTreeHostWin::SetShape(SkRegion* native_region) { |
@@ -648,7 +652,7 @@ bool DesktopWindowTreeHostWin::WillProcessWorkAreaChange() const { |
int DesktopWindowTreeHostWin::GetNonClientComponent( |
const gfx::Point& point) const { |
- gfx::Point dip_position = gfx::win::ScreenToDIPPoint(point); |
+ gfx::Point dip_position = gfx::ScreenWin::ClientToDIPPoint(GetHWND(), point); |
return native_widget_delegate_->GetNonClientComponent(dip_position); |
} |
@@ -679,6 +683,11 @@ gfx::Size DesktopWindowTreeHostWin::GetRootViewSize() const { |
return GetWidget()->GetRootView()->size(); |
} |
+gfx::Size DesktopWindowTreeHostWin::DIPToScreenSize( |
+ const gfx::Size& dip_size) const { |
+ return gfx::ScreenWin::DIPToScreenSize(GetHWND(), dip_size); |
+} |
+ |
void DesktopWindowTreeHostWin::ResetWindowControls() { |
GetWidget()->non_client_view()->ResetWindowControls(); |
} |