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

Side by Side Diff: ui/events/ozone/evdev/key_event_converter.cc

Issue 144233006: evdev: Fix infinite loop when devices are unplugged (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: dropped EventConverterEvdev Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | ui/events/ozone/evdev/touch_event_converter.cc » ('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 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 "ui/events/ozone/evdev/key_event_converter.h" 5 #include "ui/events/ozone/evdev/key_event_converter.h"
6 6
7 #include <errno.h>
7 #include <linux/input.h> 8 #include <linux/input.h>
8 9
9 #include "base/message_loop/message_pump_ozone.h" 10 #include "base/message_loop/message_pump_ozone.h"
10 #include "ui/events/event.h" 11 #include "ui/events/event.h"
11 #include "ui/events/keycodes/keyboard_codes.h" 12 #include "ui/events/keycodes/keyboard_codes.h"
12 #include "ui/events/ozone/evdev/event_modifiers.h" 13 #include "ui/events/ozone/evdev/event_modifiers.h"
13 14
14 namespace ui { 15 namespace ui {
15 16
16 namespace { 17 namespace {
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 fd_, true, base::MessagePumpLibevent::WATCH_READ, &controller_, this); 204 fd_, true, base::MessagePumpLibevent::WATCH_READ, &controller_, this);
204 } 205 }
205 206
206 void KeyEventConverterEvdev::Stop() { 207 void KeyEventConverterEvdev::Stop() {
207 controller_.StopWatchingFileDescriptor(); 208 controller_.StopWatchingFileDescriptor();
208 } 209 }
209 210
210 void KeyEventConverterEvdev::OnFileCanReadWithoutBlocking(int fd) { 211 void KeyEventConverterEvdev::OnFileCanReadWithoutBlocking(int fd) {
211 input_event inputs[4]; 212 input_event inputs[4];
212 ssize_t read_size = read(fd, inputs, sizeof(inputs)); 213 ssize_t read_size = read(fd, inputs, sizeof(inputs));
213 if (read_size <= 0) 214 if (read_size < 0) {
215 if (errno == EINTR || errno == EAGAIN)
216 return;
217 PLOG(ERROR) << "error reading device " << path_.value();
218 Stop();
214 return; 219 return;
220 }
215 221
216 CHECK_EQ(read_size % sizeof(*inputs), 0u); 222 CHECK_EQ(read_size % sizeof(*inputs), 0u);
217 ProcessEvents(inputs, read_size / sizeof(*inputs)); 223 ProcessEvents(inputs, read_size / sizeof(*inputs));
218 } 224 }
219 225
220 void KeyEventConverterEvdev::OnFileCanWriteWithoutBlocking(int fd) { 226 void KeyEventConverterEvdev::OnFileCanWriteWithoutBlocking(int fd) {
221 NOTREACHED(); 227 NOTREACHED();
222 } 228 }
223 229
224 void KeyEventConverterEvdev::ProcessEvents(const input_event* inputs, 230 void KeyEventConverterEvdev::ProcessEvents(const input_event* inputs,
(...skipping 25 matching lines...) Expand all
250 } 256 }
251 257
252 int flags = modifiers_->GetModifierFlags(); 258 int flags = modifiers_->GetModifierFlags();
253 259
254 scoped_ptr<KeyEvent> key_event( 260 scoped_ptr<KeyEvent> key_event(
255 new KeyEvent(down ? ET_KEY_PRESSED : ET_KEY_RELEASED, code, flags, true)); 261 new KeyEvent(down ? ET_KEY_PRESSED : ET_KEY_RELEASED, code, flags, true));
256 DispatchEvent(key_event.PassAs<ui::Event>()); 262 DispatchEvent(key_event.PassAs<ui::Event>());
257 } 263 }
258 264
259 } // namespace ui 265 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | ui/events/ozone/evdev/touch_event_converter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698