OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/exo/touch.h" | 5 #include "components/exo/touch.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "components/exo/surface.h" | 8 #include "components/exo/surface.h" |
9 #include "components/exo/touch_delegate.h" | 9 #include "components/exo/touch_delegate.h" |
10 #include "ui/aura/window.h" | 10 #include "ui/aura/window.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 delegate_->OnTouchDestroying(this); | 39 delegate_->OnTouchDestroying(this); |
40 if (focus_) | 40 if (focus_) |
41 focus_->RemoveSurfaceObserver(this); | 41 focus_->RemoveSurfaceObserver(this); |
42 ash::Shell::GetInstance()->RemovePreTargetHandler(this); | 42 ash::Shell::GetInstance()->RemovePreTargetHandler(this); |
43 } | 43 } |
44 | 44 |
45 //////////////////////////////////////////////////////////////////////////////// | 45 //////////////////////////////////////////////////////////////////////////////// |
46 // ui::EventHandler overrides: | 46 // ui::EventHandler overrides: |
47 | 47 |
48 void Touch::OnTouchEvent(ui::TouchEvent* event) { | 48 void Touch::OnTouchEvent(ui::TouchEvent* event) { |
| 49 if (!ash::Shell::GetInstance()->CanWindowReceiveEvents( |
| 50 (aura::Window*)event->target())) { |
| 51 event->StopPropagation(); |
| 52 return; |
| 53 } |
| 54 |
49 switch (event->type()) { | 55 switch (event->type()) { |
50 case ui::ET_TOUCH_PRESSED: { | 56 case ui::ET_TOUCH_PRESSED: { |
51 // Early out if event doesn't contain a valid target for touch device. | 57 // Early out if event doesn't contain a valid target for touch device. |
52 Surface* target = GetEffectiveTargetForEvent(event); | 58 Surface* target = GetEffectiveTargetForEvent(event); |
53 if (!target) | 59 if (!target) |
54 return; | 60 return; |
55 | 61 |
56 // If this is the first touch point then target becomes the focus surface | 62 // If this is the first touch point then target becomes the focus surface |
57 // until all touch points have been released. | 63 // until all touch points have been released. |
58 if (touch_points_.empty()) { | 64 if (touch_points_.empty()) { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 Surface* Touch::GetEffectiveTargetForEvent(ui::Event* event) const { | 148 Surface* Touch::GetEffectiveTargetForEvent(ui::Event* event) const { |
143 Surface* target = | 149 Surface* target = |
144 Surface::AsSurface(static_cast<aura::Window*>(event->target())); | 150 Surface::AsSurface(static_cast<aura::Window*>(event->target())); |
145 if (!target) | 151 if (!target) |
146 return nullptr; | 152 return nullptr; |
147 | 153 |
148 return delegate_->CanAcceptTouchEventsForSurface(target) ? target : nullptr; | 154 return delegate_->CanAcceptTouchEventsForSurface(target) ? target : nullptr; |
149 } | 155 } |
150 | 156 |
151 } // namespace exo | 157 } // namespace exo |
OLD | NEW |