Blame SOURCES/0014-Add-support-for-INPUT_PROP_TOPBUTTONPAD.patch

e94010
From e5539482f204cfa8cd053a1afed05a622f7f03dc Mon Sep 17 00:00:00 2001
e94010
From: Hans de Goede <hdegoede@redhat.com>
e94010
Date: Tue, 22 Apr 2014 18:58:11 +0200
e94010
Subject: [PATCH synaptics 14/14] Add support for INPUT_PROP_TOPBUTTONPAD
e94010
e94010
Add a HasSecondaryButtons boolean config option which defaults to true for
e94010
devices with the INPUT_PROP_TOPBUTTONPAD and false for all other devices.
e94010
e94010
Only parse the SecondarySoftButtonAreas when this option is true, effectively
e94010
disabling the top buttons when it is false. Likewise, only initialize the
e94010
SecondarySoftButtonAreas property if we enable support for it.
e94010
e94010
This means that it is now safe to always set a SecondarySoftButtonAreas
e94010
default in 50-synaptics.conf, and that he section which was intended for
e94010
use with future pnp-id matching can be dropped, as that is now all handled
e94010
in the kernel.
e94010
e94010
While at also remove the comment about disabling the bottom edge area, as that
e94010
is now done automatically.
e94010
e94010
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
e94010
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
e94010
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
e94010
(cherry picked from commit 7bf27568417691e772e715f8fc6c30ea7ec892d6)
e94010
e94010
Conflicts:
e94010
	src/eventcomm.c
e94010
e94010
(cherry picked from commit fa54c5b8fcf75531b2d6c6bb6879b3414e5c7792)
e94010
---
e94010
 conf/50-synaptics.conf |  9 ++++-----
e94010
 man/synaptics.man      | 29 +++++++++++++++++++++++------
e94010
 src/eventcomm.c        |  8 ++++++++
e94010
 src/properties.c       |  3 +++
e94010
 src/synaptics.c        |  7 ++++++-
e94010
 src/synapticsstr.h     |  1 +
e94010
 6 files changed, 45 insertions(+), 12 deletions(-)
e94010
e94010
diff --git a/conf/50-synaptics.conf b/conf/50-synaptics.conf
e94010
index dd16ca2..a3145b8 100644
e94010
--- a/conf/50-synaptics.conf
e94010
+++ b/conf/50-synaptics.conf
e94010
@@ -25,16 +25,15 @@ Section "InputClass"
e94010
         Option "Ignore" "on"
e94010
 EndSection
e94010
 
e94010
-# This option enables the bottom right corner to be a right button on
e94010
-# non-synaptics clickpads.
e94010
+# This option enables the bottom right corner to be a right button on clickpads
e94010
+# and the right and middle top areas to be right / middle buttons on clickpads
e94010
+# with a top button area.
e94010
 # This option is only interpreted by clickpads.
e94010
 Section "InputClass"
e94010
         Identifier "Default clickpad buttons"
e94010
         MatchDriver "synaptics"
e94010
         Option "SoftButtonAreas" "50% 0 82% 0 0 0 0 0"
e94010
-#       To disable the bottom edge area so the buttons only work as buttons,
e94010
-#       not for movement, set the AreaBottomEdge
e94010
-#       Option "AreaBottomEdge" "82%"
e94010
+        Option "SecondarySoftButtonAreas" "58% 0 0 8% 42% 58% 0 8%"
e94010
 EndSection
e94010
 
e94010
 # This option disables software buttons on Apple touchpads.
e94010
diff --git a/man/synaptics.man b/man/synaptics.man
e94010
index 86eb663..e35ab6c 100644
e94010
--- a/man/synaptics.man
e94010
+++ b/man/synaptics.man
e94010
@@ -453,17 +453,28 @@ buttons to share an edge value.
e94010
 Property: "Synaptics Soft Button Areas"
e94010
 .
e94010
 .TP
e94010
-.BI "Option \*qSecondarySoftButtonAreas\*q \*q" "RBL RBR RBT RBB MBL MBR MBT MBB" \*q
e94010
+.BI "Option \*qHasSecondarySoftButtons\*q \*q" boolean \*q
e94010
 This option is only available on ClickPad devices.
e94010
-Enable secondary soft button click area support on ClickPad devices (usually on
e94010
+Enable the secondary software button area support. The exact area must be
e94010
+set in option \*qSecondarySoftButtonAreas\*q.  See
e94010
+.B ClickPad support
e94010
+for more details.
e94010
+.
e94010
+.TP
e94010
+.BI "Option \*qSecondarySoftButtonAreas\*q \*q" "RBL RBR RBT RBB MBL MBR MBT MBB" \*q
e94010
+This option is only available on ClickPad devices and only if
e94010
+.B Option \*qHasSecondarySoftButtons\*q
e94010
+is enabled.
e94010
+Define the secondary soft button click areas on ClickPad devices (usually on
e94010
 top of the device).
e94010
 For the allowed values for this option, see
e94010
 .B Option \*qSoftButtonAreas\*q.
e94010
 Primary and secondary soft button areas must not overlap each other. If they do,
e94010
 the behavior of the driver is undefined.
e94010
 Property: "Synaptics Secondary Soft Button Areas". This property is only
e94010
-initialized if the option is set in the
e94010
-__xconfigfile__(__filemansuffix__).
e94010
+initialized if 
e94010
+.B Option \*qHasSecondarySoftButtons\*q 
e94010
+is enabled and this option is set in the __xconfigfile__(__filemansuffix__).
e94010
 .
e94010
 
e94010
 .SH CONFIGURATION DETAILS
e94010
@@ -690,9 +701,15 @@ area, a right or middle click is performed.
e94010
 .LP
e94010
 Some laptops, most notably the Lenovo T440, T540 and x240 series, provide a
e94010
 pointing stick without physical buttons. On those laptops, the top of the
e94010
-touchpad acts as software-emulated button area. This area can be configured
e94010
+touchpad acts as software-emulated button area. This area can be enabled
e94010
 with
e94010
-.B Option SecondarySoftButtonAreas.
e94010
+.B Option \*qHasSecondarySoftButtons\*q
e94010
+and configured
e94010
+with
e94010
+.B Option \*qSecondarySoftButtonAreas\*q.
e94010
+On some platforms, this option
e94010
+will be set automatically if the kernel detects a matching device. On Linux,
e94010
+the device must have the INPUT_PROP_TOPBUTTONPAD property set.
e94010
 
e94010
 .SH "DEVICE PROPERTIES"
e94010
 Synaptics 1.0 and higher support input device properties if the driver is
e94010
diff --git a/src/eventcomm.c b/src/eventcomm.c
e94010
index 4550ef2..a66c6b0 100644
e94010
--- a/src/eventcomm.c
e94010
+++ b/src/eventcomm.c
e94010
@@ -50,6 +50,9 @@
e94010
 #ifndef INPUT_PROP_SEMI_MT
e94010
 #define INPUT_PROP_SEMI_MT 0x03
e94010
 #endif
e94010
+#ifndef INPUT_PROP_TOPBUTTONPAD
e94010
+#define INPUT_PROP_TOPBUTTONPAD 0x04
e94010
+#endif
e94010
 
e94010
 #define SYSCALL(call) while (((call) == -1) && (errno == EINTR))
e94010
 
e94010
@@ -802,6 +805,11 @@ event_query_touch(InputInfoPtr pInfo)
e94010
         xf86IDrvMsg(pInfo, X_INFO, "found clickpad property\n");
e94010
         para->clickpad = TRUE;
e94010
     }
e94010
+
e94010
+    if (rc>= 0 && BitIsOn(&prop, INPUT_PROP_TOPBUTTONPAD)) {
e94010
+        xf86IDrvMsg(pInfo, X_INFO, "found top buttonpad property\n");
e94010
+        para->has_secondary_buttons = TRUE;
e94010
+    }
e94010
 #endif
e94010
 
e94010
     mtdev = mtdev_new_open(pInfo->fd);
e94010
diff --git a/src/properties.c b/src/properties.c
e94010
index 278114a..b3e09c0 100644
e94010
--- a/src/properties.c
e94010
+++ b/src/properties.c
e94010
@@ -173,6 +173,9 @@ InitSoftButtonProperty(InputInfoPtr pInfo)
e94010
     prop_softbutton_areas =
e94010
         InitAtom(pInfo->dev, SYNAPTICS_PROP_SOFTBUTTON_AREAS, 32, 8, values);
e94010
 
e94010
+    if (!para->has_secondary_buttons)
e94010
+        return;
e94010
+
e94010
     values[0] = para->softbutton_areas[TOP_RIGHT_BUTTON_AREA][LEFT];
e94010
     values[1] = para->softbutton_areas[TOP_RIGHT_BUTTON_AREA][RIGHT];
e94010
     values[2] = para->softbutton_areas[TOP_RIGHT_BUTTON_AREA][TOP];
e94010
diff --git a/src/synaptics.c b/src/synaptics.c
e94010
index 78adfaf..68705e7 100644
e94010
--- a/src/synaptics.c
e94010
+++ b/src/synaptics.c
e94010
@@ -659,6 +659,10 @@ set_default_parameters(InputInfoPtr pInfo)
e94010
     pars->tap_time_2 = xf86SetIntOption(opts, "MaxDoubleTapTime", 180);
e94010
     pars->click_time = xf86SetIntOption(opts, "ClickTime", 100);
e94010
     pars->clickpad = xf86SetBoolOption(opts, "ClickPad", pars->clickpad);       /* Probed */
e94010
+    if (pars->clickpad)
e94010
+        pars->has_secondary_buttons = xf86SetBoolOption(opts,
e94010
+                                                        "HasSecondarySoftButtons",
e94010
+                                                        pars->has_secondary_buttons);
e94010
     pars->clickpad_ignore_motion_time = 100; /* ms */
e94010
     /* middle mouse button emulation on a clickpad? nah, you're joking */
e94010
     middle_button_timeout = pars->clickpad ? 0 : 75;
e94010
@@ -738,7 +742,8 @@ set_default_parameters(InputInfoPtr pInfo)
e94010
     }
e94010
 
e94010
     set_primary_softbutton_areas_option(pInfo);
e94010
-    set_secondary_softbutton_areas_option(pInfo);
e94010
+    if (pars->has_secondary_buttons)
e94010
+        set_secondary_softbutton_areas_option(pInfo);
e94010
 }
e94010
 
e94010
 static double
e94010
diff --git a/src/synapticsstr.h b/src/synapticsstr.h
e94010
index 1622123..4226f06 100644
e94010
--- a/src/synapticsstr.h
e94010
+++ b/src/synapticsstr.h
e94010
@@ -172,6 +172,7 @@ typedef struct _SynapticsParameters {
e94010
     int tap_time_2;             /* max. tapping time for double taps */
e94010
     int click_time;             /* The duration of a single click */
e94010
     Bool clickpad;              /* Device is a has integrated buttons */
e94010
+    Bool has_secondary_buttons; /* Device has a top soft-button area */
e94010
     int clickpad_ignore_motion_time; /* Ignore motion for X ms after a click */
e94010
     int emulate_mid_button_time;        /* Max time between left and right button presses to
e94010
                                            emulate a middle button press. */
e94010
-- 
e94010
1.9.3
e94010