1 /************************************************************
2 * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
4 * Permission to use, copy, modify, and distribute this
5 * software and its documentation for any purpose and without
6 * fee is hereby granted, provided that the above copyright
7 * notice appear in all copies and that both that copyright
8 * notice and this permission notice appear in supporting
9 * documentation, and that the name of Silicon Graphics not be
10 * used in advertising or publicity pertaining to distribution
11 * of the software without specific prior written permission.
12 * Silicon Graphics makes no representation about the suitability
13 * of this software for any purpose. It is provided "as is"
14 * without any express or implied warranty.
16 * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
17 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
18 * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
19 * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
20 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
21 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
22 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
23 * THE USE OR PERFORMANCE OF THIS SOFTWARE.
25 ********************************************************/
28 * Copyright © 2012 Intel Corporation
29 * Copyright © 2012 Ran Benita <ran234@gmail.com>
31 * Permission is hereby granted, free of charge, to any person obtaining a
32 * copy of this software and associated documentation files (the "Software"),
33 * to deal in the Software without restriction, including without limitation
34 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
35 * and/or sell copies of the Software, and to permit persons to whom the
36 * Software is furnished to do so, subject to the following conditions:
38 * The above copyright notice and this permission notice (including the next
39 * paragraph) shall be included in all copies or substantial portions of the
42 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
43 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
44 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
45 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
46 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
47 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
48 * DEALINGS IN THE SOFTWARE.
50 * Author: Daniel Stone <daniel@fooishbar.org>
51 * Ran Benita <ran234@gmail.com>
54 #include "xkbcomp-priv.h"
60 static const ExprDef constTrue = {
61 .common = { .type = STMT_EXPR, .next = NULL },
63 .value_type = EXPR_TYPE_BOOLEAN,
64 .value = { .ival = 1 },
67 static const ExprDef constFalse = {
68 .common = { .type = STMT_EXPR, .next = NULL },
70 .value_type = EXPR_TYPE_BOOLEAN,
71 .value = { .ival = 0 },
75 ACTION_FIELD_CLEAR_LOCKS,
76 ACTION_FIELD_LATCH_TO_LOCK,
77 ACTION_FIELD_GEN_KEY_EVENT,
81 ACTION_FIELD_INCREMENT,
82 ACTION_FIELD_MODIFIERS,
89 ACTION_FIELD_CONTROLS,
97 ACTION_FIELD_MODS_TO_CLEAR,
106 info = calloc(1, sizeof(*info));
110 /* This includes PrivateAction. */
111 for (type = 0; type < ACTION_TYPE_LAST; type++)
112 info->actions[type].type = type;
114 /* Apply some "factory defaults". */
116 /* Increment default button. */
117 info->actions[ACTION_TYPE_PTR_DEFAULT].dflt.flags = 0;
118 info->actions[ACTION_TYPE_PTR_DEFAULT].dflt.value = 1;
124 FreeActionsInfo(ActionsInfo *info)
129 static const LookupEntry fieldStrings[] = {
130 { "clearLocks", ACTION_FIELD_CLEAR_LOCKS },
131 { "latchToLock", ACTION_FIELD_LATCH_TO_LOCK },
132 { "genKeyEvent", ACTION_FIELD_GEN_KEY_EVENT },
133 { "generateKeyEvent", ACTION_FIELD_GEN_KEY_EVENT },
134 { "report", ACTION_FIELD_REPORT },
135 { "default", ACTION_FIELD_DEFAULT },
136 { "affect", ACTION_FIELD_AFFECT },
137 { "increment", ACTION_FIELD_INCREMENT },
138 { "modifiers", ACTION_FIELD_MODIFIERS },
139 { "mods", ACTION_FIELD_MODIFIERS },
140 { "group", ACTION_FIELD_GROUP },
141 { "x", ACTION_FIELD_X },
142 { "y", ACTION_FIELD_Y },
143 { "accel", ACTION_FIELD_ACCEL },
144 { "accelerate", ACTION_FIELD_ACCEL },
145 { "repeat", ACTION_FIELD_ACCEL },
146 { "button", ACTION_FIELD_BUTTON },
147 { "value", ACTION_FIELD_VALUE },
148 { "controls", ACTION_FIELD_CONTROLS },
149 { "ctrls", ACTION_FIELD_CONTROLS },
150 { "type", ACTION_FIELD_TYPE },
151 { "count", ACTION_FIELD_COUNT },
152 { "screen", ACTION_FIELD_SCREEN },
153 { "same", ACTION_FIELD_SAME },
154 { "sameServer", ACTION_FIELD_SAME },
155 { "data", ACTION_FIELD_DATA },
156 { "device", ACTION_FIELD_DEVICE },
157 { "dev", ACTION_FIELD_DEVICE },
158 { "key", ACTION_FIELD_KEYCODE },
159 { "keycode", ACTION_FIELD_KEYCODE },
160 { "kc", ACTION_FIELD_KEYCODE },
161 { "clearmods", ACTION_FIELD_MODS_TO_CLEAR },
162 { "clearmodifiers", ACTION_FIELD_MODS_TO_CLEAR },
167 stringToAction(const char *str, unsigned *type_rtrn)
169 return LookupString(actionTypeNames, str, type_rtrn);
173 stringToField(const char *str, enum action_field *field_rtrn)
175 return LookupString(fieldStrings, str, field_rtrn);
179 fieldText(enum action_field field)
181 return LookupValue(fieldStrings, field);
184 /***====================================================================***/
187 ReportMismatch(struct xkb_keymap *keymap, enum xkb_action_type action,
188 enum action_field field, const char *type)
191 "Value of %s field must be of type %s; "
192 "Action %s definition ignored\n",
193 fieldText(field), type, ActionTypeText(action));
198 ReportIllegal(struct xkb_keymap *keymap, enum xkb_action_type action,
199 enum action_field field)
202 "Field %s is not defined for an action of type %s; "
203 "Action definition ignored\n",
204 fieldText(field), ActionTypeText(action));
209 ReportActionNotArray(struct xkb_keymap *keymap, enum xkb_action_type action,
210 enum action_field field)
213 "The %s field in the %s action is not an array; "
214 "Action definition ignored\n",
215 fieldText(field), ActionTypeText(action));
220 ReportNotFound(struct xkb_keymap *keymap, enum xkb_action_type action,
221 enum action_field field, const char *what, const char *bad)
224 "%s named %s not found; "
225 "Ignoring the %s field of an %s action\n",
226 what, bad, fieldText(field), ActionTypeText(action));
231 HandleNoAction(struct xkb_keymap *keymap, union xkb_action *action,
232 enum action_field field, const ExprDef *array_ndx,
233 const ExprDef *value)
240 CheckLatchLockFlags(struct xkb_keymap *keymap, enum xkb_action_type action,
241 enum action_field field, const ExprDef * value,
242 enum xkb_action_flags *flags_inout)
244 enum xkb_action_flags tmp;
247 if (field == ACTION_FIELD_CLEAR_LOCKS)
248 tmp = ACTION_LOCK_CLEAR;
249 else if (field == ACTION_FIELD_LATCH_TO_LOCK)
250 tmp = ACTION_LATCH_TO_LOCK;
252 return false; /* WSGO! */
254 if (!ExprResolveBoolean(keymap->ctx, value, &result))
255 return ReportMismatch(keymap, action, field, "boolean");
260 *flags_inout &= ~tmp;
266 CheckModifierField(struct xkb_keymap *keymap, enum xkb_action_type action,
267 const ExprDef *value, enum xkb_action_flags *flags_inout,
268 xkb_mod_mask_t *mods_rtrn)
270 if (value->op == EXPR_IDENT) {
272 valStr = xkb_atom_text(keymap->ctx, value->value.str);
273 if (valStr && (istreq(valStr, "usemodmapmods") ||
274 istreq(valStr, "modmapmods"))) {
277 *flags_inout |= ACTION_MODS_LOOKUP_MODMAP;
282 if (!ExprResolveVModMask(keymap, value, mods_rtrn))
283 return ReportMismatch(keymap, action,
284 ACTION_FIELD_MODIFIERS, "modifier mask");
286 *flags_inout &= ~ACTION_MODS_LOOKUP_MODMAP;
291 HandleSetLatchMods(struct xkb_keymap *keymap, union xkb_action *action,
292 enum action_field field, const ExprDef *array_ndx,
293 const ExprDef *value)
295 struct xkb_mod_action *act = &action->mods;
296 enum xkb_action_flags rtrn, t1;
299 if (array_ndx != NULL) {
301 case ACTION_FIELD_CLEAR_LOCKS:
302 case ACTION_FIELD_LATCH_TO_LOCK:
303 case ACTION_FIELD_MODIFIERS:
304 return ReportActionNotArray(keymap, action->type, field);
311 case ACTION_FIELD_CLEAR_LOCKS:
312 case ACTION_FIELD_LATCH_TO_LOCK:
314 if (CheckLatchLockFlags(keymap, action->type, field, value, &rtrn)) {
320 case ACTION_FIELD_MODIFIERS:
322 if (CheckModifierField(keymap, action->type, value, &t1, &t2)) {
333 return ReportIllegal(keymap, action->type, field);
337 HandleLockMods(struct xkb_keymap *keymap, union xkb_action *action,
338 enum action_field field, const ExprDef *array_ndx,
339 const ExprDef *value)
341 struct xkb_mod_action *act = &action->mods;
342 enum xkb_action_flags t1;
345 if (array_ndx && field == ACTION_FIELD_MODIFIERS)
346 return ReportActionNotArray(keymap, action->type, field);
349 case ACTION_FIELD_MODIFIERS:
351 if (CheckModifierField(keymap, action->type, value, &t1, &t2)) {
362 return ReportIllegal(keymap, action->type, field);
366 CheckGroupField(struct xkb_keymap *keymap, unsigned action,
367 const ExprDef *value, enum xkb_action_flags *flags_inout,
368 xkb_group_index_t *grp_rtrn)
372 if (value->op == EXPR_NEGATE || value->op == EXPR_UNARY_PLUS) {
373 *flags_inout &= ~ACTION_ABSOLUTE_SWITCH;
374 spec = value->value.child;
377 *flags_inout |= ACTION_ABSOLUTE_SWITCH;
381 if (!ExprResolveGroup(keymap->ctx, spec, grp_rtrn))
382 return ReportMismatch(keymap, action, ACTION_FIELD_GROUP,
383 "integer (range 1..8)");
385 if (value->op == EXPR_NEGATE)
386 *grp_rtrn = -*grp_rtrn;
387 else if (value->op != EXPR_UNARY_PLUS)
394 HandleSetLatchGroup(struct xkb_keymap *keymap, union xkb_action *action,
395 enum action_field field, const ExprDef *array_ndx,
396 const ExprDef *value)
398 struct xkb_group_action *act = &action->group;
399 enum xkb_action_flags rtrn, t1;
400 xkb_group_index_t t2;
402 if (array_ndx != NULL) {
404 case ACTION_FIELD_CLEAR_LOCKS:
405 case ACTION_FIELD_LATCH_TO_LOCK:
406 case ACTION_FIELD_GROUP:
407 return ReportActionNotArray(keymap, action->type, field);
415 case ACTION_FIELD_CLEAR_LOCKS:
416 case ACTION_FIELD_LATCH_TO_LOCK:
418 if (CheckLatchLockFlags(keymap, action->type, field, value, &rtrn)) {
424 case ACTION_FIELD_GROUP:
426 if (CheckGroupField(keymap, action->type, value, &t1, &t2)) {
437 return ReportIllegal(keymap, action->type, field);
441 HandleLockGroup(struct xkb_keymap *keymap, union xkb_action *action,
442 enum action_field field, const ExprDef *array_ndx,
443 const ExprDef *value)
445 struct xkb_group_action *act = &action->group;
446 enum xkb_action_flags t1;
447 xkb_group_index_t t2;
449 if ((array_ndx != NULL) && (field == ACTION_FIELD_GROUP))
450 return ReportActionNotArray(keymap, action->type, field);
451 if (field == ACTION_FIELD_GROUP) {
453 if (CheckGroupField(keymap, action->type, value, &t1, &t2)) {
460 return ReportIllegal(keymap, action->type, field);
464 HandleMovePtr(struct xkb_keymap *keymap, union xkb_action *action,
465 enum action_field field, const ExprDef *array_ndx,
466 const ExprDef *value)
468 struct xkb_pointer_action *act = &action->ptr;
471 if (array_ndx && (field == ACTION_FIELD_X || field == ACTION_FIELD_Y))
472 return ReportActionNotArray(keymap, action->type, field);
474 if (field == ACTION_FIELD_X || field == ACTION_FIELD_Y) {
477 if (value->op == EXPR_NEGATE || value->op == EXPR_UNARY_PLUS)
482 if (!ExprResolveInteger(keymap->ctx, value, &val))
483 return ReportMismatch(keymap, action->type, field, "integer");
485 if (field == ACTION_FIELD_X) {
487 act->flags |= ACTION_ABSOLUTE_X;
492 act->flags |= ACTION_ABSOLUTE_Y;
498 else if (field == ACTION_FIELD_ACCEL) {
501 if (!ExprResolveBoolean(keymap->ctx, value, &set))
502 return ReportMismatch(keymap, action->type, field, "boolean");
505 act->flags &= ~ACTION_NO_ACCEL;
507 act->flags |= ACTION_NO_ACCEL;
510 return ReportIllegal(keymap, action->type, field);
513 static const LookupEntry lockWhich[] = {
515 { "lock", ACTION_LOCK_NO_UNLOCK },
516 { "neither", (ACTION_LOCK_NO_LOCK | ACTION_LOCK_NO_UNLOCK) },
517 { "unlock", ACTION_LOCK_NO_LOCK },
522 HandlePtrBtn(struct xkb_keymap *keymap, union xkb_action *action,
523 enum action_field field, const ExprDef *array_ndx,
524 const ExprDef *value)
526 struct xkb_pointer_button_action *act = &action->btn;
528 if (field == ACTION_FIELD_BUTTON) {
532 return ReportActionNotArray(keymap, action->type, field);
534 if (!ExprResolveButton(keymap->ctx, value, &btn))
535 return ReportMismatch(keymap, action->type, field,
536 "integer (range 1..5)");
538 if (btn < 0 || btn > 5) {
540 "Button must specify default or be in the range 1..5; "
541 "Illegal button value %d ignored\n", btn);
548 else if (action->type == ACTION_TYPE_PTR_LOCK &&
549 field == ACTION_FIELD_AFFECT) {
550 enum xkb_action_flags val;
553 return ReportActionNotArray(keymap, action->type, field);
555 if (!ExprResolveEnum(keymap->ctx, value, &val, lockWhich))
556 return ReportMismatch(keymap, action->type, field,
559 act->flags &= ~(ACTION_LOCK_NO_LOCK | ACTION_LOCK_NO_UNLOCK);
563 else if (field == ACTION_FIELD_COUNT) {
567 return ReportActionNotArray(keymap, action->type, field);
569 /* XXX: Should this actually be ResolveButton? */
570 if (!ExprResolveButton(keymap->ctx, value, &btn))
571 return ReportMismatch(keymap, action->type, field, "integer");
573 if (btn < 0 || btn > 255) {
575 "The count field must have a value in the range 0..255; "
576 "Illegal count %d ignored\n", btn);
583 return ReportIllegal(keymap, action->type, field);
586 static const LookupEntry ptrDflts[] = {
588 { "defaultbutton", 1 },
594 HandleSetPtrDflt(struct xkb_keymap *keymap, union xkb_action *action,
595 enum action_field field, const ExprDef *array_ndx,
596 const ExprDef *value)
598 struct xkb_pointer_default_action *act = &action->dflt;
600 if (field == ACTION_FIELD_AFFECT) {
604 return ReportActionNotArray(keymap, action->type, field);
606 if (!ExprResolveEnum(keymap->ctx, value, &val, ptrDflts))
607 return ReportMismatch(keymap, action->type, field,
608 "pointer component");
611 else if (field == ACTION_FIELD_BUTTON || field == ACTION_FIELD_VALUE) {
612 const ExprDef *button;
616 return ReportActionNotArray(keymap, action->type, field);
618 if (value->op == EXPR_NEGATE || value->op == EXPR_UNARY_PLUS) {
619 act->flags &= ~ACTION_ABSOLUTE_SWITCH;
620 button = value->value.child;
623 act->flags |= ACTION_ABSOLUTE_SWITCH;
627 if (!ExprResolveButton(keymap->ctx, button, &btn))
628 return ReportMismatch(keymap, action->type, field,
629 "integer (range 1..5)");
631 if (btn < 0 || btn > 5) {
633 "New default button value must be in the range 1..5; "
634 "Illegal default button value %d ignored\n", btn);
639 "Cannot set default pointer button to \"default\"; "
640 "Illegal default button setting ignored\n");
644 act->value = (value->op == EXPR_NEGATE ? -btn: btn);
648 return ReportIllegal(keymap, action->type, field);
652 HandleSwitchScreen(struct xkb_keymap *keymap, union xkb_action *action,
653 enum action_field field, const ExprDef *array_ndx,
654 const ExprDef *value)
656 struct xkb_switch_screen_action *act = &action->screen;
658 if (field == ACTION_FIELD_SCREEN) {
663 return ReportActionNotArray(keymap, action->type, field);
665 if (value->op == EXPR_NEGATE || value->op == EXPR_UNARY_PLUS) {
666 act->flags &= ~ACTION_ABSOLUTE_SWITCH;
667 scrn = value->value.child;
670 act->flags |= ACTION_ABSOLUTE_SWITCH;
674 if (!ExprResolveInteger(keymap->ctx, scrn, &val))
675 return ReportMismatch(keymap, action->type, field,
678 if (val < 0 || val > 255) {
680 "Screen index must be in the range 1..255; "
681 "Illegal screen value %d ignored\n", val);
685 act->screen = (value->op == EXPR_NEGATE ? -val : val);
688 else if (field == ACTION_FIELD_SAME) {
692 return ReportActionNotArray(keymap, action->type, field);
694 if (!ExprResolveBoolean(keymap->ctx, value, &set))
695 return ReportMismatch(keymap, action->type, field, "boolean");
698 act->flags &= ~ACTION_SAME_SCREEN;
700 act->flags |= ACTION_SAME_SCREEN;
705 return ReportIllegal(keymap, action->type, field);
709 HandleSetLockControls(struct xkb_keymap *keymap, union xkb_action *action,
710 enum action_field field, const ExprDef *array_ndx,
711 const ExprDef *value)
713 struct xkb_controls_action *act = &action->ctrls;
715 if (field == ACTION_FIELD_CONTROLS) {
719 return ReportActionNotArray(keymap, action->type, field);
721 if (!ExprResolveMask(keymap->ctx, value, &mask, ctrlMaskNames))
722 return ReportMismatch(keymap, action->type, field,
729 return ReportIllegal(keymap, action->type, field);
733 HandlePrivate(struct xkb_keymap *keymap, union xkb_action *action,
734 enum action_field field, const ExprDef *array_ndx,
735 const ExprDef *value)
737 struct xkb_private_action *act = &action->priv;
739 if (field == ACTION_FIELD_TYPE) {
742 if (!ExprResolveInteger(keymap->ctx, value, &type))
743 return ReportMismatch(keymap, ACTION_TYPE_PRIVATE, field, "integer");
745 if (type < 0 || type > 255) {
747 "Private action type must be in the range 0..255; "
748 "Illegal type %d ignored\n", type);
752 act->type = (uint8_t) type;
755 else if (field == ACTION_FIELD_DATA) {
756 if (array_ndx == NULL) {
761 if (!ExprResolveString(keymap->ctx, value, &val))
762 return ReportMismatch(keymap, action->type, field, "string");
764 str = xkb_atom_text(keymap->ctx, val);
766 if (len < 1 || len > 7) {
767 log_warn(keymap->ctx,
768 "A private action has 7 data bytes; "
769 "Extra %d bytes ignored\n", len - 6);
773 strncpy((char *) act->data, str, sizeof(act->data));
779 if (!ExprResolveInteger(keymap->ctx, array_ndx, &ndx)) {
781 "Array subscript must be integer; "
782 "Illegal subscript ignored\n");
786 if (ndx < 0 || ndx >= sizeof(act->data)) {
788 "The data for a private action is %zu bytes long; "
789 "Attempt to use data[%d] ignored\n",
790 sizeof(act->data), ndx);
794 if (!ExprResolveInteger(keymap->ctx, value, &datum))
795 return ReportMismatch(keymap, act->type, field, "integer");
797 if (datum < 0 || datum > 255) {
799 "All data for a private action must be 0..255; "
800 "Illegal datum %d ignored\n", datum);
804 act->data[ndx] = (uint8_t) datum;
809 return ReportIllegal(keymap, ACTION_TYPE_NONE, field);
812 typedef bool (*actionHandler)(struct xkb_keymap *keymap,
813 union xkb_action *action,
814 enum action_field field,
815 const ExprDef *array_ndx,
816 const ExprDef *value);
818 static const actionHandler handleAction[ACTION_TYPE_LAST] = {
819 [ACTION_TYPE_NONE] = HandleNoAction,
820 [ACTION_TYPE_MOD_SET] = HandleSetLatchMods,
821 [ACTION_TYPE_MOD_LATCH] = HandleSetLatchMods,
822 [ACTION_TYPE_MOD_LOCK] = HandleLockMods,
823 [ACTION_TYPE_GROUP_SET] = HandleSetLatchGroup,
824 [ACTION_TYPE_GROUP_LATCH] = HandleSetLatchGroup,
825 [ACTION_TYPE_GROUP_LOCK] = HandleLockGroup,
826 [ACTION_TYPE_PTR_MOVE] = HandleMovePtr,
827 [ACTION_TYPE_PTR_BUTTON] = HandlePtrBtn,
828 [ACTION_TYPE_PTR_LOCK] = HandlePtrBtn,
829 [ACTION_TYPE_PTR_DEFAULT] = HandleSetPtrDflt,
830 [ACTION_TYPE_TERMINATE] = HandleNoAction,
831 [ACTION_TYPE_SWITCH_VT] = HandleSwitchScreen,
832 [ACTION_TYPE_CTRL_SET] = HandleSetLockControls,
833 [ACTION_TYPE_CTRL_LOCK] = HandleSetLockControls,
834 [ACTION_TYPE_PRIVATE] = HandlePrivate,
837 /***====================================================================***/
840 HandleActionDef(ExprDef *def, struct xkb_keymap *keymap,
841 union xkb_action *action, ActionsInfo *info)
847 if (def->op != EXPR_ACTION_DECL) {
848 log_err(keymap->ctx, "Expected an action definition, found %s\n",
849 expr_op_type_to_string(def->op));
853 str = xkb_atom_text(keymap->ctx, def->value.action.name);
854 if (!stringToAction(str, &hndlrType)) {
855 log_err(keymap->ctx, "Unknown action %s\n", str);
860 * Get the default values for this action type, as modified by
861 * statements such as:
862 * latchMods.clearLocks = True;
864 *action = info->actions[hndlrType];
867 * Now change the action properties as specified for this
868 * particular instance, e.g. "modifiers" and "clearLocks" in:
869 * SetMods(modifiers=Alt,clearLocks);
871 for (arg = def->value.action.args; arg != NULL;
872 arg = (ExprDef *) arg->common.next) {
873 const ExprDef *value;
874 ExprDef *field, *arrayRtrn;
875 const char *elemRtrn, *fieldRtrn;
876 enum action_field fieldNdx;
878 if (arg->op == EXPR_ASSIGN) {
879 field = arg->value.binary.left;
880 value = arg->value.binary.right;
882 else if (arg->op == EXPR_NOT || arg->op == EXPR_INVERT) {
883 field = arg->value.child;
891 if (!ExprResolveLhs(keymap->ctx, field, &elemRtrn, &fieldRtrn,
897 "Cannot change defaults in an action definition; "
898 "Ignoring attempt to change %s.%s\n",
899 elemRtrn, fieldRtrn);
903 if (!stringToField(fieldRtrn, &fieldNdx)) {
904 log_err(keymap->ctx, "Unknown field name %s\n", fieldRtrn);
908 if (!handleAction[hndlrType](keymap, action, fieldNdx, arrayRtrn,
918 SetActionField(struct xkb_keymap *keymap, const char *elem, const char *field,
919 ExprDef *array_ndx, ExprDef *value, ActionsInfo *info)
922 enum action_field action_field;
924 if (!stringToAction(elem, &action))
927 if (!stringToField(field, &action_field)) {
928 log_err(keymap->ctx, "\"%s\" is not a legal field name\n", field);
932 return handleAction[action](keymap, &info->actions[action],
933 action_field, array_ndx, value);