Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(281)

Side by Side Diff: components/exo/pointer.cc

Issue 1750633002: components/exo: Extend pointer to use v5 protocol (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed nits Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | components/exo/pointer_delegate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "ash/shell_window_ids.h" 8 #include "ash/shell_window_ids.h"
9 #include "components/exo/pointer_delegate.h" 9 #include "components/exo/pointer_delegate.h"
10 #include "components/exo/surface.h" 10 #include "components/exo/surface.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 focus_ = nullptr; 85 focus_ = nullptr;
86 } 86 }
87 // Second generate an enter event if focus moved to a new target. 87 // Second generate an enter event if focus moved to a new target.
88 if (target) { 88 if (target) {
89 delegate_->OnPointerEnter(target, event->location(), 89 delegate_->OnPointerEnter(target, event->location(),
90 event->button_flags()); 90 event->button_flags());
91 location_ = event->location(); 91 location_ = event->location();
92 focus_ = target; 92 focus_ = target;
93 focus_->AddSurfaceObserver(this); 93 focus_->AddSurfaceObserver(this);
94 } 94 }
95 delegate_->OnPointerFrame();
95 } 96 }
96 97
97 switch (event->type()) { 98 switch (event->type()) {
98 case ui::ET_MOUSE_PRESSED: 99 case ui::ET_MOUSE_PRESSED:
99 case ui::ET_MOUSE_RELEASED: 100 case ui::ET_MOUSE_RELEASED:
100 if (focus_) { 101 if (focus_) {
101 delegate_->OnPointerButton(event->time_stamp(), 102 delegate_->OnPointerButton(event->time_stamp(),
102 event->changed_button_flags(), 103 event->changed_button_flags(),
103 event->type() == ui::ET_MOUSE_PRESSED); 104 event->type() == ui::ET_MOUSE_PRESSED);
105 delegate_->OnPointerFrame();
104 } 106 }
105 break; 107 break;
106 case ui::ET_MOUSE_MOVED: 108 case ui::ET_MOUSE_MOVED:
107 case ui::ET_MOUSE_DRAGGED: 109 case ui::ET_MOUSE_DRAGGED:
108 // Generate motion event if location changed. We need to check location 110 // Generate motion event if location changed. We need to check location
109 // here as mouse movement can generate both "moved" and "entered" events 111 // here as mouse movement can generate both "moved" and "entered" events
110 // but OnPointerMotion should only be called if location changed since 112 // but OnPointerMotion should only be called if location changed since
111 // OnPointerEnter was called. 113 // OnPointerEnter was called.
112 if (focus_ && event->location() != location_) { 114 if (focus_ && event->location() != location_) {
113 delegate_->OnPointerMotion(event->time_stamp(), event->location()); 115 delegate_->OnPointerMotion(event->time_stamp(), event->location());
116 delegate_->OnPointerFrame();
114 location_ = event->location(); 117 location_ = event->location();
115 } 118 }
116 break; 119 break;
117 case ui::ET_SCROLL: 120 case ui::ET_SCROLL:
118 if (focus_) { 121 if (focus_) {
119 ui::ScrollEvent* scroll_event = static_cast<ui::ScrollEvent*>(event); 122 ui::ScrollEvent* scroll_event = static_cast<ui::ScrollEvent*>(event);
120 delegate_->OnPointerWheel( 123 delegate_->OnPointerScroll(
121 event->time_stamp(), 124 event->time_stamp(),
122 gfx::Vector2d(scroll_event->x_offset(), scroll_event->y_offset())); 125 gfx::Vector2dF(scroll_event->x_offset(), scroll_event->y_offset()),
126 false);
127 delegate_->OnPointerFrame();
123 } 128 }
124 break; 129 break;
125 case ui::ET_MOUSEWHEEL: 130 case ui::ET_MOUSEWHEEL:
126 if (focus_) { 131 if (focus_) {
127 delegate_->OnPointerWheel( 132 delegate_->OnPointerScroll(
128 event->time_stamp(), 133 event->time_stamp(),
129 static_cast<ui::MouseWheelEvent*>(event)->offset()); 134 static_cast<ui::MouseWheelEvent*>(event)->offset(), true);
135 delegate_->OnPointerFrame();
136 }
137 break;
138 case ui::ET_SCROLL_FLING_START:
139 if (focus_) {
140 delegate_->OnPointerScrollStop(event->time_stamp());
141 delegate_->OnPointerFrame();
142 }
143 break;
144 case ui::ET_SCROLL_FLING_CANCEL:
145 if (focus_) {
146 delegate_->OnPointerScrollCancel(event->time_stamp());
147 delegate_->OnPointerFrame();
130 } 148 }
131 break; 149 break;
132 case ui::ET_MOUSE_ENTERED: 150 case ui::ET_MOUSE_ENTERED:
133 case ui::ET_MOUSE_EXITED: 151 case ui::ET_MOUSE_EXITED:
134 case ui::ET_MOUSE_CAPTURE_CHANGED: 152 case ui::ET_MOUSE_CAPTURE_CHANGED:
135 case ui::ET_SCROLL_FLING_START:
136 case ui::ET_SCROLL_FLING_CANCEL:
137 break; 153 break;
138 default: 154 default:
139 NOTREACHED(); 155 NOTREACHED();
140 break; 156 break;
141 } 157 }
142 158
143 // Update cursor widget to reflect current focus and pointer location. 159 // Update cursor widget to reflect current focus and pointer location.
144 if (focus_) { 160 if (focus_) {
145 if (!widget_) 161 if (!widget_)
146 CreatePointerWidget(); 162 CreatePointerWidget();
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 Surface* Pointer::GetEffectiveTargetForEvent(ui::Event* event) const { 225 Surface* Pointer::GetEffectiveTargetForEvent(ui::Event* event) const {
210 Surface* target = 226 Surface* target =
211 Surface::AsSurface(static_cast<aura::Window*>(event->target())); 227 Surface::AsSurface(static_cast<aura::Window*>(event->target()));
212 if (!target) 228 if (!target)
213 return nullptr; 229 return nullptr;
214 230
215 return delegate_->CanAcceptPointerEventsForSurface(target) ? target : nullptr; 231 return delegate_->CanAcceptPointerEventsForSurface(target) ? target : nullptr;
216 } 232 }
217 233
218 } // namespace exo 234 } // namespace exo
OLDNEW
« no previous file with comments | « no previous file | components/exo/pointer_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698