From 7b3010b26d4b704ae35bd89b570694cbffbea48c Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 21 Dec 2023 11:28:04 +1000 Subject: [PATCH] dix: initialize the XTest sendEventsProc for all devices XTest requests lets the client specify a device ID, only if none is specified do we fall back to the XTEST special device. As of commit aa4074251 input: Add new hook DeviceSendEventsProc for XTEST regular devices are no longer able to send XTest events because they have no sendEventsProc set. This caused issue #1574 and the crash was fixed with commit e820030de xtest: Check whether there is a sendEventsProc to call but we still cannot send XTest events through a specific device. Fix this by defaulting every device to the XTest send function and punting it to the DDX (i.e. Xwayland) to override the devices as necessary. Fixes e820030de2da3d0064f36504ccad53302e0f718d Fixes aa4074251fa6135f65687b39cf11e1432208846c (cherry picked from commit de0031eefd5648c2b7464efc2e89fede7c364097) --- Xext/xtest.c | 5 +---- dix/devices.c | 2 ++ include/exevents.h | 7 +++++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Xext/xtest.c b/Xext/xtest.c index 4d2910a60..f03d8c951 100644 --- a/Xext/xtest.c +++ b/Xext/xtest.c @@ -148,7 +148,7 @@ ProcXTestCompareCursor(ClientPtr client) return Success; } -static void +void XTestDeviceSendEvents(DeviceIntPtr dev, int type, int detail, @@ -645,9 +645,6 @@ AllocXTestDevice(ClientPtr client, const char *name, XIGetKnownProperty(XI_PROP_XTEST_DEVICE), FALSE); XIRegisterPropertyHandler(*keybd, DeviceSetXTestProperty, NULL, NULL); - - (*ptr)->sendEventsProc = XTestDeviceSendEvents; - (*keybd)->sendEventsProc = XTestDeviceSendEvents; } free(xtestname); diff --git a/dix/devices.c b/dix/devices.c index 257dad184..8fe4a341c 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -283,6 +283,8 @@ AddInputDevice(ClientPtr client, DeviceProc deviceProc, Bool autoStart) dev->deviceGrab.DeactivateGrab = DeactivateKeyboardGrab; dev->deviceGrab.sync.event = calloc(1, sizeof(InternalEvent)); + dev->sendEventsProc = XTestDeviceSendEvents; + XkbSetExtension(dev, ProcessKeyboardEvent); dev->coreEvents = TRUE; diff --git a/include/exevents.h b/include/exevents.h index c900c7b2c..7e3029fc9 100644 --- a/include/exevents.h +++ b/include/exevents.h @@ -305,4 +305,11 @@ XISetEventMask(DeviceIntPtr dev, WindowPtr win, ClientPtr client, extern int XICheckInvalidMaskBits(ClientPtr client, unsigned char *mask, int len); +void +XTestDeviceSendEvents(DeviceIntPtr dev, + int type, + int detail, + int flags, + const ValuatorMask *mask); + #endif /* EXEVENTS_H */