Replace more defines with enums
Mostly the ones used to track the fields of types/keys/leds which were already defined. Signed-off-by: Ran Benita <ran234@gmail.com>master
parent
3bea189bd5
commit
cead852713
|
@ -29,8 +29,16 @@
|
||||||
#include "action.h"
|
#include "action.h"
|
||||||
#include "vmod.h"
|
#include "vmod.h"
|
||||||
|
|
||||||
|
enum si_field {
|
||||||
|
SI_FIELD_VIRTUAL_MOD = (1 << 0),
|
||||||
|
SI_FIELD_ACTION = (1 << 1),
|
||||||
|
SI_FIELD_AUTO_REPEAT = (1 << 2),
|
||||||
|
SI_FIELD_LOCKING_KEY = (1 << 3),
|
||||||
|
SI_FIELD_LEVEL_ONE_ONLY = (1 << 4),
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct _SymInterpInfo {
|
typedef struct _SymInterpInfo {
|
||||||
unsigned short defined;
|
enum si_field defined;
|
||||||
unsigned file_id;
|
unsigned file_id;
|
||||||
enum merge_mode merge;
|
enum merge_mode merge;
|
||||||
struct list entry;
|
struct list entry;
|
||||||
|
@ -38,14 +46,18 @@ typedef struct _SymInterpInfo {
|
||||||
struct xkb_sym_interpret interp;
|
struct xkb_sym_interpret interp;
|
||||||
} SymInterpInfo;
|
} SymInterpInfo;
|
||||||
|
|
||||||
#define _SI_VirtualMod (1 << 0)
|
enum led_field {
|
||||||
#define _SI_Action (1 << 1)
|
LED_FIELD_INDEX = (1 << 0),
|
||||||
#define _SI_AutoRepeat (1 << 2)
|
LED_FIELD_MODS = (1 << 1),
|
||||||
#define _SI_LockingKey (1 << 3)
|
LED_FIELD_GROUPS = (1 << 2),
|
||||||
#define _SI_LevelOneOnly (1 << 4)
|
LED_FIELD_CTRLS = (1 << 3),
|
||||||
|
LED_FIELD_EXPLICIT = (1 << 4),
|
||||||
|
LED_FIELD_AUTOMATIC = (1 << 5),
|
||||||
|
LED_FIELD_DRIVES_KBD = (1 << 6),
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct _LEDInfo {
|
typedef struct _LEDInfo {
|
||||||
unsigned short defined;
|
enum led_field defined;
|
||||||
unsigned file_id;
|
unsigned file_id;
|
||||||
enum merge_mode merge;
|
enum merge_mode merge;
|
||||||
struct list entry;
|
struct list entry;
|
||||||
|
@ -61,14 +73,6 @@ typedef struct _LEDInfo {
|
||||||
unsigned int ctrls;
|
unsigned int ctrls;
|
||||||
} LEDInfo;
|
} LEDInfo;
|
||||||
|
|
||||||
#define _LED_Index (1 << 0)
|
|
||||||
#define _LED_Mods (1 << 1)
|
|
||||||
#define _LED_Groups (1 << 2)
|
|
||||||
#define _LED_Ctrls (1 << 3)
|
|
||||||
#define _LED_Explicit (1 << 4)
|
|
||||||
#define _LED_Automatic (1 << 5)
|
|
||||||
#define _LED_DrivesKbd (1 << 6)
|
|
||||||
|
|
||||||
typedef struct _GroupCompatInfo {
|
typedef struct _GroupCompatInfo {
|
||||||
unsigned file_id;
|
unsigned file_id;
|
||||||
enum merge_mode merge;
|
enum merge_mode merge;
|
||||||
|
@ -247,8 +251,8 @@ FindMatchingInterp(CompatInfo * info, SymInterpInfo * new)
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
UseNewInterpField(unsigned field, SymInterpInfo *old, SymInterpInfo *new,
|
UseNewInterpField(enum si_field field, SymInterpInfo *old, SymInterpInfo *new,
|
||||||
int verbosity, unsigned *collide)
|
int verbosity, enum si_field *collide)
|
||||||
{
|
{
|
||||||
if (!(old->defined & field))
|
if (!(old->defined & field))
|
||||||
return true;
|
return true;
|
||||||
|
@ -267,7 +271,7 @@ UseNewInterpField(unsigned field, SymInterpInfo *old, SymInterpInfo *new,
|
||||||
static bool
|
static bool
|
||||||
AddInterp(CompatInfo * info, SymInterpInfo * new)
|
AddInterp(CompatInfo * info, SymInterpInfo * new)
|
||||||
{
|
{
|
||||||
unsigned collide;
|
enum si_field collide;
|
||||||
SymInterpInfo *old;
|
SymInterpInfo *old;
|
||||||
struct list entry;
|
struct list entry;
|
||||||
int verbosity = xkb_get_log_verbosity(info->keymap->ctx);
|
int verbosity = xkb_get_log_verbosity(info->keymap->ctx);
|
||||||
|
@ -288,33 +292,33 @@ AddInterp(CompatInfo * info, SymInterpInfo * new)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UseNewInterpField(_SI_VirtualMod, old, new, verbosity,
|
if (UseNewInterpField(SI_FIELD_VIRTUAL_MOD, old, new, verbosity,
|
||||||
&collide)) {
|
&collide)) {
|
||||||
old->interp.virtual_mod = new->interp.virtual_mod;
|
old->interp.virtual_mod = new->interp.virtual_mod;
|
||||||
old->defined |= _SI_VirtualMod;
|
old->defined |= SI_FIELD_VIRTUAL_MOD;
|
||||||
}
|
}
|
||||||
if (UseNewInterpField(_SI_Action, old, new, verbosity,
|
if (UseNewInterpField(SI_FIELD_ACTION, old, new, verbosity,
|
||||||
&collide)) {
|
&collide)) {
|
||||||
old->interp.act = new->interp.act;
|
old->interp.act = new->interp.act;
|
||||||
old->defined |= _SI_Action;
|
old->defined |= SI_FIELD_ACTION;
|
||||||
}
|
}
|
||||||
if (UseNewInterpField(_SI_AutoRepeat, old, new, verbosity,
|
if (UseNewInterpField(SI_FIELD_AUTO_REPEAT, old, new, verbosity,
|
||||||
&collide)) {
|
&collide)) {
|
||||||
old->interp.flags &= ~XkbSI_AutoRepeat;
|
old->interp.flags &= ~XkbSI_AutoRepeat;
|
||||||
old->interp.flags |= (new->interp.flags & XkbSI_AutoRepeat);
|
old->interp.flags |= (new->interp.flags & XkbSI_AutoRepeat);
|
||||||
old->defined |= _SI_AutoRepeat;
|
old->defined |= SI_FIELD_AUTO_REPEAT;
|
||||||
}
|
}
|
||||||
if (UseNewInterpField(_SI_LockingKey, old, new, verbosity,
|
if (UseNewInterpField(SI_FIELD_LOCKING_KEY, old, new, verbosity,
|
||||||
&collide)) {
|
&collide)) {
|
||||||
old->interp.flags &= ~XkbSI_LockingKey;
|
old->interp.flags &= ~XkbSI_LockingKey;
|
||||||
old->interp.flags |= (new->interp.flags & XkbSI_LockingKey);
|
old->interp.flags |= (new->interp.flags & XkbSI_LockingKey);
|
||||||
old->defined |= _SI_LockingKey;
|
old->defined |= SI_FIELD_LOCKING_KEY;
|
||||||
}
|
}
|
||||||
if (UseNewInterpField(_SI_LevelOneOnly, old, new, verbosity,
|
if (UseNewInterpField(SI_FIELD_LEVEL_ONE_ONLY, old, new, verbosity,
|
||||||
&collide)) {
|
&collide)) {
|
||||||
old->interp.match &= ~XkbSI_LevelOneOnly;
|
old->interp.match &= ~XkbSI_LevelOneOnly;
|
||||||
old->interp.match |= (new->interp.match & XkbSI_LevelOneOnly);
|
old->interp.match |= (new->interp.match & XkbSI_LevelOneOnly);
|
||||||
old->defined |= _SI_LevelOneOnly;
|
old->defined |= SI_FIELD_LEVEL_ONE_ONLY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (collide) {
|
if (collide) {
|
||||||
|
@ -409,8 +413,8 @@ ResolveStateAndPredicate(ExprDef * expr,
|
||||||
/***====================================================================***/
|
/***====================================================================***/
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
UseNewLEDField(unsigned field, LEDInfo *old, LEDInfo *new,
|
UseNewLEDField(enum led_field field, LEDInfo *old, LEDInfo *new,
|
||||||
int verbosity, unsigned *collide)
|
int verbosity, enum led_field *collide)
|
||||||
{
|
{
|
||||||
if (!(old->defined & field))
|
if (!(old->defined & field))
|
||||||
return true;
|
return true;
|
||||||
|
@ -430,7 +434,7 @@ static bool
|
||||||
AddIndicatorMap(CompatInfo *info, LEDInfo *new)
|
AddIndicatorMap(CompatInfo *info, LEDInfo *new)
|
||||||
{
|
{
|
||||||
LEDInfo *old;
|
LEDInfo *old;
|
||||||
unsigned collide;
|
enum led_field collide;
|
||||||
struct xkb_context *ctx = info->keymap->ctx;
|
struct xkb_context *ctx = info->keymap->ctx;
|
||||||
int verbosity = xkb_get_log_verbosity(ctx);
|
int verbosity = xkb_get_log_verbosity(ctx);
|
||||||
|
|
||||||
|
@ -460,46 +464,46 @@ AddIndicatorMap(CompatInfo *info, LEDInfo *new)
|
||||||
}
|
}
|
||||||
|
|
||||||
collide = 0;
|
collide = 0;
|
||||||
if (UseNewLEDField(_LED_Index, old, new, verbosity,
|
if (UseNewLEDField(LED_FIELD_INDEX, old, new, verbosity,
|
||||||
&collide)) {
|
&collide)) {
|
||||||
old->indicator = new->indicator;
|
old->indicator = new->indicator;
|
||||||
old->defined |= _LED_Index;
|
old->defined |= LED_FIELD_INDEX;
|
||||||
}
|
}
|
||||||
if (UseNewLEDField(_LED_Mods, old, new, verbosity,
|
if (UseNewLEDField(LED_FIELD_MODS, old, new, verbosity,
|
||||||
&collide)) {
|
&collide)) {
|
||||||
old->which_mods = new->which_mods;
|
old->which_mods = new->which_mods;
|
||||||
old->real_mods = new->real_mods;
|
old->real_mods = new->real_mods;
|
||||||
old->vmods = new->vmods;
|
old->vmods = new->vmods;
|
||||||
old->defined |= _LED_Mods;
|
old->defined |= LED_FIELD_MODS;
|
||||||
}
|
}
|
||||||
if (UseNewLEDField(_LED_Groups, old, new, verbosity,
|
if (UseNewLEDField(LED_FIELD_GROUPS, old, new, verbosity,
|
||||||
&collide)) {
|
&collide)) {
|
||||||
old->which_groups = new->which_groups;
|
old->which_groups = new->which_groups;
|
||||||
old->groups = new->groups;
|
old->groups = new->groups;
|
||||||
old->defined |= _LED_Groups;
|
old->defined |= LED_FIELD_GROUPS;
|
||||||
}
|
}
|
||||||
if (UseNewLEDField(_LED_Ctrls, old, new, verbosity,
|
if (UseNewLEDField(LED_FIELD_CTRLS, old, new, verbosity,
|
||||||
&collide)) {
|
&collide)) {
|
||||||
old->ctrls = new->ctrls;
|
old->ctrls = new->ctrls;
|
||||||
old->defined |= _LED_Ctrls;
|
old->defined |= LED_FIELD_CTRLS;
|
||||||
}
|
}
|
||||||
if (UseNewLEDField(_LED_Explicit, old, new, verbosity,
|
if (UseNewLEDField(LED_FIELD_EXPLICIT, old, new, verbosity,
|
||||||
&collide)) {
|
&collide)) {
|
||||||
old->flags &= ~XkbIM_NoExplicit;
|
old->flags &= ~XkbIM_NoExplicit;
|
||||||
old->flags |= (new->flags & XkbIM_NoExplicit);
|
old->flags |= (new->flags & XkbIM_NoExplicit);
|
||||||
old->defined |= _LED_Explicit;
|
old->defined |= LED_FIELD_EXPLICIT;
|
||||||
}
|
}
|
||||||
if (UseNewLEDField(_LED_Automatic, old, new, verbosity,
|
if (UseNewLEDField(LED_FIELD_AUTOMATIC, old, new, verbosity,
|
||||||
&collide)) {
|
&collide)) {
|
||||||
old->flags &= ~XkbIM_NoAutomatic;
|
old->flags &= ~XkbIM_NoAutomatic;
|
||||||
old->flags |= (new->flags & XkbIM_NoAutomatic);
|
old->flags |= (new->flags & XkbIM_NoAutomatic);
|
||||||
old->defined |= _LED_Automatic;
|
old->defined |= LED_FIELD_AUTOMATIC;
|
||||||
}
|
}
|
||||||
if (UseNewLEDField(_LED_DrivesKbd, old, new, verbosity,
|
if (UseNewLEDField(LED_FIELD_DRIVES_KBD, old, new, verbosity,
|
||||||
&collide)) {
|
&collide)) {
|
||||||
old->flags &= ~XkbIM_LEDDrivesKB;
|
old->flags &= ~XkbIM_LEDDrivesKB;
|
||||||
old->flags |= (new->flags & XkbIM_LEDDrivesKB);
|
old->flags |= (new->flags & XkbIM_LEDDrivesKB);
|
||||||
old->defined |= _LED_DrivesKbd;
|
old->defined |= LED_FIELD_DRIVES_KBD;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (collide) {
|
if (collide) {
|
||||||
|
@ -642,7 +646,7 @@ SetInterpField(CompatInfo *info, SymInterpInfo *si, const char *field,
|
||||||
if (!HandleActionDef(value, keymap, &si->interp.act.any, info->act))
|
if (!HandleActionDef(value, keymap, &si->interp.act.any, info->act))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
si->defined |= _SI_Action;
|
si->defined |= SI_FIELD_ACTION;
|
||||||
}
|
}
|
||||||
else if (istreq(field, "virtualmodifier") ||
|
else if (istreq(field, "virtualmodifier") ||
|
||||||
istreq(field, "virtualmod")) {
|
istreq(field, "virtualmod")) {
|
||||||
|
@ -653,7 +657,7 @@ SetInterpField(CompatInfo *info, SymInterpInfo *si, const char *field,
|
||||||
return ReportSIBadType(info, si, field, "virtual modifier");
|
return ReportSIBadType(info, si, field, "virtual modifier");
|
||||||
|
|
||||||
si->interp.virtual_mod = ndx;
|
si->interp.virtual_mod = ndx;
|
||||||
si->defined |= _SI_VirtualMod;
|
si->defined |= SI_FIELD_VIRTUAL_MOD;
|
||||||
}
|
}
|
||||||
else if (istreq(field, "repeat")) {
|
else if (istreq(field, "repeat")) {
|
||||||
bool set;
|
bool set;
|
||||||
|
@ -669,7 +673,7 @@ SetInterpField(CompatInfo *info, SymInterpInfo *si, const char *field,
|
||||||
else
|
else
|
||||||
si->interp.flags &= ~XkbSI_AutoRepeat;
|
si->interp.flags &= ~XkbSI_AutoRepeat;
|
||||||
|
|
||||||
si->defined |= _SI_AutoRepeat;
|
si->defined |= SI_FIELD_AUTO_REPEAT;
|
||||||
}
|
}
|
||||||
else if (istreq(field, "locking")) {
|
else if (istreq(field, "locking")) {
|
||||||
bool set;
|
bool set;
|
||||||
|
@ -685,7 +689,7 @@ SetInterpField(CompatInfo *info, SymInterpInfo *si, const char *field,
|
||||||
else
|
else
|
||||||
si->interp.flags &= ~XkbSI_LockingKey;
|
si->interp.flags &= ~XkbSI_LockingKey;
|
||||||
|
|
||||||
si->defined |= _SI_LockingKey;
|
si->defined |= SI_FIELD_LOCKING_KEY;
|
||||||
}
|
}
|
||||||
else if (istreq(field, "usemodmap") ||
|
else if (istreq(field, "usemodmap") ||
|
||||||
istreq(field, "usemodmapmods")) {
|
istreq(field, "usemodmapmods")) {
|
||||||
|
@ -702,7 +706,7 @@ SetInterpField(CompatInfo *info, SymInterpInfo *si, const char *field,
|
||||||
else
|
else
|
||||||
si->interp.match &= ~XkbSI_LevelOneOnly;
|
si->interp.match &= ~XkbSI_LevelOneOnly;
|
||||||
|
|
||||||
si->defined |= _SI_LevelOneOnly;
|
si->defined |= SI_FIELD_LEVEL_ONE_ONLY;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return ReportBadField(keymap, "symbol interpretation", field,
|
return ReportBadField(keymap, "symbol interpretation", field,
|
||||||
|
@ -764,7 +768,7 @@ SetIndicatorMapField(CompatInfo *info, LEDInfo *led,
|
||||||
|
|
||||||
led->real_mods = mask & 0xff;
|
led->real_mods = mask & 0xff;
|
||||||
led->vmods = (mask >> 8) & 0xff;
|
led->vmods = (mask >> 8) & 0xff;
|
||||||
led->defined |= _LED_Mods;
|
led->defined |= LED_FIELD_MODS;
|
||||||
}
|
}
|
||||||
else if (istreq(field, "groups")) {
|
else if (istreq(field, "groups")) {
|
||||||
unsigned int mask;
|
unsigned int mask;
|
||||||
|
@ -776,7 +780,7 @@ SetIndicatorMapField(CompatInfo *info, LEDInfo *led,
|
||||||
return ReportIndicatorBadType(info, led, field, "group mask");
|
return ReportIndicatorBadType(info, led, field, "group mask");
|
||||||
|
|
||||||
led->groups = mask;
|
led->groups = mask;
|
||||||
led->defined |= _LED_Groups;
|
led->defined |= LED_FIELD_GROUPS;
|
||||||
}
|
}
|
||||||
else if (istreq(field, "controls") || istreq(field, "ctrls")) {
|
else if (istreq(field, "controls") || istreq(field, "ctrls")) {
|
||||||
unsigned int mask;
|
unsigned int mask;
|
||||||
|
@ -789,7 +793,7 @@ SetIndicatorMapField(CompatInfo *info, LEDInfo *led,
|
||||||
"controls mask");
|
"controls mask");
|
||||||
|
|
||||||
led->ctrls = mask;
|
led->ctrls = mask;
|
||||||
led->defined |= _LED_Ctrls;
|
led->defined |= LED_FIELD_CTRLS;
|
||||||
}
|
}
|
||||||
else if (istreq(field, "allowexplicit")) {
|
else if (istreq(field, "allowexplicit")) {
|
||||||
bool set;
|
bool set;
|
||||||
|
@ -805,7 +809,7 @@ SetIndicatorMapField(CompatInfo *info, LEDInfo *led,
|
||||||
else
|
else
|
||||||
led->flags |= XkbIM_NoExplicit;
|
led->flags |= XkbIM_NoExplicit;
|
||||||
|
|
||||||
led->defined |= _LED_Explicit;
|
led->defined |= LED_FIELD_EXPLICIT;
|
||||||
}
|
}
|
||||||
else if (istreq(field, "whichmodstate") ||
|
else if (istreq(field, "whichmodstate") ||
|
||||||
istreq(field, "whichmodifierstate")) {
|
istreq(field, "whichmodifierstate")) {
|
||||||
|
@ -851,7 +855,7 @@ SetIndicatorMapField(CompatInfo *info, LEDInfo *led,
|
||||||
else
|
else
|
||||||
led->flags &= ~XkbIM_LEDDrivesKB;
|
led->flags &= ~XkbIM_LEDDrivesKB;
|
||||||
|
|
||||||
led->defined |= _LED_DrivesKbd;
|
led->defined |= LED_FIELD_DRIVES_KBD;
|
||||||
}
|
}
|
||||||
else if (istreq(field, "index")) {
|
else if (istreq(field, "index")) {
|
||||||
int ndx;
|
int ndx;
|
||||||
|
@ -873,7 +877,7 @@ SetIndicatorMapField(CompatInfo *info, LEDInfo *led,
|
||||||
}
|
}
|
||||||
|
|
||||||
led->indicator = (xkb_led_index_t) ndx;
|
led->indicator = (xkb_led_index_t) ndx;
|
||||||
led->defined |= _LED_Index;
|
led->defined |= LED_FIELD_INDEX;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log_err(info->keymap->ctx,
|
log_err(info->keymap->ctx,
|
||||||
|
|
|
@ -37,14 +37,15 @@ typedef struct _PreserveInfo {
|
||||||
unsigned short preVMods;
|
unsigned short preVMods;
|
||||||
} PreserveInfo;
|
} PreserveInfo;
|
||||||
|
|
||||||
#define _KT_Name (1 << 0)
|
enum type_field {
|
||||||
#define _KT_Mask (1 << 1)
|
TYPE_FIELD_MASK = (1 << 0),
|
||||||
#define _KT_Map (1 << 2)
|
TYPE_FIELD_MAP = (1 << 1),
|
||||||
#define _KT_Preserve (1 << 3)
|
TYPE_FIELD_PRESERVE = (1 << 2),
|
||||||
#define _KT_LevelNames (1 << 4)
|
TYPE_FIELD_LEVEL_NAME = (1 << 3),
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct _KeyTypeInfo {
|
typedef struct _KeyTypeInfo {
|
||||||
unsigned short defined;
|
enum type_field defined;
|
||||||
unsigned file_id;
|
unsigned file_id;
|
||||||
enum merge_mode merge;
|
enum merge_mode merge;
|
||||||
struct list entry;
|
struct list entry;
|
||||||
|
@ -723,7 +724,7 @@ SetKeyTypeField(KeyTypesInfo *info, KeyTypeInfo *type,
|
||||||
|
|
||||||
mods = mask & 0xff; /* core mods */
|
mods = mask & 0xff; /* core mods */
|
||||||
vmods = (mask >> 8) & 0xffff; /* xkb virtual mods */
|
vmods = (mask >> 8) & 0xffff; /* xkb virtual mods */
|
||||||
if (type->defined & _KT_Mask) {
|
if (type->defined & TYPE_FIELD_MASK) {
|
||||||
log_warn(info->keymap->ctx,
|
log_warn(info->keymap->ctx,
|
||||||
"Multiple modifier mask definitions for key type %s; "
|
"Multiple modifier mask definitions for key type %s; "
|
||||||
"Using %s, ignoring %s\n",
|
"Using %s, ignoring %s\n",
|
||||||
|
@ -734,19 +735,19 @@ SetKeyTypeField(KeyTypesInfo *info, KeyTypeInfo *type,
|
||||||
}
|
}
|
||||||
type->mask = mods;
|
type->mask = mods;
|
||||||
type->vmask = vmods;
|
type->vmask = vmods;
|
||||||
type->defined |= _KT_Mask;
|
type->defined |= TYPE_FIELD_MASK;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (istreq(field, "map")) {
|
else if (istreq(field, "map")) {
|
||||||
type->defined |= _KT_Map;
|
type->defined |= TYPE_FIELD_MAP;
|
||||||
return SetMapEntry(info, type, arrayNdx, value);
|
return SetMapEntry(info, type, arrayNdx, value);
|
||||||
}
|
}
|
||||||
else if (istreq(field, "preserve")) {
|
else if (istreq(field, "preserve")) {
|
||||||
type->defined |= _KT_Preserve;
|
type->defined |= TYPE_FIELD_PRESERVE;
|
||||||
return SetPreserve(info, type, arrayNdx, value);
|
return SetPreserve(info, type, arrayNdx, value);
|
||||||
}
|
}
|
||||||
else if (istreq(field, "levelname") || istreq(field, "level_name")) {
|
else if (istreq(field, "levelname") || istreq(field, "level_name")) {
|
||||||
type->defined |= _KT_LevelNames;
|
type->defined |= TYPE_FIELD_LEVEL_NAME;
|
||||||
return SetLevelName(info, type, arrayNdx, value);
|
return SetLevelName(info, type, arrayNdx, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,18 +37,22 @@
|
||||||
typedef darray(xkb_keysym_t) darray_xkb_keysym_t;
|
typedef darray(xkb_keysym_t) darray_xkb_keysym_t;
|
||||||
typedef darray(union xkb_action) darray_xkb_action;
|
typedef darray(union xkb_action) darray_xkb_action;
|
||||||
|
|
||||||
#define RepeatYes 1
|
enum key_repeat {
|
||||||
#define RepeatNo 0
|
KEY_REPEAT_YES = 1,
|
||||||
#define RepeatUndefined ~((unsigned) 0)
|
KEY_REPEAT_NO = 0,
|
||||||
|
KEY_REPEAT_UNDEFINED = -1
|
||||||
|
};
|
||||||
|
|
||||||
#define _Key_Syms (1 << 0)
|
enum key_field {
|
||||||
#define _Key_Acts (1 << 1)
|
KEY_FIELD_SYMS = (1 << 0),
|
||||||
#define _Key_Repeat (1 << 2)
|
KEY_FIELD_ACTS = (1 << 1),
|
||||||
#define _Key_Behavior (1 << 3)
|
KEY_FIELD_REPEAT = (1 << 2),
|
||||||
#define _Key_Type_Dflt (1 << 4)
|
KEY_FIELD_BEHAVIOR = (1 << 3),
|
||||||
#define _Key_Types (1 << 5)
|
KEY_FIELD_TYPE_DFLT = (1 << 4),
|
||||||
#define _Key_GroupInfo (1 << 6)
|
KEY_FIELD_TYPES = (1 << 5),
|
||||||
#define _Key_VModMap (1 << 7)
|
KEY_FIELD_GROUPINFO = (1 << 6),
|
||||||
|
KEY_FIELD_VMODMAP = (1 << 7),
|
||||||
|
};
|
||||||
|
|
||||||
static inline const char *
|
static inline const char *
|
||||||
longText(unsigned long val)
|
longText(unsigned long val)
|
||||||
|
@ -60,7 +64,7 @@ longText(unsigned long val)
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct _KeyInfo {
|
typedef struct _KeyInfo {
|
||||||
unsigned short defined;
|
enum key_field defined;
|
||||||
unsigned file_id;
|
unsigned file_id;
|
||||||
enum merge_mode merge;
|
enum merge_mode merge;
|
||||||
|
|
||||||
|
@ -88,7 +92,7 @@ typedef struct _KeyInfo {
|
||||||
darray_xkb_action acts[XkbNumKbdGroups];
|
darray_xkb_action acts[XkbNumKbdGroups];
|
||||||
|
|
||||||
xkb_atom_t types[XkbNumKbdGroups];
|
xkb_atom_t types[XkbNumKbdGroups];
|
||||||
unsigned repeat;
|
enum key_repeat repeat;
|
||||||
struct xkb_behavior behavior;
|
struct xkb_behavior behavior;
|
||||||
unsigned short vmodmap;
|
unsigned short vmodmap;
|
||||||
xkb_atom_t dfltType;
|
xkb_atom_t dfltType;
|
||||||
|
@ -125,7 +129,7 @@ InitKeyInfo(KeyInfo *keyi, unsigned file_id)
|
||||||
keyi->behavior.type = XkbKB_Default;
|
keyi->behavior.type = XkbKB_Default;
|
||||||
keyi->behavior.data = 0;
|
keyi->behavior.data = 0;
|
||||||
keyi->vmodmap = 0;
|
keyi->vmodmap = 0;
|
||||||
keyi->repeat = RepeatUndefined;
|
keyi->repeat = KEY_REPEAT_UNDEFINED;
|
||||||
keyi->out_of_range_group_action = 0;
|
keyi->out_of_range_group_action = 0;
|
||||||
keyi->out_of_range_group_number = 0;
|
keyi->out_of_range_group_number = 0;
|
||||||
}
|
}
|
||||||
|
@ -487,8 +491,8 @@ out:
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
UseNewKeyField(unsigned field, KeyInfo *old, KeyInfo *new, int verbosity,
|
UseNewKeyField(enum key_field field, KeyInfo *old, KeyInfo *new,
|
||||||
unsigned *collide)
|
int verbosity, enum key_field *collide)
|
||||||
{
|
{
|
||||||
if (!(old->defined & field))
|
if (!(old->defined & field))
|
||||||
return true;
|
return true;
|
||||||
|
@ -509,7 +513,7 @@ static bool
|
||||||
MergeKeys(SymbolsInfo *info, KeyInfo *into, KeyInfo *from)
|
MergeKeys(SymbolsInfo *info, KeyInfo *into, KeyInfo *from)
|
||||||
{
|
{
|
||||||
xkb_group_index_t i;
|
xkb_group_index_t i;
|
||||||
unsigned collide = 0;
|
enum key_field collide = 0;
|
||||||
bool report;
|
bool report;
|
||||||
int verbosity = xkb_get_log_verbosity(info->keymap->ctx);
|
int verbosity = xkb_get_log_verbosity(info->keymap->ctx);
|
||||||
|
|
||||||
|
@ -544,16 +548,16 @@ MergeKeys(SymbolsInfo *info, KeyInfo *into, KeyInfo *from)
|
||||||
from->numLevels[i] = 0;
|
from->numLevels[i] = 0;
|
||||||
from->symsDefined &= ~(1 << i);
|
from->symsDefined &= ~(1 << i);
|
||||||
if (!darray_empty(into->syms[i]))
|
if (!darray_empty(into->syms[i]))
|
||||||
into->defined |= _Key_Syms;
|
into->defined |= KEY_FIELD_SYMS;
|
||||||
if (!darray_empty(into->acts[i]))
|
if (!darray_empty(into->acts[i]))
|
||||||
into->defined |= _Key_Acts;
|
into->defined |= KEY_FIELD_ACTS;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (report) {
|
if (report) {
|
||||||
if (!darray_empty(into->syms[i]))
|
if (!darray_empty(into->syms[i]))
|
||||||
collide |= _Key_Syms;
|
collide |= KEY_FIELD_SYMS;
|
||||||
if (!darray_empty(into->acts[i]))
|
if (!darray_empty(into->acts[i]))
|
||||||
collide |= _Key_Acts;
|
collide |= KEY_FIELD_ACTS;
|
||||||
}
|
}
|
||||||
MergeKeyGroups(info, into, from, (unsigned) i);
|
MergeKeyGroups(info, into, from, (unsigned) i);
|
||||||
}
|
}
|
||||||
|
@ -562,7 +566,7 @@ MergeKeys(SymbolsInfo *info, KeyInfo *into, KeyInfo *from)
|
||||||
if ((into->types[i] != XKB_ATOM_NONE) && report &&
|
if ((into->types[i] != XKB_ATOM_NONE) && report &&
|
||||||
(into->types[i] != from->types[i])) {
|
(into->types[i] != from->types[i])) {
|
||||||
xkb_atom_t use, ignore;
|
xkb_atom_t use, ignore;
|
||||||
collide |= _Key_Types;
|
collide |= KEY_FIELD_TYPES;
|
||||||
if (from->merge != MERGE_AUGMENT) {
|
if (from->merge != MERGE_AUGMENT) {
|
||||||
use = from->types[i];
|
use = from->types[i];
|
||||||
ignore = into->types[i];
|
ignore = into->types[i];
|
||||||
|
@ -587,26 +591,26 @@ MergeKeys(SymbolsInfo *info, KeyInfo *into, KeyInfo *from)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UseNewKeyField(_Key_Behavior, into, from, verbosity, &collide)) {
|
if (UseNewKeyField(KEY_FIELD_BEHAVIOR, into, from, verbosity, &collide)) {
|
||||||
into->behavior = from->behavior;
|
into->behavior = from->behavior;
|
||||||
into->defined |= _Key_Behavior;
|
into->defined |= KEY_FIELD_BEHAVIOR;
|
||||||
}
|
}
|
||||||
if (UseNewKeyField(_Key_VModMap, into, from, verbosity, &collide)) {
|
if (UseNewKeyField(KEY_FIELD_VMODMAP, into, from, verbosity, &collide)) {
|
||||||
into->vmodmap = from->vmodmap;
|
into->vmodmap = from->vmodmap;
|
||||||
into->defined |= _Key_VModMap;
|
into->defined |= KEY_FIELD_VMODMAP;
|
||||||
}
|
}
|
||||||
if (UseNewKeyField(_Key_Repeat, into, from, verbosity, &collide)) {
|
if (UseNewKeyField(KEY_FIELD_REPEAT, into, from, verbosity, &collide)) {
|
||||||
into->repeat = from->repeat;
|
into->repeat = from->repeat;
|
||||||
into->defined |= _Key_Repeat;
|
into->defined |= KEY_FIELD_REPEAT;
|
||||||
}
|
}
|
||||||
if (UseNewKeyField(_Key_Type_Dflt, into, from, verbosity, &collide)) {
|
if (UseNewKeyField(KEY_FIELD_TYPE_DFLT, into, from, verbosity, &collide)) {
|
||||||
into->dfltType = from->dfltType;
|
into->dfltType = from->dfltType;
|
||||||
into->defined |= _Key_Type_Dflt;
|
into->defined |= KEY_FIELD_TYPE_DFLT;
|
||||||
}
|
}
|
||||||
if (UseNewKeyField(_Key_GroupInfo, into, from, verbosity, &collide)) {
|
if (UseNewKeyField(KEY_FIELD_GROUPINFO, into, from, verbosity, &collide)) {
|
||||||
into->out_of_range_group_action = from->out_of_range_group_action;
|
into->out_of_range_group_action = from->out_of_range_group_action;
|
||||||
into->out_of_range_group_number = from->out_of_range_group_number;
|
into->out_of_range_group_number = from->out_of_range_group_number;
|
||||||
into->defined |= _Key_GroupInfo;
|
into->defined |= KEY_FIELD_GROUPINFO;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (collide)
|
if (collide)
|
||||||
|
@ -1010,13 +1014,13 @@ static const LookupEntry lockingEntries[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static const LookupEntry repeatEntries[] = {
|
static const LookupEntry repeatEntries[] = {
|
||||||
{ "true", RepeatYes },
|
{ "true", KEY_REPEAT_YES },
|
||||||
{ "yes", RepeatYes },
|
{ "yes", KEY_REPEAT_YES },
|
||||||
{ "on", RepeatYes },
|
{ "on", KEY_REPEAT_YES },
|
||||||
{ "false", RepeatNo },
|
{ "false", KEY_REPEAT_NO },
|
||||||
{ "no", RepeatNo },
|
{ "no", KEY_REPEAT_NO },
|
||||||
{ "off", RepeatNo },
|
{ "off", KEY_REPEAT_NO },
|
||||||
{ "default", RepeatUndefined },
|
{ "default", KEY_REPEAT_UNDEFINED },
|
||||||
{ NULL, 0 }
|
{ NULL, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1038,7 +1042,7 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
|
||||||
|
|
||||||
if (arrayNdx == NULL) {
|
if (arrayNdx == NULL) {
|
||||||
keyi->dfltType = xkb_atom_intern(ctx, str);
|
keyi->dfltType = xkb_atom_intern(ctx, str);
|
||||||
keyi->defined |= _Key_Type_Dflt;
|
keyi->defined |= KEY_FIELD_TYPE_DFLT;
|
||||||
}
|
}
|
||||||
else if (!ExprResolveGroup(ctx, arrayNdx, &ndx)) {
|
else if (!ExprResolveGroup(ctx, arrayNdx, &ndx)) {
|
||||||
log_err(info->keymap->ctx,
|
log_err(info->keymap->ctx,
|
||||||
|
@ -1065,7 +1069,7 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
|
||||||
ok = ExprResolveVModMask(info->keymap, value, &mask);
|
ok = ExprResolveVModMask(info->keymap, value, &mask);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
keyi->vmodmap = (mask >> 8);
|
keyi->vmodmap = (mask >> 8);
|
||||||
keyi->defined |= _Key_VModMap;
|
keyi->defined |= KEY_FIELD_VMODMAP;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log_err(info->keymap->ctx,
|
log_err(info->keymap->ctx,
|
||||||
|
@ -1082,7 +1086,7 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
|
||||||
ok = ExprResolveEnum(ctx, value, &val, lockingEntries);
|
ok = ExprResolveEnum(ctx, value, &val, lockingEntries);
|
||||||
if (ok)
|
if (ok)
|
||||||
keyi->behavior.type = val;
|
keyi->behavior.type = val;
|
||||||
keyi->defined |= _Key_Behavior;
|
keyi->defined |= KEY_FIELD_BEHAVIOR;
|
||||||
}
|
}
|
||||||
else if (istreq(field, "radiogroup") ||
|
else if (istreq(field, "radiogroup") ||
|
||||||
istreq(field, "permanentradiogroup") ||
|
istreq(field, "permanentradiogroup") ||
|
||||||
|
@ -1114,7 +1118,7 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
keyi->repeat = val;
|
keyi->repeat = val;
|
||||||
keyi->defined |= _Key_Repeat;
|
keyi->defined |= KEY_FIELD_REPEAT;
|
||||||
}
|
}
|
||||||
else if (istreq(field, "groupswrap") ||
|
else if (istreq(field, "groupswrap") ||
|
||||||
istreq(field, "wrapgroups")) {
|
istreq(field, "wrapgroups")) {
|
||||||
|
@ -1133,7 +1137,7 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
|
||||||
else
|
else
|
||||||
keyi->out_of_range_group_action = XkbClampIntoRange;
|
keyi->out_of_range_group_action = XkbClampIntoRange;
|
||||||
|
|
||||||
keyi->defined |= _Key_GroupInfo;
|
keyi->defined |= KEY_FIELD_GROUPINFO;
|
||||||
}
|
}
|
||||||
else if (istreq(field, "groupsclamp") ||
|
else if (istreq(field, "groupsclamp") ||
|
||||||
istreq(field, "clampgroups")) {
|
istreq(field, "clampgroups")) {
|
||||||
|
@ -1152,7 +1156,7 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
|
||||||
else
|
else
|
||||||
keyi->out_of_range_group_action = XkbWrapIntoRange;
|
keyi->out_of_range_group_action = XkbWrapIntoRange;
|
||||||
|
|
||||||
keyi->defined |= _Key_GroupInfo;
|
keyi->defined |= KEY_FIELD_GROUPINFO;
|
||||||
}
|
}
|
||||||
else if (istreq(field, "groupsredirect") ||
|
else if (istreq(field, "groupsredirect") ||
|
||||||
istreq(field, "redirectgroups")) {
|
istreq(field, "redirectgroups")) {
|
||||||
|
@ -1168,7 +1172,7 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
|
||||||
|
|
||||||
keyi->out_of_range_group_action = XkbRedirectIntoRange;
|
keyi->out_of_range_group_action = XkbRedirectIntoRange;
|
||||||
keyi->out_of_range_group_number = grp - 1;
|
keyi->out_of_range_group_number = grp - 1;
|
||||||
keyi->defined |= _Key_GroupInfo;
|
keyi->defined |= KEY_FIELD_GROUPINFO;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log_err(info->keymap->ctx,
|
log_err(info->keymap->ctx,
|
||||||
|
@ -1810,7 +1814,7 @@ CopySymbolsDef(SymbolsInfo *info, KeyInfo *keyi,
|
||||||
outActs = NULL;
|
outActs = NULL;
|
||||||
|
|
||||||
key->num_groups = nGroups;
|
key->num_groups = nGroups;
|
||||||
if (keyi->defined & _Key_GroupInfo) {
|
if (keyi->defined & KEY_FIELD_GROUPINFO) {
|
||||||
key->out_of_range_group_number = keyi->out_of_range_group_number;
|
key->out_of_range_group_number = keyi->out_of_range_group_number;
|
||||||
key->out_of_range_group_action = keyi->out_of_range_group_action;
|
key->out_of_range_group_action = keyi->out_of_range_group_action;
|
||||||
}
|
}
|
||||||
|
@ -1865,12 +1869,12 @@ CopySymbolsDef(SymbolsInfo *info, KeyInfo *keyi,
|
||||||
key->explicit |= XkbExplicitBehaviorMask;
|
key->explicit |= XkbExplicitBehaviorMask;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (keyi->defined & _Key_VModMap) {
|
if (keyi->defined & KEY_FIELD_VMODMAP) {
|
||||||
key->vmodmap = keyi->vmodmap;
|
key->vmodmap = keyi->vmodmap;
|
||||||
key->explicit |= XkbExplicitVModMapMask;
|
key->explicit |= XkbExplicitVModMapMask;
|
||||||
}
|
}
|
||||||
if (keyi->repeat != RepeatUndefined) {
|
if (keyi->repeat != KEY_REPEAT_UNDEFINED) {
|
||||||
key->repeats = keyi->repeat == RepeatYes;
|
key->repeats = (keyi->repeat == KEY_REPEAT_YES);
|
||||||
key->explicit |= XkbExplicitAutoRepeatMask;
|
key->explicit |= XkbExplicitAutoRepeatMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue