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/pointer.h" | 5 #include "components/exo/pointer.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "components/exo/pointer_delegate.h" | 8 #include "components/exo/pointer_delegate.h" |
9 #include "components/exo/surface.h" | 9 #include "components/exo/surface.h" |
10 #include "ui/aura/window.h" | 10 #include "ui/aura/window.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 // generate enter and leave events. | 37 // generate enter and leave events. |
38 if (target != focus_) { | 38 if (target != focus_) { |
39 // First generate a leave event if we currently have a target in focus. | 39 // First generate a leave event if we currently have a target in focus. |
40 if (focus_) { | 40 if (focus_) { |
41 delegate_->OnPointerLeave(focus_); | 41 delegate_->OnPointerLeave(focus_); |
42 focus_->RemoveSurfaceObserver(this); | 42 focus_->RemoveSurfaceObserver(this); |
43 focus_ = nullptr; | 43 focus_ = nullptr; |
44 } | 44 } |
45 // Second generate an enter event if focus moved to a new target. | 45 // Second generate an enter event if focus moved to a new target. |
46 if (target) { | 46 if (target) { |
47 int button_flags = | 47 delegate_->OnPointerEnter(target, event->location(), |
48 event->flags() & | 48 event->button_flags()); |
49 (ui::EF_LEFT_MOUSE_BUTTON | ui::EF_MIDDLE_MOUSE_BUTTON | | |
50 ui::EF_RIGHT_MOUSE_BUTTON | ui::EF_BACK_MOUSE_BUTTON | | |
51 ui::EF_FORWARD_MOUSE_BUTTON); | |
52 delegate_->OnPointerEnter(target, event->location(), button_flags); | |
53 location_ = event->location(); | 49 location_ = event->location(); |
54 focus_ = target; | 50 focus_ = target; |
55 focus_->AddSurfaceObserver(this); | 51 focus_->AddSurfaceObserver(this); |
56 } | 52 } |
57 } | 53 } |
58 switch (event->type()) { | 54 switch (event->type()) { |
59 case ui::ET_MOUSE_PRESSED: | 55 case ui::ET_MOUSE_PRESSED: |
60 case ui::ET_MOUSE_RELEASED: | 56 case ui::ET_MOUSE_RELEASED: |
61 if (focus_) { | 57 if (focus_) { |
62 delegate_->OnPointerButton(event->time_stamp(), | 58 delegate_->OnPointerButton(event->time_stamp(), |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 Surface* Pointer::GetEffectiveTargetForEvent(ui::Event* event) const { | 103 Surface* Pointer::GetEffectiveTargetForEvent(ui::Event* event) const { |
108 Surface* target = | 104 Surface* target = |
109 Surface::AsSurface(static_cast<aura::Window*>(event->target())); | 105 Surface::AsSurface(static_cast<aura::Window*>(event->target())); |
110 if (!target) | 106 if (!target) |
111 return nullptr; | 107 return nullptr; |
112 | 108 |
113 return delegate_->CanAcceptPointerEventsForSurface(target) ? target : nullptr; | 109 return delegate_->CanAcceptPointerEventsForSurface(target) ? target : nullptr; |
114 } | 110 } |
115 | 111 |
116 } // namespace exo | 112 } // namespace exo |
OLD | NEW |