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

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

Issue 2629653002: Add window position offset. (Closed)
Patch Set: Created 3 years, 11 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_default.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/ui/ws/platform_display_default.cc
diff --git a/services/ui/ws/platform_display_default.cc b/services/ui/ws/platform_display_default.cc
index ba50d304de71e5c49d5ddb1ad6b59cdc2821b125..41dbf48055ed235aaa9cef30b76bf6362a606835 100644
--- a/services/ui/ws/platform_display_default.cc
+++ b/services/ui/ws/platform_display_default.cc
@@ -169,6 +169,11 @@ void PlatformDisplayDefault::UpdateEventRootLocation(ui::LocatedEvent* event) {
}
void PlatformDisplayDefault::OnBoundsChanged(const gfx::Rect& new_bounds) {
+ // Since we aren't resizing the Chrome OS display size, if the user resizes
+ // the window or the WM doesn't honor the requested size then cursor
+ // locations end up incorrect.
+ window_height_offset_ = new_bounds.height() - metrics_.pixel_size.height();
+
// We only care if the window size has changed.
if (new_bounds.size() == metrics_.pixel_size)
return;
@@ -181,8 +186,13 @@ void PlatformDisplayDefault::OnBoundsChanged(const gfx::Rect& new_bounds) {
void PlatformDisplayDefault::OnDamageRect(const gfx::Rect& damaged_region) {}
void PlatformDisplayDefault::DispatchEvent(ui::Event* event) {
- if (event->IsLocatedEvent())
- UpdateEventRootLocation(event->AsLocatedEvent());
+ if (event->IsLocatedEvent()) {
+ ui::LocatedEvent* located_event = event->AsLocatedEvent();
+ gfx::PointF location = located_event->location_f();
+ location.Offset(0, -window_height_offset_);
+ located_event->set_location_f(location);
+ UpdateEventRootLocation(located_event);
tonikitoo 2017/01/13 17:07:14 driven-by comment: maybe moving moving this offset
+ }
if (event->IsScrollEvent()) {
// TODO(moshayedi): crbug.com/602859. Dispatch scroll events as
« no previous file with comments | « services/ui/ws/platform_display_default.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698