| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/views/event_utils.h" | 5 #include "ui/views/event_utils.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "ui/aura/client/screen_position_client.h" | 9 #include "ui/aura/client/screen_position_client.h" |
| 10 #include "ui/aura/root_window.h" | 10 #include "ui/aura/root_window.h" |
| 11 #include "ui/events/event.h" | 11 #include "ui/events/event.h" |
| 12 #include "ui/gfx/point.h" | 12 #include "ui/gfx/point.h" |
| 13 | 13 |
| 14 using aura::client::ScreenPositionClient; | 14 using aura::client::ScreenPositionClient; |
| 15 | 15 |
| 16 namespace views { | 16 namespace views { |
| 17 | 17 |
| 18 bool RepostLocatedEvent(gfx::NativeWindow window, | 18 bool RepostLocatedEvent(gfx::NativeWindow window, |
| 19 const ui::LocatedEvent& event) { | 19 const ui::LocatedEvent& event) { |
| 20 if (!window) | 20 if (!window) |
| 21 return false; | 21 return false; |
| 22 | 22 |
| 23 aura::RootWindow* root_window = window->GetRootWindow(); | 23 aura::Window* root_window = window->GetRootWindow(); |
| 24 | 24 |
| 25 gfx::Point root_loc(event.location()); | 25 gfx::Point root_loc(event.location()); |
| 26 ScreenPositionClient* spc = GetScreenPositionClient(root_window); | 26 ScreenPositionClient* spc = |
| 27 aura::client::GetScreenPositionClient(root_window); |
| 27 if (!spc) | 28 if (!spc) |
| 28 return false; | 29 return false; |
| 29 | 30 |
| 30 spc->ConvertPointFromScreen(root_window, &root_loc); | 31 spc->ConvertPointFromScreen(root_window, &root_loc); |
| 31 | 32 |
| 32 scoped_ptr<ui::LocatedEvent> relocated; | 33 scoped_ptr<ui::LocatedEvent> relocated; |
| 33 if (event.IsMouseEvent()) { | 34 if (event.IsMouseEvent()) { |
| 34 const ui::MouseEvent& orig = static_cast<const ui::MouseEvent&>(event); | 35 const ui::MouseEvent& orig = static_cast<const ui::MouseEvent&>(event); |
| 35 relocated.reset(new ui::MouseEvent(orig)); | 36 relocated.reset(new ui::MouseEvent(orig)); |
| 36 } else if (event.IsGestureEvent()) { | 37 } else if (event.IsGestureEvent()) { |
| 37 const ui::GestureEvent& orig = static_cast<const ui::GestureEvent&>(event); | 38 const ui::GestureEvent& orig = static_cast<const ui::GestureEvent&>(event); |
| 38 relocated.reset(new ui::GestureEvent(orig)); | 39 relocated.reset(new ui::GestureEvent(orig)); |
| 39 } else { | 40 } else { |
| 40 NOTREACHED(); | 41 NOTREACHED(); |
| 41 return false; | 42 return false; |
| 42 } | 43 } |
| 43 relocated->set_location(root_loc); | 44 relocated->set_location(root_loc); |
| 44 relocated->set_root_location(root_loc); | 45 relocated->set_root_location(root_loc); |
| 45 | 46 |
| 46 root_window->RepostEvent(*relocated); | 47 root_window->GetDispatcher()->RepostEvent(*relocated); |
| 47 return true; | 48 return true; |
| 48 } | 49 } |
| 49 | 50 |
| 50 } // namespace views | 51 } // namespace views |
| OLD | NEW |