aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <RedSoxFan@users.noreply.github.com>2018-11-18 14:05:03 -0500
committerLibravatar GitHub <noreply@github.com>2018-11-18 14:05:03 -0500
commitb2c5248ad36a7a5cf342aa44a21a0956c025c43f (patch)
tree265d4ea923f1329d1e7661c0f92a242337318d58 /common
parentMerge pull request #3147 from emersion/set10 (diff)
parentAdd scroll factor config option. (diff)
downloadsway-b2c5248ad36a7a5cf342aa44a21a0956c025c43f.tar.gz
sway-b2c5248ad36a7a5cf342aa44a21a0956c025c43f.tar.zst
sway-b2c5248ad36a7a5cf342aa44a21a0956c025c43f.zip
Merge pull request #3018 from sxmichaels/add-scroll-factor
Add scroll factor input command.
Diffstat (limited to 'common')
-rw-r--r--common/util.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/common/util.c b/common/util.c
index f4588b57..0caafb39 100644
--- a/common/util.c
+++ b/common/util.c
@@ -3,6 +3,7 @@
3#include <sys/types.h> 3#include <sys/types.h>
4#include <sys/stat.h> 4#include <sys/stat.h>
5#include <unistd.h> 5#include <unistd.h>
6#include <float.h>
6#include <math.h> 7#include <math.h>
7#include <stdint.h> 8#include <stdint.h>
8#include <stdio.h> 9#include <stdio.h>
@@ -140,6 +141,17 @@ bool parse_boolean(const char *boolean, bool current) {
140 return false; 141 return false;
141} 142}
142 143
144float parse_float(const char *value) {
145 errno = 0;
146 char *end;
147 float flt = strtof(value, &end);
148 if (*end || errno) {
149 wlr_log(WLR_DEBUG, "Invalid float value '%s', defaulting to NAN", value);
150 return NAN;
151 }
152 return flt;
153}
154
143enum wlr_direction opposite_direction(enum wlr_direction d) { 155enum wlr_direction opposite_direction(enum wlr_direction d) {
144 switch (d) { 156 switch (d) {
145 case WLR_DIRECTION_UP: 157 case WLR_DIRECTION_UP: