aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input/cursor.c
diff options
context:
space:
mode:
authorLibravatar emersion <contact@emersion.fr>2018-04-27 17:30:45 +0100
committerLibravatar emersion <contact@emersion.fr>2018-04-27 17:30:45 +0100
commit860d2384b434cd1576d9029f20db62b583895cf4 (patch)
treed7ce3b90e4de67b467decb62592531b5bbd64269 /sway/input/cursor.c
parentMerge pull request #1866 from ggreer/swaybar-cmd-sh (diff)
downloadsway-860d2384b434cd1576d9029f20db62b583895cf4.tar.gz
sway-860d2384b434cd1576d9029f20db62b583895cf4.tar.zst
sway-860d2384b434cd1576d9029f20db62b583895cf4.zip
Update for swaywm/wlroots#923
Diffstat (limited to 'sway/input/cursor.c')
-rw-r--r--sway/input/cursor.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index 944ad8eb..64b95e7d 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -1,4 +1,5 @@
1#define _XOPEN_SOURCE 700 1#define _XOPEN_SOURCE 700
2#include <math.h>
2#ifdef __linux__ 3#ifdef __linux__
3#include <linux/input-event-codes.h> 4#include <linux/input-event-codes.h>
4#elif __FreeBSD__ 5#elif __FreeBSD__
@@ -262,18 +263,11 @@ static void handle_touch_motion(struct wl_listener *listener, void *data) {
262} 263}
263 264
264static double apply_mapping_from_coord(double low, double high, double value) { 265static double apply_mapping_from_coord(double low, double high, double value) {
265 if (value == -1) { 266 if (isnan(value)) {
266 return value; 267 return value;
267 } 268 }
268 269
269 value = (value - low) / (high - low); 270 return (value - low) / (high - low);
270 if (value < 0) {
271 return 0;
272 } else if (value > 1) {
273 return 1;
274 } else {
275 return value;
276 }
277} 271}
278 272
279static void apply_mapping_from_region(struct wlr_input_device *device, 273static void apply_mapping_from_region(struct wlr_input_device *device,
@@ -300,7 +294,7 @@ static void handle_tool_axis(struct wl_listener *listener, void *data) {
300 struct wlr_event_tablet_tool_axis *event = data; 294 struct wlr_event_tablet_tool_axis *event = data;
301 struct sway_input_device *input_device = event->device->data; 295 struct sway_input_device *input_device = event->device->data;
302 296
303 double x = -1, y = -1; 297 double x = NAN, y = NAN;
304 if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_X)) { 298 if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_X)) {
305 x = event->x; 299 x = event->x;
306 } 300 }