OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/logging.h" | 5 #include "base/logging.h" |
6 #include "base/basictypes.h" | 6 #include "base/basictypes.h" |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "ui/aura/root_window.h" | 8 #include "ui/aura/root_window.h" |
9 #include "ui/aura/ui_controls_aura.h" | 9 #include "ui/aura/ui_controls_aura.h" |
10 #include "ui/ui_controls/ui_controls_aura.h" | 10 #include "ui/ui_controls/ui_controls_aura.h" |
11 #include "ui/ui_controls/ui_controls_internal_win.h" | 11 #include "ui/ui_controls/ui_controls_internal_win.h" |
12 | 12 |
13 namespace aura { | 13 namespace aura { |
14 namespace { | 14 namespace { |
15 class UIControlsWin : public ui_controls::UIControlsAura { | 15 class UIControlsWin : public ui_controls::UIControlsAura { |
16 public: | 16 public: |
17 UIControlsWin(RootWindow* root_window) : root_window_(root_window) { | 17 UIControlsWin() {} |
18 } | |
19 | 18 |
20 // UIControlsAura overrides: | 19 // UIControlsAura overrides: |
21 virtual bool SendKeyPress(gfx::NativeWindow native_window, | 20 virtual bool SendKeyPress(gfx::NativeWindow native_window, |
22 ui::KeyboardCode key, | 21 ui::KeyboardCode key, |
23 bool control, | 22 bool control, |
24 bool shift, | 23 bool shift, |
25 bool alt, | 24 bool alt, |
26 bool command) { | 25 bool command) { |
27 DCHECK(!command); // No command key on Aura | 26 DCHECK(!command); // No command key on Aura |
28 HWND window = native_window->GetRootWindow()->GetAcceleratedWidget(); | 27 HWND window = native_window->GetRootWindow()->GetAcceleratedWidget(); |
29 return ui_controls::internal::SendKeyPressImpl( | 28 return ui_controls::internal::SendKeyPressImpl( |
30 window, key, control, shift, alt, base::Closure()); | 29 window, key, control, shift, alt, base::Closure()); |
31 } | 30 } |
32 virtual bool SendKeyPressNotifyWhenDone(gfx::NativeWindow native_window, | 31 virtual bool SendKeyPressNotifyWhenDone(gfx::NativeWindow native_window, |
33 ui::KeyboardCode key, | 32 ui::KeyboardCode key, |
34 bool control, | 33 bool control, |
35 bool shift, | 34 bool shift, |
36 bool alt, | 35 bool alt, |
37 bool command, | 36 bool command, |
38 const base::Closure& task) { | 37 const base::Closure& task) { |
39 DCHECK(!command); // No command key on Aura | 38 DCHECK(!command); // No command key on Aura |
40 HWND window = native_window->GetRootWindow()->GetAcceleratedWidget(); | 39 HWND window = native_window->GetRootWindow()->GetAcceleratedWidget(); |
41 return ui_controls::internal::SendKeyPressImpl( | 40 return ui_controls::internal::SendKeyPressImpl( |
42 window, key, control, shift, alt, task); | 41 window, key, control, shift, alt, task); |
43 } | 42 } |
44 virtual bool SendMouseMove(long x, long y) { | 43 virtual bool SendMouseMove(long x, long y) { |
45 gfx::Point point(x, y); | 44 gfx::Point point(x, y); |
46 root_window_->ConvertPointToNativeScreen(&point); | |
47 return ui_controls::internal::SendMouseMoveImpl( | 45 return ui_controls::internal::SendMouseMoveImpl( |
48 point.x(), point.y(), base::Closure()); | 46 point.x(), point.y(), base::Closure()); |
49 } | 47 } |
50 virtual bool SendMouseMoveNotifyWhenDone(long x, | 48 virtual bool SendMouseMoveNotifyWhenDone(long x, |
51 long y, | 49 long y, |
52 const base::Closure& task) { | 50 const base::Closure& task) { |
53 gfx::Point point(x, y); | 51 gfx::Point point(x, y); |
54 root_window_->ConvertPointToNativeScreen(&point); | |
55 return ui_controls::internal::SendMouseMoveImpl(point.x(), point.y(), task); | 52 return ui_controls::internal::SendMouseMoveImpl(point.x(), point.y(), task); |
56 } | 53 } |
57 virtual bool SendMouseEvents(ui_controls::MouseButton type, int state) { | 54 virtual bool SendMouseEvents(ui_controls::MouseButton type, int state) { |
58 return ui_controls::internal::SendMouseEventsImpl( | 55 return ui_controls::internal::SendMouseEventsImpl( |
59 type, state, base::Closure()); | 56 type, state, base::Closure()); |
60 } | 57 } |
61 virtual bool SendMouseEventsNotifyWhenDone(ui_controls::MouseButton type, | 58 virtual bool SendMouseEventsNotifyWhenDone(ui_controls::MouseButton type, |
62 int state, | 59 int state, |
63 const base::Closure& task) { | 60 const base::Closure& task) { |
64 return ui_controls::internal::SendMouseEventsImpl(type, state, task); | 61 return ui_controls::internal::SendMouseEventsImpl(type, state, task); |
65 } | 62 } |
66 virtual bool SendMouseClick(ui_controls::MouseButton type) { | 63 virtual bool SendMouseClick(ui_controls::MouseButton type) { |
67 return SendMouseEvents(type, ui_controls::UP | ui_controls::DOWN); | 64 return SendMouseEvents(type, ui_controls::UP | ui_controls::DOWN); |
68 } | 65 } |
69 virtual void RunClosureAfterAllPendingUIEvents(const base::Closure& closure) { | 66 virtual void RunClosureAfterAllPendingUIEvents(const base::Closure& closure) { |
70 // On windows, posting UI events is synchronous so just post the closure. | 67 // On windows, posting UI events is synchronous so just post the closure. |
71 MessageLoopForUI::current()->PostTask(FROM_HERE, closure); | 68 MessageLoopForUI::current()->PostTask(FROM_HERE, closure); |
72 } | 69 } |
73 | 70 |
74 private: | 71 private: |
75 RootWindow* root_window_; | |
76 DISALLOW_COPY_AND_ASSIGN(UIControlsWin); | 72 DISALLOW_COPY_AND_ASSIGN(UIControlsWin); |
77 }; | 73 }; |
78 | 74 |
79 } // namespace | 75 } // namespace |
80 | 76 |
81 ui_controls::UIControlsAura* CreateUIControlsAura(RootWindow* root_window) { | 77 ui_controls::UIControlsAura* CreateUIControlsAura(RootWindow* root_window) { |
82 return new UIControlsWin(root_window); | 78 return new UIControlsWin(); |
83 } | 79 } |
84 | 80 |
85 } // namespace aura | 81 } // namespace aura |
OLD | NEW |