[PATCH 1/3] XKB: Split filter execution into a separate function
Peter Hutterer
peter.hutterer at who-t.net
Thu Nov 27 21:58:57 PST 2014
On Mon, Nov 24, 2014 at 10:17:32PM +0000, Daniel Stone wrote:
> 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: Daniel Stone <daniels at collabora.com>
> Tested-by: Giulio Camuffo <giuliocamuffo at gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
Cheers,
Peter
> ---
> xkb/xkbActions.c | 144 +++++++++++++++++++++++++++++--------------------------
> 1 file changed, 76 insertions(+), 68 deletions(-)
>
> diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c
> index c44f44b..c6cbf56 100644
> --- a/xkb/xkbActions.c
> +++ b/xkb/xkbActions.c
> @@ -1192,6 +1192,80 @@ XkbPushLockedStateToSlaves(DeviceIntPtr master, int evtype, int key)
> }
> }
>
> +static void
> +XkbActionGetFilter(DeviceIntPtr dev, DeviceEvent *event, KeyCode key,
> + XkbAction *act, int *sendEvent)
> +{
> + XkbSrvInfoPtr xkbi = dev->key->xkbInfo;
> + XkbFilterPtr filter;
> +
> + switch (act->type) {
> + case XkbSA_SetMods:
> + case XkbSA_SetGroup:
> + filter = _XkbNextFreeFilter(xkbi);
> + *sendEvent = _XkbFilterSetState(xkbi, filter, key, act);
> + break;
> + case XkbSA_LatchMods:
> + case XkbSA_LatchGroup:
> + filter = _XkbNextFreeFilter(xkbi);
> + *sendEvent = _XkbFilterLatchState(xkbi, filter, key, act);
> + break;
> + case XkbSA_LockMods:
> + case XkbSA_LockGroup:
> + filter = _XkbNextFreeFilter(xkbi);
> + *sendEvent = _XkbFilterLockState(xkbi, filter, key, act);
> + break;
> + case XkbSA_ISOLock:
> + filter = _XkbNextFreeFilter(xkbi);
> + *sendEvent = _XkbFilterISOLock(xkbi, filter, key, act);
> + break;
> + case XkbSA_MovePtr:
> + filter = _XkbNextFreeFilter(xkbi);
> + *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);
> + break;
> + case XkbSA_Terminate:
> + *sendEvent = XkbDDXTerminateServer(dev, key, act);
> + break;
> + case XkbSA_SwitchScreen:
> + filter = _XkbNextFreeFilter(xkbi);
> + *sendEvent = _XkbFilterSwitchScreen(xkbi, filter, key, act);
> + break;
> + case XkbSA_SetControls:
> + case XkbSA_LockControls:
> + filter = _XkbNextFreeFilter(xkbi);
> + *sendEvent = _XkbFilterControls(xkbi, filter, key, act);
> + break;
> + case XkbSA_ActionMessage:
> + filter = _XkbNextFreeFilter(xkbi);
> + *sendEvent = _XkbFilterActionMessage(xkbi, filter, key, act);
> + break;
> + case XkbSA_RedirectKey:
> + filter = _XkbNextFreeFilter(xkbi);
> + /* redirect actions must create a new DeviceEvent. The
> + * source device id for this event cannot be obtained from
> + * 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);
> + break;
> + case XkbSA_DeviceBtn:
> + case XkbSA_LockDeviceBtn:
> + filter = _XkbNextFreeFilter(xkbi);
> + *sendEvent = _XkbFilterDeviceBtn(xkbi, filter, key, act);
> + break;
> + case XkbSA_XFree86Private:
> + filter = _XkbNextFreeFilter(xkbi);
> + *sendEvent = _XkbFilterXF86Private(xkbi, filter, key, act);
> + break;
> + }
> +}
> +
> void
> XkbHandleActions(DeviceIntPtr dev, DeviceIntPtr kbd, DeviceEvent *event)
> {
> @@ -1201,7 +1275,6 @@ XkbHandleActions(DeviceIntPtr dev, DeviceIntPtr kbd, DeviceEvent *event)
> int sendEvent;
> Bool genStateNotify;
> XkbAction act;
> - XkbFilterPtr filter;
> Bool keyEvent;
> Bool pressEvent;
> ProcessInputProc backupproc;
> @@ -1229,74 +1302,9 @@ XkbHandleActions(DeviceIntPtr dev, DeviceIntPtr kbd, DeviceEvent *event)
> act = XkbGetButtonAction(kbd, dev, key);
> key |= BTN_ACT_FLAG;
> }
> +
> sendEvent = _XkbApplyFilters(xkbi, key, &act);
> - if (sendEvent) {
> - switch (act.type) {
> - case XkbSA_SetMods:
> - case XkbSA_SetGroup:
> - filter = _XkbNextFreeFilter(xkbi);
> - sendEvent = _XkbFilterSetState(xkbi, filter, key, &act);
> - break;
> - case XkbSA_LatchMods:
> - case XkbSA_LatchGroup:
> - filter = _XkbNextFreeFilter(xkbi);
> - sendEvent = _XkbFilterLatchState(xkbi, filter, key, &act);
> - break;
> - case XkbSA_LockMods:
> - case XkbSA_LockGroup:
> - filter = _XkbNextFreeFilter(xkbi);
> - sendEvent = _XkbFilterLockState(xkbi, filter, key, &act);
> - break;
> - case XkbSA_ISOLock:
> - filter = _XkbNextFreeFilter(xkbi);
> - sendEvent = _XkbFilterISOLock(xkbi, filter, key, &act);
> - break;
> - case XkbSA_MovePtr:
> - filter = _XkbNextFreeFilter(xkbi);
> - 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);
> - break;
> - case XkbSA_Terminate:
> - sendEvent = XkbDDXTerminateServer(dev, key, &act);
> - break;
> - case XkbSA_SwitchScreen:
> - filter = _XkbNextFreeFilter(xkbi);
> - sendEvent = _XkbFilterSwitchScreen(xkbi, filter, key, &act);
> - break;
> - case XkbSA_SetControls:
> - case XkbSA_LockControls:
> - filter = _XkbNextFreeFilter(xkbi);
> - sendEvent = _XkbFilterControls(xkbi, filter, key, &act);
> - break;
> - case XkbSA_ActionMessage:
> - filter = _XkbNextFreeFilter(xkbi);
> - sendEvent = _XkbFilterActionMessage(xkbi, filter, key, &act);
> - break;
> - case XkbSA_RedirectKey:
> - filter = _XkbNextFreeFilter(xkbi);
> - /* redirect actions must create a new DeviceEvent. The
> - * source device id for this event cannot be obtained from
> - * 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);
> - break;
> - case XkbSA_DeviceBtn:
> - case XkbSA_LockDeviceBtn:
> - filter = _XkbNextFreeFilter(xkbi);
> - sendEvent = _XkbFilterDeviceBtn(xkbi, filter, key, &act);
> - break;
> - case XkbSA_XFree86Private:
> - filter = _XkbNextFreeFilter(xkbi);
> - sendEvent = _XkbFilterXF86Private(xkbi, filter, key, &act);
> - break;
> - }
> - }
> + XkbActionGetFilter(dev, event, key, &act, &sendEvent);
> }
> else {
> if (!keyEvent)
> --
> 2.1.0
>
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
>
More information about the xorg-devel
mailing list