Index: ui/aura/env_input_state_controller.cc |
diff --git a/ui/aura/env_input_state_controller.cc b/ui/aura/env_input_state_controller.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..37ec8d2f85725332ab87496bcd738a29f1d9ef8e |
--- /dev/null |
+++ b/ui/aura/env_input_state_controller.cc |
@@ -0,0 +1,64 @@ |
+// Copyright 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/env_input_state_controller.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 EnvInputStateController::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 EnvInputStateController::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; |
+} |
+ |
+void EnvInputStateController::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 EnvInputStateController::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 |