Index: ui/aura/window_event_dispatcher_delegate.cc |
diff --git a/ui/aura/window_event_dispatcher_delegate.cc b/ui/aura/window_event_dispatcher_delegate.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..3ae25ede30f4bcf455cb56e7a915944eb5fba85f |
--- /dev/null |
+++ b/ui/aura/window_event_dispatcher_delegate.cc |
@@ -0,0 +1,68 @@ |
+// Copyright (c) 2016 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 "ui/aura/window_event_dispatcher_delegate.h" |
+ |
+#include "ui/aura/client/screen_position_client.h" |
+#include "ui/aura/env.h" |
+#include "ui/events/event.h" |
+#include "ui/gfx/geometry/point.h" |
+ |
+namespace aura { |
+ |
+void WindowEventDispatcherDelegate::SetLastMouseLocation( |
+ const Window* root_window, const gfx::Point& location_in_root) const { |
+ client::ScreenPositionClient* client = |
+ client::GetScreenPositionClient(root_window); |
+ if (client) { |
+ gfx::Point location_in_screen = location_in_root; |
+ client->ConvertPointToScreen(root_window, &location_in_screen); |
+ Env::GetInstance()->set_last_mouse_location(location_in_screen); |
+ } else { |
+ Env::GetInstance()->set_last_mouse_location(location_in_root); |
+ } |
+} |
+ |
+gfx::Point WindowEventDispatcherDelegate::GetLastMouseLocationInRoot( |
+ const Window* window) const { |
+ gfx::Point location = Env::GetInstance()->last_mouse_location(); |
+ client::ScreenPositionClient* client = |
+ client::GetScreenPositionClient(window); |
+ if (client) |
+ client->ConvertPointFromScreen(window, &location); |
+ return location; |
+} |
+ |
+bool WindowEventDispatcherDelegate::IsMouseButtonDown() const { |
+ return Env::GetInstance()->IsMouseButtonDown(); |
+} |
+ |
+void WindowEventDispatcherDelegate::PreDispatchMouseEvent(ui::MouseEvent* event) |
+ const { |
+ switch (event->type()) { |
+ case ui::ET_MOUSE_PRESSED: |
+ Env::GetInstance()->set_mouse_button_flags(event->button_flags()); |
+ break; |
+ case ui::ET_MOUSE_RELEASED: |
+ Env::GetInstance()->set_mouse_button_flags( |
+ event->button_flags() & ~event->changed_button_flags()); |
+ break; |
+ default: |
+ break; |
+ } |
+} |
+ |
+void WindowEventDispatcherDelegate::PreDispatchTouchEvent( |
+ ui::TouchEvent* event, uint32_t touch_ids_down) const { |
+ switch (event->type()) { |
+ case ui::ET_TOUCH_PRESSED: |
+ case ui::ET_TOUCH_RELEASED: |
+ Env::GetInstance()->set_touch_down(touch_ids_down != 0); |
+ break; |
+ default: |
+ break; |
+ } |
+} |
+ |
+} // namespace aura |