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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 // TODO(mazda): Support the case passive grab is taken. | 47 // TODO(mazda): Support the case passive grab is taken. |
48 return GetUIControlsForRootWindow(ash::wm::GetRootWindowAt(point_in_screen)); | 48 return GetUIControlsForRootWindow(ash::wm::GetRootWindowAt(point_in_screen)); |
49 } | 49 } |
50 | 50 |
51 } // namespace | 51 } // namespace |
52 | 52 |
53 class UIControlsAsh : public UIControlsAura { | 53 class UIControlsAsh : public UIControlsAura { |
54 public: | 54 public: |
55 UIControlsAsh() { | 55 UIControlsAsh() { |
56 } | 56 } |
57 virtual ~UIControlsAsh() { | 57 ~UIControlsAsh() override {} |
58 } | |
59 | 58 |
60 // UIControslAura overrides: | 59 // UIControslAura overrides: |
61 virtual bool SendKeyPress(gfx::NativeWindow window, | 60 bool SendKeyPress(gfx::NativeWindow window, |
62 ui::KeyboardCode key, | 61 ui::KeyboardCode key, |
63 bool control, | 62 bool control, |
64 bool shift, | 63 bool shift, |
65 bool alt, | 64 bool alt, |
66 bool command) override { | 65 bool command) override { |
67 return SendKeyPressNotifyWhenDone( | 66 return SendKeyPressNotifyWhenDone( |
68 window, key, control, shift, alt, command, base::Closure()); | 67 window, key, control, shift, alt, command, base::Closure()); |
69 } | 68 } |
70 | 69 |
71 virtual bool SendKeyPressNotifyWhenDone( | 70 bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window, |
72 gfx::NativeWindow window, | 71 ui::KeyboardCode key, |
73 ui::KeyboardCode key, | 72 bool control, |
74 bool control, | 73 bool shift, |
75 bool shift, | 74 bool alt, |
76 bool alt, | 75 bool command, |
77 bool command, | 76 const base::Closure& closure) override { |
78 const base::Closure& closure) override { | |
79 aura::Window* root = | 77 aura::Window* root = |
80 window ? window->GetRootWindow() : ash::Shell::GetTargetRootWindow(); | 78 window ? window->GetRootWindow() : ash::Shell::GetTargetRootWindow(); |
81 UIControlsAura* ui_controls = GetUIControlsForRootWindow(root); | 79 UIControlsAura* ui_controls = GetUIControlsForRootWindow(root); |
82 return ui_controls && ui_controls->SendKeyPressNotifyWhenDone( | 80 return ui_controls && ui_controls->SendKeyPressNotifyWhenDone( |
83 window, key, control, shift, alt, command, closure); | 81 window, key, control, shift, alt, command, closure); |
84 } | 82 } |
85 | 83 |
86 virtual bool SendMouseMove(long x, long y) override { | 84 bool SendMouseMove(long x, long y) override { |
87 gfx::Point p(x, y); | 85 gfx::Point p(x, y); |
88 UIControlsAura* ui_controls = GetUIControlsAt(p); | 86 UIControlsAura* ui_controls = GetUIControlsAt(p); |
89 return ui_controls && ui_controls->SendMouseMove(p.x(), p.y()); | 87 return ui_controls && ui_controls->SendMouseMove(p.x(), p.y()); |
90 } | 88 } |
91 | 89 |
92 virtual bool SendMouseMoveNotifyWhenDone( | 90 bool SendMouseMoveNotifyWhenDone(long x, |
93 long x, | 91 long y, |
94 long y, | 92 const base::Closure& closure) override { |
95 const base::Closure& closure) override { | |
96 gfx::Point p(x, y); | 93 gfx::Point p(x, y); |
97 UIControlsAura* ui_controls = GetUIControlsAt(p); | 94 UIControlsAura* ui_controls = GetUIControlsAt(p); |
98 return ui_controls && | 95 return ui_controls && |
99 ui_controls->SendMouseMoveNotifyWhenDone(p.x(), p.y(), closure); | 96 ui_controls->SendMouseMoveNotifyWhenDone(p.x(), p.y(), closure); |
100 } | 97 } |
101 | 98 |
102 virtual bool SendMouseEvents(MouseButton type, int state) override { | 99 bool SendMouseEvents(MouseButton type, int state) override { |
103 gfx::Point p(ash::Shell::GetScreen()->GetCursorScreenPoint()); | 100 gfx::Point p(ash::Shell::GetScreen()->GetCursorScreenPoint()); |
104 UIControlsAura* ui_controls = GetUIControlsAt(p); | 101 UIControlsAura* ui_controls = GetUIControlsAt(p); |
105 return ui_controls && ui_controls->SendMouseEvents(type, state); | 102 return ui_controls && ui_controls->SendMouseEvents(type, state); |
106 } | 103 } |
107 | 104 |
108 virtual bool SendMouseEventsNotifyWhenDone( | 105 bool SendMouseEventsNotifyWhenDone(MouseButton type, |
109 MouseButton type, int state, const base::Closure& closure) override { | 106 int state, |
| 107 const base::Closure& closure) override { |
110 gfx::Point p(aura::Env::GetInstance()->last_mouse_location()); | 108 gfx::Point p(aura::Env::GetInstance()->last_mouse_location()); |
111 UIControlsAura* ui_controls = GetUIControlsAt(p); | 109 UIControlsAura* ui_controls = GetUIControlsAt(p); |
112 return ui_controls && ui_controls->SendMouseEventsNotifyWhenDone( | 110 return ui_controls && ui_controls->SendMouseEventsNotifyWhenDone( |
113 type, state, closure); | 111 type, state, closure); |
114 } | 112 } |
115 | 113 |
116 virtual bool SendMouseClick(MouseButton type) override { | 114 bool SendMouseClick(MouseButton type) override { |
117 gfx::Point p(ash::Shell::GetScreen()->GetCursorScreenPoint()); | 115 gfx::Point p(ash::Shell::GetScreen()->GetCursorScreenPoint()); |
118 UIControlsAura* ui_controls = GetUIControlsAt(p); | 116 UIControlsAura* ui_controls = GetUIControlsAt(p); |
119 return ui_controls && ui_controls->SendMouseClick(type); | 117 return ui_controls && ui_controls->SendMouseClick(type); |
120 } | 118 } |
121 | 119 |
122 virtual void RunClosureAfterAllPendingUIEvents( | 120 void RunClosureAfterAllPendingUIEvents( |
123 const base::Closure& closure) override { | 121 const base::Closure& closure) override { |
124 UIControlsAura* ui_controls = GetUIControlsForRootWindow( | 122 UIControlsAura* ui_controls = GetUIControlsForRootWindow( |
125 ash::Shell::GetTargetRootWindow()); | 123 ash::Shell::GetTargetRootWindow()); |
126 if (ui_controls) | 124 if (ui_controls) |
127 ui_controls->RunClosureAfterAllPendingUIEvents(closure); | 125 ui_controls->RunClosureAfterAllPendingUIEvents(closure); |
128 } | 126 } |
129 | 127 |
130 private: | 128 private: |
131 DISALLOW_COPY_AND_ASSIGN(UIControlsAsh); | 129 DISALLOW_COPY_AND_ASSIGN(UIControlsAsh); |
132 }; | 130 }; |
133 | 131 |
134 ui_controls::UIControlsAura* CreateAshUIControls() { | 132 ui_controls::UIControlsAura* CreateAshUIControls() { |
135 return new ash::test::UIControlsAsh(); | 133 return new ash::test::UIControlsAsh(); |
136 } | 134 } |
137 | 135 |
138 } // namespace test | 136 } // namespace test |
139 } // namespace ash | 137 } // namespace ash |
OLD | NEW |