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

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