[PATCH xf86-video-nested v2 1/5] Make nested input driver build optional (and disabled by default)

Laércio de Sousa laerciosousa at sme-mogidascruzes.sp.gov.br
Thu Nov 6 09:18:10 PST 2014


This patch allow skipping build of nested input driver included
in xf86-video-nested code. Actually, nested input driver is not
needed for single-GPU multiseat setups, and may need maintenance
for other use cases.

Nested input driver build will be disabled by default.
If one wants to build it, just pass configure option --enable-nested-input.

Signed-off-by: Laércio de Sousa <laerciosousa at sme-mogidascruzes.sp.gov.br>
---
 configure.ac       | 30 +++++++++++++++++++++++++-----
 src/Makefile.am    | 10 ++++++++--
 src/client.h       |  3 +++
 src/driver.c       | 13 +++++++++++++
 src/nested_input.c |  9 +++++----
 src/xlibclient.c   | 36 ++++++++++++++++++++++++++++--------
 6 files changed, 82 insertions(+), 19 deletions(-)

diff --git a/configure.ac b/configure.ac
index 32e9ab0..7bdb8ca 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,5 @@
 #  Copyright 2005 Adam Jackson.
+#            2014 Prefeitura de Mogi das Cruzes, SP, Brazil.
 #
 #  Permission is hereby granted, free of charge, to any person obtaining a
 #  copy of this software and associated documentation files (the "Software"),
@@ -22,7 +23,7 @@
 
 # Initialize Autoconf
 AC_PREREQ([2.60])
-AC_INIT([xf86-video-nestedy],
+AC_INIT([xf86-video-nested],
         [0.1.0],
         [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
         [xf86-video-nested])
@@ -45,11 +46,24 @@ AC_DISABLE_STATIC
 AC_PROG_LIBTOOL
 
 # Define a configure option for an alternate module directory
-AC_ARG_WITH(xorg-module-dir, [  --with-xorg-module-dir=DIR ],
-                             [ moduledir="$withval" ],
-                             [ moduledir="$libdir/xorg/modules" ])
-AC_SUBST(moduledir)
+AC_ARG_WITH([xorg-module-dir],
+            AS_HELP_STRING([--with-xorg-module-dir=DIR],
+                           [Alternate Xorg module directory]),
+            [moduledir="$withval"],
+            [moduledir="$libdir/xorg/modules"])
+AC_SUBST([moduledir])
 
+# Define a configure option to enable/disable nested input driver build
+AC_ARG_ENABLE([nested-input],
+              AS_HELP_STRING([--enable-nested-input],
+                             [Enable building nested input driver]),
+              [NESTED_INPUT="$enableval"],
+              [NESTED_INPUT=no])
+AC_SUBST([NESTED_INPUT])
+AM_CONDITIONAL([NESTED_INPUT], [test "x$NESTED_INPUT" = xyes])
+if test "x$NESTED_INPUT" = xyes; then
+    AC_DEFINE([NESTED_INPUT], [1], [Define if nested input driver is enabled])
+fi
 
 # Store the list of server defined optional extensions in REQUIRED_MODULES
 #XORG_DRIVER_CHECK_EXT(RANDR, randrproto)
@@ -69,3 +83,9 @@ AC_CONFIG_FILES([
                 src/Makefile
 ])
 AC_OUTPUT
+AC_MSG_RESULT([
+	$PACKAGE_NAME	$VERSION
+
+	moduledir:		${moduledir}
+	nested input:		${NESTED_INPUT}
+])
diff --git a/src/Makefile.am b/src/Makefile.am
index 44dc656..11e610d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -18,7 +18,8 @@
 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 # DEALINGS IN THE SOFTWARE.
 #
-# Author: Paulo Zanoni <pzanoni at mandriva.com>
+# Authors: Paulo Zanoni <pzanoni at mandriva.com>
+#          Laércio de Sousa <laerciosousa at sme-mogidascruzes.sp.gov.br>
 #
 
 AM_CFLAGS = $(XORG_CFLAGS) $(PCIACCESS_CFLAGS) $(X11_CFLAGS) $(XEXT_CFLAGS)
@@ -26,6 +27,11 @@ AM_CFLAGS = $(XORG_CFLAGS) $(PCIACCESS_CFLAGS) $(X11_CFLAGS) $(XEXT_CFLAGS)
 nested_drv_la_LTLIBRARIES = nested_drv.la
 nested_drv_la_LDFLAGS = -module -avoid-version
 nested_drv_la_LIBADD = $(XORG_LIBS) $(X11_LIBS) $(XEXT_LIBS)
+
 nested_drv_ladir = @moduledir@/drivers
 
-nested_drv_la_SOURCES = driver.c nested_input.c nested_input.h xlibclient.c client.h compat-api.h
+nested_drv_la_SOURCES = driver.c client.h compat-api.h xlibclient.c
+
+if NESTED_INPUT
+nested_drv_la_SOURCES += nested_input.h nested_input.c
+endif
diff --git a/src/client.h b/src/client.h
index 4c73b3c..c6f88af 100644
--- a/src/client.h
+++ b/src/client.h
@@ -27,6 +27,7 @@
  * Colin Hill <colin.james.hill at gmail.com>
  * Weseung Hwang <weseung at gmail.com>
  * Nathaniel Way <nathanielcw at hotmail.com>
+ * Laércio de Sousa <laerciosousa at sme-mogidascruzes.sp.gov.br>
  */
 
 #include <colormap.h>
@@ -72,4 +73,6 @@ void NestedClientSetDevicePtr(NestedClientPrivatePtr pPriv, DeviceIntPtr dev);
 
 int NestedClientGetFileDescriptor(NestedClientPrivatePtr pPriv);
 
+#ifdef NESTED_INPUT
 Bool NestedClientGetKeyboardMappings(NestedClientPrivatePtr pPriv, KeySymsPtr keySyms, CARD8 *modmap, XkbControlsPtr ctrls);
+#endif
diff --git a/src/driver.c b/src/driver.c
index 68b7aa8..b573a97 100644
--- a/src/driver.c
+++ b/src/driver.c
@@ -27,6 +27,7 @@
  * Colin Hill <colin.james.hill at gmail.com>
  * Weseung Hwang <weseung at gmail.com>
  * Nathaniel Way <nathanielcw at hotmail.com>
+ * Laércio de Sousa <laerciosousa at sme-mogidascruzes.sp.gov.br>
  */
 
 #include <stdlib.h>
@@ -44,12 +45,16 @@
 #include <xf86.h>
 #include <xf86Module.h>
 #include <xf86str.h>
+#ifdef NESTED_INPUT
 #include "xf86Xinput.h"
+#endif
 
 #include "compat-api.h"
 
 #include "client.h"
+#ifdef NESTED_INPUT
 #include "nested_input.h"
+#endif
 
 #define NESTED_VERSION 0
 #define NESTED_NAME "NESTED"
@@ -129,6 +134,7 @@ _X_EXPORT DriverRec NESTED = {
     0     /* PciProbe */
 };
 
+#ifdef NESTED_INPUT
 _X_EXPORT InputDriverRec NESTEDINPUT = {
     1,
     "nestedinput",
@@ -138,6 +144,7 @@ _X_EXPORT InputDriverRec NESTEDINPUT = {
     NULL,
     0,
 };
+#endif
 
 static XF86ModuleVersionInfo NestedVersRec = {
     NESTED_DRIVER_NAME,
@@ -184,7 +191,9 @@ NestedSetup(pointer module, pointer opts, int *errmaj, int *errmin) {
         setupDone = TRUE;
         
         xf86AddDriver(&NESTED, module, HaveDriverFuncs);
+#ifdef NESTED_INPUT
         xf86AddInputDriver(&NESTEDINPUT, module, 0);
+#endif
         
         return (pointer)1;
     } else {
@@ -525,11 +534,13 @@ NestedAddMode(ScrnInfoPtr pScrn, int width, int height) {
 
 // Wrapper for timed call to NestedInputLoadDriver.  Used with timer in order
 // to force the initialization to wait until the input core is initialized.
+#ifdef NESTED_INPUT
 static CARD32
 NestedMouseTimer(OsTimerPtr timer, CARD32 time, pointer arg) {
     NestedInputLoadDriver(arg);
     return 0;
 }
+#endif
 
 static void
 NestedBlockHandler(pointer data, OSTimePtr wt, pointer LastSelectMask) {
@@ -577,7 +588,9 @@ static Bool NestedScreenInit(SCREEN_INIT_ARGS_DECL)
     
     // Schedule the NestedInputLoadDriver function to load once the
     // input core is initialized.
+#ifdef NESTED_INPUT
     TimerSet(NULL, 0, 1, NestedMouseTimer, pNested->clientData);
+#endif
 
     miClearVisualTypes();
     if (!miSetVisualTypesAndMasks(pScrn->depth,
diff --git a/src/nested_input.c b/src/nested_input.c
index 9d2e0d3..9122b30 100644
--- a/src/nested_input.c
+++ b/src/nested_input.c
@@ -27,8 +27,13 @@
  * Colin Hill <colin.james.hill at gmail.com>
  * Weseung Hwang <weseung at gmail.com>
  * Nathaniel Way <nathanielcw at hotmail.com>
+ * Laércio de Sousa <laerciosousa at sme-mogidascruzes.sp.gov.br>
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <errno.h>
 #include <fcntl.h>
 #include <stdlib.h>
@@ -47,10 +52,6 @@
 #include <xf86_OSproc.h>
 #include <xkbsrv.h>
 
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
 #include "client.h"
 #include "nested_input.h"
 
diff --git a/src/xlibclient.c b/src/xlibclient.c
index f7fe652..0f1034a 100644
--- a/src/xlibclient.c
+++ b/src/xlibclient.c
@@ -27,8 +27,13 @@
  * Colin Hill <colin.james.hill at gmail.com>
  * Weseung Hwang <weseung at gmail.com>
  * Nathaniel Way <nathanielcw at hotmail.com>
+ * Laércio de Sousa <laerciosousa at sme-mogidascruzes.sp.gov.br>
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <stdlib.h>
 
 #include <sys/ipc.h>
@@ -36,19 +41,19 @@
 
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
+#ifdef NESTED_INPUT
 #include <X11/XKBlib.h>
+#endif
 #include <X11/extensions/XShm.h>
 
 #include <xorg-server.h>
 #include <xf86.h>
 
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
 #include "client.h"
 
+#ifdef NESTED_INPUT
 #include "nested_input.h"
+#endif
 
 struct NestedClientPrivate {
     Display *display;
@@ -67,6 +72,7 @@ struct NestedClientPrivate {
     DeviceIntPtr dev; // The pointer to the input device.  Passed back to the
                       // input driver when posting input events.
 
+#ifdef NESTED_INPUT
     struct {
         int op;
         int event;
@@ -74,6 +80,7 @@ struct NestedClientPrivate {
         int major;
         int minor;
     } xkb;
+#endif
 };
 
 /* Checks if a display is open */
@@ -181,6 +188,7 @@ NestedClientCreateScreen(int scrnIndex,
     if (!pPriv->display)
         return NULL;
 
+#ifdef NESTED_INPUT
     supported = XkbQueryExtension(pPriv->display, &pPriv->xkb.op, &pPriv->xkb.event,
                                   &pPriv->xkb.error, &pPriv->xkb.major, &pPriv->xkb.minor);
     if (!supported) {
@@ -188,6 +196,7 @@ NestedClientCreateScreen(int scrnIndex,
         XCloseDisplay(pPriv->display);
         return NULL;
     }
+#endif
 
     pPriv->screenNumber = DefaultScreen(pPriv->display);
     pPriv->screen = ScreenOfDisplay(pPriv->display, pPriv->screenNumber);
@@ -210,10 +219,17 @@ NestedClientCreateScreen(int scrnIndex,
     
     XMapWindow(pPriv->display, pPriv->window);
 
-    XSelectInput(pPriv->display, pPriv->window, ExposureMask | 
-         PointerMotionMask | EnterWindowMask | LeaveWindowMask |
-         ButtonPressMask | ButtonReleaseMask | KeyPressMask |
-         KeyReleaseMask);
+    XSelectInput(pPriv->display, pPriv->window,
+#ifdef NESTED_INPUT
+                 PointerMotionMask |
+                 EnterWindowMask   |
+                 LeaveWindowMask   |
+                 ButtonPressMask   |
+                 ButtonReleaseMask |
+                 KeyPressMask      |
+                 KeyReleaseMask    |
+#endif
+                 ExposureMask);
 
     if (!NestedClientTryXShm(pPriv, scrnIndex, width, height, depth)) {
         pPriv->img = XCreateImage(pPriv->display,
@@ -318,6 +334,7 @@ NestedClientCheckEvents(NestedClientPrivatePtr pPriv) {
                                      ((XExposeEvent*)&ev)->height);
             break;
 
+#ifdef NESTED_INPUT
         case MotionNotify:
             if (!pPriv->dev) {
                 xf86DrvMsg(pPriv->scrnIndex, X_INFO, "Input device is not yet initialized, ignoring input.\n");
@@ -348,6 +365,7 @@ NestedClientCheckEvents(NestedClientPrivatePtr pPriv) {
 
             NestedInputPostKeyboardEvent(pPriv->dev, ev.xkey.keycode, ev.type == KeyPress);
             break;
+#endif
         }
     }
 }
@@ -373,6 +391,7 @@ NestedClientGetFileDescriptor(NestedClientPrivatePtr pPriv) {
     return ConnectionNumber(pPriv->display);
 }
 
+#ifdef NESTED_INPUT
 Bool NestedClientGetKeyboardMappings(NestedClientPrivatePtr pPriv, KeySymsPtr keySyms, CARD8 *modmap, XkbControlsPtr ctrls) {
     XModifierKeymap *modifier_keymap;
     KeySym *keymap;
@@ -419,3 +438,4 @@ Bool NestedClientGetKeyboardMappings(NestedClientPrivatePtr pPriv, KeySymsPtr ke
     XkbFreeKeyboard(xkb, 0, False);
     return TRUE;
 }
+#endif
-- 
2.1.2



More information about the xorg-devel mailing list