input: Add new hook DeviceSendEventsProc for XTEST

For Xwayland, we need to be able to send the events that would normally
be processed by the normal Xserver event processing to be forwarded to
the Wayland compositor (somehow).

Add a new hook “DeviceSendEventsProc” attached to the device so that
Xwayland can implement its own routine instead of the “normal” XTEST
implementation which generates and processes X input events.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
This commit is contained in:
Olivier Fourdan 2020-06-18 14:34:58 +02:00
parent 9f3559d5c0
commit aa4074251f
3 changed files with 41 additions and 21 deletions

View File

@ -148,6 +148,35 @@ ProcXTestCompareCursor(ClientPtr client)
return Success;
}
static void
XTestDeviceSendEvents(DeviceIntPtr dev,
int type,
int detail,
int flags,
const ValuatorMask *mask)
{
int nevents = 0;
int i;
switch (type) {
case MotionNotify:
nevents = GetPointerEvents(xtest_evlist, dev, type, 0, flags, mask);
break;
case ButtonPress:
case ButtonRelease:
nevents = GetPointerEvents(xtest_evlist, dev, type, detail, flags, mask);
break;
case KeyPress:
case KeyRelease:
nevents =
GetKeyboardEvents(xtest_evlist, dev, type, detail);
break;
}
for (i = 0; i < nevents; i++)
mieqProcessDeviceEvent(dev, &xtest_evlist[i], miPointerGetScreen(inputInfo.pointer));
}
static int
ProcXTestFakeInput(ClientPtr client)
{
@ -161,8 +190,6 @@ ProcXTestFakeInput(ClientPtr client)
int valuators[MAX_VALUATORS] = { 0 };
int numValuators = 0;
int firstValuator = 0;
int nevents = 0;
int i;
int base = 0;
int flags = 0;
int need_ptr_update = 1;
@ -408,26 +435,9 @@ ProcXTestFakeInput(ClientPtr client)
if (screenIsSaved == SCREEN_SAVER_ON)
dixSaveScreens(serverClient, SCREEN_SAVER_OFF, ScreenSaverReset);
switch (type) {
case MotionNotify:
valuator_mask_set_range(&mask, firstValuator, numValuators, valuators);
nevents = GetPointerEvents(xtest_evlist, dev, type, 0, flags, &mask);
break;
case ButtonPress:
case ButtonRelease:
valuator_mask_set_range(&mask, firstValuator, numValuators, valuators);
nevents = GetPointerEvents(xtest_evlist, dev, type, ev->u.u.detail,
flags, &mask);
break;
case KeyPress:
case KeyRelease:
nevents =
GetKeyboardEvents(xtest_evlist, dev, type, ev->u.u.detail);
break;
}
valuator_mask_set_range(&mask, firstValuator, numValuators, valuators);
for (i = 0; i < nevents; i++)
mieqProcessDeviceEvent(dev, &xtest_evlist[i], miPointerGetScreen(inputInfo.pointer));
(*dev->sendEventsProc) (dev, type, ev->u.u.detail, flags, &mask);
if (need_ptr_update)
miPointerUpdateSprite(dev);
@ -634,6 +644,9 @@ 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);

View File

@ -191,6 +191,12 @@ typedef Bool (*PointerAccelSchemeInitProc) (DeviceIntPtr /*dev */ ,
struct _ValuatorAccelerationRec *
/*protoScheme */ );
typedef void (*DeviceSendEventsProc) (DeviceIntPtr /*dev */ ,
int /* event type */ ,
int /* detail, buttons or keycode */ ,
int /* flags */ ,
const ValuatorMask * /* valuators */ );
typedef struct _DeviceRec {
void *devicePrivate;
ProcessInputProc processInputProc; /* current */

View File

@ -628,6 +628,7 @@ typedef struct _DeviceIntRec {
/* XTest related master device id */
int xtest_master_id;
DeviceSendEventsProc sendEventsProc;
struct _SyncCounter *idle_counter;
} DeviceIntRec;