Add support for default rules/model/layout Right now it just comes from build-time, but eventually this should be sourced from configuration files at runtime too. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
diff --git a/configure.ac b/configure.ac
index b5a83bc..12db771 100644
--- a/configure.ac
+++ b/configure.ac
@@ -97,6 +97,29 @@ AC_ARG_WITH([xkb_config_root],
[XKBCONFIGROOT="$xkb_base"])
AC_SUBST([XKBCONFIGROOT])
+AC_ARG_WITH([default_rules],
+ [AS_HELP_STRING([--with-default-rules=<path>],
+ [Default XKB ruleset (default: evdev)])],
+ [DEFAULT_XKB_RULES="$withval"],
+ [DEFAULT_XKB_RULES="evdev"])
+AC_DEFINE_UNQUOTED([DEFAULT_XKB_RULES], ["$DEFAULT_XKB_RULES"],
+ [Default XKB ruleset])
+
+AC_ARG_WITH([default_model],
+ [AS_HELP_STRING([--with-default-model=<path>],
+ [Default XKB model (default: pc105)])],
+ [DEFAULT_XKB_MODEL="$withval"],
+ [DEFAULT_XKB_MODEL="pc105"])
+AC_DEFINE_UNQUOTED([DEFAULT_XKB_MODEL], ["$DEFAULT_XKB_MODEL"],
+ [Default XKB model])
+
+AC_ARG_WITH([default_layout],
+ [AS_HELP_STRING([--with-default-layout=<path>],
+ [Default XKB layout (default: us)])],
+ [DEFAULT_XKB_LAYOUT="$withval"],
+ [DEFAULT_XKB_LAYOUT="us"])
+AC_DEFINE_UNQUOTED([DEFAULT_XKB_LAYOUT], ["$DEFAULT_XKB_LAYOUT"],
+ [Default XKB layout])
AC_CONFIG_FILES([
Makefile
diff --git a/src/xkbcomp/xkbcomp.c b/src/xkbcomp/xkbcomp.c
index 2932ba3..b18cd70 100644
--- a/src/xkbcomp/xkbcomp.c
+++ b/src/xkbcomp/xkbcomp.c
@@ -246,21 +246,24 @@ xkb_map_new_from_kccgst(struct xkb_context *ctx,
XKB_EXPORT struct xkb_keymap *
xkb_map_new_from_names(struct xkb_context *ctx,
- const struct xkb_rule_names *rmlvo,
+ const struct xkb_rule_names *rmlvo_in,
enum xkb_map_compile_flags flags)
{
struct xkb_component_names *kkctgs;
struct xkb_keymap *keymap;
+ struct xkb_rule_names rmlvo = *rmlvo_in;
- if (!rmlvo || ISEMPTY(rmlvo->rules) || ISEMPTY(rmlvo->layout)) {
- log_err(ctx, "rules and layout required to generate XKB keymap\n");
- return NULL;
- }
+ if (ISEMPTY(rmlvo.rules))
+ rmlvo.rules = DEFAULT_XKB_RULES;
+ if (ISEMPTY(rmlvo.model))
+ rmlvo.model = DEFAULT_XKB_MODEL;
+ if (ISEMPTY(rmlvo.layout))
+ rmlvo.layout = DEFAULT_XKB_LAYOUT;
- kkctgs = xkb_components_from_rules(ctx, rmlvo);
+ kkctgs = xkb_components_from_rules(ctx, &rmlvo);
if (!kkctgs) {
log_err(ctx, "failed to generate XKB components from rules \"%s\"\n",
- rmlvo->rules);
+ rmlvo.rules);
return NULL;
}
diff --git a/test/rulescomp.c b/test/rulescomp.c
index e2f4aec..30c0df8 100644
--- a/test/rulescomp.c
+++ b/test/rulescomp.c
@@ -100,7 +100,6 @@ int main(int argc, char *argv[])
assert(test_rmlvo(ctx, "evdev", "pc105", "us", "intl", ""));
assert(test_rmlvo(ctx, "evdev", "pc105", "us", "intl", "grp:alts_toggle"));
- assert(!test_rmlvo(ctx, "", "", "", "", ""));
assert(!test_rmlvo(ctx, "base", "", "", "", ""));
assert(!test_rmlvo(ctx, "base", "pc105", "", "", ""));
assert(!test_rmlvo(ctx, "badrules", "", "us", "", ""));