summaryrefslogtreecommitdiff
path: root/sway/commands/input/map_from_region.c
diff options
context:
space:
mode:
authorReza Jelveh <[email protected]>2024-04-15 13:39:41 +0800
committerGitHub <[email protected]>2024-04-15 01:39:41 -0400
commitfb86ed6b0588dfdebfb66ce875bc63cfa0a897f6 (patch)
tree29857a1769107adc58696f08d379f608aa4e29a2 /sway/commands/input/map_from_region.c
parenta5e79676c4bd22fc5902182acf0667907202a465 (diff)
feat: 1.9 merge (#277)
Co-authored-by: William McKinnon <[email protected]> Co-authored-by: Erik Reider <[email protected]>
Diffstat (limited to 'sway/commands/input/map_from_region.c')
-rw-r--r--sway/commands/input/map_from_region.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/sway/commands/input/map_from_region.c b/sway/commands/input/map_from_region.c
index de00b714..4400e111 100644
--- a/sway/commands/input/map_from_region.c
+++ b/sway/commands/input/map_from_region.c
@@ -11,11 +11,21 @@ static bool parse_coords(const char *str, double *x, double *y, bool *mm) {
*mm = false;
char *end;
- *x = strtod(str, &end);
- if (end[0] != 'x') {
- return false;
+
+ // Check for "0x" prefix to avoid strtod treating the string as hex
+ if (str[0] == '0' && str[1] == 'x') {
+ if (strlen(str) < 3) {
+ return false;
+ }
+ *x = 0;
+ end = (char *)str + 2;
+ } else {
+ *x = strtod(str, &end);
+ if (end[0] != 'x') {
+ return false;
+ }
+ ++end;
}
- ++end;
*y = strtod(end, &end);
if (end[0] == 'm') {