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/tablet_event_converter_evdev.h" | 5 #include "ui/events/ozone/evdev/tablet_event_converter_evdev.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <linux/input.h> | 8 #include <linux/input.h> |
9 | 9 |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 abs_value_dirty_ = true; | 99 abs_value_dirty_ = true; |
100 break; | 100 break; |
101 case ABS_Y: | 101 case ABS_Y: |
102 y_abs_location_ = input.value; | 102 y_abs_location_ = input.value; |
103 abs_value_dirty_ = true; | 103 abs_value_dirty_ = true; |
104 break; | 104 break; |
105 } | 105 } |
106 } | 106 } |
107 | 107 |
108 void TabletEventConverterEvdev::UpdateCursor() { | 108 void TabletEventConverterEvdev::UpdateCursor() { |
109 int width = cursor_->GetCursorDisplayBounds().width(); | 109 gfx::Rect display_bounds = cursor_->GetCursorDisplayBounds(); |
110 int height = cursor_->GetCursorDisplayBounds().height(); | 110 |
111 int x = ((x_abs_location_ - x_abs_min_) * width) / x_abs_range_; | 111 int x = |
112 int y = ((y_abs_location_ - y_abs_min_) * height) / y_abs_range_; | 112 ((x_abs_location_ - x_abs_min_) * display_bounds.width()) / x_abs_range_; |
| 113 int y = |
| 114 ((y_abs_location_ - y_abs_min_) * display_bounds.height()) / y_abs_range_; |
| 115 |
| 116 x += display_bounds.x(); |
| 117 y += display_bounds.y(); |
113 | 118 |
114 cursor_->MoveCursorTo(gfx::PointF(x, y)); | 119 cursor_->MoveCursorTo(gfx::PointF(x, y)); |
115 } | 120 } |
116 | 121 |
117 void TabletEventConverterEvdev::DispatchMouseButton(const input_event& input) { | 122 void TabletEventConverterEvdev::DispatchMouseButton(const input_event& input) { |
118 if (!cursor_) | 123 if (!cursor_) |
119 return; | 124 return; |
120 | 125 |
121 unsigned int modifier; | 126 unsigned int modifier; |
122 // These are the same as X11 behaviour | 127 // These are the same as X11 behaviour |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 | 163 |
159 callback_.Run(make_scoped_ptr( | 164 callback_.Run(make_scoped_ptr( |
160 new MouseEvent(ui::ET_MOUSE_MOVED, cursor_->location(), | 165 new MouseEvent(ui::ET_MOUSE_MOVED, cursor_->location(), |
161 cursor_->location(), modifiers_->GetModifierFlags(), | 166 cursor_->location(), modifiers_->GetModifierFlags(), |
162 /* changed_button_flags */ 0))); | 167 /* changed_button_flags */ 0))); |
163 | 168 |
164 abs_value_dirty_ = false; | 169 abs_value_dirty_ = false; |
165 } | 170 } |
166 | 171 |
167 } // namespace ui | 172 } // namespace ui |
OLD | NEW |