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

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