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 12 matching lines...) Expand all Loading... |
23 namespace { | 23 namespace { |
24 | 24 |
25 using ui_controls::UIControlsAura; | 25 using ui_controls::UIControlsAura; |
26 using ui_controls::MouseButton; | 26 using ui_controls::MouseButton; |
27 | 27 |
28 DEFINE_OWNED_WINDOW_PROPERTY_KEY(UIControlsAura, kUIControlsKey, NULL); | 28 DEFINE_OWNED_WINDOW_PROPERTY_KEY(UIControlsAura, kUIControlsKey, NULL); |
29 | 29 |
30 // Returns the UIControls object for RootWindow. | 30 // Returns the UIControls object for RootWindow. |
31 // kUIControlsKey is owned property and UIControls object | 31 // kUIControlsKey is owned property and UIControls object |
32 // will be deleted when the root window is deleted. | 32 // will be deleted when the root window is deleted. |
33 UIControlsAura* GetUIControlsForRootWindow(aura::RootWindow* root_window) { | 33 UIControlsAura* GetUIControlsForRootWindow(aura::Window* root_window) { |
34 UIControlsAura* native_ui_control = | 34 UIControlsAura* native_ui_control = |
35 root_window->GetProperty(kUIControlsKey); | 35 root_window->GetProperty(kUIControlsKey); |
36 if (!native_ui_control) { | 36 if (!native_ui_control) { |
37 native_ui_control = aura::test::CreateUIControlsAura(root_window); | 37 native_ui_control = |
| 38 aura::test::CreateUIControlsAura(root_window->GetDispatcher()); |
38 // Pass the ownership to the |root_window|. | 39 // Pass the ownership to the |root_window|. |
39 root_window->SetProperty(kUIControlsKey, native_ui_control); | 40 root_window->SetProperty(kUIControlsKey, native_ui_control); |
40 } | 41 } |
41 return native_ui_control; | 42 return native_ui_control; |
42 } | 43 } |
43 | 44 |
44 // Returns the UIControls object for the RootWindow at the |point_in_screen| | 45 // Returns the UIControls object for the RootWindow at the |point_in_screen| |
45 // in virtual screen coordinates, and updates the |point| relative to the | 46 // in virtual screen coordinates, and updates the |point| relative to the |
46 // UIControlsAura's root window. NULL if there is no RootWindow under | 47 // UIControlsAura's root window. NULL if there is no RootWindow under |
47 // the |point_in_screen|. | 48 // the |point_in_screen|. |
48 UIControlsAura* GetUIControlsAt(gfx::Point* point_in_screen) { | 49 UIControlsAura* GetUIControlsAt(gfx::Point* point_in_screen) { |
49 // TODO(mazda): Support the case passive grab is taken. | 50 // TODO(mazda): Support the case passive grab is taken. |
50 aura::RootWindow* root = ash::wm::GetRootWindowAt(*point_in_screen); | 51 aura::Window* root = ash::wm::GetRootWindowAt(*point_in_screen); |
51 | 52 |
52 aura::client::ScreenPositionClient* screen_position_client = | 53 aura::client::ScreenPositionClient* screen_position_client = |
53 aura::client::GetScreenPositionClient(root); | 54 aura::client::GetScreenPositionClient(root); |
54 if (screen_position_client) | 55 if (screen_position_client) |
55 screen_position_client->ConvertPointFromScreen(root, point_in_screen); | 56 screen_position_client->ConvertPointFromScreen(root, point_in_screen); |
56 | 57 |
57 return GetUIControlsForRootWindow(root); | 58 return GetUIControlsForRootWindow(root); |
58 } | 59 } |
59 | 60 |
60 } // namespace | 61 } // namespace |
(...skipping 17 matching lines...) Expand all Loading... |
78 } | 79 } |
79 | 80 |
80 virtual bool SendKeyPressNotifyWhenDone( | 81 virtual bool SendKeyPressNotifyWhenDone( |
81 gfx::NativeWindow window, | 82 gfx::NativeWindow window, |
82 ui::KeyboardCode key, | 83 ui::KeyboardCode key, |
83 bool control, | 84 bool control, |
84 bool shift, | 85 bool shift, |
85 bool alt, | 86 bool alt, |
86 bool command, | 87 bool command, |
87 const base::Closure& closure) OVERRIDE { | 88 const base::Closure& closure) OVERRIDE { |
88 aura::RootWindow* root = | 89 aura::Window* root = |
89 window ? window->GetRootWindow() : ash::Shell::GetTargetRootWindow(); | 90 window ? window->GetRootWindow() : ash::Shell::GetTargetRootWindow(); |
90 UIControlsAura* ui_controls = GetUIControlsForRootWindow(root); | 91 UIControlsAura* ui_controls = GetUIControlsForRootWindow(root); |
91 return ui_controls && ui_controls->SendKeyPressNotifyWhenDone( | 92 return ui_controls && ui_controls->SendKeyPressNotifyWhenDone( |
92 window, key, control, shift, alt, command, closure); | 93 window, key, control, shift, alt, command, closure); |
93 } | 94 } |
94 | 95 |
95 virtual bool SendMouseMove(long x, long y) OVERRIDE { | 96 virtual bool SendMouseMove(long x, long y) OVERRIDE { |
96 gfx::Point p(x, y); | 97 gfx::Point p(x, y); |
97 UIControlsAura* ui_controls = GetUIControlsAt(&p); | 98 UIControlsAura* ui_controls = GetUIControlsAt(&p); |
98 return ui_controls && ui_controls->SendMouseMove(p.x(), p.y()); | 99 return ui_controls && ui_controls->SendMouseMove(p.x(), p.y()); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 private: | 140 private: |
140 DISALLOW_COPY_AND_ASSIGN(UIControlsAsh); | 141 DISALLOW_COPY_AND_ASSIGN(UIControlsAsh); |
141 }; | 142 }; |
142 | 143 |
143 ui_controls::UIControlsAura* CreateAshUIControls() { | 144 ui_controls::UIControlsAura* CreateAshUIControls() { |
144 return new ash::test::UIControlsAsh(); | 145 return new ash::test::UIControlsAsh(); |
145 } | 146 } |
146 | 147 |
147 } // namespace test | 148 } // namespace test |
148 } // namespace ash | 149 } // namespace ash |
OLD | NEW |