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

Unified Diff: ui/aura/mus/window_port_mus.cc

Issue 2579883002: Scale bounds in aura-mus client-lib and NativeWidgetMus in hdpi mode. (Closed)
Patch Set: Created 4 years 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 side-by-side diff with in-line comments
Download patch
Index: ui/aura/mus/window_port_mus.cc
diff --git a/ui/aura/mus/window_port_mus.cc b/ui/aura/mus/window_port_mus.cc
index da5774c1935d7a7a56b1a23f5c0734bb665636cc..d27fad3acd996243f92509112957809462e3bdff 100644
--- a/ui/aura/mus/window_port_mus.cc
+++ b/ui/aura/mus/window_port_mus.cc
@@ -14,8 +14,21 @@
#include "ui/aura/window_delegate.h"
#include "ui/aura/window_observer.h"
#include "ui/aura/window_property.h"
+#include "ui/display/screen.h"
+#include "ui/gfx/geometry/dip_util.h"
namespace aura {
+namespace {
+
+// Helper function to get the device_scale_factor() of the display::Display
+// nearest to |window|.
+float ScaleFactorForDisplay(Window* window) {
+ return display::Screen::GetScreen()
+ ->GetDisplayNearestWindow(window)
+ .device_scale_factor();
+}
+
+} // namespace
WindowPortMus::WindowMusChangeDataImpl::WindowMusChangeDataImpl() = default;
@@ -208,7 +221,8 @@ void WindowPortMus::SetBoundsFromServer(const gfx::Rect& bounds) {
ServerChangeData data;
data.bounds = bounds;
ScopedServerChange change(this, ServerChangeType::BOUNDS, data);
- window_->SetBounds(bounds);
+ window_->SetBounds(
+ gfx::ConvertRectToDIP(ScaleFactorForDisplay(window_), bounds));
}
void WindowPortMus::SetVisibleFromServer(bool visible) {
@@ -408,7 +422,8 @@ void WindowPortMus::OnVisibilityChanged(bool visible) {
void WindowPortMus::OnDidChangeBounds(const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) {
ServerChangeData change_data;
- change_data.bounds = new_bounds;
+ change_data.bounds =
+ gfx::ConvertRectToPixel(ScaleFactorForDisplay(window_), new_bounds);
if (!RemoveChangeByTypeAndData(ServerChangeType::BOUNDS, change_data))
window_tree_client_->OnWindowMusBoundsChanged(this, old_bounds, new_bounds);
}

Powered by Google App Engine
This is Rietveld 408576698