OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 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/window_event_dispatcher_delegate.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 WindowEventDispatcherDelegate::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 WindowEventDispatcherDelegate::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 bool WindowEventDispatcherDelegate::IsMouseButtonDown() const { |
| 38 return Env::GetInstance()->IsMouseButtonDown(); |
| 39 } |
| 40 |
| 41 void WindowEventDispatcherDelegate::PreDispatchMouseEvent(ui::MouseEvent* event) |
| 42 const { |
| 43 switch (event->type()) { |
| 44 case ui::ET_MOUSE_PRESSED: |
| 45 Env::GetInstance()->set_mouse_button_flags(event->button_flags()); |
| 46 break; |
| 47 case ui::ET_MOUSE_RELEASED: |
| 48 Env::GetInstance()->set_mouse_button_flags( |
| 49 event->button_flags() & ~event->changed_button_flags()); |
| 50 break; |
| 51 default: |
| 52 break; |
| 53 } |
| 54 } |
| 55 |
| 56 void WindowEventDispatcherDelegate::PreDispatchTouchEvent( |
| 57 ui::TouchEvent* event, uint32_t touch_ids_down) const { |
| 58 switch (event->type()) { |
| 59 case ui::ET_TOUCH_PRESSED: |
| 60 case ui::ET_TOUCH_RELEASED: |
| 61 Env::GetInstance()->set_touch_down(touch_ids_down != 0); |
| 62 break; |
| 63 default: |
| 64 break; |
| 65 } |
| 66 } |
| 67 |
| 68 } // namespace aura |
OLD | NEW |