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

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