| 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/sticky_keys/sticky_keys_controller.h" | 5 #include "ash/sticky_keys/sticky_keys_controller.h" |
| 6 | 6 |
| 7 #if defined(USE_X11) | 7 #if defined(USE_X11) |
| 8 #include <X11/extensions/XInput2.h> | 8 #include <X11/extensions/XInput2.h> |
| 9 #include <X11/Xlib.h> | 9 #include <X11/Xlib.h> |
| 10 #undef RootWindow | 10 #undef RootWindow |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 // StickyKeysHandlerDelegate overrides. | 40 // StickyKeysHandlerDelegate overrides. |
| 41 virtual void DispatchKeyEvent(ui::KeyEvent* event, | 41 virtual void DispatchKeyEvent(ui::KeyEvent* event, |
| 42 aura::Window* target) OVERRIDE; | 42 aura::Window* target) OVERRIDE; |
| 43 | 43 |
| 44 virtual void DispatchMouseEvent(ui::MouseEvent* event, | 44 virtual void DispatchMouseEvent(ui::MouseEvent* event, |
| 45 aura::Window* target) OVERRIDE; | 45 aura::Window* target) OVERRIDE; |
| 46 | 46 |
| 47 virtual void DispatchScrollEvent(ui::ScrollEvent* event, | 47 virtual void DispatchScrollEvent(ui::ScrollEvent* event, |
| 48 aura::Window* target) OVERRIDE; | 48 aura::Window* target) OVERRIDE; |
| 49 private: | 49 private: |
| 50 void DispatchEvent(ui::Event* event, aura::Window* target); |
| 51 |
| 50 DISALLOW_COPY_AND_ASSIGN(StickyKeysHandlerDelegateImpl); | 52 DISALLOW_COPY_AND_ASSIGN(StickyKeysHandlerDelegateImpl); |
| 51 }; | 53 }; |
| 52 | 54 |
| 53 StickyKeysHandlerDelegateImpl::StickyKeysHandlerDelegateImpl() { | 55 StickyKeysHandlerDelegateImpl::StickyKeysHandlerDelegateImpl() { |
| 54 } | 56 } |
| 55 | 57 |
| 56 StickyKeysHandlerDelegateImpl::~StickyKeysHandlerDelegateImpl() { | 58 StickyKeysHandlerDelegateImpl::~StickyKeysHandlerDelegateImpl() { |
| 57 } | 59 } |
| 58 | 60 |
| 59 void StickyKeysHandlerDelegateImpl::DispatchKeyEvent(ui::KeyEvent* event, | 61 void StickyKeysHandlerDelegateImpl::DispatchKeyEvent(ui::KeyEvent* event, |
| 60 aura::Window* target) { | 62 aura::Window* target) { |
| 61 DCHECK(target); | 63 DispatchEvent(event, target); |
| 62 target->GetDispatcher()->AsWindowTreeHostDelegate()->OnHostKeyEvent(event); | |
| 63 } | 64 } |
| 64 | 65 |
| 65 void StickyKeysHandlerDelegateImpl::DispatchMouseEvent(ui::MouseEvent* event, | 66 void StickyKeysHandlerDelegateImpl::DispatchMouseEvent(ui::MouseEvent* event, |
| 66 aura::Window* target) { | 67 aura::Window* target) { |
| 67 DCHECK(target); | 68 DCHECK(target); |
| 68 // We need to send a new, untransformed mouse event to the host. | 69 // We need to send a new, untransformed mouse event to the host. |
| 69 if (event->IsMouseWheelEvent()) { | 70 if (event->IsMouseWheelEvent()) { |
| 70 ui::MouseWheelEvent new_event(*static_cast<ui::MouseWheelEvent*>(event)); | 71 ui::MouseWheelEvent new_event(*static_cast<ui::MouseWheelEvent*>(event)); |
| 71 target->GetDispatcher()->AsWindowTreeHostDelegate() | 72 DispatchEvent(&new_event, target); |
| 72 ->OnHostMouseEvent(&new_event); | |
| 73 } else { | 73 } else { |
| 74 ui::MouseEvent new_event(*event, target, target->GetRootWindow()); | 74 ui::MouseEvent new_event(*event, target, target->GetRootWindow()); |
| 75 target->GetDispatcher()->AsWindowTreeHostDelegate() | 75 DispatchEvent(&new_event, target); |
| 76 ->OnHostMouseEvent(&new_event); | |
| 77 } | 76 } |
| 78 } | 77 } |
| 79 | 78 |
| 80 void StickyKeysHandlerDelegateImpl::DispatchScrollEvent( | 79 void StickyKeysHandlerDelegateImpl::DispatchScrollEvent( |
| 81 ui::ScrollEvent* event, | 80 ui::ScrollEvent* event, |
| 82 aura::Window* target) { | 81 aura::Window* target) { |
| 82 DispatchEvent(event, target); |
| 83 } |
| 84 |
| 85 void StickyKeysHandlerDelegateImpl::DispatchEvent(ui::Event* event, |
| 86 aura::Window* target) { |
| 83 DCHECK(target); | 87 DCHECK(target); |
| 84 target->GetDispatcher()->AsWindowTreeHostDelegate() | 88 ui::EventDispatchDetails details = |
| 85 ->OnHostScrollEvent(event); | 89 target->GetDispatcher()->OnEventFromSource(event); |
| 90 if (details.dispatcher_destroyed) |
| 91 return; |
| 86 } | 92 } |
| 87 | 93 |
| 88 } // namespace | 94 } // namespace |
| 89 | 95 |
| 90 /////////////////////////////////////////////////////////////////////////////// | 96 /////////////////////////////////////////////////////////////////////////////// |
| 91 // StickyKeys | 97 // StickyKeys |
| 92 StickyKeysController::StickyKeysController() | 98 StickyKeysController::StickyKeysController() |
| 93 : enabled_(false) { | 99 : enabled_(false) { |
| 94 } | 100 } |
| 95 | 101 |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 &xievent->mods.effective)); | 472 &xievent->mods.effective)); |
| 467 } | 473 } |
| 468 } | 474 } |
| 469 #elif defined(USE_OZONE) | 475 #elif defined(USE_OZONE) |
| 470 NOTIMPLEMENTED() << "Modifier key is not handled"; | 476 NOTIMPLEMENTED() << "Modifier key is not handled"; |
| 471 #endif | 477 #endif |
| 472 event->set_flags(event->flags() | modifier_flag_); | 478 event->set_flags(event->flags() | modifier_flag_); |
| 473 } | 479 } |
| 474 | 480 |
| 475 } // namespace ash | 481 } // namespace ash |
| OLD | NEW |