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;
121 info->actions[ACTION_TYPE_PTR_MOVE].ptr.flags = ACTION_ACCEL;
122 info->actions[ACTION_TYPE_SWITCH_VT].screen.flags = ACTION_SAME_SCREEN;
128 FreeActionsInfo(ActionsInfo *info)
133 static const LookupEntry fieldStrings[] = {
134 { "clearLocks", ACTION_FIELD_CLEAR_LOCKS },
135 { "latchToLock", ACTION_FIELD_LATCH_TO_LOCK },
136 { "genKeyEvent", ACTION_FIELD_GEN_KEY_EVENT },
137 { "generateKeyEvent", ACTION_FIELD_GEN_KEY_EVENT },
138 { "report", ACTION_FIELD_REPORT },
139 { "default", ACTION_FIELD_DEFAULT },
140 { "affect", ACTION_FIELD_AFFECT },
141 { "increment", ACTION_FIELD_INCREMENT },
142 { "modifiers", ACTION_FIELD_MODIFIERS },
143 { "mods", ACTION_FIELD_MODIFIERS },
144 { "group", ACTION_FIELD_GROUP },
145 { "x", ACTION_FIELD_X },
146 { "y", ACTION_FIELD_Y },
147 { "accel", ACTION_FIELD_ACCEL },
148 { "accelerate", ACTION_FIELD_ACCEL },
149 { "repeat", ACTION_FIELD_ACCEL },
150 { "button", ACTION_FIELD_BUTTON },
151 { "value", ACTION_FIELD_VALUE },
152 { "controls", ACTION_FIELD_CONTROLS },
153 { "ctrls", ACTION_FIELD_CONTROLS },
154 { "type", ACTION_FIELD_TYPE },
155 { "count", ACTION_FIELD_COUNT },
156 { "screen", ACTION_FIELD_SCREEN },
157 { "same", ACTION_FIELD_SAME },
158 { "sameServer", ACTION_FIELD_SAME },
159 { "data", ACTION_FIELD_DATA },
160 { "device", ACTION_FIELD_DEVICE },
161 { "dev", ACTION_FIELD_DEVICE },
162 { "key", ACTION_FIELD_KEYCODE },
163 { "keycode", ACTION_FIELD_KEYCODE },
164 { "kc", ACTION_FIELD_KEYCODE },
165 { "clearmods", ACTION_FIELD_MODS_TO_CLEAR },
166 { "clearmodifiers", ACTION_FIELD_MODS_TO_CLEAR },
171 stringToAction(const char *str, unsigned *type_rtrn)
173 return LookupString(actionTypeNames, str, type_rtrn);
177 stringToField(const char *str, enum action_field *field_rtrn)
179 return LookupString(fieldStrings, str, field_rtrn);
183 fieldText(enum action_field field)
185 return LookupValue(fieldStrings, field);
188 /***====================================================================***/
191 ReportMismatch(struct xkb_context *ctx, enum xkb_action_type action,
192 enum action_field field, const char *type)
195 "Value of %s field must be of type %s; "
196 "Action %s definition ignored\n",
197 fieldText(field), type, ActionTypeText(action));
202 ReportIllegal(struct xkb_context *ctx, enum xkb_action_type action,
203 enum action_field field)
206 "Field %s is not defined for an action of type %s; "
207 "Action definition ignored\n",
208 fieldText(field), ActionTypeText(action));
213 ReportActionNotArray(struct xkb_context *ctx, enum xkb_action_type action,
214 enum action_field field)
217 "The %s field in the %s action is not an array; "
218 "Action definition ignored\n",
219 fieldText(field), ActionTypeText(action));
224 HandleNoAction(struct xkb_keymap *keymap, union xkb_action *action,
225 enum action_field field, const ExprDef *array_ndx,
226 const ExprDef *value)
233 CheckBooleanFlag(struct xkb_context *ctx, enum xkb_action_type action,
234 enum action_field field, enum xkb_action_flags flag,
235 const ExprDef *array_ndx, const ExprDef *value,
236 enum xkb_action_flags *flags_inout)
241 return ReportActionNotArray(ctx, action, field);
243 if (!ExprResolveBoolean(ctx, value, &set))
244 return ReportMismatch(ctx, action, field, "boolean");
247 *flags_inout |= flag;
249 *flags_inout &= ~flag;
255 CheckModifierField(struct xkb_keymap *keymap, enum xkb_action_type action,
256 const ExprDef *array_ndx, const ExprDef *value,
257 enum xkb_action_flags *flags_inout, xkb_mod_mask_t *mods_rtrn)
260 return ReportActionNotArray(keymap->ctx, action, ACTION_FIELD_MODIFIERS);
262 if (value->expr.op == EXPR_IDENT) {
264 valStr = xkb_atom_text(keymap->ctx, value->ident.ident);
265 if (valStr && (istreq(valStr, "usemodmapmods") ||
266 istreq(valStr, "modmapmods"))) {
268 *flags_inout |= ACTION_MODS_LOOKUP_MODMAP;
273 if (!ExprResolveModMask(keymap, value, MOD_BOTH, mods_rtrn))
274 return ReportMismatch(keymap->ctx, 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;
288 if (field == ACTION_FIELD_CLEAR_LOCKS)
289 return CheckBooleanFlag(keymap->ctx, action->type, field,
290 ACTION_LOCK_CLEAR, array_ndx, value,
292 if (field == ACTION_FIELD_LATCH_TO_LOCK)
293 return CheckBooleanFlag(keymap->ctx, action->type, field,
294 ACTION_LATCH_TO_LOCK, array_ndx, value,
296 if (field == ACTION_FIELD_MODIFIERS)
297 return CheckModifierField(keymap, action->type, array_ndx, value,
298 &act->flags, &act->mods.mods);
300 return ReportIllegal(keymap->ctx, action->type, field);
303 static const LookupEntry lockWhich[] = {
305 { "lock", ACTION_LOCK_NO_UNLOCK },
306 { "neither", (ACTION_LOCK_NO_LOCK | ACTION_LOCK_NO_UNLOCK) },
307 { "unlock", ACTION_LOCK_NO_LOCK },
312 CheckAffectField(struct xkb_context *ctx, enum xkb_action_type action,
313 const ExprDef *array_ndx, const ExprDef *value,
314 enum xkb_action_flags *flags_inout)
316 enum xkb_action_flags flags;
319 return ReportActionNotArray(ctx, action, ACTION_FIELD_AFFECT);
321 if (!ExprResolveEnum(ctx, value, &flags, lockWhich))
322 return ReportMismatch(ctx, action, ACTION_FIELD_AFFECT,
323 "lock, unlock, both, neither");
325 *flags_inout &= ~(ACTION_LOCK_NO_LOCK | ACTION_LOCK_NO_UNLOCK);
326 *flags_inout |= flags;
331 HandleLockMods(struct xkb_keymap *keymap, union xkb_action *action,
332 enum action_field field, const ExprDef *array_ndx,
333 const ExprDef *value)
335 struct xkb_mod_action *act = &action->mods;
337 if (field == ACTION_FIELD_MODIFIERS)
338 return CheckModifierField(keymap, action->type, array_ndx, value,
339 &act->flags, &act->mods.mods);
340 else if (field == ACTION_FIELD_AFFECT)
341 return CheckAffectField(keymap->ctx, action->type, array_ndx, value,
344 return ReportIllegal(keymap->ctx, action->type, field);
348 CheckGroupField(struct xkb_context *ctx, unsigned action,
349 const ExprDef *array_ndx, const ExprDef *value,
350 enum xkb_action_flags *flags_inout, int32_t *group_rtrn)
353 xkb_layout_index_t idx;
354 enum xkb_action_flags flags = *flags_inout;
357 return ReportActionNotArray(ctx, action, ACTION_FIELD_GROUP);
359 if (value->expr.op == EXPR_NEGATE || value->expr.op == EXPR_UNARY_PLUS) {
360 flags &= ~ACTION_ABSOLUTE_SWITCH;
361 spec = value->unary.child;
364 flags |= ACTION_ABSOLUTE_SWITCH;
368 if (!ExprResolveGroup(ctx, spec, &idx))
369 return ReportMismatch(ctx, action, ACTION_FIELD_GROUP,
370 "integer (range 1..8)");
372 /* +n, -n are relative, n is absolute. */
373 if (value->expr.op == EXPR_NEGATE || value->expr.op == EXPR_UNARY_PLUS) {
374 *group_rtrn = (int32_t) idx;
375 if (value->expr.op == EXPR_NEGATE)
376 *group_rtrn = -*group_rtrn;
379 *group_rtrn = (int32_t) (idx - 1);
381 *flags_inout = flags;
386 HandleSetLatchGroup(struct xkb_keymap *keymap, union xkb_action *action,
387 enum action_field field, const ExprDef *array_ndx,
388 const ExprDef *value)
390 struct xkb_group_action *act = &action->group;
392 if (field == ACTION_FIELD_CLEAR_LOCKS)
393 return CheckBooleanFlag(keymap->ctx, action->type, field,
394 ACTION_LOCK_CLEAR, array_ndx, value,
396 if (field == ACTION_FIELD_LATCH_TO_LOCK)
397 return CheckBooleanFlag(keymap->ctx, action->type, field,
398 ACTION_LATCH_TO_LOCK, array_ndx, value,
400 if (field == ACTION_FIELD_GROUP)
401 return CheckGroupField(keymap->ctx, action->type, array_ndx, value,
402 &act->flags, &act->group);
404 return ReportIllegal(keymap->ctx, action->type, field);
408 HandleLockGroup(struct xkb_keymap *keymap, union xkb_action *action,
409 enum action_field field, const ExprDef *array_ndx,
410 const ExprDef *value)
412 struct xkb_group_action *act = &action->group;
414 if (field == ACTION_FIELD_GROUP)
415 return CheckGroupField(keymap->ctx, action->type, array_ndx, value,
416 &act->flags, &act->group);
418 return ReportIllegal(keymap->ctx, action->type, field);
422 HandleMovePtr(struct xkb_keymap *keymap, union xkb_action *action,
423 enum action_field field, const ExprDef *array_ndx,
424 const ExprDef *value)
426 struct xkb_pointer_action *act = &action->ptr;
428 if (field == ACTION_FIELD_X || field == ACTION_FIELD_Y) {
430 const bool absolute = (value->expr.op != EXPR_NEGATE &&
431 value->expr.op != EXPR_UNARY_PLUS);
434 return ReportActionNotArray(keymap->ctx, action->type, field);
436 if (!ExprResolveInteger(keymap->ctx, value, &val))
437 return ReportMismatch(keymap->ctx, action->type, field, "integer");
439 if (val < INT16_MIN || val > INT16_MAX) {
441 "The %s field in the %s action must be in range %d..%d; "
442 "Action definition ignored\n",
443 fieldText(field), ActionTypeText(action->type),
444 INT16_MIN, INT16_MAX);
448 if (field == ACTION_FIELD_X) {
450 act->flags |= ACTION_ABSOLUTE_X;
451 act->x = (int16_t) val;
455 act->flags |= ACTION_ABSOLUTE_Y;
456 act->y = (int16_t) val;
461 else if (field == ACTION_FIELD_ACCEL) {
462 return CheckBooleanFlag(keymap->ctx, action->type, field,
463 ACTION_ACCEL, array_ndx, value, &act->flags);
466 return ReportIllegal(keymap->ctx, action->type, field);
470 HandlePtrBtn(struct xkb_keymap *keymap, union xkb_action *action,
471 enum action_field field, const ExprDef *array_ndx,
472 const ExprDef *value)
474 struct xkb_pointer_button_action *act = &action->btn;
476 if (field == ACTION_FIELD_BUTTON) {
480 return ReportActionNotArray(keymap->ctx, action->type, field);
482 if (!ExprResolveButton(keymap->ctx, value, &btn))
483 return ReportMismatch(keymap->ctx, action->type, field,
484 "integer (range 1..5)");
486 if (btn < 0 || btn > 5) {
488 "Button must specify default or be in the range 1..5; "
489 "Illegal button value %d ignored\n", btn);
496 else if (action->type == ACTION_TYPE_PTR_LOCK &&
497 field == ACTION_FIELD_AFFECT) {
498 return CheckAffectField(keymap->ctx, action->type, array_ndx, value,
501 else if (field == ACTION_FIELD_COUNT) {
505 return ReportActionNotArray(keymap->ctx, action->type, field);
507 if (!ExprResolveInteger(keymap->ctx, value, &val))
508 return ReportMismatch(keymap->ctx, action->type, field, "integer");
510 if (val < 0 || val > 255) {
512 "The count field must have a value in the range 0..255; "
513 "Illegal count %d ignored\n", val);
517 act->count = (uint8_t) val;
521 return ReportIllegal(keymap->ctx, action->type, field);
524 static const LookupEntry ptrDflts[] = {
526 { "defaultbutton", 1 },
532 HandleSetPtrDflt(struct xkb_keymap *keymap, union xkb_action *action,
533 enum action_field field, const ExprDef *array_ndx,
534 const ExprDef *value)
536 struct xkb_pointer_default_action *act = &action->dflt;
538 if (field == ACTION_FIELD_AFFECT) {
542 return ReportActionNotArray(keymap->ctx, action->type, field);
544 if (!ExprResolveEnum(keymap->ctx, value, &val, ptrDflts))
545 return ReportMismatch(keymap->ctx, action->type, field,
546 "pointer component");
549 else if (field == ACTION_FIELD_BUTTON || field == ACTION_FIELD_VALUE) {
550 const ExprDef *button;
554 return ReportActionNotArray(keymap->ctx, action->type, field);
556 if (value->expr.op == EXPR_NEGATE ||
557 value->expr.op == EXPR_UNARY_PLUS) {
558 act->flags &= ~ACTION_ABSOLUTE_SWITCH;
559 button = value->unary.child;
562 act->flags |= ACTION_ABSOLUTE_SWITCH;
566 if (!ExprResolveButton(keymap->ctx, button, &btn))
567 return ReportMismatch(keymap->ctx, action->type, field,
568 "integer (range 1..5)");
570 if (btn < 0 || btn > 5) {
572 "New default button value must be in the range 1..5; "
573 "Illegal default button value %d ignored\n", btn);
578 "Cannot set default pointer button to \"default\"; "
579 "Illegal default button setting ignored\n");
583 act->value = (value->expr.op == EXPR_NEGATE ? -btn: btn);
587 return ReportIllegal(keymap->ctx, action->type, field);
591 HandleSwitchScreen(struct xkb_keymap *keymap, union xkb_action *action,
592 enum action_field field, const ExprDef *array_ndx,
593 const ExprDef *value)
595 struct xkb_switch_screen_action *act = &action->screen;
597 if (field == ACTION_FIELD_SCREEN) {
602 return ReportActionNotArray(keymap->ctx, action->type, field);
604 if (value->expr.op == EXPR_NEGATE ||
605 value->expr.op == EXPR_UNARY_PLUS) {
606 act->flags &= ~ACTION_ABSOLUTE_SWITCH;
607 scrn = value->unary.child;
610 act->flags |= ACTION_ABSOLUTE_SWITCH;
614 if (!ExprResolveInteger(keymap->ctx, scrn, &val))
615 return ReportMismatch(keymap->ctx, action->type, field,
618 if (val < 0 || val > 255) {
620 "Screen index must be in the range 1..255; "
621 "Illegal screen value %d ignored\n", val);
625 act->screen = (value->expr.op == EXPR_NEGATE ? -val : val);
628 else if (field == ACTION_FIELD_SAME) {
629 return CheckBooleanFlag(keymap->ctx, action->type, field,
630 ACTION_SAME_SCREEN, array_ndx, value,
634 return ReportIllegal(keymap->ctx, action->type, field);
638 HandleSetLockControls(struct xkb_keymap *keymap, union xkb_action *action,
639 enum action_field field, const ExprDef *array_ndx,
640 const ExprDef *value)
642 struct xkb_controls_action *act = &action->ctrls;
644 if (field == ACTION_FIELD_CONTROLS) {
648 return ReportActionNotArray(keymap->ctx, action->type, field);
650 if (!ExprResolveMask(keymap->ctx, value, &mask, ctrlMaskNames))
651 return ReportMismatch(keymap->ctx, action->type, field,
657 else if (field == ACTION_FIELD_AFFECT) {
658 return CheckAffectField(keymap->ctx, action->type, array_ndx, value,
662 return ReportIllegal(keymap->ctx, action->type, field);
666 HandlePrivate(struct xkb_keymap *keymap, union xkb_action *action,
667 enum action_field field, const ExprDef *array_ndx,
668 const ExprDef *value)
670 struct xkb_private_action *act = &action->priv;
672 if (field == ACTION_FIELD_TYPE) {
676 return ReportActionNotArray(keymap->ctx, action->type, field);
678 if (!ExprResolveInteger(keymap->ctx, value, &type))
679 return ReportMismatch(keymap->ctx, ACTION_TYPE_PRIVATE, field, "integer");
681 if (type < 0 || type > 255) {
683 "Private action type must be in the range 0..255; "
684 "Illegal type %d ignored\n", type);
689 * It's possible for someone to write something like this:
690 * actions = [ Private(type=3,data[0]=1,data[1]=3,data[2]=3) ]
691 * where the type refers to some existing action type, e.g. LockMods.
692 * This assumes that this action's struct is laid out in memory
693 * exactly as described in the XKB specification and libraries.
694 * We, however, have changed these structs in various ways, so this
695 * assumption is no longer true. Since this is a lousy "feature", we
696 * make actions like these no-ops for now.
698 if (type < ACTION_TYPE_PRIVATE) {
699 log_info(keymap->ctx,
700 "Private actions of type %s are not supported; Ignored\n",
701 ActionTypeText(type));
702 act->type = ACTION_TYPE_NONE;
705 act->type = (enum xkb_action_type) type;
710 else if (field == ACTION_FIELD_DATA) {
711 if (array_ndx == NULL) {
716 if (!ExprResolveString(keymap->ctx, value, &val))
717 return ReportMismatch(keymap->ctx, action->type, field, "string");
719 str = xkb_atom_text(keymap->ctx, val);
721 if (len < 1 || len > 7) {
722 log_warn(keymap->ctx,
723 "A private action has 7 data bytes; "
724 "Illegal data ignored\n");
728 strncpy((char *) act->data, str, sizeof(act->data));
734 if (!ExprResolveInteger(keymap->ctx, array_ndx, &ndx)) {
736 "Array subscript must be integer; "
737 "Illegal subscript ignored\n");
741 if (ndx < 0 || (size_t) ndx >= sizeof(act->data)) {
743 "The data for a private action is %lu bytes long; "
744 "Attempt to use data[%d] ignored\n",
745 (unsigned long) sizeof(act->data), ndx);
749 if (!ExprResolveInteger(keymap->ctx, value, &datum))
750 return ReportMismatch(keymap->ctx, act->type, field, "integer");
752 if (datum < 0 || datum > 255) {
754 "All data for a private action must be 0..255; "
755 "Illegal datum %d ignored\n", datum);
759 act->data[ndx] = (uint8_t) datum;
764 return ReportIllegal(keymap->ctx, ACTION_TYPE_NONE, field);
767 typedef bool (*actionHandler)(struct xkb_keymap *keymap,
768 union xkb_action *action,
769 enum action_field field,
770 const ExprDef *array_ndx,
771 const ExprDef *value);
773 static const actionHandler handleAction[_ACTION_TYPE_NUM_ENTRIES] = {
774 [ACTION_TYPE_NONE] = HandleNoAction,
775 [ACTION_TYPE_MOD_SET] = HandleSetLatchMods,
776 [ACTION_TYPE_MOD_LATCH] = HandleSetLatchMods,
777 [ACTION_TYPE_MOD_LOCK] = HandleLockMods,
778 [ACTION_TYPE_GROUP_SET] = HandleSetLatchGroup,
779 [ACTION_TYPE_GROUP_LATCH] = HandleSetLatchGroup,
780 [ACTION_TYPE_GROUP_LOCK] = HandleLockGroup,
781 [ACTION_TYPE_PTR_MOVE] = HandleMovePtr,
782 [ACTION_TYPE_PTR_BUTTON] = HandlePtrBtn,
783 [ACTION_TYPE_PTR_LOCK] = HandlePtrBtn,
784 [ACTION_TYPE_PTR_DEFAULT] = HandleSetPtrDflt,
785 [ACTION_TYPE_TERMINATE] = HandleNoAction,
786 [ACTION_TYPE_SWITCH_VT] = HandleSwitchScreen,
787 [ACTION_TYPE_CTRL_SET] = HandleSetLockControls,
788 [ACTION_TYPE_CTRL_LOCK] = HandleSetLockControls,
789 [ACTION_TYPE_PRIVATE] = HandlePrivate,
792 /***====================================================================***/
795 HandleActionDef(ExprDef *def, struct xkb_keymap *keymap,
796 union xkb_action *action, ActionsInfo *info)
800 unsigned handler_type;
802 if (def->expr.op != EXPR_ACTION_DECL) {
803 log_err(keymap->ctx, "Expected an action definition, found %s\n",
804 expr_op_type_to_string(def->expr.op));
808 str = xkb_atom_text(keymap->ctx, def->action.name);
809 if (!stringToAction(str, &handler_type)) {
810 log_err(keymap->ctx, "Unknown action %s\n", str);
815 * Get the default values for this action type, as modified by
816 * statements such as:
817 * latchMods.clearLocks = True;
819 *action = info->actions[handler_type];
822 * Now change the action properties as specified for this
823 * particular instance, e.g. "modifiers" and "clearLocks" in:
824 * SetMods(modifiers=Alt,clearLocks);
826 for (arg = def->action.args; arg != NULL;
827 arg = (ExprDef *) arg->common.next) {
828 const ExprDef *value;
829 ExprDef *field, *arrayRtrn;
830 const char *elemRtrn, *fieldRtrn;
831 enum action_field fieldNdx;
833 if (arg->expr.op == EXPR_ASSIGN) {
834 field = arg->binary.left;
835 value = arg->binary.right;
837 else if (arg->expr.op == EXPR_NOT || arg->expr.op == EXPR_INVERT) {
838 field = arg->unary.child;
839 value = (const ExprDef *) &constFalse;
843 value = (const ExprDef *) &constTrue;
846 if (!ExprResolveLhs(keymap->ctx, field, &elemRtrn, &fieldRtrn,
852 "Cannot change defaults in an action definition; "
853 "Ignoring attempt to change %s.%s\n",
854 elemRtrn, fieldRtrn);
858 if (!stringToField(fieldRtrn, &fieldNdx)) {
859 log_err(keymap->ctx, "Unknown field name %s\n", fieldRtrn);
863 if (!handleAction[handler_type](keymap, action, fieldNdx, arrayRtrn,
872 SetActionField(struct xkb_keymap *keymap, const char *elem, const char *field,
873 ExprDef *array_ndx, ExprDef *value, ActionsInfo *info)
876 enum action_field action_field;
878 if (!stringToAction(elem, &action))
881 if (!stringToField(field, &action_field)) {
882 log_err(keymap->ctx, "\"%s\" is not a legal field name\n", field);
886 return handleAction[action](keymap, &info->actions[action],
887 action_field, array_ndx, value);