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

Unified Diff: ash/host/ash_window_tree_host.cc

Issue 657603002: ash: ozone: apply transformation to events outside the root window (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Flatten TranslateLocatedEvent() Created 6 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
« no previous file with comments | « ash/host/ash_window_tree_host.h ('k') | ash/host/ash_window_tree_host_ozone.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/host/ash_window_tree_host.cc
diff --git a/ash/host/ash_window_tree_host.cc b/ash/host/ash_window_tree_host.cc
new file mode 100644
index 0000000000000000000000000000000000000000..916f5d848c435a451be40661f2180b8072e4316f
--- /dev/null
+++ b/ash/host/ash_window_tree_host.cc
@@ -0,0 +1,39 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ash/host/ash_window_tree_host.h"
+
+#include "ui/aura/client/screen_position_client.h"
+#include "ui/aura/window_tree_host.h"
+#include "ui/events/event.h"
+#include "ui/gfx/rect.h"
+
+namespace ash {
+
+void AshWindowTreeHost::TranslateLocatedEvent(ui::LocatedEvent* event) {
+ if (event->IsTouchEvent())
+ return;
+
+ aura::WindowTreeHost* wth = AsWindowTreeHost();
+ aura::Window* root_window = wth->window();
+ aura::client::ScreenPositionClient* screen_position_client =
+ aura::client::GetScreenPositionClient(root_window);
+ gfx::Rect local(wth->GetBounds().size());
+ local.Inset(GetHostInsets());
+
+ if (screen_position_client && !local.Contains(event->location())) {
+ gfx::Point location(event->location());
+ // In order to get the correct point in screen coordinates
+ // during passive grab, we first need to find on which host window
+ // the mouse is on, and find out the screen coordinates on that
+ // host window, then convert it back to this host window's coordinate.
+ screen_position_client->ConvertHostPointToScreen(root_window, &location);
+ screen_position_client->ConvertPointFromScreen(root_window, &location);
+ wth->ConvertPointToHost(&location);
+ event->set_location(location);
+ event->set_root_location(location);
+ }
+}
+
+} // namespace ash
« no previous file with comments | « ash/host/ash_window_tree_host.h ('k') | ash/host/ash_window_tree_host_ozone.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698