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

Side by Side Diff: remoting/client/plugin/pepper_input_handler.cc

Issue 1760633003: Notify normalizing input filters on blur. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix host build. 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 | « remoting/client/plugin/pepper_input_handler.h ('k') | remoting/protocol/input_event_tracker.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 (c) 2012 The Chromium Authors. All rights reserved. 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 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 "remoting/client/plugin/pepper_input_handler.h" 5 #include "remoting/client/plugin/pepper_input_handler.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "ppapi/cpp/image_data.h" 10 #include "ppapi/cpp/image_data.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 mouse_event.set_delta_x(delta.x()); 104 mouse_event.set_delta_x(delta.x());
105 mouse_event.set_delta_y(delta.y()); 105 mouse_event.set_delta_y(delta.y());
106 } 106 }
107 return mouse_event; 107 return mouse_event;
108 } 108 }
109 109
110 } // namespace 110 } // namespace
111 111
112 PepperInputHandler::PepperInputHandler( 112 PepperInputHandler::PepperInputHandler(
113 protocol::InputEventTracker* input_tracker) 113 protocol::InputEventTracker* input_tracker)
114 : input_stub_(nullptr), 114 : input_tracker_(input_tracker),
115 input_tracker_(input_tracker),
116 has_focus_(false), 115 has_focus_(false),
117 send_mouse_input_when_unfocused_(false), 116 send_mouse_input_when_unfocused_(false),
118 send_mouse_move_deltas_(false), 117 send_mouse_move_deltas_(false),
119 wheel_delta_x_(0), 118 wheel_delta_x_(0),
120 wheel_delta_y_(0), 119 wheel_delta_y_(0),
121 wheel_ticks_x_(0), 120 wheel_ticks_x_(0),
122 wheel_ticks_y_(0), 121 wheel_ticks_y_(0),
123 detect_stuck_modifiers_(false) { 122 detect_stuck_modifiers_(false) {
124 } 123 }
125 124
126 bool PepperInputHandler::HandleInputEvent(const pp::InputEvent& event) { 125 bool PepperInputHandler::HandleInputEvent(const pp::InputEvent& event) {
127 if (detect_stuck_modifiers_) 126 if (detect_stuck_modifiers_)
128 ReleaseAllIfModifiersStuck(event); 127 ReleaseAllIfModifiersStuck(event);
129 128
130 switch (event.GetType()) { 129 switch (event.GetType()) {
131 // Touch input cases. 130 // Touch input cases.
132 case PP_INPUTEVENT_TYPE_TOUCHSTART: 131 case PP_INPUTEVENT_TYPE_TOUCHSTART:
133 case PP_INPUTEVENT_TYPE_TOUCHMOVE: 132 case PP_INPUTEVENT_TYPE_TOUCHMOVE:
134 case PP_INPUTEVENT_TYPE_TOUCHEND: 133 case PP_INPUTEVENT_TYPE_TOUCHEND:
135 case PP_INPUTEVENT_TYPE_TOUCHCANCEL: { 134 case PP_INPUTEVENT_TYPE_TOUCHCANCEL: {
136 if (!input_stub_)
137 return true;
138 pp::TouchInputEvent pp_touch_event(event); 135 pp::TouchInputEvent pp_touch_event(event);
139 input_stub_->InjectTouchEvent(MakeTouchEvent(pp_touch_event)); 136 input_tracker_->InjectTouchEvent(MakeTouchEvent(pp_touch_event));
140 return true; 137 return true;
141 } 138 }
142 139
143 case PP_INPUTEVENT_TYPE_CONTEXTMENU: { 140 case PP_INPUTEVENT_TYPE_CONTEXTMENU: {
144 // We need to return true here or else we'll get a local (plugin) context 141 // We need to return true here or else we'll get a local (plugin) context
145 // menu instead of the mouseup event for the right click. 142 // menu instead of the mouseup event for the right click.
146 return true; 143 return true;
147 } 144 }
148 145
149 case PP_INPUTEVENT_TYPE_KEYDOWN: 146 case PP_INPUTEVENT_TYPE_KEYDOWN:
150 case PP_INPUTEVENT_TYPE_KEYUP: { 147 case PP_INPUTEVENT_TYPE_KEYUP: {
151 if (!input_stub_)
152 return true;
153 pp::KeyboardInputEvent pp_key_event(event); 148 pp::KeyboardInputEvent pp_key_event(event);
154 input_stub_->InjectKeyEvent(MakeKeyEvent(pp_key_event)); 149 input_tracker_->InjectKeyEvent(MakeKeyEvent(pp_key_event));
155 return true; 150 return true;
156 } 151 }
157 152
158 case PP_INPUTEVENT_TYPE_MOUSEDOWN: 153 case PP_INPUTEVENT_TYPE_MOUSEDOWN:
159 case PP_INPUTEVENT_TYPE_MOUSEUP: { 154 case PP_INPUTEVENT_TYPE_MOUSEUP: {
160 if (!has_focus_ && !send_mouse_input_when_unfocused_) 155 if (!has_focus_ && !send_mouse_input_when_unfocused_)
161 return false; 156 return false;
162 if (!input_stub_)
163 return true;
164 157
165 pp::MouseInputEvent pp_mouse_event(event); 158 pp::MouseInputEvent pp_mouse_event(event);
166 protocol::MouseEvent mouse_event( 159 protocol::MouseEvent mouse_event(
167 MakeMouseEvent(pp_mouse_event, send_mouse_move_deltas_)); 160 MakeMouseEvent(pp_mouse_event, send_mouse_move_deltas_));
168 switch (pp_mouse_event.GetButton()) { 161 switch (pp_mouse_event.GetButton()) {
169 case PP_INPUTEVENT_MOUSEBUTTON_LEFT: 162 case PP_INPUTEVENT_MOUSEBUTTON_LEFT:
170 mouse_event.set_button(protocol::MouseEvent::BUTTON_LEFT); 163 mouse_event.set_button(protocol::MouseEvent::BUTTON_LEFT);
171 break; 164 break;
172 case PP_INPUTEVENT_MOUSEBUTTON_MIDDLE: 165 case PP_INPUTEVENT_MOUSEBUTTON_MIDDLE:
173 mouse_event.set_button(protocol::MouseEvent::BUTTON_MIDDLE); 166 mouse_event.set_button(protocol::MouseEvent::BUTTON_MIDDLE);
174 break; 167 break;
175 case PP_INPUTEVENT_MOUSEBUTTON_RIGHT: 168 case PP_INPUTEVENT_MOUSEBUTTON_RIGHT:
176 mouse_event.set_button(protocol::MouseEvent::BUTTON_RIGHT); 169 mouse_event.set_button(protocol::MouseEvent::BUTTON_RIGHT);
177 break; 170 break;
178 case PP_INPUTEVENT_MOUSEBUTTON_NONE: 171 case PP_INPUTEVENT_MOUSEBUTTON_NONE:
179 break; 172 break;
180 } 173 }
181 if (mouse_event.has_button()) { 174 if (mouse_event.has_button()) {
182 bool is_down = (event.GetType() == PP_INPUTEVENT_TYPE_MOUSEDOWN); 175 bool is_down = (event.GetType() == PP_INPUTEVENT_TYPE_MOUSEDOWN);
183 mouse_event.set_button_down(is_down); 176 mouse_event.set_button_down(is_down);
184 input_stub_->InjectMouseEvent(mouse_event); 177 input_tracker_->InjectMouseEvent(mouse_event);
185 } 178 }
186 179
187 return true; 180 return true;
188 } 181 }
189 182
190 case PP_INPUTEVENT_TYPE_MOUSEMOVE: 183 case PP_INPUTEVENT_TYPE_MOUSEMOVE:
191 case PP_INPUTEVENT_TYPE_MOUSEENTER: 184 case PP_INPUTEVENT_TYPE_MOUSEENTER:
192 case PP_INPUTEVENT_TYPE_MOUSELEAVE: { 185 case PP_INPUTEVENT_TYPE_MOUSELEAVE: {
193 if (!has_focus_ && !send_mouse_input_when_unfocused_) 186 if (!has_focus_ && !send_mouse_input_when_unfocused_)
194 return false; 187 return false;
195 if (!input_stub_)
196 return true;
197 188
198 pp::MouseInputEvent pp_mouse_event(event); 189 pp::MouseInputEvent pp_mouse_event(event);
199 input_stub_->InjectMouseEvent( 190 input_tracker_->InjectMouseEvent(
200 MakeMouseEvent(pp_mouse_event, send_mouse_move_deltas_)); 191 MakeMouseEvent(pp_mouse_event, send_mouse_move_deltas_));
201 192
202 return true; 193 return true;
203 } 194 }
204 195
205 case PP_INPUTEVENT_TYPE_WHEEL: { 196 case PP_INPUTEVENT_TYPE_WHEEL: {
206 if (!has_focus_ && !send_mouse_input_when_unfocused_) 197 if (!has_focus_ && !send_mouse_input_when_unfocused_)
207 return false; 198 return false;
208 if (!input_stub_)
209 return true;
210 199
211 pp::WheelInputEvent pp_wheel_event(event); 200 pp::WheelInputEvent pp_wheel_event(event);
212 201
213 // Ignore scroll-by-page events, for now. 202 // Ignore scroll-by-page events, for now.
214 if (pp_wheel_event.GetScrollByPage()) 203 if (pp_wheel_event.GetScrollByPage())
215 return true; 204 return true;
216 205
217 // Add this event to our accumulated sub-pixel deltas and clicks. 206 // Add this event to our accumulated sub-pixel deltas and clicks.
218 pp::FloatPoint delta = pp_wheel_event.GetDelta(); 207 pp::FloatPoint delta = pp_wheel_event.GetDelta();
219 wheel_delta_x_ += delta.x(); 208 wheel_delta_x_ += delta.x();
(...skipping 19 matching lines...) Expand all
239 // that can't inject pixel-based scroll events that the client will 228 // that can't inject pixel-based scroll events that the client will
240 // accumulate them into tick-based scrolling, which gives a better 229 // accumulate them into tick-based scrolling, which gives a better
241 // overall experience than trying to do this host-side. 230 // overall experience than trying to do this host-side.
242 int ticks_x = static_cast<int>(wheel_ticks_x_); 231 int ticks_x = static_cast<int>(wheel_ticks_x_);
243 int ticks_y = static_cast<int>(wheel_ticks_y_); 232 int ticks_y = static_cast<int>(wheel_ticks_y_);
244 wheel_ticks_x_ -= ticks_x; 233 wheel_ticks_x_ -= ticks_x;
245 wheel_ticks_y_ -= ticks_y; 234 wheel_ticks_y_ -= ticks_y;
246 mouse_event.set_wheel_ticks_x(ticks_x); 235 mouse_event.set_wheel_ticks_x(ticks_x);
247 mouse_event.set_wheel_ticks_y(ticks_y); 236 mouse_event.set_wheel_ticks_y(ticks_y);
248 237
249 input_stub_->InjectMouseEvent(mouse_event); 238 input_tracker_->InjectMouseEvent(mouse_event);
250 } 239 }
251 return true; 240 return true;
252 } 241 }
253 242
254 case PP_INPUTEVENT_TYPE_CHAR: 243 case PP_INPUTEVENT_TYPE_CHAR:
255 // Consume but ignore character input events. 244 // Consume but ignore character input events.
256 return true; 245 return true;
257 246
258 default: { 247 default: {
259 VLOG(0) << "Unhandled input event: " << event.GetType(); 248 VLOG(0) << "Unhandled input event: " << event.GetType();
(...skipping 27 matching lines...) Expand all
287 input_tracker_->ReleaseAllIfModifiersStuck( 276 input_tracker_->ReleaseAllIfModifiersStuck(
288 (modifiers & PP_INPUTEVENT_MODIFIER_ALTKEY) != 0, 277 (modifiers & PP_INPUTEVENT_MODIFIER_ALTKEY) != 0,
289 (modifiers & PP_INPUTEVENT_MODIFIER_CONTROLKEY) != 0, 278 (modifiers & PP_INPUTEVENT_MODIFIER_CONTROLKEY) != 0,
290 (modifiers & PP_INPUTEVENT_MODIFIER_METAKEY) != 0, 279 (modifiers & PP_INPUTEVENT_MODIFIER_METAKEY) != 0,
291 (modifiers & PP_INPUTEVENT_MODIFIER_SHIFTKEY) != 0); 280 (modifiers & PP_INPUTEVENT_MODIFIER_SHIFTKEY) != 0);
292 } 281 }
293 } 282 }
294 } 283 }
295 284
296 } // namespace remoting 285 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/plugin/pepper_input_handler.h ('k') | remoting/protocol/input_event_tracker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698