Blame SOURCES/0001-Add-a-DPIScaleFactor-option-as-temporary-solution-to.patch

545df2
From badaa13b7193344a3dd1a81b03baa4bc540faa92 Mon Sep 17 00:00:00 2001
545df2
From: Peter Hutterer <peter.hutterer@who-t.net>
545df2
Date: Thu, 18 May 2017 14:45:18 +1000
545df2
Subject: [PATCH xf86-input-libinput] Add a DPIScaleFactor option as temporary
545df2
 solution to the hidpi issue
545df2
545df2
https://bugzilla.redhat.com/show_bug.cgi?id=1413306
545df2
---
545df2
 man/libinput.man   | 21 +++++++++++++++++++++
545df2
 src/xf86libinput.c | 26 ++++++++++++++++++++++++++
545df2
 2 files changed, 47 insertions(+)
545df2
545df2
diff --git a/man/libinput.man b/man/libinput.man
545df2
index c9fec4e..888891c 100644
545df2
--- a/man/libinput.man
545df2
+++ b/man/libinput.man
545df2
@@ -401,6 +401,27 @@ This driver does not work with \fBOption \*qDevice\*q\fR set to an event
545df2
 node in \fI/dev/input/by-id\fR and \fI/dev/input/by-path\fR. This can be
545df2
 usually be worked by using \fBSection \*qInputClass\*q\fR with an
545df2
 appropriate \fBMatch*\fR statement in the __xconfigfile__(__filemansuffix__).
545df2
+.PP
545df2
+This driver does not know about the display pixel density and submits motion
545df2
+events assuming an approximate display density of 96dpi. On high-dpi
545df2
+screens this results in a slower physical motion of the cursor (a one-pixel
545df2
+movement is a smaller physical movement on the screen). This can make
545df2
+interaction with the desktop difficult.
545df2
+.PP
545df2
+.TP 7
545df2
+.BI "Option \*qDPIScaleFactor\*q float
545df2
+This is a
545df2
+.B temporary
545df2
+solution. The factor should be set to the approximate ratio of the host display
545df2
+compared to the default 96dpi. For example, a display with 200dpi should set
545df2
+a factor of 2.0.
545df2
+.PP
545df2
+If set, x/y motion will be unconditionally multiplied by this factor,
545df2
+resulting in faster movement of the cursor. Note that this may make some
545df2
+pixels unadressable and should be used with caution.
545df2
+.PP
545df2
+.B This option is a temporary solution.
545df2
+It may be removed in any future update of this driver.
545df2
 
545df2
 .SH AUTHORS
545df2
 Peter Hutterer
545df2
diff --git a/src/xf86libinput.c b/src/xf86libinput.c
545df2
index 92817a5..dd600e6 100644
545df2
--- a/src/xf86libinput.c
545df2
+++ b/src/xf86libinput.c
545df2
@@ -182,6 +182,8 @@ struct xf86libinput {
545df2
 	struct scale_factor {
545df2
 		double x, y;
545df2
 	} area_scale_factor;
545df2
+
545df2
+	double dpi_scale_factor; /* Fedora hack */
545df2
 };
545df2
 
545df2
 enum event_handling {
545df2
@@ -1448,6 +1450,11 @@ xf86libinput_handle_motion(InputInfoPtr pInfo, struct libinput_event_pointer *ev
545df2
 	x = libinput_event_pointer_get_dx(event);
545df2
 	y = libinput_event_pointer_get_dy(event);
545df2
 
545df2
+	if (driver_data->dpi_scale_factor > 0.0) {
545df2
+		x *= driver_data->dpi_scale_factor;
545df2
+		y *= driver_data->dpi_scale_factor;
545df2
+	}
545df2
+
545df2
 	valuator_mask_zero(mask);
545df2
 
545df2
 	{
545df2
@@ -3448,6 +3455,25 @@ xf86libinput_pre_init(InputDriverPtr drv,
545df2
 
545df2
 	xf86libinput_parse_options(pInfo, driver_data, device);
545df2
 
545df2
+	/* XXX:
545df2
+	   Fedora hack for bug https://bugzilla.redhat.com/show_bug.cgi?id=1413306
545df2
+	   This is temporary only, but at least makes it work for now.
545df2
+	 */
545df2
+
545df2
+	if (xf86CheckRealOption(pInfo->options, "DPIScaleFactor", 0.0) != 0.0) {
545df2
+		xf86IDrvMsg(pInfo, X_WARNING,
545df2
+			    "\n"
545df2
+			    "******************** WARNING ********************\n"
545df2
+			    "* DPIScaleFactor option is a temporary solution *\n"
545df2
+			    "* and may cease to work without warning!        *\n"
545df2
+			    "******************** WARNING ********************\n");
545df2
+		driver_data->dpi_scale_factor = xf86SetRealOption(pInfo->options, "DPIScaleFactor", 0.0);
545df2
+		if (driver_data->dpi_scale_factor < 0.0) {
545df2
+			xf86IDrvMsg(pInfo, X_ERROR, "Invalid DPIScaleFactor, ignoring value\n");
545df2
+			driver_data->dpi_scale_factor = 0.0;
545df2
+		}
545df2
+	}
545df2
+
545df2
 	/* Device is both keyboard and pointer. Drop the keyboard cap from
545df2
 	 * this device, create a separate device instead */
545df2
 	if (!is_subdevice &&
545df2
-- 
545df2
2.31.1
545df2