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