From 2087fbe090509cfbe4d61ed1fccad886b14f0060 Mon Sep 17 00:00:00 2001 From: Willow Barraco Date: Sun, 15 Oct 2023 20:22:14 +0200 Subject: [PATCH] Add a -s to scale the edge sizes With some very HiDPI screen, it is hard to trigger edge triggers. --- config.def.h | 1 + lisgd.1 | 5 +++++ lisgd.c | 19 +++++++++++-------- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/config.def.h b/config.def.h index d07f50d..f02e624 100644 --- a/config.def.h +++ b/config.def.h @@ -20,6 +20,7 @@ double edgesizeleft = 50.0; double edgesizetop = 50.0; double edgesizeright = 50.0; double edgesizebottom = 50.0; +double edgessizecaling = 1.0; char *device = "/dev/input/touchscreen"; //Gestures can also be specified interactively from the command line using -g diff --git a/lisgd.1 b/lisgd.1 index 55a359a..dd197cc 100644 --- a/lisgd.1 +++ b/lisgd.1 @@ -96,6 +96,11 @@ edge-based gestures. Should be used in conjunction with -w. If unset, and either the DISPLAY or WAYLAND_DISPLAY env var is set, X/Wayland dynamic screen geometry detection will be used instead. +.TP +.BR \-s ", " \-s\ edgessizecaling\fR +Scale the edge sizes with this value. It is very usefull with very hidpi screens, +to help detecting edge gestures. + .TP .BR \-v \fR Enables verbose mode which prints debugging messages. diff --git a/lisgd.c b/lisgd.c index 2d1e775..921f5bc 100644 --- a/lisgd.c +++ b/lisgd.c @@ -178,22 +178,22 @@ Edge gesturecalculateedge(double x0, double y0, double x1, double y1) { Edge horizontal = EdgeNone; Edge vertical = EdgeNone; - if (x0 <= edgesizeleft) { + if (x0 <= edgesizeleft * edgessizecaling) { horizontal = EdgeLeft; - } else if (x0 >= screenwidth - edgesizeright) { + } else if (x0 >= screenwidth - edgesizeright * edgessizecaling) { horizontal = EdgeRight; - } else if (x1 <= edgesizeleft) { + } else if (x1 <= edgesizeleft * edgessizecaling) { horizontal = EdgeLeft; - } else if (x1 >= screenwidth - edgesizeright) { + } else if (x1 >= screenwidth - edgesizeright * edgessizecaling) { horizontal = EdgeRight; } - if (y0 <= edgesizetop) { + if (y0 <= edgesizetop * edgessizecaling) { vertical = EdgeTop; - } else if (y0 >= screenheight - edgesizebottom) { + } else if (y0 >= screenheight - edgesizebottom * edgessizecaling) { vertical = EdgeBottom; - } else if (y1 <= edgesizetop) { + } else if (y1 <= edgesizetop * edgessizecaling) { vertical = EdgeTop; - } else if (y1 >= screenheight - edgesizebottom) { + } else if (y1 >= screenheight - edgesizebottom * edgessizecaling) { vertical = EdgeBottom; } if (horizontal == EdgeLeft && vertical == EdgeTop) { @@ -553,6 +553,9 @@ main(int argc, char *argv[]) } else if (!strcmp(argv[i], "-w")) { if (i == argc - 1) die("option -w expects a value"); screenwidth = atoi(argv[++i]); + } else if (!strcmp(argv[i], "-s")) { + if (i == argc - 1) die("option -s expects a value"); + edgessizecaling = atof(argv[++i]); } else if (!strcmp(argv[i], "-g")) { if (i == argc - 1) die("option -g expects a value"); gestsarrlen++; -- 2.45.2