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

Unified Diff: services/ui/ws/platform_display.cc

Issue 2230963003: Fix window/display bounds with multiple windows in mus. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes. Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « services/ui/ws/platform_display.h ('k') | services/ui/ws/platform_display_init_params.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/ui/ws/platform_display.cc
diff --git a/services/ui/ws/platform_display.cc b/services/ui/ws/platform_display.cc
index bb9c47774b6b6154f4a39c01b7a6321a5e6c2de8..4fe70ee8bbcff244eb99f92a7a54fed27a986597 100644
--- a/services/ui/ws/platform_display.cc
+++ b/services/ui/ws/platform_display.cc
@@ -55,12 +55,12 @@ PlatformDisplay* PlatformDisplay::Create(
DefaultPlatformDisplay::DefaultPlatformDisplay(
const PlatformDisplayInitParams& init_params)
: id_(init_params.display_id),
+ platform_screen_(init_params.platform_screen),
#if !defined(OS_ANDROID)
cursor_loader_(ui::CursorLoader::Create()),
#endif
frame_generator_(new FrameGenerator(this, init_params.surfaces_state)) {
metrics_.bounds = init_params.display_bounds;
- // TODO(rjkroege): Preserve the display_id when Ozone platform can use it.
}
void DefaultPlatformDisplay::Init(PlatformDisplayDelegate* delegate) {
@@ -168,23 +168,36 @@ gfx::Rect DefaultPlatformDisplay::GetBounds() const {
return metrics_.bounds;
}
+bool DefaultPlatformDisplay::IsPrimaryDisplay() const {
+ return platform_screen_->GetPrimaryDisplayId() == id_;
+}
+
void DefaultPlatformDisplay::UpdateMetrics(const gfx::Rect& bounds,
float device_scale_factor) {
if (display::Display::HasForceDeviceScaleFactor())
device_scale_factor = display::Display::GetForcedDeviceScaleFactor();
- if (metrics_.bounds == bounds &&
+
+ // We don't care about the origin of the platform window, as that may not be
+ // related to the origin of the display in our screen space.
+ if (metrics_.bounds.size() == bounds.size() &&
metrics_.device_scale_factor == device_scale_factor)
return;
+ // TODO(kylechar): If the window size is updated then we may need to update
+ // the origin for any other windows.
ViewportMetrics old_metrics = metrics_;
- metrics_.bounds = bounds;
+ metrics_.bounds.set_size(bounds.size());
metrics_.device_scale_factor = device_scale_factor;
delegate_->OnViewportMetricsChanged(old_metrics, metrics_);
}
+void DefaultPlatformDisplay::UpdateEventRootLocation(ui::LocatedEvent* event) {
+ gfx::Point location = event->location();
+ location.Offset(metrics_.bounds.x(), metrics_.bounds.y());
+ event->set_root_location(location);
+}
+
void DefaultPlatformDisplay::OnBoundsChanged(const gfx::Rect& new_bounds) {
- // TODO(kylechar): We should keep track of the actual top left of the window
- // and also the internal top left of the window (eg. first window is at 0,0).
UpdateMetrics(new_bounds, metrics_.device_scale_factor);
}
@@ -193,6 +206,9 @@ void DefaultPlatformDisplay::OnDamageRect(const gfx::Rect& damaged_region) {
}
void DefaultPlatformDisplay::DispatchEvent(ui::Event* event) {
+ if (event->IsLocatedEvent())
+ UpdateEventRootLocation(event->AsLocatedEvent());
+
if (event->IsScrollEvent()) {
// TODO(moshayedi): crbug.com/602859. Dispatch scroll events as
// they are once we have proper support for scroll events.
« no previous file with comments | « services/ui/ws/platform_display.h ('k') | services/ui/ws/platform_display_init_params.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698