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 for (type = 0; type < _ACTION_TYPE_NUM_ENTRIES; type++)
111 info->actions[type].type = type;
113 /* Apply some "factory defaults". */
115 /* Increment default button. */
116 info->actions[ACTION_TYPE_PTR_DEFAULT].dflt.flags = 0;
117 info->actions[ACTION_TYPE_PTR_DEFAULT].dflt.value = 1;
123 FreeActionsInfo(ActionsInfo *info)
128 static const LookupEntry fieldStrings[] = {
129 { "clearLocks", ACTION_FIELD_CLEAR_LOCKS },
130 { "latchToLock", ACTION_FIELD_LATCH_TO_LOCK },
131 { "genKeyEvent", ACTION_FIELD_GEN_KEY_EVENT },
132 { "generateKeyEvent", ACTION_FIELD_GEN_KEY_EVENT },
133 { "report", ACTION_FIELD_REPORT },
134 { "default", ACTION_FIELD_DEFAULT },
135 { "affect", ACTION_FIELD_AFFECT },
136 { "increment", ACTION_FIELD_INCREMENT },
137 { "modifiers", ACTION_FIELD_MODIFIERS },
138 { "mods", ACTION_FIELD_MODIFIERS },
139 { "group", ACTION_FIELD_GROUP },
140 { "x", ACTION_FIELD_X },
141 { "y", ACTION_FIELD_Y },
142 { "accel", ACTION_FIELD_ACCEL },
143 { "accelerate", ACTION_FIELD_ACCEL },
144 { "repeat", ACTION_FIELD_ACCEL },
145 { "button", ACTION_FIELD_BUTTON },
146 { "value", ACTION_FIELD_VALUE },
147 { "controls", ACTION_FIELD_CONTROLS },
148 { "ctrls", ACTION_FIELD_CONTROLS },
149 { "type", ACTION_FIELD_TYPE },
150 { "count", ACTION_FIELD_COUNT },
151 { "screen", ACTION_FIELD_SCREEN },
152 { "same", ACTION_FIELD_SAME },
153 { "sameServer", ACTION_FIELD_SAME },
154 { "data", ACTION_FIELD_DATA },
155 { "device", ACTION_FIELD_DEVICE },
156 { "dev", ACTION_FIELD_DEVICE },
157 { "key", ACTION_FIELD_KEYCODE },
158 { "keycode", ACTION_FIELD_KEYCODE },
159 { "kc", ACTION_FIELD_KEYCODE },
160 { "clearmods", ACTION_FIELD_MODS_TO_CLEAR },
161 { "clearmodifiers", ACTION_FIELD_MODS_TO_CLEAR },
166 stringToAction(const char *str, unsigned *type_rtrn)
168 return LookupString(actionTypeNames, str, type_rtrn);
172 stringToField(const char *str, enum action_field *field_rtrn)
174 return LookupString(fieldStrings, str, field_rtrn);
178 fieldText(enum action_field field)
180 return LookupValue(fieldStrings, field);
183 /***====================================================================***/
186 ReportMismatch(struct xkb_keymap *keymap, enum xkb_action_type action,
187 enum action_field field, const char *type)
190 "Value of %s field must be of type %s; "
191 "Action %s definition ignored\n",
192 fieldText(field), type, ActionTypeText(action));
197 ReportIllegal(struct xkb_keymap *keymap, enum xkb_action_type action,
198 enum action_field field)
201 "Field %s is not defined for an action of type %s; "
202 "Action definition ignored\n",
203 fieldText(field), ActionTypeText(action));
208 ReportActionNotArray(struct xkb_keymap *keymap, enum xkb_action_type action,
209 enum action_field field)
212 "The %s field in the %s action is not an array; "
213 "Action definition ignored\n",
214 fieldText(field), ActionTypeText(action));
219 ReportNotFound(struct xkb_keymap *keymap, enum xkb_action_type action,
220 enum action_field field, const char *what, const char *bad)
223 "%s named %s not found; "
224 "Ignoring the %s field of an %s action\n",
225 what, bad, fieldText(field), ActionTypeText(action));
230 HandleNoAction(struct xkb_keymap *keymap, union xkb_action *action,
231 enum action_field field, const ExprDef *array_ndx,
232 const ExprDef *value)
239 CheckLatchLockFlags(struct xkb_keymap *keymap, enum xkb_action_type action,
240 enum action_field field, const ExprDef * value,
241 enum xkb_action_flags *flags_inout)
243 enum xkb_action_flags tmp;
246 if (field == ACTION_FIELD_CLEAR_LOCKS)
247 tmp = ACTION_LOCK_CLEAR;
248 else if (field == ACTION_FIELD_LATCH_TO_LOCK)
249 tmp = ACTION_LATCH_TO_LOCK;
251 return false; /* WSGO! */
253 if (!ExprResolveBoolean(keymap->ctx, value, &result))
254 return ReportMismatch(keymap, action, field, "boolean");
259 *flags_inout &= ~tmp;
265 CheckModifierField(struct xkb_keymap *keymap, enum xkb_action_type action,
266 const ExprDef *value, enum xkb_action_flags *flags_inout,
267 xkb_mod_mask_t *mods_rtrn)
269 if (value->op == EXPR_IDENT) {
271 valStr = xkb_atom_text(keymap->ctx, value->value.str);
272 if (valStr && (istreq(valStr, "usemodmapmods") ||
273 istreq(valStr, "modmapmods"))) {
276 *flags_inout |= ACTION_MODS_LOOKUP_MODMAP;
281 if (!ExprResolveModMask(keymap, value, MOD_BOTH, mods_rtrn))
282 return ReportMismatch(keymap, action,
283 ACTION_FIELD_MODIFIERS, "modifier mask");
285 *flags_inout &= ~ACTION_MODS_LOOKUP_MODMAP;
290 HandleSetLatchMods(struct xkb_keymap *keymap, union xkb_action *action,
291 enum action_field field, const ExprDef *array_ndx,
292 const ExprDef *value)
294 struct xkb_mod_action *act = &action->mods;
295 enum xkb_action_flags rtrn, t1;
298 if (array_ndx != NULL) {
300 case ACTION_FIELD_CLEAR_LOCKS:
301 case ACTION_FIELD_LATCH_TO_LOCK:
302 case ACTION_FIELD_MODIFIERS:
303 return ReportActionNotArray(keymap, action->type, field);
310 case ACTION_FIELD_CLEAR_LOCKS:
311 case ACTION_FIELD_LATCH_TO_LOCK:
313 if (CheckLatchLockFlags(keymap, action->type, field, value, &rtrn)) {
319 case ACTION_FIELD_MODIFIERS:
321 if (CheckModifierField(keymap, action->type, value, &t1, &t2)) {
332 return ReportIllegal(keymap, action->type, field);
336 HandleLockMods(struct xkb_keymap *keymap, union xkb_action *action,
337 enum action_field field, const ExprDef *array_ndx,
338 const ExprDef *value)
340 struct xkb_mod_action *act = &action->mods;
341 enum xkb_action_flags t1;
344 if (array_ndx && field == ACTION_FIELD_MODIFIERS)
345 return ReportActionNotArray(keymap, action->type, field);
348 case ACTION_FIELD_MODIFIERS:
350 if (CheckModifierField(keymap, action->type, value, &t1, &t2)) {
361 return ReportIllegal(keymap, action->type, field);
365 CheckGroupField(struct xkb_keymap *keymap, unsigned action,
366 const ExprDef *value, enum xkb_action_flags *flags_inout,
367 xkb_layout_index_t *grp_rtrn)
371 if (value->op == EXPR_NEGATE || value->op == EXPR_UNARY_PLUS) {
372 *flags_inout &= ~ACTION_ABSOLUTE_SWITCH;
373 spec = value->value.child;
376 *flags_inout |= ACTION_ABSOLUTE_SWITCH;
380 if (!ExprResolveGroup(keymap->ctx, spec, grp_rtrn))
381 return ReportMismatch(keymap, action, ACTION_FIELD_GROUP,
382 "integer (range 1..8)");
384 if (value->op == EXPR_NEGATE)
385 *grp_rtrn = -*grp_rtrn;
386 else if (value->op != EXPR_UNARY_PLUS)
393 HandleSetLatchGroup(struct xkb_keymap *keymap, union xkb_action *action,
394 enum action_field field, const ExprDef *array_ndx,
395 const ExprDef *value)
397 struct xkb_group_action *act = &action->group;
398 enum xkb_action_flags rtrn, t1;
399 xkb_layout_index_t t2;
401 if (array_ndx != NULL) {
403 case ACTION_FIELD_CLEAR_LOCKS:
404 case ACTION_FIELD_LATCH_TO_LOCK:
405 case ACTION_FIELD_GROUP:
406 return ReportActionNotArray(keymap, action->type, field);
414 case ACTION_FIELD_CLEAR_LOCKS:
415 case ACTION_FIELD_LATCH_TO_LOCK:
417 if (CheckLatchLockFlags(keymap, action->type, field, value, &rtrn)) {
423 case ACTION_FIELD_GROUP:
425 if (CheckGroupField(keymap, action->type, value, &t1, &t2)) {
436 return ReportIllegal(keymap, action->type, field);
440 HandleLockGroup(struct xkb_keymap *keymap, union xkb_action *action,
441 enum action_field field, const ExprDef *array_ndx,
442 const ExprDef *value)
444 struct xkb_group_action *act = &action->group;
445 enum xkb_action_flags t1;
446 xkb_layout_index_t t2;
448 if ((array_ndx != NULL) && (field == ACTION_FIELD_GROUP))
449 return ReportActionNotArray(keymap, action->type, field);
450 if (field == ACTION_FIELD_GROUP) {
452 if (CheckGroupField(keymap, action->type, value, &t1, &t2)) {
459 return ReportIllegal(keymap, action->type, field);
463 HandleMovePtr(struct xkb_keymap *keymap, union xkb_action *action,
464 enum action_field field, const ExprDef *array_ndx,
465 const ExprDef *value)
467 struct xkb_pointer_action *act = &action->ptr;
470 if (array_ndx && (field == ACTION_FIELD_X || field == ACTION_FIELD_Y))
471 return ReportActionNotArray(keymap, action->type, field);
473 if (field == ACTION_FIELD_X || field == ACTION_FIELD_Y) {
476 if (value->op == EXPR_NEGATE || value->op == EXPR_UNARY_PLUS)
481 if (!ExprResolveInteger(keymap->ctx, value, &val))
482 return ReportMismatch(keymap, action->type, field, "integer");
484 if (field == ACTION_FIELD_X) {
486 act->flags |= ACTION_ABSOLUTE_X;
491 act->flags |= ACTION_ABSOLUTE_Y;
497 else if (field == ACTION_FIELD_ACCEL) {
500 if (!ExprResolveBoolean(keymap->ctx, value, &set))
501 return ReportMismatch(keymap, action->type, field, "boolean");
504 act->flags &= ~ACTION_NO_ACCEL;
506 act->flags |= ACTION_NO_ACCEL;
509 return ReportIllegal(keymap, action->type, field);
512 static const LookupEntry lockWhich[] = {
514 { "lock", ACTION_LOCK_NO_UNLOCK },
515 { "neither", (ACTION_LOCK_NO_LOCK | ACTION_LOCK_NO_UNLOCK) },
516 { "unlock", ACTION_LOCK_NO_LOCK },
521 HandlePtrBtn(struct xkb_keymap *keymap, union xkb_action *action,
522 enum action_field field, const ExprDef *array_ndx,
523 const ExprDef *value)
525 struct xkb_pointer_button_action *act = &action->btn;
527 if (field == ACTION_FIELD_BUTTON) {
531 return ReportActionNotArray(keymap, action->type, field);
533 if (!ExprResolveButton(keymap->ctx, value, &btn))
534 return ReportMismatch(keymap, action->type, field,
535 "integer (range 1..5)");
537 if (btn < 0 || btn > 5) {
539 "Button must specify default or be in the range 1..5; "
540 "Illegal button value %d ignored\n", btn);
547 else if (action->type == ACTION_TYPE_PTR_LOCK &&
548 field == ACTION_FIELD_AFFECT) {
549 enum xkb_action_flags val;
552 return ReportActionNotArray(keymap, action->type, field);
554 if (!ExprResolveEnum(keymap->ctx, value, &val, lockWhich))
555 return ReportMismatch(keymap, action->type, field,
558 act->flags &= ~(ACTION_LOCK_NO_LOCK | ACTION_LOCK_NO_UNLOCK);
562 else if (field == ACTION_FIELD_COUNT) {
566 return ReportActionNotArray(keymap, action->type, field);
568 /* XXX: Should this actually be ResolveButton? */
569 if (!ExprResolveButton(keymap->ctx, value, &btn))
570 return ReportMismatch(keymap, action->type, field, "integer");
572 if (btn < 0 || btn > 255) {
574 "The count field must have a value in the range 0..255; "
575 "Illegal count %d ignored\n", btn);
582 return ReportIllegal(keymap, action->type, field);
585 static const LookupEntry ptrDflts[] = {
587 { "defaultbutton", 1 },
593 HandleSetPtrDflt(struct xkb_keymap *keymap, union xkb_action *action,
594 enum action_field field, const ExprDef *array_ndx,
595 const ExprDef *value)
597 struct xkb_pointer_default_action *act = &action->dflt;
599 if (field == ACTION_FIELD_AFFECT) {
603 return ReportActionNotArray(keymap, action->type, field);
605 if (!ExprResolveEnum(keymap->ctx, value, &val, ptrDflts))
606 return ReportMismatch(keymap, action->type, field,
607 "pointer component");
610 else if (field == ACTION_FIELD_BUTTON || field == ACTION_FIELD_VALUE) {
611 const ExprDef *button;
615 return ReportActionNotArray(keymap, action->type, field);
617 if (value->op == EXPR_NEGATE || value->op == EXPR_UNARY_PLUS) {
618 act->flags &= ~ACTION_ABSOLUTE_SWITCH;
619 button = value->value.child;
622 act->flags |= ACTION_ABSOLUTE_SWITCH;
626 if (!ExprResolveButton(keymap->ctx, button, &btn))
627 return ReportMismatch(keymap, action->type, field,
628 "integer (range 1..5)");
630 if (btn < 0 || btn > 5) {
632 "New default button value must be in the range 1..5; "
633 "Illegal default button value %d ignored\n", btn);
638 "Cannot set default pointer button to \"default\"; "
639 "Illegal default button setting ignored\n");
643 act->value = (value->op == EXPR_NEGATE ? -btn: btn);
647 return ReportIllegal(keymap, action->type, field);
651 HandleSwitchScreen(struct xkb_keymap *keymap, union xkb_action *action,
652 enum action_field field, const ExprDef *array_ndx,
653 const ExprDef *value)
655 struct xkb_switch_screen_action *act = &action->screen;
657 if (field == ACTION_FIELD_SCREEN) {
662 return ReportActionNotArray(keymap, action->type, field);
664 if (value->op == EXPR_NEGATE || value->op == EXPR_UNARY_PLUS) {
665 act->flags &= ~ACTION_ABSOLUTE_SWITCH;
666 scrn = value->value.child;
669 act->flags |= ACTION_ABSOLUTE_SWITCH;
673 if (!ExprResolveInteger(keymap->ctx, scrn, &val))
674 return ReportMismatch(keymap, action->type, field,
677 if (val < 0 || val > 255) {
679 "Screen index must be in the range 1..255; "
680 "Illegal screen value %d ignored\n", val);
684 act->screen = (value->op == EXPR_NEGATE ? -val : val);
687 else if (field == ACTION_FIELD_SAME) {
691 return ReportActionNotArray(keymap, action->type, field);
693 if (!ExprResolveBoolean(keymap->ctx, value, &set))
694 return ReportMismatch(keymap, action->type, field, "boolean");
697 act->flags &= ~ACTION_SAME_SCREEN;
699 act->flags |= ACTION_SAME_SCREEN;
704 return ReportIllegal(keymap, action->type, field);
708 HandleSetLockControls(struct xkb_keymap *keymap, union xkb_action *action,
709 enum action_field field, const ExprDef *array_ndx,
710 const ExprDef *value)
712 struct xkb_controls_action *act = &action->ctrls;
714 if (field == ACTION_FIELD_CONTROLS) {
718 return ReportActionNotArray(keymap, action->type, field);
720 if (!ExprResolveMask(keymap->ctx, value, &mask, ctrlMaskNames))
721 return ReportMismatch(keymap, action->type, field,
728 return ReportIllegal(keymap, action->type, field);
732 HandlePrivate(struct xkb_keymap *keymap, union xkb_action *action,
733 enum action_field field, const ExprDef *array_ndx,
734 const ExprDef *value)
736 struct xkb_private_action *act = &action->priv;
738 if (field == ACTION_FIELD_TYPE) {
741 if (!ExprResolveInteger(keymap->ctx, value, &type))
742 return ReportMismatch(keymap, ACTION_TYPE_PRIVATE, field, "integer");
744 if (type < 0 || type > 255) {
746 "Private action type must be in the range 0..255; "
747 "Illegal type %d ignored\n", type);
751 act->type = (enum xkb_action_type) type;
754 else if (field == ACTION_FIELD_DATA) {
755 if (array_ndx == NULL) {
760 if (!ExprResolveString(keymap->ctx, value, &val))
761 return ReportMismatch(keymap, action->type, field, "string");
763 str = xkb_atom_text(keymap->ctx, val);
765 if (len < 1 || len > 7) {
766 log_warn(keymap->ctx,
767 "A private action has 7 data bytes; "
768 "Extra %d bytes ignored\n", len - 6);
772 strncpy((char *) act->data, str, sizeof(act->data));
778 if (!ExprResolveInteger(keymap->ctx, array_ndx, &ndx)) {
780 "Array subscript must be integer; "
781 "Illegal subscript ignored\n");
785 if (ndx < 0 || ndx >= sizeof(act->data)) {
787 "The data for a private action is %lu bytes long; "
788 "Attempt to use data[%d] ignored\n",
789 (unsigned long) sizeof(act->data), ndx);
793 if (!ExprResolveInteger(keymap->ctx, value, &datum))
794 return ReportMismatch(keymap, act->type, field, "integer");
796 if (datum < 0 || datum > 255) {
798 "All data for a private action must be 0..255; "
799 "Illegal datum %d ignored\n", datum);
803 act->data[ndx] = (uint8_t) datum;
808 return ReportIllegal(keymap, ACTION_TYPE_NONE, field);
811 typedef bool (*actionHandler)(struct xkb_keymap *keymap,
812 union xkb_action *action,
813 enum action_field field,
814 const ExprDef *array_ndx,
815 const ExprDef *value);
817 static const actionHandler handleAction[_ACTION_TYPE_NUM_ENTRIES] = {
818 [ACTION_TYPE_NONE] = HandleNoAction,
819 [ACTION_TYPE_MOD_SET] = HandleSetLatchMods,
820 [ACTION_TYPE_MOD_LATCH] = HandleSetLatchMods,
821 [ACTION_TYPE_MOD_LOCK] = HandleLockMods,
822 [ACTION_TYPE_GROUP_SET] = HandleSetLatchGroup,
823 [ACTION_TYPE_GROUP_LATCH] = HandleSetLatchGroup,
824 [ACTION_TYPE_GROUP_LOCK] = HandleLockGroup,
825 [ACTION_TYPE_PTR_MOVE] = HandleMovePtr,
826 [ACTION_TYPE_PTR_BUTTON] = HandlePtrBtn,
827 [ACTION_TYPE_PTR_LOCK] = HandlePtrBtn,
828 [ACTION_TYPE_PTR_DEFAULT] = HandleSetPtrDflt,
829 [ACTION_TYPE_TERMINATE] = HandleNoAction,
830 [ACTION_TYPE_SWITCH_VT] = HandleSwitchScreen,
831 [ACTION_TYPE_CTRL_SET] = HandleSetLockControls,
832 [ACTION_TYPE_CTRL_LOCK] = HandleSetLockControls,
833 [ACTION_TYPE_PRIVATE] = HandlePrivate,
836 /***====================================================================***/
839 HandleActionDef(ExprDef *def, struct xkb_keymap *keymap,
840 union xkb_action *action, ActionsInfo *info)
846 if (def->op != EXPR_ACTION_DECL) {
847 log_err(keymap->ctx, "Expected an action definition, found %s\n",
848 expr_op_type_to_string(def->op));
852 str = xkb_atom_text(keymap->ctx, def->value.action.name);
853 if (!stringToAction(str, &hndlrType)) {
854 log_err(keymap->ctx, "Unknown action %s\n", str);
859 * Get the default values for this action type, as modified by
860 * statements such as:
861 * latchMods.clearLocks = True;
863 *action = info->actions[hndlrType];
866 * Now change the action properties as specified for this
867 * particular instance, e.g. "modifiers" and "clearLocks" in:
868 * SetMods(modifiers=Alt,clearLocks);
870 for (arg = def->value.action.args; arg != NULL;
871 arg = (ExprDef *) arg->common.next) {
872 const ExprDef *value;
873 ExprDef *field, *arrayRtrn;
874 const char *elemRtrn, *fieldRtrn;
875 enum action_field fieldNdx;
877 if (arg->op == EXPR_ASSIGN) {
878 field = arg->value.binary.left;
879 value = arg->value.binary.right;
881 else if (arg->op == EXPR_NOT || arg->op == EXPR_INVERT) {
882 field = arg->value.child;
890 if (!ExprResolveLhs(keymap->ctx, field, &elemRtrn, &fieldRtrn,
896 "Cannot change defaults in an action definition; "
897 "Ignoring attempt to change %s.%s\n",
898 elemRtrn, fieldRtrn);
902 if (!stringToField(fieldRtrn, &fieldNdx)) {
903 log_err(keymap->ctx, "Unknown field name %s\n", fieldRtrn);
907 if (!handleAction[hndlrType](keymap, action, fieldNdx, arrayRtrn,
917 SetActionField(struct xkb_keymap *keymap, const char *elem, const char *field,
918 ExprDef *array_ndx, ExprDef *value, ActionsInfo *info)
921 enum action_field action_field;
923 if (!stringToAction(elem, &action))
926 if (!stringToField(field, &action_field)) {
927 log_err(keymap->ctx, "\"%s\" is not a legal field name\n", field);
931 return handleAction[action](keymap, &info->actions[action],
932 action_field, array_ndx, value);