#!/bin/sh # Build script for xf86-input-mouse (autotools, Template A). # # Phase 2 Task 4 (M3). Ships a pre-generated `configure` - straight Template A, # same shape as xf86-input-keyboard. # # Patches (patches/, applied below): # 01-6892799-mouse-fd-persist.patch - reorder DEVICE_ON/DEVICE_OFF/ # DEVICE_CLOSE in src/mouse.c so the /dev/mouse fd (+ Xisb buffer) is # opened once and closed only at DEVICE_CLOSE, surviving console mode # switches (VT enter/leave otherwise churns close()/open() on the VUID # stream on every switch). Equivalent of OI's 01-6892799.patch. # # Module install dir: same reasoning as xf86-input-keyboard - configure.ac # computes inputdir=${moduledir}/input, so pass --with-xorg-module-dir # pointing at .../xlibre-25/drivers so the result lands at # .../xlibre-25/drivers/input, matching xorg-server.pc's input_drivers_dir. set -e # Resolve the port dir (holds patches/) BEFORE cd'ing into the extracted source. PORTDIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) cd "$SRCDIR" # --- Hammerhead/illumos portability patches --- for p in "$PORTDIR"/patches/*.patch; do [ -f "$p" ] || continue echo "==> Applying patch: $(basename "$p")" patch -p1 < "$p" done export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH" export CFLAGS="${CFLAGS} -I$PREFIX/include -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS" export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib" # sun_mouse.c's CheckRelToAbs() calls libdevinfo's di_init()/di_walk_node() # under HAVE_ABSOLUTE_MOUSE_SCALING (on by default), but neither # configure.ac nor src/Makefile.am declares the libdevinfo dependency # anywhere - a genuine upstream build-system gap for the Solaris/illumos # path, not something a source patch fixes. automake's generated link line # includes $(LIBS), so just set it before configure so it gets baked into # mouse_drv.la's link command. Found at Xorg startup (ld.so.1 relocation # error: symbol di_init not found), not at compile time - configure/gmake # both succeed without this; only actually loading the .so into Xorg fails. export LIBS="${LIBS} -ldevinfo" # MANDATORY libtool fix (Template A) - piggyback hammerhead onto the # kopensolaris arm in configure's dynamic-linker case block. if [ -f configure ]; then sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure fi # OS-detection fix: the generated configure picks the source file to build # via `case $host_os in ... solaris*) OS_MOUSE_NAME=sun ;; ... esac`, then # src/Makefile.am uses @OS_MOUSE_NAME@_mouse.c. Our host_os is "hammerhead", # not "solaris*", so OS_MOUSE_NAME is left empty and the build tries to # compile a literal "_mouse.c" (missing file). Piggyback hammerhead* onto # the solaris* arm so OS_MOUSE_NAME=sun selects sun_mouse.c (the VUID # /dev/mouse backend this task is porting). if [ -f configure ]; then sed -i -E 's/^ solaris\*\)$/ solaris* | hammerhead*)/' configure fi ./configure \ --prefix="$PREFIX" \ --build="$BUILD_TRIPLE" \ --host="$BUILD_TRIPLE" \ --sysconfdir="$SYSCONFDIR" \ --disable-static \ --with-xorg-module-dir="$PREFIX/lib/xorg/modules/xlibre-25/drivers" gmake -j${JOBS:-1} gmake install DESTDIR="$PKGDIR" # xf86-input-mouse - X.Org mouse input driver # # Phase 2 Task 4 (M3): the VUID /dev/mouse backend (src/mouse.c / # src/sun_mouse.c) is already upstream. One local patch reorders the # DEVICE_ON/DEVICE_OFF/DEVICE_CLOSE handling in src/mouse.c so the # /dev/mouse fd is opened once (at first DEVICE_ON) and closed only at # DEVICE_CLOSE, instead of being closed/reopened on every console mode # switch (see patches/01-6892799-mouse-fd-persist.patch). That same patch # also defines a local `sign()` macro fallback in src/mouse.c: this old # (2019-era) driver relies on the X server's misc.h `sign()` macro, which # the XLibre 25.1.8 SDK no longer provides - an SDK-drift build failure # unrelated to the VUID port itself, found on first alpha10 build attempt. [package] name = "xf86-input-mouse" version = "1.9.5" release = 1 description = "X.Org mouse input driver (illumos /dev/mouse VUID backend)" url = "https://gitlab.freedesktop.org/xorg/driver/xf86-input-mouse" license = "MIT" maintainer = "Chris Tusa " arch = "x86_64" [dependencies] runtime = ["xlibre-xserver-xorg"] build = ["xlibre-xserver-xorg", "util-macros"] [[source]] file = "xf86-input-mouse-1.9.5.tar.gz" urls = ["https://www.x.org/archive/individual/driver/xf86-input-mouse-1.9.5.tar.gz"] checksum = "dc75c9e97f269b5edf80b3bb17ecac7f31c093cd27f74b5220b9d07ee63e0b25" extract = true [build] parallel = true --- a/src/mouse.c 2026-07-23 13:55:22.649216163 -0500 +++ b/src/mouse.c 2026-07-23 14:01:32.777853582 -0500 @@ -1772,6 +1772,26 @@ break; case DEVICE_ON: + /* + * illumos/Solaris CR 6892799 fix: the VUID /dev/mouse stream + * (unlike a plain serial line) does not tolerate being closed + * and reopened across every console mode switch (X VT + * enter/leave toggles DEVICE_OFF/DEVICE_ON around each + * switch). Keep the fd + Xisb buffer alive once opened; only + * (re)open here on the very first DEVICE_ON, or if a prior + * open attempt failed. DEVICE_OFF no longer closes the fd - + * the real close now happens once, in DEVICE_CLOSE. + */ + if (pInfo->fd != -1) { + /* Already open from a previous DEVICE_ON - just re-enable. */ + xf86FlushInput(pInfo->fd); + xf86AddEnabledDevice(pInfo); + if (pMse->emulate3Buttons || pMse->emulate3ButtonsSoft) { + RegisterBlockAndWakeupHandlers (MouseBlockHandler, + MouseWakeupHandler, + (pointer) pInfo); + } + } else { pInfo->fd = xf86OpenSerial(pInfo->options); if (pInfo->fd == -1) xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name); @@ -1820,6 +1840,7 @@ } } } + } pMse->lastButtons = 0; pMse->lastMappedButtons = 0; pMse->emulateState = 0; @@ -1832,12 +1853,11 @@ case DEVICE_OFF: if (pInfo->fd != -1) { xf86RemoveEnabledDevice(pInfo); - if (pMse->buffer) { - XisbFree(pMse->buffer); - pMse->buffer = NULL; - } - xf86CloseSerial(pInfo->fd); - pInfo->fd = -1; + /* + * 6892799: do NOT close/free the buffer or fd here - the + * VUID /dev/mouse stream must survive the mode switch. + * Actual teardown is deferred to DEVICE_CLOSE. + */ if (pMse->emulate3Buttons || pMse->emulate3ButtonsSoft) { RemoveBlockAndWakeupHandlers (MouseBlockHandler, @@ -1848,6 +1868,16 @@ device->public.on = FALSE; break; case DEVICE_CLOSE: + /* 6892799: the fd/buffer were kept open across DEVICE_OFF/ON + * cycles; do the real close here, once, at final teardown. */ + if (pInfo->fd != -1) { + if (pMse->buffer) { + XisbFree(pMse->buffer); + pMse->buffer = NULL; + } + xf86CloseSerial(pInfo->fd); + pInfo->fd = -1; + } free(pMse->mousePriv); pMse->mousePriv = NULL; break; @@ -3738,6 +3768,16 @@ #define VAL_THRESHOLD 40 /* + * SDK-drift compat fix: mouse.c relies on the X server's misc.h `sign()` + * macro, which the XLibre 25.1.8 SDK this port builds against no longer + * provides (dropped upstream). Define the historical semantics locally if + * it is not already defined by the SDK. + */ +#ifndef sign +#define sign(x) ((x) > 0 ? 1 : ((x) < 0 ? -1 : 0)) +#endif + +/* * checkForErraticMovements() -- check if mouse 'jumps around'. */ static void