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"
59 static const ExprBoolean constTrue = {
61 .common = { .type = STMT_EXPR, .next = NULL },
63 .value_type = EXPR_TYPE_BOOLEAN,
68 static const ExprBoolean constFalse = {
70 .common = { .type = STMT_EXPR, .next = NULL },
72 .value_type = EXPR_TYPE_BOOLEAN,
78 ACTION_FIELD_CLEAR_LOCKS,
79 ACTION_FIELD_LATCH_TO_LOCK,
80 ACTION_FIELD_GEN_KEY_EVENT,
84 ACTION_FIELD_INCREMENT,
85 ACTION_FIELD_MODIFIERS,
92 ACTION_FIELD_CONTROLS,
100 ACTION_FIELD_MODS_TO_CLEAR,
109 info = calloc(1, sizeof(*info));
113 for (type = 0; type < _ACTION_TYPE_NUM_ENTRIES; type++)
114 info->actions[type].type = type;
116 /* Apply some "factory defaults". */
118 /* Increment default button. */
119 info->actions[ACTION_TYPE_PTR_DEFAULT].dflt.flags = 0;
120 info->actions[ACTION_TYPE_PTR_DEFAULT].dflt.value = 1;
126 FreeActionsInfo(ActionsInfo *info)
131 static const LookupEntry fieldStrings[] = {
132 { "clearLocks", ACTION_FIELD_CLEAR_LOCKS },
133 { "latchToLock", ACTION_FIELD_LATCH_TO_LOCK },
134 { "genKeyEvent", ACTION_FIELD_GEN_KEY_EVENT },
135 { "generateKeyEvent", ACTION_FIELD_GEN_KEY_EVENT },
136 { "report", ACTION_FIELD_REPORT },
137 { "default", ACTION_FIELD_DEFAULT },
138 { "affect", ACTION_FIELD_AFFECT },
139 { "increment", ACTION_FIELD_INCREMENT },
140 { "modifiers", ACTION_FIELD_MODIFIERS },
141 { "mods", ACTION_FIELD_MODIFIERS },
142 { "group", ACTION_FIELD_GROUP },
143 { "x", ACTION_FIELD_X },
144 { "y", ACTION_FIELD_Y },
145 { "accel", ACTION_FIELD_ACCEL },
146 { "accelerate", ACTION_FIELD_ACCEL },
147 { "repeat", ACTION_FIELD_ACCEL },
148 { "button", ACTION_FIELD_BUTTON },
149 { "value", ACTION_FIELD_VALUE },
150 { "controls", ACTION_FIELD_CONTROLS },
151 { "ctrls", ACTION_FIELD_CONTROLS },
152 { "type", ACTION_FIELD_TYPE },
153 { "count", ACTION_FIELD_COUNT },
154 { "screen", ACTION_FIELD_SCREEN },
155 { "same", ACTION_FIELD_SAME },
156 { "sameServer", ACTION_FIELD_SAME },
157 { "data", ACTION_FIELD_DATA },
158 { "device", ACTION_FIELD_DEVICE },
159 { "dev", ACTION_FIELD_DEVICE },
160 { "key", ACTION_FIELD_KEYCODE },
161 { "keycode", ACTION_FIELD_KEYCODE },
162 { "kc", ACTION_FIELD_KEYCODE },
163 { "clearmods", ACTION_FIELD_MODS_TO_CLEAR },
164 { "clearmodifiers", ACTION_FIELD_MODS_TO_CLEAR },
169 stringToAction(const char *str, unsigned *type_rtrn)
171 return LookupString(actionTypeNames, str, type_rtrn);
175 stringToField(const char *str, enum action_field *field_rtrn)
177 return LookupString(fieldStrings, str, field_rtrn);
181 fieldText(enum action_field field)
183 return LookupValue(fieldStrings, field);
186 /***====================================================================***/
189 ReportMismatch(struct xkb_keymap *keymap, enum xkb_action_type action,
190 enum action_field field, const char *type)
193 "Value of %s field must be of type %s; "
194 "Action %s definition ignored\n",
195 fieldText(field), type, ActionTypeText(action));
200 ReportIllegal(struct xkb_keymap *keymap, enum xkb_action_type action,
201 enum action_field field)
204 "Field %s is not defined for an action of type %s; "
205 "Action definition ignored\n",
206 fieldText(field), ActionTypeText(action));
211 ReportActionNotArray(struct xkb_keymap *keymap, enum xkb_action_type action,
212 enum action_field field)
215 "The %s field in the %s action is not an array; "
216 "Action definition ignored\n",
217 fieldText(field), ActionTypeText(action));
222 HandleNoAction(struct xkb_keymap *keymap, union xkb_action *action,
223 enum action_field field, const ExprDef *array_ndx,
224 const ExprDef *value)
231 CheckLatchLockFlags(struct xkb_keymap *keymap, enum xkb_action_type action,
232 enum action_field field, const ExprDef *value,
233 enum xkb_action_flags *flags_inout)
235 enum xkb_action_flags tmp;
238 if (field == ACTION_FIELD_CLEAR_LOCKS)
239 tmp = ACTION_LOCK_CLEAR;
240 else if (field == ACTION_FIELD_LATCH_TO_LOCK)
241 tmp = ACTION_LATCH_TO_LOCK;
243 return false; /* WSGO! */
245 if (!ExprResolveBoolean(keymap->ctx, value, &result))
246 return ReportMismatch(keymap, action, field, "boolean");
251 *flags_inout &= ~tmp;
257 CheckModifierField(struct xkb_keymap *keymap, enum xkb_action_type action,
258 const ExprDef *value, enum xkb_action_flags *flags_inout,
259 xkb_mod_mask_t *mods_rtrn)
261 if (value->expr.op == EXPR_IDENT) {
263 valStr = xkb_atom_text(keymap->ctx, value->ident.ident);
264 if (valStr && (istreq(valStr, "usemodmapmods") ||
265 istreq(valStr, "modmapmods"))) {
268 *flags_inout |= ACTION_MODS_LOOKUP_MODMAP;
273 if (!ExprResolveModMask(keymap, value, MOD_BOTH, mods_rtrn))
274 return ReportMismatch(keymap, action,
275 ACTION_FIELD_MODIFIERS, "modifier mask");
277 *flags_inout &= ~ACTION_MODS_LOOKUP_MODMAP;
282 HandleSetLatchMods(struct xkb_keymap *keymap, union xkb_action *action,
283 enum action_field field, const ExprDef *array_ndx,
284 const ExprDef *value)
286 struct xkb_mod_action *act = &action->mods;
287 enum xkb_action_flags rtrn, t1;
290 if (array_ndx != NULL) {
292 case ACTION_FIELD_CLEAR_LOCKS:
293 case ACTION_FIELD_LATCH_TO_LOCK:
294 case ACTION_FIELD_MODIFIERS:
295 return ReportActionNotArray(keymap, action->type, field);
302 case ACTION_FIELD_CLEAR_LOCKS:
303 case ACTION_FIELD_LATCH_TO_LOCK:
305 if (CheckLatchLockFlags(keymap, action->type, field, value, &rtrn)) {
311 case ACTION_FIELD_MODIFIERS:
313 if (CheckModifierField(keymap, action->type, value, &t1, &t2)) {
324 return ReportIllegal(keymap, action->type, field);
328 HandleLockMods(struct xkb_keymap *keymap, union xkb_action *action,
329 enum action_field field, const ExprDef *array_ndx,
330 const ExprDef *value)
332 struct xkb_mod_action *act = &action->mods;
333 enum xkb_action_flags t1;
336 if (array_ndx && field == ACTION_FIELD_MODIFIERS)
337 return ReportActionNotArray(keymap, action->type, field);
340 case ACTION_FIELD_MODIFIERS:
342 if (CheckModifierField(keymap, action->type, value, &t1, &t2)) {
353 return ReportIllegal(keymap, action->type, field);
357 CheckGroupField(struct xkb_keymap *keymap, unsigned action,
358 const ExprDef *value, enum xkb_action_flags *flags_inout,
359 xkb_layout_index_t *grp_rtrn)
363 if (value->expr.op == EXPR_NEGATE || value->expr.op == EXPR_UNARY_PLUS) {
364 *flags_inout &= ~ACTION_ABSOLUTE_SWITCH;
365 spec = value->unary.child;
368 *flags_inout |= ACTION_ABSOLUTE_SWITCH;
372 if (!ExprResolveGroup(keymap->ctx, spec, grp_rtrn))
373 return ReportMismatch(keymap, action, ACTION_FIELD_GROUP,
374 "integer (range 1..8)");
376 if (value->expr.op == EXPR_NEGATE)
377 *grp_rtrn = -*grp_rtrn;
378 else if (value->expr.op != EXPR_UNARY_PLUS)
385 HandleSetLatchGroup(struct xkb_keymap *keymap, union xkb_action *action,
386 enum action_field field, const ExprDef *array_ndx,
387 const ExprDef *value)
389 struct xkb_group_action *act = &action->group;
390 enum xkb_action_flags rtrn, t1;
391 xkb_layout_index_t t2;
393 if (array_ndx != NULL) {
395 case ACTION_FIELD_CLEAR_LOCKS:
396 case ACTION_FIELD_LATCH_TO_LOCK:
397 case ACTION_FIELD_GROUP:
398 return ReportActionNotArray(keymap, action->type, field);
406 case ACTION_FIELD_CLEAR_LOCKS:
407 case ACTION_FIELD_LATCH_TO_LOCK:
409 if (CheckLatchLockFlags(keymap, action->type, field, value, &rtrn)) {
415 case ACTION_FIELD_GROUP:
417 if (CheckGroupField(keymap, action->type, value, &t1, &t2)) {
428 return ReportIllegal(keymap, action->type, field);
432 HandleLockGroup(struct xkb_keymap *keymap, union xkb_action *action,
433 enum action_field field, const ExprDef *array_ndx,
434 const ExprDef *value)
436 struct xkb_group_action *act = &action->group;
437 enum xkb_action_flags t1;
438 xkb_layout_index_t t2;
440 if ((array_ndx != NULL) && (field == ACTION_FIELD_GROUP))
441 return ReportActionNotArray(keymap, action->type, field);
442 if (field == ACTION_FIELD_GROUP) {
444 if (CheckGroupField(keymap, action->type, value, &t1, &t2)) {
451 return ReportIllegal(keymap, action->type, field);
455 HandleMovePtr(struct xkb_keymap *keymap, union xkb_action *action,
456 enum action_field field, const ExprDef *array_ndx,
457 const ExprDef *value)
459 struct xkb_pointer_action *act = &action->ptr;
461 if (array_ndx && (field == ACTION_FIELD_X || field == ACTION_FIELD_Y))
462 return ReportActionNotArray(keymap, action->type, field);
464 if (field == ACTION_FIELD_X || field == ACTION_FIELD_Y) {
466 const bool absolute = (value->expr.op != EXPR_NEGATE &&
467 value->expr.op != EXPR_UNARY_PLUS);
469 if (!ExprResolveInteger(keymap->ctx, value, &val))
470 return ReportMismatch(keymap, action->type, field, "integer");
472 if (field == ACTION_FIELD_X) {
474 act->flags |= ACTION_ABSOLUTE_X;
479 act->flags |= ACTION_ABSOLUTE_Y;
485 else if (field == ACTION_FIELD_ACCEL) {
488 if (!ExprResolveBoolean(keymap->ctx, value, &set))
489 return ReportMismatch(keymap, action->type, field, "boolean");
492 act->flags &= ~ACTION_NO_ACCEL;
494 act->flags |= ACTION_NO_ACCEL;
497 return ReportIllegal(keymap, action->type, field);
500 static const LookupEntry lockWhich[] = {
502 { "lock", ACTION_LOCK_NO_UNLOCK },
503 { "neither", (ACTION_LOCK_NO_LOCK | ACTION_LOCK_NO_UNLOCK) },
504 { "unlock", ACTION_LOCK_NO_LOCK },
509 HandlePtrBtn(struct xkb_keymap *keymap, union xkb_action *action,
510 enum action_field field, const ExprDef *array_ndx,
511 const ExprDef *value)
513 struct xkb_pointer_button_action *act = &action->btn;
515 if (field == ACTION_FIELD_BUTTON) {
519 return ReportActionNotArray(keymap, action->type, field);
521 if (!ExprResolveButton(keymap->ctx, value, &btn))
522 return ReportMismatch(keymap, action->type, field,
523 "integer (range 1..5)");
525 if (btn < 0 || btn > 5) {
527 "Button must specify default or be in the range 1..5; "
528 "Illegal button value %d ignored\n", btn);
535 else if (action->type == ACTION_TYPE_PTR_LOCK &&
536 field == ACTION_FIELD_AFFECT) {
537 enum xkb_action_flags val;
540 return ReportActionNotArray(keymap, action->type, field);
542 if (!ExprResolveEnum(keymap->ctx, value, &val, lockWhich))
543 return ReportMismatch(keymap, action->type, field,
546 act->flags &= ~(ACTION_LOCK_NO_LOCK | ACTION_LOCK_NO_UNLOCK);
550 else if (field == ACTION_FIELD_COUNT) {
554 return ReportActionNotArray(keymap, action->type, field);
556 /* XXX: Should this actually be ResolveButton? */
557 if (!ExprResolveButton(keymap->ctx, value, &btn))
558 return ReportMismatch(keymap, action->type, field, "integer");
560 if (btn < 0 || btn > 255) {
562 "The count field must have a value in the range 0..255; "
563 "Illegal count %d ignored\n", btn);
570 return ReportIllegal(keymap, action->type, field);
573 static const LookupEntry ptrDflts[] = {
575 { "defaultbutton", 1 },
581 HandleSetPtrDflt(struct xkb_keymap *keymap, union xkb_action *action,
582 enum action_field field, const ExprDef *array_ndx,
583 const ExprDef *value)
585 struct xkb_pointer_default_action *act = &action->dflt;
587 if (field == ACTION_FIELD_AFFECT) {
591 return ReportActionNotArray(keymap, action->type, field);
593 if (!ExprResolveEnum(keymap->ctx, value, &val, ptrDflts))
594 return ReportMismatch(keymap, action->type, field,
595 "pointer component");
598 else if (field == ACTION_FIELD_BUTTON || field == ACTION_FIELD_VALUE) {
599 const ExprDef *button;
603 return ReportActionNotArray(keymap, action->type, field);
605 if (value->expr.op == EXPR_NEGATE ||
606 value->expr.op == EXPR_UNARY_PLUS) {
607 act->flags &= ~ACTION_ABSOLUTE_SWITCH;
608 button = value->unary.child;
611 act->flags |= ACTION_ABSOLUTE_SWITCH;
615 if (!ExprResolveButton(keymap->ctx, button, &btn))
616 return ReportMismatch(keymap, action->type, field,
617 "integer (range 1..5)");
619 if (btn < 0 || btn > 5) {
621 "New default button value must be in the range 1..5; "
622 "Illegal default button value %d ignored\n", btn);
627 "Cannot set default pointer button to \"default\"; "
628 "Illegal default button setting ignored\n");
632 act->value = (value->expr.op == EXPR_NEGATE ? -btn: btn);
636 return ReportIllegal(keymap, action->type, field);
640 HandleSwitchScreen(struct xkb_keymap *keymap, union xkb_action *action,
641 enum action_field field, const ExprDef *array_ndx,
642 const ExprDef *value)
644 struct xkb_switch_screen_action *act = &action->screen;
646 if (field == ACTION_FIELD_SCREEN) {
651 return ReportActionNotArray(keymap, action->type, field);
653 if (value->expr.op == EXPR_NEGATE ||
654 value->expr.op == EXPR_UNARY_PLUS) {
655 act->flags &= ~ACTION_ABSOLUTE_SWITCH;
656 scrn = value->unary.child;
659 act->flags |= ACTION_ABSOLUTE_SWITCH;
663 if (!ExprResolveInteger(keymap->ctx, scrn, &val))
664 return ReportMismatch(keymap, action->type, field,
667 if (val < 0 || val > 255) {
669 "Screen index must be in the range 1..255; "
670 "Illegal screen value %d ignored\n", val);
674 act->screen = (value->expr.op == EXPR_NEGATE ? -val : val);
677 else if (field == ACTION_FIELD_SAME) {
681 return ReportActionNotArray(keymap, action->type, field);
683 if (!ExprResolveBoolean(keymap->ctx, value, &set))
684 return ReportMismatch(keymap, action->type, field, "boolean");
687 act->flags &= ~ACTION_SAME_SCREEN;
689 act->flags |= ACTION_SAME_SCREEN;
694 return ReportIllegal(keymap, action->type, field);
698 HandleSetLockControls(struct xkb_keymap *keymap, union xkb_action *action,
699 enum action_field field, const ExprDef *array_ndx,
700 const ExprDef *value)
702 struct xkb_controls_action *act = &action->ctrls;
704 if (field == ACTION_FIELD_CONTROLS) {
708 return ReportActionNotArray(keymap, action->type, field);
710 if (!ExprResolveMask(keymap->ctx, value, &mask, ctrlMaskNames))
711 return ReportMismatch(keymap, action->type, field,
718 return ReportIllegal(keymap, action->type, field);
722 HandlePrivate(struct xkb_keymap *keymap, union xkb_action *action,
723 enum action_field field, const ExprDef *array_ndx,
724 const ExprDef *value)
726 struct xkb_private_action *act = &action->priv;
728 if (field == ACTION_FIELD_TYPE) {
731 if (!ExprResolveInteger(keymap->ctx, value, &type))
732 return ReportMismatch(keymap, ACTION_TYPE_PRIVATE, field, "integer");
734 if (type < 0 || type > 255) {
736 "Private action type must be in the range 0..255; "
737 "Illegal type %d ignored\n", type);
742 * It's possible for someone to write something like this:
743 * actions = [ Private(type=3,data[0]=1,data[1]=3,data[2]=3) ]
744 * where the type refers to some existing action type, e.g. LockMods.
745 * This assumes that this action's struct is laid out in memory
746 * exactly as described in the XKB specification and libraries.
747 * We, however, have changed these structs in various ways, so this
748 * assumption is no longer true. Since this is a lousy "feature", we
749 * make actions like these no-ops for now.
751 if (type < ACTION_TYPE_PRIVATE) {
752 log_info(keymap->ctx,
753 "Private actions of type %s are not supported; Ignored\n",
754 ActionTypeText(type));
755 act->type = ACTION_TYPE_NONE;
758 act->type = (enum xkb_action_type) type;
763 else if (field == ACTION_FIELD_DATA) {
764 if (array_ndx == NULL) {
769 if (!ExprResolveString(keymap->ctx, value, &val))
770 return ReportMismatch(keymap, action->type, field, "string");
772 str = xkb_atom_text(keymap->ctx, val);
774 if (len < 1 || len > 7) {
775 log_warn(keymap->ctx,
776 "A private action has 7 data bytes; "
777 "Extra %d bytes ignored\n", len - 6);
781 strncpy((char *) act->data, str, sizeof(act->data));
787 if (!ExprResolveInteger(keymap->ctx, array_ndx, &ndx)) {
789 "Array subscript must be integer; "
790 "Illegal subscript ignored\n");
794 if (ndx < 0 || ndx >= sizeof(act->data)) {
796 "The data for a private action is %lu bytes long; "
797 "Attempt to use data[%d] ignored\n",
798 (unsigned long) sizeof(act->data), ndx);
802 if (!ExprResolveInteger(keymap->ctx, value, &datum))
803 return ReportMismatch(keymap, act->type, field, "integer");
805 if (datum < 0 || datum > 255) {
807 "All data for a private action must be 0..255; "
808 "Illegal datum %d ignored\n", datum);
812 act->data[ndx] = (uint8_t) datum;
817 return ReportIllegal(keymap, ACTION_TYPE_NONE, field);
820 typedef bool (*actionHandler)(struct xkb_keymap *keymap,
821 union xkb_action *action,
822 enum action_field field,
823 const ExprDef *array_ndx,
824 const ExprDef *value);
826 static const actionHandler handleAction[_ACTION_TYPE_NUM_ENTRIES] = {
827 [ACTION_TYPE_NONE] = HandleNoAction,
828 [ACTION_TYPE_MOD_SET] = HandleSetLatchMods,
829 [ACTION_TYPE_MOD_LATCH] = HandleSetLatchMods,
830 [ACTION_TYPE_MOD_LOCK] = HandleLockMods,
831 [ACTION_TYPE_GROUP_SET] = HandleSetLatchGroup,
832 [ACTION_TYPE_GROUP_LATCH] = HandleSetLatchGroup,
833 [ACTION_TYPE_GROUP_LOCK] = HandleLockGroup,
834 [ACTION_TYPE_PTR_MOVE] = HandleMovePtr,
835 [ACTION_TYPE_PTR_BUTTON] = HandlePtrBtn,
836 [ACTION_TYPE_PTR_LOCK] = HandlePtrBtn,
837 [ACTION_TYPE_PTR_DEFAULT] = HandleSetPtrDflt,
838 [ACTION_TYPE_TERMINATE] = HandleNoAction,
839 [ACTION_TYPE_SWITCH_VT] = HandleSwitchScreen,
840 [ACTION_TYPE_CTRL_SET] = HandleSetLockControls,
841 [ACTION_TYPE_CTRL_LOCK] = HandleSetLockControls,
842 [ACTION_TYPE_PRIVATE] = HandlePrivate,
845 /***====================================================================***/
848 HandleActionDef(ExprDef *def, struct xkb_keymap *keymap,
849 union xkb_action *action, ActionsInfo *info)
853 unsigned handler_type;
855 if (def->expr.op != EXPR_ACTION_DECL) {
856 log_err(keymap->ctx, "Expected an action definition, found %s\n",
857 expr_op_type_to_string(def->expr.op));
861 str = xkb_atom_text(keymap->ctx, def->action.name);
862 if (!stringToAction(str, &handler_type)) {
863 log_err(keymap->ctx, "Unknown action %s\n", str);
868 * Get the default values for this action type, as modified by
869 * statements such as:
870 * latchMods.clearLocks = True;
872 *action = info->actions[handler_type];
875 * Now change the action properties as specified for this
876 * particular instance, e.g. "modifiers" and "clearLocks" in:
877 * SetMods(modifiers=Alt,clearLocks);
879 for (arg = def->action.args; arg != NULL;
880 arg = (ExprDef *) arg->common.next) {
881 const ExprDef *value;
882 ExprDef *field, *arrayRtrn;
883 const char *elemRtrn, *fieldRtrn;
884 enum action_field fieldNdx;
886 if (arg->expr.op == EXPR_ASSIGN) {
887 field = arg->binary.left;
888 value = arg->binary.right;
890 else if (arg->expr.op == EXPR_NOT || arg->expr.op == EXPR_INVERT) {
891 field = arg->unary.child;
892 value = (const ExprDef *) &constFalse;
896 value = (const ExprDef *) &constTrue;
899 if (!ExprResolveLhs(keymap->ctx, field, &elemRtrn, &fieldRtrn,
905 "Cannot change defaults in an action definition; "
906 "Ignoring attempt to change %s.%s\n",
907 elemRtrn, fieldRtrn);
911 if (!stringToField(fieldRtrn, &fieldNdx)) {
912 log_err(keymap->ctx, "Unknown field name %s\n", fieldRtrn);
916 if (!handleAction[handler_type](keymap, action, fieldNdx, arrayRtrn,
926 SetActionField(struct xkb_keymap *keymap, const char *elem, const char *field,
927 ExprDef *array_ndx, ExprDef *value, ActionsInfo *info)
930 enum action_field action_field;
932 if (!stringToAction(elem, &action))
935 if (!stringToField(field, &action_field)) {
936 log_err(keymap->ctx, "\"%s\" is not a legal field name\n", field);
940 return handleAction[action](keymap, &info->actions[action],
941 action_field, array_ndx, value);