[PATCH] libinput-drv: Move properties to a separate header

Olivier Fourdan ofourdan at redhat.com
Tue Jan 20 04:54:10 PST 2015


And install the header as part of the SDK, so that applications interfacing
with the libinput driver do not have to copy paste all the properties' names.

Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
---
 Makefile.am                   |  5 +++-
 configure.ac                  |  4 ++-
 include/Makefile.am           | 21 +++++++++++++++
 include/libinput-properties.h | 62 ++++++++++++++++++++++++++++++++++++++++++
 src/libinput.c                | 63 ++++++++++++++-----------------------------
 xorg-libinput.pc.in           |  6 +++++
 6 files changed, 116 insertions(+), 45 deletions(-)
 create mode 100644 include/Makefile.am
 create mode 100644 include/libinput-properties.h
 create mode 100644 xorg-libinput.pc.in

diff --git a/Makefile.am b/Makefile.am
index a963530..99e6808 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -21,9 +21,12 @@
 
 DISTCHECK_CONFIGURE_FLAGS = --with-sdkdir='$${includedir}/xorg'
 
-SUBDIRS = src man
+SUBDIRS = src include man
 MAINTAINERCLEANFILES = ChangeLog INSTALL
 
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = xorg-libinput.pc
+
 .PHONY: ChangeLog INSTALL
 
 INSTALL:
diff --git a/configure.ac b/configure.ac
index 9a41170..55a1372 100644
--- a/configure.ac
+++ b/configure.ac
@@ -68,6 +68,8 @@ DRIVER_NAME=libinput
 AC_SUBST([DRIVER_NAME])
 
 AC_CONFIG_FILES([Makefile
+		 include/Makefile
 		 src/Makefile
-		 man/Makefile])
+		 man/Makefile
+		 xorg-libinput.pc])
 AC_OUTPUT
diff --git a/include/Makefile.am b/include/Makefile.am
new file mode 100644
index 0000000..4d3467b
--- /dev/null
+++ b/include/Makefile.am
@@ -0,0 +1,21 @@
+#  Copyright 2005 Adam Jackson.
+#
+#  Permission is hereby granted, free of charge, to any person obtaining a
+#  copy of this software and associated documentation files (the "Software"),
+#  to deal in the Software without restriction, including without limitation
+#  on the rights to use, copy, modify, merge, publish, distribute, sub
+#  license, and/or sell copies of the Software, and to permit persons to whom
+#  the Software is furnished to do so, subject to the following conditions:
+#
+#  The above copyright notice and this permission notice (including the next
+#  paragraph) shall be included in all copies or substantial portions of the
+#  Software.
+#
+#  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+#  FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
+#  ADAM JACKSON BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+#  IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+#  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+sdk_HEADERS = libinput-properties.h
diff --git a/include/libinput-properties.h b/include/libinput-properties.h
new file mode 100644
index 0000000..90899c3
--- /dev/null
+++ b/include/libinput-properties.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright © 2015 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of Red Hat
+ * not be used in advertising or publicity pertaining to distribution
+ * of the software without specific, written prior permission.  Red
+ * Hat makes no representations about the suitability of this software
+ * for any purpose.  It is provided "as is" without express or implied
+ * warranty.
+ *
+ * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _LIBINPUT_PROPERTIES_H_
+#define _LIBINPUT_PROPERTIES_H_
+
+/* Tapping enabled/disabled: BOOL, 1 value */
+#define LIBINPUT_PROP_TAP "libinput Tapping Enabled"
+
+/* Calibration matrix: FLOAT, 9 values of a 3x3 matrix, in rows */
+#define LIBINPUT_PROP_CALIBRATION "libinput Calibration Matrix"
+
+/* Pointer accel speed: FLOAT, 1 value, 32 bit */
+#define LIBINPUT_PROP_ACCEL "libinput Accel Speed"
+
+/* Natural scrolling: BOOL, 1 value */
+#define LIBINPUT_PROP_NATURAL_SCROLL "libinput Natural Scrolling Enabled"
+
+/* Send-events mode: BOOL read-only, 2 values in order disabled,
+   disabled-on-external-mouse */
+#define LIBINPUT_PROP_SENDEVENTS_AVAILABLE "libinput Send Events Modes Available"
+
+/* Send-events mode: BOOL, 2 values in order disabled,
+   disabled-on-external-mouse */
+#define LIBINPUT_PROP_SENDEVENTS_ENABLED "libinput Send Events Mode Enabled"
+
+/* Left-handed enabled/disabled: BOOL, 1 value */
+#define LIBINPUT_PROP_LEFT_HANDED "libinput Left Handed Enabled"
+
+/* Scroll method: BOOL read-only, 3 values in order 2fg, edge, button.
+   shows available scroll methods */
+#define LIBINPUT_PROP_SCROLL_METHODS_AVAILABLE "libinput Scroll Methods Available"
+
+/* Scroll method: BOOL, 3 values in order 2fg, edge, button
+   only one is enabled at a time at max */
+#define LIBINPUT_PROP_SCROLL_METHOD_ENABLED "libinput Scroll Method Enabled"
+
+/* Scroll button for button scrolling: 32-bit int, 1 value */
+#define LIBINPUT_PROP_SCROLL_BUTTON "libinput Button Scrolling Button"
+
+#endif /* _LIBINPUT_PROPERTIES_H_ */
+
diff --git a/src/libinput.c b/src/libinput.c
index cddfd26..52b385e 100644
--- a/src/libinput.c
+++ b/src/libinput.c
@@ -41,6 +41,8 @@
 
 #include <X11/Xatom.h>
 
+#include "libinput-properties.h"
+
 #ifndef XI86_SERVER_FD
 #define XI86_SERVER_FD 0x20
 #endif
@@ -57,31 +59,6 @@
  */
 #define TOUCH_AXIS_MAX 0xffff
 
-/* Tapping enabled/disabled: BOOL, 1 value */
-#define PROP_TAP "libinput Tapping Enabled"
-/* Calibration matrix: FLOAT, 9 values of a 3x3 matrix, in rows */
-#define PROP_CALIBRATION "libinput Calibration Matrix"
-/* Pointer accel speed: FLOAT, 1 value, 32 bit */
-#define PROP_ACCEL "libinput Accel Speed"
-/* Natural scrolling: BOOL, 1 value */
-#define PROP_NATURAL_SCROLL "libinput Natural Scrolling Enabled"
-/* Send-events mode: BOOL read-only, 2 values in order disabled,
-   disabled-on-external-mouse */
-#define PROP_SENDEVENTS_AVAILABLE "libinput Send Events Modes Available"
-/* Send-events mode: BOOL, 2 values in order disabled,
-   disabled-on-external-mouse */
-#define PROP_SENDEVENTS_ENABLED "libinput Send Events Mode Enabled"
-/* Left-handed enabled/disabled: BOOL, 1 value */
-#define PROP_LEFT_HANDED "libinput Left Handed Enabled"
-/* Scroll method: BOOL read-only, 3 values in order 2fg, edge, button.
-   shows available scroll methods */
-#define PROP_SCROLL_METHODS_AVAILABLE "libinput Scroll Methods Available"
-/* Scroll method: BOOL, 3 values in order 2fg, edge, button
-   only one is enabled at a time at max */
-#define PROP_SCROLL_METHOD_ENABLED "libinput Scroll Method Enabled"
-/* Scroll button for button scrolling: 32-bit int, 1 value */
-#define PROP_SCROLL_BUTTON "libinput Button Scrolling Button"
-
 struct xf86libinput_driver {
 	struct libinput *libinput;
 	int device_enabled_count;
@@ -1618,7 +1595,7 @@ LibinputInitProperty(DeviceIntPtr dev)
 	if (libinput_device_config_tap_get_finger_count(device) > 0) {
 		BOOL tap = driver_data->options.tapping;
 
-		prop_tap = MakeAtom(PROP_TAP, strlen(PROP_TAP), TRUE);
+		prop_tap = MakeAtom(LIBINPUT_PROP_TAP, strlen(LIBINPUT_PROP_TAP), TRUE);
 		rc = XIChangeDeviceProperty(dev, prop_tap, XA_INTEGER, 8,
 					    PropModeReplace, 1, &tap, FALSE);
 		if (rc != Success)
@@ -1636,8 +1613,8 @@ LibinputInitProperty(DeviceIntPtr dev)
 		calibration[7] = 0;
 		calibration[8] = 1;
 
-		prop_calibration = MakeAtom(PROP_CALIBRATION,
-					    strlen(PROP_CALIBRATION),
+		prop_calibration = MakeAtom(LIBINPUT_PROP_CALIBRATION,
+					    strlen(LIBINPUT_PROP_CALIBRATION),
 					    TRUE);
 
 		rc = XIChangeDeviceProperty(dev, prop_calibration, prop_float, 32,
@@ -1650,7 +1627,7 @@ LibinputInitProperty(DeviceIntPtr dev)
 	if (libinput_device_config_accel_is_available(device)) {
 		float speed = driver_data->options.speed;
 
-		prop_accel = MakeAtom(PROP_ACCEL, strlen(PROP_ACCEL), TRUE);
+		prop_accel = MakeAtom(LIBINPUT_PROP_ACCEL, strlen(LIBINPUT_PROP_ACCEL), TRUE);
 		rc = XIChangeDeviceProperty(dev, prop_accel, prop_float, 32,
 					    PropModeReplace, 1, &speed, FALSE);
 		if (rc != Success)
@@ -1661,8 +1638,8 @@ LibinputInitProperty(DeviceIntPtr dev)
 	if (libinput_device_config_scroll_has_natural_scroll(device)) {
 		BOOL natural_scroll = driver_data->options.natural_scrolling;
 
-		prop_natural_scroll = MakeAtom(PROP_NATURAL_SCROLL,
-					       strlen(PROP_NATURAL_SCROLL),
+		prop_natural_scroll = MakeAtom(LIBINPUT_PROP_NATURAL_SCROLL,
+					       strlen(LIBINPUT_PROP_NATURAL_SCROLL),
 					       TRUE);
 		rc = XIChangeDeviceProperty(dev, prop_natural_scroll, XA_INTEGER, 8,
 					    PropModeReplace, 1, &natural_scroll, FALSE);
@@ -1681,8 +1658,8 @@ LibinputInitProperty(DeviceIntPtr dev)
 		if (sendevent_modes & LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE)
 			modes[1] = TRUE;
 
-		prop_sendevents_available = MakeAtom(PROP_SENDEVENTS_AVAILABLE,
-						     strlen(PROP_SENDEVENTS_AVAILABLE),
+		prop_sendevents_available = MakeAtom(LIBINPUT_PROP_SENDEVENTS_AVAILABLE,
+						     strlen(LIBINPUT_PROP_SENDEVENTS_AVAILABLE),
 						     TRUE);
 		rc = XIChangeDeviceProperty(dev, prop_sendevents_available,
 					    XA_INTEGER, 8,
@@ -1703,8 +1680,8 @@ LibinputInitProperty(DeviceIntPtr dev)
 			break;
 		}
 
-		prop_sendevents_enabled = MakeAtom(PROP_SENDEVENTS_ENABLED,
-						   strlen(PROP_SENDEVENTS_ENABLED),
+		prop_sendevents_enabled = MakeAtom(LIBINPUT_PROP_SENDEVENTS_ENABLED,
+						   strlen(LIBINPUT_PROP_SENDEVENTS_ENABLED),
 						   TRUE);
 		rc = XIChangeDeviceProperty(dev, prop_sendevents_enabled,
 					    XA_INTEGER, 8,
@@ -1718,8 +1695,8 @@ LibinputInitProperty(DeviceIntPtr dev)
 	if (libinput_device_config_left_handed_is_available(device)) {
 		BOOL left_handed = driver_data->options.left_handed;
 
-		prop_left_handed = MakeAtom(PROP_LEFT_HANDED,
-					    strlen(PROP_LEFT_HANDED),
+		prop_left_handed = MakeAtom(LIBINPUT_PROP_LEFT_HANDED,
+					    strlen(LIBINPUT_PROP_LEFT_HANDED),
 					    TRUE);
 		rc = XIChangeDeviceProperty(dev, prop_left_handed,
 					    XA_INTEGER, 8,
@@ -1742,8 +1719,8 @@ LibinputInitProperty(DeviceIntPtr dev)
 			methods[2] = TRUE;
 
 		prop_scroll_methods_available =
-			MakeAtom(PROP_SCROLL_METHODS_AVAILABLE,
-				 strlen(PROP_SCROLL_METHODS_AVAILABLE),
+			MakeAtom(LIBINPUT_PROP_SCROLL_METHODS_AVAILABLE,
+				 strlen(LIBINPUT_PROP_SCROLL_METHODS_AVAILABLE),
 				 TRUE);
 		rc = XIChangeDeviceProperty(dev,
 					    prop_scroll_methods_available,
@@ -1775,8 +1752,8 @@ LibinputInitProperty(DeviceIntPtr dev)
 		}
 
 		prop_scroll_method_enabled =
-			MakeAtom(PROP_SCROLL_METHOD_ENABLED,
-				 strlen(PROP_SCROLL_METHOD_ENABLED),
+			MakeAtom(LIBINPUT_PROP_SCROLL_METHOD_ENABLED,
+				 strlen(LIBINPUT_PROP_SCROLL_METHOD_ENABLED),
 				 TRUE);
 		rc = XIChangeDeviceProperty(dev,
 					    prop_scroll_method_enabled,
@@ -1796,8 +1773,8 @@ LibinputInitProperty(DeviceIntPtr dev)
 	    LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN) {
 		CARD32 scroll_button = driver_data->options.scroll_button;
 
-		prop_scroll_button = MakeAtom(PROP_SCROLL_BUTTON,
-					    strlen(PROP_SCROLL_BUTTON),
+		prop_scroll_button = MakeAtom(LIBINPUT_PROP_SCROLL_BUTTON,
+					    strlen(LIBINPUT_PROP_SCROLL_BUTTON),
 					    TRUE);
 		rc = XIChangeDeviceProperty(dev, prop_scroll_button,
 					    XA_CARDINAL, 32,
diff --git a/xorg-libinput.pc.in b/xorg-libinput.pc.in
new file mode 100644
index 0000000..ff98189
--- /dev/null
+++ b/xorg-libinput.pc.in
@@ -0,0 +1,6 @@
+sdkdir=@sdkdir@
+
+Name: xorg-libinput
+Description: X.Org libinput input driver.
+Version: @PACKAGE_VERSION@
+Cflags: -I${sdkdir}
-- 
2.1.0



More information about the xorg-devel mailing list