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