OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/touch_event_converter_evdev.h" | 5 #include "ui/events/ozone/evdev/touch_event_converter_evdev.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <linux/input.h> | 9 #include <linux/input.h> |
10 #include <poll.h> | 10 #include <poll.h> |
11 #include <stdio.h> | 11 #include <stdio.h> |
12 #include <unistd.h> | 12 #include <unistd.h> |
13 | 13 |
14 #include <cmath> | 14 #include <cmath> |
15 #include <limits> | 15 #include <limits> |
16 | 16 |
17 #include "base/bind.h" | 17 #include "base/bind.h" |
18 #include "base/callback.h" | 18 #include "base/callback.h" |
19 #include "base/logging.h" | 19 #include "base/logging.h" |
20 #include "base/memory/scoped_vector.h" | 20 #include "base/memory/scoped_vector.h" |
21 #include "base/message_loop/message_pump_ozone.h" | 21 #include "base/message_loop/message_loop.h" |
22 #include "ui/events/event.h" | 22 #include "ui/events/event.h" |
23 #include "ui/events/event_constants.h" | 23 #include "ui/events/event_constants.h" |
24 #include "ui/events/ozone/event_factory_ozone.h" | 24 #include "ui/events/ozone/event_factory_ozone.h" |
25 #include "ui/gfx/screen.h" | 25 #include "ui/gfx/screen.h" |
26 | 26 |
27 namespace { | 27 namespace { |
28 | 28 |
29 // Number is determined empirically. | 29 // Number is determined empirically. |
30 // TODO(rjkroege): Configure this per device. | 30 // TODO(rjkroege): Configure this per device. |
31 const float kFingerWidth = 25.f; | 31 const float kFingerWidth = 25.f; |
(...skipping 30 matching lines...) Expand all Loading... |
62 return; // No scaling. | 62 return; // No scaling. |
63 gfx::Display display = screen->GetPrimaryDisplay(); | 63 gfx::Display display = screen->GetPrimaryDisplay(); |
64 gfx::Size size = display.GetSizeInPixel(); | 64 gfx::Size size = display.GetSizeInPixel(); |
65 | 65 |
66 x_scale_ = (double)size.width() / (x_max_ - x_min_); | 66 x_scale_ = (double)size.width() / (x_max_ - x_min_); |
67 y_scale_ = (double)size.height() / (y_max_ - y_min_); | 67 y_scale_ = (double)size.height() / (y_max_ - y_min_); |
68 VLOG(1) << "touch scaling x_scale=" << x_scale_ << " y_scale=" << y_scale_; | 68 VLOG(1) << "touch scaling x_scale=" << x_scale_ << " y_scale=" << y_scale_; |
69 } | 69 } |
70 | 70 |
71 void TouchEventConverterEvdev::Start() { | 71 void TouchEventConverterEvdev::Start() { |
72 base::MessagePumpOzone::Current()->WatchFileDescriptor( | 72 base::MessageLoopForUI::current()->WatchFileDescriptor( |
73 fd_, true, base::MessagePumpLibevent::WATCH_READ, &controller_, this); | 73 fd_, true, base::MessagePumpLibevent::WATCH_READ, &controller_, this); |
74 } | 74 } |
75 | 75 |
76 void TouchEventConverterEvdev::Stop() { | 76 void TouchEventConverterEvdev::Stop() { |
77 controller_.StopWatchingFileDescriptor(); | 77 controller_.StopWatchingFileDescriptor(); |
78 } | 78 } |
79 | 79 |
80 void TouchEventConverterEvdev::OnFileCanWriteWithoutBlocking(int /* fd */) { | 80 void TouchEventConverterEvdev::OnFileCanWriteWithoutBlocking(int /* fd */) { |
81 // Read-only file-descriptors. | 81 // Read-only file-descriptors. |
82 NOTREACHED(); | 82 NOTREACHED(); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 NOTIMPLEMENTED() << "invalid type: " << input.type; | 178 NOTIMPLEMENTED() << "invalid type: " << input.type; |
179 } | 179 } |
180 } | 180 } |
181 for (ScopedVector<ui::TouchEvent>::iterator iter = touch_events.begin(); | 181 for (ScopedVector<ui::TouchEvent>::iterator iter = touch_events.begin(); |
182 iter != touch_events.end(); ++iter) { | 182 iter != touch_events.end(); ++iter) { |
183 DispatchEventToCallback(*iter); | 183 DispatchEventToCallback(*iter); |
184 } | 184 } |
185 } | 185 } |
186 | 186 |
187 } // namespace ui | 187 } // namespace ui |
OLD | NEW |