OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ui/aura/env_input_state_controller.h" |
| 6 |
| 7 #include "ui/aura/client/screen_position_client.h" |
| 8 #include "ui/aura/env.h" |
| 9 #include "ui/events/event.h" |
| 10 #include "ui/gfx/geometry/point.h" |
| 11 |
| 12 namespace aura { |
| 13 |
| 14 void EnvInputStateController::SetLastMouseLocation( |
| 15 const Window* root_window, const gfx::Point& location_in_root) const { |
| 16 client::ScreenPositionClient* client = |
| 17 client::GetScreenPositionClient(root_window); |
| 18 if (client) { |
| 19 gfx::Point location_in_screen = location_in_root; |
| 20 client->ConvertPointToScreen(root_window, &location_in_screen); |
| 21 Env::GetInstance()->set_last_mouse_location(location_in_screen); |
| 22 } else { |
| 23 Env::GetInstance()->set_last_mouse_location(location_in_root); |
| 24 } |
| 25 } |
| 26 |
| 27 gfx::Point EnvInputStateController::GetLastMouseLocationInRoot( |
| 28 const Window* window) const { |
| 29 gfx::Point location = Env::GetInstance()->last_mouse_location(); |
| 30 client::ScreenPositionClient* client = |
| 31 client::GetScreenPositionClient(window); |
| 32 if (client) |
| 33 client->ConvertPointFromScreen(window, &location); |
| 34 return location; |
| 35 } |
| 36 |
| 37 void EnvInputStateController::PreDispatchMouseEvent(ui::MouseEvent* event) |
| 38 const { |
| 39 switch (event->type()) { |
| 40 case ui::ET_MOUSE_PRESSED: |
| 41 Env::GetInstance()->set_mouse_button_flags(event->button_flags()); |
| 42 break; |
| 43 case ui::ET_MOUSE_RELEASED: |
| 44 Env::GetInstance()->set_mouse_button_flags( |
| 45 event->button_flags() & ~event->changed_button_flags()); |
| 46 break; |
| 47 default: |
| 48 break; |
| 49 } |
| 50 } |
| 51 |
| 52 void EnvInputStateController::PreDispatchTouchEvent( |
| 53 ui::TouchEvent* event, uint32_t touch_ids_down) const { |
| 54 switch (event->type()) { |
| 55 case ui::ET_TOUCH_PRESSED: |
| 56 case ui::ET_TOUCH_RELEASED: |
| 57 Env::GetInstance()->set_touch_down(touch_ids_down != 0); |
| 58 break; |
| 59 default: |
| 60 break; |
| 61 } |
| 62 } |
| 63 |
| 64 } // namespace aura |
OLD | NEW |