[PATCH]: mtdev could be disabled at configuration

Marc Chalain marc.chalain at gmail.com
Tue Jun 11 06:53:42 PDT 2013


OK I used macro instead inline function. It's the same for the compiler (in
this case).
evdev: add --disable-mtdev option to configure and bypass the mtdev
functions when the library is not available.

---
 configure.ac |   17 ++++++++++++++---
 src/evdev.c  |    9 ++++++++-
 2 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/configure.ac b/configure.ac
index b625221..2bdff35 100644
--- a/configure.ac
+++ b/configure.ac
@@ -132,7 +132,7 @@ AC_ARG_ENABLE(drm-compositor, [
--enable-drm-compositor],,
 AM_CONDITIONAL(ENABLE_DRM_COMPOSITOR, test x$enable_drm_compositor = xyes
-a x$enable_egl = xyes)
 if test x$enable_drm_compositor = xyes -a x$enable_egl = xyes; then
   AC_DEFINE([BUILD_DRM_COMPOSITOR], [1], [Build the DRM compositor])
-  PKG_CHECK_MODULES(DRM_COMPOSITOR, [libudev >= 136 libdrm >= 2.4.30 gbm
mtdev >= 1.1.0])
+  PKG_CHECK_MODULES(DRM_COMPOSITOR, [libudev >= 136 libdrm >= 2.4.30 gbm])
 fi


@@ -161,7 +161,7 @@ AM_CONDITIONAL(ENABLE_RPI_COMPOSITOR, test
"x$enable_rpi_compositor" = "xyes")
 have_bcm_host="no"
 if test "x$enable_rpi_compositor" = "xyes"; then
   AC_DEFINE([BUILD_RPI_COMPOSITOR], [1], [Build the compositor for
Raspberry Pi])
-  PKG_CHECK_MODULES(RPI_COMPOSITOR, [libudev >= 136 mtdev >= 1.1.0])
+  PKG_CHECK_MODULES(RPI_COMPOSITOR, [libudev >= 136])
   PKG_CHECK_MODULES(RPI_BCM_HOST, [bcm_host],
                     [have_bcm_host="yes"
                      AC_DEFINE([HAVE_BCM_HOST], [1], [have Raspberry Pi
BCM headers])],
@@ -176,7 +176,7 @@ AM_CONDITIONAL([ENABLE_FBDEV_COMPOSITOR],
                [test x$enable_fbdev_compositor = xyes])
 AS_IF([test x$enable_fbdev_compositor = xyes], [
   AC_DEFINE([BUILD_FBDEV_COMPOSITOR], [1], [Build the fbdev compositor])
-  PKG_CHECK_MODULES([FBDEV_COMPOSITOR], [libudev >= 136 mtdev >= 1.1.0])
+  PKG_CHECK_MODULES([FBDEV_COMPOSITOR], [libudev >= 136 ])
 ])

 AC_ARG_ENABLE([rdp-compositor], [  --enable-rdp-compositor],,
@@ -203,6 +203,17 @@ PKG_CHECK_MODULES(WEBP, [libwebp], [have_webp=yes],
[have_webp=no])
 AS_IF([test "x$have_webp" = "xyes"],
       [AC_DEFINE([HAVE_WEBP], [1], [Have webp])])

+AC_ARG_ENABLE(mtdev,
+              AS_HELP_STRING([--disable-mtdev],
+                             [do not support multitouch library
libmtdev]),,
+          enable_mtdev=auto)
+AM_CONDITIONAL(ENABLE_MTDEV, test "x$enable_mtdev" = "xyes")
+if test "x$enable_mtdev" != "xno"; then
+    PKG_CHECK_MODULES(MTDEV, [mtdev >= 1.1.0], [have_mtdev=yes],
[have_mtdev=no])
+    AS_IF([test "x$have_mtdev" = "xyes"],
+          [AC_DEFINE([HAVE_MTDEV], [1], [Have Multitouch device support])])
+fi
+
 AC_CHECK_LIB([jpeg], [jpeg_CreateDecompress], have_jpeglib=yes)
 if test x$have_jpeglib = xyes; then
   JPEG_LIBS="-ljpeg"
diff --git a/src/evdev.c b/src/evdev.c
index 122a2d9..b2a5eba 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -27,7 +27,15 @@
 #include <linux/input.h>
 #include <unistd.h>
 #include <fcntl.h>
+#ifdef HAVE_MTDEV
 #include <mtdev.h>
+#else
+struct mtdev
+{ int none;};
+#define mtdev_close_delete(...) do{}while(0)
+#define mtdev_get(...) 0
+#define mtdev_new_open(...) NULL
+#endif

 #include "compositor.h"
 #include "evdev.h"
@@ -565,7 +573,6 @@ evdev_device_create(struct weston_seat *seat, const
char *path, int device_fd)
     if (device->dispatch == NULL)
         goto err1;

-
     if (device->is_mt) {
         device->mtdev = mtdev_new_open(device->fd);
         if (!device->mtdev)
-- 
1.7.9.5




2013/6/11 Pekka Paalanen <ppaalanen at gmail.com>

> On Tue, 11 Jun 2013 14:41:18 +0200
> Marc Chalain <marc.chalain at gmail.com> wrote:
>
> > Hello
> > The detection of the library is automatically done during the
> > configuration. The option is not useful.
> >
> > And the use #ifdef HAVE_MTDEV seems to be simpler, if in the future this
> > feature will disappear.
> >
> > What I do ? I send again or I increase the complexity.
>
> Send again. I think distro packagers would like a ./configure switch
> with yes/no/auto, defaulting to auto.
>
> I didn't even realize the --disable-mtdev was not actually a configure
> option.
>
> Here's what I meant earlier (pseudo code):
>
> #ifdef HAVE_MTDEV
> #include <mtdev.h>
> #else
> struct mtdev
> {
>         int dummy;
> };
>
> static inline int
> mtdev_get(struct mtdev *, int, blah*, int)
> {
>         return -1;
> }
>
> static inline void
> mtdev_close_delete(struct mtdev *)
> {
> }
> #endif
>
> That way the significant code will have only one #ifdef after the above
> in the top of the file.
>
> device->mtdev will always be NULL, anyway, so these stubs will never be
> called, and the compiler is still happy.
>
>
> Thanks,
> pq
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20130611/2f00e818/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-evdev-add-disable-mtdev-option-to-configure-and-bypa.patch
Type: application/octet-stream
Size: 3472 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20130611/2f00e818/attachment-0001.obj>


More information about the wayland-devel mailing list