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

Unified Diff: ash/host/ash_window_tree_host_ozone.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: Change GetBounds() visibility from public to protected Created 6 years, 1 month 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 | « no previous file | ash/wm/drag_window_resizer.cc » ('j') | ui/aura/window_tree_host_ozone.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/host/ash_window_tree_host_ozone.cc
diff --git a/ash/host/ash_window_tree_host_ozone.cc b/ash/host/ash_window_tree_host_ozone.cc
index 764eededa4163e8959b9ebf8cee8fbc8cf93111d..6dc42a79313b69f1f54810df4c3940d791d060f4 100644
--- a/ash/host/ash_window_tree_host_ozone.cc
+++ b/ash/host/ash_window_tree_host_ozone.cc
@@ -8,6 +8,7 @@
#include "ash/host/root_window_transformer.h"
#include "ash/host/transformer_helper.h"
#include "base/command_line.h"
+#include "ui/aura/client/screen_position_client.h"
#include "ui/aura/window_tree_host_ozone.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/transform.h"
@@ -34,6 +35,9 @@ class AshWindowTreeHostOzone : public AshWindowTreeHost,
virtual gfx::Transform GetRootTransform() const override;
virtual gfx::Transform GetInverseRootTransform() const override;
virtual void UpdateRootWindowSize(const gfx::Size& host_size) override;
+ virtual void DispatchEvent(ui::Event* event) override;
+
+ void TranslateMouseEvent(ui::LocatedEvent* event);
sadrul 2014/11/11 14:41:14 non-override before overrides
llandwerlin-old 2014/11/11 18:29:17 Done.
TransformerHelper transformer_helper_;
@@ -87,6 +91,34 @@ void AshWindowTreeHostOzone::UpdateRootWindowSize(const gfx::Size& host_size) {
transformer_helper_.UpdateWindowSize(host_size);
}
+void AshWindowTreeHostOzone::DispatchEvent(ui::Event* event) {
+ if (event->IsMouseEvent() || event->IsScrollEvent())
+ TranslateMouseEvent(static_cast<ui::LocatedEvent*>(event));
+ SendEventToProcessor(event);
+}
+
+void AshWindowTreeHostOzone::TranslateMouseEvent(ui::LocatedEvent* event) {
+ aura::Window* root_window = window();
+ aura::client::ScreenPositionClient* screen_position_client =
+ aura::client::GetScreenPositionClient(root_window);
+ gfx::Rect local(GetBounds().size());
+
+ local.Inset(transformer_helper_.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);
+ ConvertPointToHost(&location);
+ event->set_location(location);
+ event->set_root_location(location);
+ }
+}
+
} // namespace
AshWindowTreeHost* AshWindowTreeHost::Create(
« no previous file with comments | « no previous file | ash/wm/drag_window_resizer.cc » ('j') | ui/aura/window_tree_host_ozone.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698