interactive-evdev: includes options
Currently there is no interactive tool allowing to set the include paths of the context, such as in "compile-keymap". Note that only "interactive-evdev" makes sense, because it does not rely on a compositor. Add --include and --include-defaults to "interactive-evdev" tool. The code is adapted from "compile-keymap".master
parent
2c86216b5b
commit
de9d82077c
|
@ -59,6 +59,7 @@ static bool report_state_changes;
|
||||||
static bool with_compose;
|
static bool with_compose;
|
||||||
static enum xkb_consumed_mode consumed_mode = XKB_CONSUMED_MODE_XKB;
|
static enum xkb_consumed_mode consumed_mode = XKB_CONSUMED_MODE_XKB;
|
||||||
|
|
||||||
|
#define DEFAULT_INCLUDE_PATH_PLACEHOLDER "__defaults__"
|
||||||
#define NLONGS(n) (((n) + LONG_BIT - 1) / LONG_BIT)
|
#define NLONGS(n) (((n) + LONG_BIT - 1) / LONG_BIT)
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
@ -365,8 +366,9 @@ sigintr_handler(int signum)
|
||||||
static void
|
static void
|
||||||
usage(FILE *fp, char *progname)
|
usage(FILE *fp, char *progname)
|
||||||
{
|
{
|
||||||
fprintf(fp, "Usage: %s [--rules=<rules>] [--model=<model>] "
|
fprintf(fp, "Usage: %s [--include=<path>] [--include-defaults] "
|
||||||
"[--layout=<layout>] [--variant=<variant>] [--options=<options>]\n",
|
"[--rules=<rules>] [--model=<model>] [--layout=<layout>] "
|
||||||
|
"[--variant=<variant>] [--options=<options>]\n",
|
||||||
progname);
|
progname);
|
||||||
fprintf(fp, " or: %s --keymap <path to keymap file>\n",
|
fprintf(fp, " or: %s --keymap <path to keymap file>\n",
|
||||||
progname);
|
progname);
|
||||||
|
@ -386,6 +388,8 @@ main(int argc, char *argv[])
|
||||||
struct xkb_context *ctx = NULL;
|
struct xkb_context *ctx = NULL;
|
||||||
struct xkb_keymap *keymap = NULL;
|
struct xkb_keymap *keymap = NULL;
|
||||||
struct xkb_compose_table *compose_table = NULL;
|
struct xkb_compose_table *compose_table = NULL;
|
||||||
|
const char *includes[64];
|
||||||
|
size_t num_includes = 0;
|
||||||
const char *rules = NULL;
|
const char *rules = NULL;
|
||||||
const char *model = NULL;
|
const char *model = NULL;
|
||||||
const char *layout = NULL;
|
const char *layout = NULL;
|
||||||
|
@ -395,6 +399,8 @@ main(int argc, char *argv[])
|
||||||
const char *locale;
|
const char *locale;
|
||||||
struct sigaction act;
|
struct sigaction act;
|
||||||
enum options {
|
enum options {
|
||||||
|
OPT_INCLUDE,
|
||||||
|
OPT_INCLUDE_DEFAULTS,
|
||||||
OPT_RULES,
|
OPT_RULES,
|
||||||
OPT_MODEL,
|
OPT_MODEL,
|
||||||
OPT_LAYOUT,
|
OPT_LAYOUT,
|
||||||
|
@ -408,6 +414,8 @@ main(int argc, char *argv[])
|
||||||
};
|
};
|
||||||
static struct option opts[] = {
|
static struct option opts[] = {
|
||||||
{"help", no_argument, 0, 'h'},
|
{"help", no_argument, 0, 'h'},
|
||||||
|
{"include", required_argument, 0, OPT_INCLUDE},
|
||||||
|
{"include-defaults", no_argument, 0, OPT_INCLUDE_DEFAULTS},
|
||||||
{"rules", required_argument, 0, OPT_RULES},
|
{"rules", required_argument, 0, OPT_RULES},
|
||||||
{"model", required_argument, 0, OPT_MODEL},
|
{"model", required_argument, 0, OPT_MODEL},
|
||||||
{"layout", required_argument, 0, OPT_LAYOUT},
|
{"layout", required_argument, 0, OPT_LAYOUT},
|
||||||
|
@ -432,6 +440,20 @@ main(int argc, char *argv[])
|
||||||
break;
|
break;
|
||||||
|
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
|
case OPT_INCLUDE:
|
||||||
|
if (num_includes >= ARRAY_SIZE(includes)) {
|
||||||
|
fprintf(stderr, "error: too many includes\n");
|
||||||
|
exit(EXIT_INVALID_USAGE);
|
||||||
|
}
|
||||||
|
includes[num_includes++] = optarg;
|
||||||
|
break;
|
||||||
|
case OPT_INCLUDE_DEFAULTS:
|
||||||
|
if (num_includes >= ARRAY_SIZE(includes)) {
|
||||||
|
fprintf(stderr, "error: too many includes\n");
|
||||||
|
exit(EXIT_INVALID_USAGE);
|
||||||
|
}
|
||||||
|
includes[num_includes++] = DEFAULT_INCLUDE_PATH_PLACEHOLDER;
|
||||||
|
break;
|
||||||
case OPT_RULES:
|
case OPT_RULES:
|
||||||
rules = optarg;
|
rules = optarg;
|
||||||
break;
|
break;
|
||||||
|
@ -479,12 +501,23 @@ main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
|
ctx = xkb_context_new(XKB_CONTEXT_NO_DEFAULT_INCLUDES);
|
||||||
if (!ctx) {
|
if (!ctx) {
|
||||||
fprintf(stderr, "Couldn't create xkb context\n");
|
fprintf(stderr, "Couldn't create xkb context\n");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (num_includes == 0)
|
||||||
|
includes[num_includes++] = DEFAULT_INCLUDE_PATH_PLACEHOLDER;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < num_includes; i++) {
|
||||||
|
const char *include = includes[i];
|
||||||
|
if (strcmp(include, DEFAULT_INCLUDE_PATH_PLACEHOLDER) == 0)
|
||||||
|
xkb_context_include_path_append_default(ctx);
|
||||||
|
else
|
||||||
|
xkb_context_include_path_append(ctx, include);
|
||||||
|
}
|
||||||
|
|
||||||
if (keymap_path) {
|
if (keymap_path) {
|
||||||
FILE *file = fopen(keymap_path, "rb");
|
FILE *file = fopen(keymap_path, "rb");
|
||||||
if (!file) {
|
if (!file) {
|
||||||
|
|
|
@ -37,6 +37,18 @@ This is a debugging tool, its behavior or output is not guaranteed to be stable.
|
||||||
.It Fl \-help
|
.It Fl \-help
|
||||||
Print help and exit
|
Print help and exit
|
||||||
.
|
.
|
||||||
|
.It Fl \-include Ar PATH
|
||||||
|
Add the given path to the include path list.
|
||||||
|
This option is order\-dependent, include paths given first are searched first.
|
||||||
|
If an include path is given, the default include path list is not used.
|
||||||
|
Use
|
||||||
|
.Fl -\-include\-defaults
|
||||||
|
to add the default include paths.
|
||||||
|
.
|
||||||
|
.It Fl \-include\-defaults
|
||||||
|
Add the default set of include directories.
|
||||||
|
This option is order-dependent, include paths given first are searched first.
|
||||||
|
.
|
||||||
.It Fl \-rules Ar rules
|
.It Fl \-rules Ar rules
|
||||||
The XKB ruleset
|
The XKB ruleset
|
||||||
.
|
.
|
||||||
|
|
Loading…
Reference in New Issue