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

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

Issue 2680043004: WIP: have aura-mus convert to dips before sending out events (Closed)
Patch Set: caveat Created 3 years, 10 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 | « mash/quick_launch/quick_launch.cc ('k') | ui/aura/window_event_dispatcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/mus/window_tree_client.cc
diff --git a/ui/aura/mus/window_tree_client.cc b/ui/aura/mus/window_tree_client.cc
index b71391bc5bab8f5977235c55f7e570fe3f791b1c..27200233613e7a7091088f10cfba238a263947e8 100644
--- a/ui/aura/mus/window_tree_client.cc
+++ b/ui/aura/mus/window_tree_client.cc
@@ -44,6 +44,7 @@
#include "ui/aura/window_delegate.h"
#include "ui/aura/window_tracker.h"
#include "ui/base/ui_base_types.h"
+#include "ui/compositor/compositor.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
#include "ui/events/event.h"
@@ -1132,6 +1133,25 @@ void WindowTreeClient::OnWindowInputEvent(uint32_t event_id,
return;
}
+ // Mus sends screen coordinates, need to convert to DIPs.
+ if (event->IsLocatedEvent() && !roots_.empty()) {
+ // TODO: this isn't right, we need to find the matching host and use it's
+ // scale.
+ const float scale_factor = (*roots_.begin())
+ ->GetWindow()
+ ->GetHost()
+ ->compositor()
+ ->device_scale_factor();
+ if (scale_factor != 1) {
+ gfx::Point host_location = gfx::ConvertPointToDIP(
+ scale_factor, event->AsLocatedEvent()->location());
+ event->AsLocatedEvent()->set_location(host_location);
+ gfx::Point root_location = gfx::ConvertPointToDIP(
+ scale_factor, event->AsLocatedEvent()->root_location());
+ event->AsLocatedEvent()->set_root_location(root_location);
+ }
+ }
+
if (matches_pointer_watcher && has_pointer_watcher_) {
DCHECK(event->IsPointerEvent());
delegate_->OnPointerEventObserved(*event->AsPointerEvent(),
« no previous file with comments | « mash/quick_launch/quick_launch.cc ('k') | ui/aura/window_event_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698