From e391956a6a8995f8deeb900553d163f7efdf37de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Sat, 26 Apr 2025 22:45:35 +0200 Subject: [PATCH 1/2] Correctly label pointing device as absolute, not relative The input device actually reports absolute events, not relative. Interestingly it worked before, probably because of InitAbsoluteClassDeviceStruct, but some applications were confused about mismatching mode. Adjust also min/max values based on max resolution supported by the qubes dummy driver. Fixes QubesOS/qubes-issues#7316 --- xf86-input-mfndev/src/qubes.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/xf86-input-mfndev/src/qubes.c b/xf86-input-mfndev/src/qubes.c index 350640e1..cc5c2dba 100644 --- a/xf86-input-mfndev/src/qubes.c +++ b/xf86-input-mfndev/src/qubes.c @@ -328,8 +328,8 @@ static void QubesInitAxesLabels(QubesDevicePtr pQubes, int natoms, const char **labels; int labels_len = 0; - labels = rel_labels; - labels_len = ArrayLength(rel_labels); + labels = abs_labels; + labels_len = ArrayLength(abs_labels); memset(atoms, 0, natoms * sizeof(Atom)); @@ -360,11 +360,12 @@ static int _qubes_init_axes(DeviceIntPtr device) #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7 atoms, #endif - GetMotionHistorySize(), 0)) + GetMotionHistorySize(), + Absolute)) return BadAlloc; #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 12 - pInfo->dev->valuator->mode = Relative; + pInfo->dev->valuator->mode = Absolute; #endif #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 13 if (!InitAbsoluteClassDeviceStruct(device)) @@ -372,10 +373,10 @@ static int _qubes_init_axes(DeviceIntPtr device) #endif for (i = 0; i < pQubes->axes; i++) { - xf86InitValuatorAxisStruct(device, i, *pQubes->labels, -1, - -1, 1, 1, 1 + xf86InitValuatorAxisStruct(device, i, atoms[i], 0, + 32767, 1, 1, 1 #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 12 - , Relative + , Absolute #endif ); xf86InitValuatorDefaults(device, i); From 6898bf9d51cf66dd77418901b465ed841dfd440a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Thu, 8 May 2025 19:40:17 +0200 Subject: [PATCH 2/2] Add error checking on input device init --- xf86-input-mfndev/src/qubes.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/xf86-input-mfndev/src/qubes.c b/xf86-input-mfndev/src/qubes.c index cc5c2dba..81eaecf0 100644 --- a/xf86-input-mfndev/src/qubes.c +++ b/xf86-input-mfndev/src/qubes.c @@ -263,7 +263,8 @@ static void QubesUnInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags) static int _qubes_init_kbd(DeviceIntPtr device) { - InitKeyboardDeviceStruct(device, NULL, NULL, NULL); + if (!InitKeyboardDeviceStruct(device, NULL, NULL, NULL)) + return BadAlloc; return Success; } @@ -485,14 +486,22 @@ static int QubesControl(DeviceIntPtr device, int what) InputInfoPtr pInfo = device->public.devicePrivate; QubesDevicePtr pQubes = pInfo->private; DeviceIntPtr master_kbd = NULL; + int ret; switch (what) { case DEVICE_INIT: device->public.on = FALSE; - _qubes_init_buttons(device); - _qubes_init_axes(device); - _qubes_init_kbd(device); - InitPtrFeedbackClassDeviceStruct(device, QubesPtrCtrlProc); + ret = _qubes_init_buttons(device); + if (ret != Success) + return ret; + ret = _qubes_init_axes(device); + if (ret != Success) + return ret; + ret = _qubes_init_kbd(device); + if (ret != Success) + return ret; + if (!InitPtrFeedbackClassDeviceStruct(device, QubesPtrCtrlProc)) + return BadAlloc; break; /* Switch device on. Establish socket, start event delivery. */