Commit 2e61901e authored by Daniel Stone's avatar Daniel Stone Committed by Peter Hutterer

XKB: Split filter execution into a separate function

Move the giant state machine which maps from a key action to actually
running the filters into a separate function, to be used when adding
KeyFocusIn.
Signed-off-by: 's avatarDaniel Stone <daniels@collabora.com>
Tested-by: 's avatarGiulio Camuffo <giuliocamuffo@gmail.com>
Reviewed-by: 's avatarPeter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: 's avatarPeter Hutterer <peter.hutterer@who-t.net>
parent 71ba8269
......@@ -1199,90 +1199,58 @@ XkbPushLockedStateToSlaves(DeviceIntPtr master, int evtype, int key)
}
}
void
XkbHandleActions(DeviceIntPtr dev, DeviceIntPtr kbd, DeviceEvent *event)
static void
XkbActionGetFilter(DeviceIntPtr dev, DeviceEvent *event, KeyCode key,
XkbAction *act, int *sendEvent)
{
int key, bit, i;
XkbSrvInfoPtr xkbi;
KeyClassPtr keyc;
int sendEvent;
Bool genStateNotify;
XkbAction act;
XkbSrvInfoPtr xkbi = dev->key->xkbInfo;
XkbFilterPtr filter;
Bool keyEvent;
Bool pressEvent;
ProcessInputProc backupproc;
xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev);
keyc = kbd->key;
xkbi = keyc->xkbInfo;
key = event->detail.key;
genStateNotify = _XkbEnsureStateChange(xkbi);
xkbi->clearMods = xkbi->setMods = 0;
xkbi->groupChange = 0;
sendEvent = 1;
keyEvent = ((event->type == ET_KeyPress) || (event->type == ET_KeyRelease));
pressEvent = ((event->type == ET_KeyPress) ||
(event->type == ET_ButtonPress));
if (pressEvent) {
if (keyEvent)
act = XkbGetKeyAction(xkbi, &xkbi->state, key);
else {
act = XkbGetButtonAction(kbd, dev, key);
key |= BTN_ACT_FLAG;
}
sendEvent = _XkbApplyFilters(xkbi, key, &act);
if (sendEvent) {
switch (act.type) {
switch (act->type) {
case XkbSA_SetMods:
case XkbSA_SetGroup:
filter = _XkbNextFreeFilter(xkbi);
sendEvent = _XkbFilterSetState(xkbi, filter, key, &act);
*sendEvent = _XkbFilterSetState(xkbi, filter, key, act);
break;
case XkbSA_LatchMods:
case XkbSA_LatchGroup:
filter = _XkbNextFreeFilter(xkbi);
sendEvent = _XkbFilterLatchState(xkbi, filter, key, &act);
*sendEvent = _XkbFilterLatchState(xkbi, filter, key, act);
break;
case XkbSA_LockMods:
case XkbSA_LockGroup:
filter = _XkbNextFreeFilter(xkbi);
sendEvent = _XkbFilterLockState(xkbi, filter, key, &act);
*sendEvent = _XkbFilterLockState(xkbi, filter, key, act);
break;
case XkbSA_ISOLock:
filter = _XkbNextFreeFilter(xkbi);
sendEvent = _XkbFilterISOLock(xkbi, filter, key, &act);
*sendEvent = _XkbFilterISOLock(xkbi, filter, key, act);
break;
case XkbSA_MovePtr:
filter = _XkbNextFreeFilter(xkbi);
sendEvent = _XkbFilterPointerMove(xkbi, filter, key, &act);
*sendEvent = _XkbFilterPointerMove(xkbi, filter, key, act);
break;
case XkbSA_PtrBtn:
case XkbSA_LockPtrBtn:
case XkbSA_SetPtrDflt:
filter = _XkbNextFreeFilter(xkbi);
sendEvent = _XkbFilterPointerBtn(xkbi, filter, key, &act);
*sendEvent = _XkbFilterPointerBtn(xkbi, filter, key, act);
break;
case XkbSA_Terminate:
sendEvent = XkbDDXTerminateServer(dev, key, &act);
*sendEvent = XkbDDXTerminateServer(dev, key, act);
break;
case XkbSA_SwitchScreen:
filter = _XkbNextFreeFilter(xkbi);
sendEvent = _XkbFilterSwitchScreen(xkbi, filter, key, &act);
*sendEvent = _XkbFilterSwitchScreen(xkbi, filter, key, act);
break;
case XkbSA_SetControls:
case XkbSA_LockControls:
filter = _XkbNextFreeFilter(xkbi);
sendEvent = _XkbFilterControls(xkbi, filter, key, &act);
*sendEvent = _XkbFilterControls(xkbi, filter, key, act);
break;
case XkbSA_ActionMessage:
filter = _XkbNextFreeFilter(xkbi);
sendEvent = _XkbFilterActionMessage(xkbi, filter, key, &act);
*sendEvent = _XkbFilterActionMessage(xkbi, filter, key, act);
break;
case XkbSA_RedirectKey:
filter = _XkbNextFreeFilter(xkbi);
......@@ -1291,19 +1259,59 @@ XkbHandleActions(DeviceIntPtr dev, DeviceIntPtr kbd, DeviceEvent *event)
* xkbi, so we pass it here explicitly. The field deviceid
* equals to xkbi->device->id. */
filter->priv = event->sourceid;
sendEvent = _XkbFilterRedirectKey(xkbi, filter, key, &act);
*sendEvent = _XkbFilterRedirectKey(xkbi, filter, key, act);
break;
case XkbSA_DeviceBtn:
case XkbSA_LockDeviceBtn:
filter = _XkbNextFreeFilter(xkbi);
sendEvent = _XkbFilterDeviceBtn(xkbi, filter, key, &act);
*sendEvent = _XkbFilterDeviceBtn(xkbi, filter, key, act);
break;
case XkbSA_XFree86Private:
filter = _XkbNextFreeFilter(xkbi);
sendEvent = _XkbFilterXF86Private(xkbi, filter, key, &act);
*sendEvent = _XkbFilterXF86Private(xkbi, filter, key, act);
break;
}
}
void
XkbHandleActions(DeviceIntPtr dev, DeviceIntPtr kbd, DeviceEvent *event)
{
int key, bit, i;
XkbSrvInfoPtr xkbi;
KeyClassPtr keyc;
int sendEvent;
Bool genStateNotify;
XkbAction act;
Bool keyEvent;
Bool pressEvent;
ProcessInputProc backupproc;
xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev);
keyc = kbd->key;
xkbi = keyc->xkbInfo;
key = event->detail.key;
genStateNotify = _XkbEnsureStateChange(xkbi);
xkbi->clearMods = xkbi->setMods = 0;
xkbi->groupChange = 0;
sendEvent = 1;
keyEvent = ((event->type == ET_KeyPress) || (event->type == ET_KeyRelease));
pressEvent = ((event->type == ET_KeyPress) ||
(event->type == ET_ButtonPress));
if (pressEvent) {
if (keyEvent)
act = XkbGetKeyAction(xkbi, &xkbi->state, key);
else {
act = XkbGetButtonAction(kbd, dev, key);
key |= BTN_ACT_FLAG;
}
sendEvent = _XkbApplyFilters(xkbi, key, &act);
XkbActionGetFilter(dev, event, key, &act, &sendEvent);
}
else {
if (!keyEvent)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment