| 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 "ash/shell.h" | 5 #include "ash/shell.h" |
| 6 #include "ash/shell_factory.h" | 6 #include "ash/shell_factory.h" |
| 7 #include "ash/wm/coordinate_conversion.h" | 7 #include "ash/wm/coordinate_conversion.h" |
| 8 #include "ash/wm/window_properties.h" | 8 #include "ash/wm/window_properties.h" |
| 9 #include "ui/aura/client/capture_client.h" | 9 #include "ui/aura/client/capture_client.h" |
| 10 #include "ui/aura/client/screen_position_client.h" | 10 #include "ui/aura/client/screen_position_client.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 root_window->GetProperty(kUIControlsKey); | 35 root_window->GetProperty(kUIControlsKey); |
| 36 if (!native_ui_control) { | 36 if (!native_ui_control) { |
| 37 native_ui_control = | 37 native_ui_control = |
| 38 aura::test::CreateUIControlsAura(root_window->GetDispatcher()); | 38 aura::test::CreateUIControlsAura(root_window->GetDispatcher()); |
| 39 // Pass the ownership to the |root_window|. | 39 // Pass the ownership to the |root_window|. |
| 40 root_window->SetProperty(kUIControlsKey, native_ui_control); | 40 root_window->SetProperty(kUIControlsKey, native_ui_control); |
| 41 } | 41 } |
| 42 return native_ui_control; | 42 return native_ui_control; |
| 43 } | 43 } |
| 44 | 44 |
| 45 // Returns the UIControls object for the RootWindow at the |point_in_screen| | 45 // Returns the UIControls object for the RootWindow at |point_in_screen|. |
| 46 // in virtual screen coordinates, and updates the |point| relative to the | 46 UIControlsAura* GetUIControlsAt(const gfx::Point& point_in_screen) { |
| 47 // UIControlsAura's root window. NULL if there is no RootWindow under | |
| 48 // the |point_in_screen|. | |
| 49 UIControlsAura* GetUIControlsAt(gfx::Point* point_in_screen) { | |
| 50 // TODO(mazda): Support the case passive grab is taken. | 47 // TODO(mazda): Support the case passive grab is taken. |
| 51 aura::Window* root = ash::wm::GetRootWindowAt(*point_in_screen); | 48 return GetUIControlsForRootWindow(ash::wm::GetRootWindowAt(point_in_screen)); |
| 52 | |
| 53 aura::client::ScreenPositionClient* screen_position_client = | |
| 54 aura::client::GetScreenPositionClient(root); | |
| 55 if (screen_position_client) | |
| 56 screen_position_client->ConvertPointFromScreen(root, point_in_screen); | |
| 57 | |
| 58 return GetUIControlsForRootWindow(root); | |
| 59 } | 49 } |
| 60 | 50 |
| 61 } // namespace | 51 } // namespace |
| 62 | 52 |
| 63 class UIControlsAsh : public UIControlsAura { | 53 class UIControlsAsh : public UIControlsAura { |
| 64 public: | 54 public: |
| 65 UIControlsAsh() { | 55 UIControlsAsh() { |
| 66 } | 56 } |
| 67 virtual ~UIControlsAsh() { | 57 virtual ~UIControlsAsh() { |
| 68 } | 58 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 88 const base::Closure& closure) OVERRIDE { | 78 const base::Closure& closure) OVERRIDE { |
| 89 aura::Window* root = | 79 aura::Window* root = |
| 90 window ? window->GetRootWindow() : ash::Shell::GetTargetRootWindow(); | 80 window ? window->GetRootWindow() : ash::Shell::GetTargetRootWindow(); |
| 91 UIControlsAura* ui_controls = GetUIControlsForRootWindow(root); | 81 UIControlsAura* ui_controls = GetUIControlsForRootWindow(root); |
| 92 return ui_controls && ui_controls->SendKeyPressNotifyWhenDone( | 82 return ui_controls && ui_controls->SendKeyPressNotifyWhenDone( |
| 93 window, key, control, shift, alt, command, closure); | 83 window, key, control, shift, alt, command, closure); |
| 94 } | 84 } |
| 95 | 85 |
| 96 virtual bool SendMouseMove(long x, long y) OVERRIDE { | 86 virtual bool SendMouseMove(long x, long y) OVERRIDE { |
| 97 gfx::Point p(x, y); | 87 gfx::Point p(x, y); |
| 98 UIControlsAura* ui_controls = GetUIControlsAt(&p); | 88 UIControlsAura* ui_controls = GetUIControlsAt(p); |
| 99 return ui_controls && ui_controls->SendMouseMove(p.x(), p.y()); | 89 return ui_controls && ui_controls->SendMouseMove(p.x(), p.y()); |
| 100 } | 90 } |
| 101 | 91 |
| 102 virtual bool SendMouseMoveNotifyWhenDone( | 92 virtual bool SendMouseMoveNotifyWhenDone( |
| 103 long x, | 93 long x, |
| 104 long y, | 94 long y, |
| 105 const base::Closure& closure) OVERRIDE { | 95 const base::Closure& closure) OVERRIDE { |
| 106 gfx::Point p(x, y); | 96 gfx::Point p(x, y); |
| 107 UIControlsAura* ui_controls = GetUIControlsAt(&p); | 97 UIControlsAura* ui_controls = GetUIControlsAt(p); |
| 108 return ui_controls && | 98 return ui_controls && |
| 109 ui_controls->SendMouseMoveNotifyWhenDone(p.x(), p.y(), closure); | 99 ui_controls->SendMouseMoveNotifyWhenDone(p.x(), p.y(), closure); |
| 110 } | 100 } |
| 111 | 101 |
| 112 virtual bool SendMouseEvents(MouseButton type, int state) OVERRIDE { | 102 virtual bool SendMouseEvents(MouseButton type, int state) OVERRIDE { |
| 113 gfx::Point p(ash::Shell::GetScreen()->GetCursorScreenPoint()); | 103 gfx::Point p(ash::Shell::GetScreen()->GetCursorScreenPoint()); |
| 114 UIControlsAura* ui_controls = GetUIControlsAt(&p); | 104 UIControlsAura* ui_controls = GetUIControlsAt(p); |
| 115 return ui_controls && ui_controls->SendMouseEvents(type, state); | 105 return ui_controls && ui_controls->SendMouseEvents(type, state); |
| 116 } | 106 } |
| 117 | 107 |
| 118 virtual bool SendMouseEventsNotifyWhenDone( | 108 virtual bool SendMouseEventsNotifyWhenDone( |
| 119 MouseButton type, int state, const base::Closure& closure) OVERRIDE { | 109 MouseButton type, int state, const base::Closure& closure) OVERRIDE { |
| 120 gfx::Point p(aura::Env::GetInstance()->last_mouse_location()); | 110 gfx::Point p(aura::Env::GetInstance()->last_mouse_location()); |
| 121 UIControlsAura* ui_controls = GetUIControlsAt(&p); | 111 UIControlsAura* ui_controls = GetUIControlsAt(p); |
| 122 return ui_controls && ui_controls->SendMouseEventsNotifyWhenDone( | 112 return ui_controls && ui_controls->SendMouseEventsNotifyWhenDone( |
| 123 type, state, closure); | 113 type, state, closure); |
| 124 } | 114 } |
| 125 | 115 |
| 126 virtual bool SendMouseClick(MouseButton type) OVERRIDE { | 116 virtual bool SendMouseClick(MouseButton type) OVERRIDE { |
| 127 gfx::Point p(ash::Shell::GetScreen()->GetCursorScreenPoint()); | 117 gfx::Point p(ash::Shell::GetScreen()->GetCursorScreenPoint()); |
| 128 UIControlsAura* ui_controls = GetUIControlsAt(&p); | 118 UIControlsAura* ui_controls = GetUIControlsAt(p); |
| 129 return ui_controls && ui_controls->SendMouseClick(type); | 119 return ui_controls && ui_controls->SendMouseClick(type); |
| 130 } | 120 } |
| 131 | 121 |
| 132 virtual void RunClosureAfterAllPendingUIEvents( | 122 virtual void RunClosureAfterAllPendingUIEvents( |
| 133 const base::Closure& closure) OVERRIDE { | 123 const base::Closure& closure) OVERRIDE { |
| 134 UIControlsAura* ui_controls = GetUIControlsForRootWindow( | 124 UIControlsAura* ui_controls = GetUIControlsForRootWindow( |
| 135 ash::Shell::GetTargetRootWindow()); | 125 ash::Shell::GetTargetRootWindow()); |
| 136 if (ui_controls) | 126 if (ui_controls) |
| 137 ui_controls->RunClosureAfterAllPendingUIEvents(closure); | 127 ui_controls->RunClosureAfterAllPendingUIEvents(closure); |
| 138 } | 128 } |
| 139 | 129 |
| 140 private: | 130 private: |
| 141 DISALLOW_COPY_AND_ASSIGN(UIControlsAsh); | 131 DISALLOW_COPY_AND_ASSIGN(UIControlsAsh); |
| 142 }; | 132 }; |
| 143 | 133 |
| 144 ui_controls::UIControlsAura* CreateAshUIControls() { | 134 ui_controls::UIControlsAura* CreateAshUIControls() { |
| 145 return new ash::test::UIControlsAsh(); | 135 return new ash::test::UIControlsAsh(); |
| 146 } | 136 } |
| 147 | 137 |
| 148 } // namespace test | 138 } // namespace test |
| 149 } // namespace ash | 139 } // namespace ash |
| OLD | NEW |