Index: ui/aura/root_window_host_win.cc |
diff --git a/ui/aura/root_window_host_win.cc b/ui/aura/root_window_host_win.cc |
index 1109b72e103340b6d681eb59931cc9f5e0e027cc..e8d50f95cdb5910bc6d92e90b07832a4a95bb53a 100644 |
--- a/ui/aura/root_window_host_win.cc |
+++ b/ui/aura/root_window_host_win.cc |
@@ -14,11 +14,18 @@ |
#include "ui/base/cursor/cursor_loader_win.h" |
#include "ui/base/events/event.h" |
#include "ui/base/view_prop.h" |
+#include "ui/gfx/display.h" |
+#include "ui/gfx/screen.h" |
using std::max; |
using std::min; |
namespace aura { |
+namespace { |
+ |
+bool use_popup_as_root_window_for_test = false; |
+ |
+} // namespace |
// static |
RootWindowHost* RootWindowHost::Create(const gfx::Rect& bounds) { |
@@ -37,6 +44,8 @@ RootWindowHostWin::RootWindowHostWin(const gfx::Rect& bounds) |
has_capture_(false), |
saved_window_style_(0), |
saved_window_ex_style_(0) { |
+ if (use_popup_as_root_window_for_test) |
+ set_window_style(WS_POPUP); |
Init(NULL, bounds); |
SetWindowText(hwnd(), L"aura::RootWindow!"); |
} |
@@ -121,11 +130,19 @@ void RootWindowHostWin::SetBounds(const gfx::Rect& bounds) { |
SetWindowPos( |
hwnd(), |
NULL, |
- 0, |
- 0, |
+ window_rect.left, |
+ window_rect.top, |
window_rect.right - window_rect.left, |
window_rect.bottom - window_rect.top, |
SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOREDRAW | SWP_NOREPOSITION); |
+ |
+ // Explicity call OnHostResized when the scale has changed because |
+ // the window size may not have changed. |
+ float current_scale = delegate_->GetDeviceScaleFactor(); |
+ float new_scale = gfx::Screen::GetScreenFor(delegate_->AsRootWindow())-> |
+ GetDisplayNearestWindow(delegate_->AsRootWindow()).device_scale_factor(); |
+ if (current_scale != new_scale) |
+ delegate_->OnHostResized(bounds.size()); |
} |
gfx::Point RootWindowHostWin::GetLocationOnNativeScreen() const { |
@@ -281,4 +298,13 @@ void RootWindowHostWin::OnSize(UINT param, const CSize& size) { |
delegate_->OnHostResized(gfx::Size(size.cx, size.cy)); |
} |
+namespace test { |
+ |
+// static |
+void SetUsePopupAsRootWindowForTest(bool use) { |
+ use_popup_as_root_window_for_test = use; |
+} |
+ |
+} // namespace test |
+ |
} // namespace aura |