kmscon: add --xkb-repeat-rate/delay command-line arguments
authorDavid Herrmann <dh.herrmann@googlemail.com>
Tue, 9 Oct 2012 11:23:09 +0000 (13:23 +0200)
committerDavid Herrmann <dh.herrmann@googlemail.com>
Tue, 9 Oct 2012 11:23:09 +0000 (13:23 +0200)
These new arguments allow changing the xkb-repeat settings for kmscon.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
src/main.c
src/main.h
src/uterm.h
src/uterm_input.c
src/uterm_input.h
src/uterm_input_uxkb.c

index 4852bbb..7061848 100644 (file)
@@ -161,7 +161,9 @@ static void seat_new(struct kmscon_app *app,
        ret = uterm_input_new(&seat->input, app->eloop,
                              kmscon_conf.xkb_layout,
                              kmscon_conf.xkb_variant,
-                             kmscon_conf.xkb_options);
+                             kmscon_conf.xkb_options,
+                             kmscon_conf.xkb_repeat_delay,
+                             kmscon_conf.xkb_repeat_rate);
        if (ret)
                goto err_name;
 
@@ -464,9 +466,13 @@ static void print_help()
                "\t    --render-timing         [off]   Print renderer timing information\n"
                "\n"
                "Input Device Options:\n"
-               "\t    --xkb-layout <layout>   [us]    Set XkbLayout for input devices\n"
-               "\t    --xkb-variant <variant> [-]     Set XkbVariant for input devices\n"
-               "\t    --xkb-options <options> [-]     Set XkbOptions for input devices\n"
+               "\t    --xkb-layout <layout>      [us] Set XkbLayout for input devices\n"
+               "\t    --xkb-variant <variant>    [-]  Set XkbVariant for input devices\n"
+               "\t    --xkb-options <options>    [-]  Set XkbOptions for input devices\n"
+               "\t    --xkb-repeat-delay <msecs> [250]\n"
+               "\t                                 Initial delay for key-repeat in ms\n"
+               "\t    --xkb-repeat-rate <msecs>  [25]\n"
+               "\t                                 Delay between two key-repeats in ms\n"
                "\n"
                "\t    --grab-scroll-up <grab>   [<Shift>Up]\n"
                "\t                                Shortcut to scroll up\n"
@@ -642,6 +648,8 @@ struct conf_option options[] = {
        CONF_OPTION_STRING(0, "xkb-layout", NULL, &kmscon_conf.xkb_layout, "us"),
        CONF_OPTION_STRING(0, "xkb-variant", NULL, &kmscon_conf.xkb_variant, ""),
        CONF_OPTION_STRING(0, "xkb-options", NULL, &kmscon_conf.xkb_options, ""),
+       CONF_OPTION_UINT(0, "xkb-repeat-delay", NULL, &kmscon_conf.xkb_repeat_delay, 250),
+       CONF_OPTION_UINT(0, "xkb-repeat-rate", NULL, &kmscon_conf.xkb_repeat_rate, 25),
        CONF_OPTION_STRING(0, "font-engine", NULL, &kmscon_conf.font_engine, "pango"),
        CONF_OPTION_UINT(0, "font-size", NULL, &kmscon_conf.font_size, 12),
        CONF_OPTION_STRING(0, "font-name", NULL, &kmscon_conf.font_name, "monospace"),
index ebb796d..c609dbc 100644 (file)
@@ -61,6 +61,8 @@ struct kmscon_conf_t {
        char *xkb_layout;
        char *xkb_variant;
        char *xkb_options;
+       unsigned int xkb_repeat_delay;
+       unsigned int xkb_repeat_rate;
 
        /* TERM value */
        char *term;
index 5424462..f1045fa 100644 (file)
@@ -288,7 +288,9 @@ typedef void (*uterm_input_cb) (struct uterm_input *input,
 int uterm_input_new(struct uterm_input **out, struct ev_eloop *eloop,
                    const char *layout,
                    const char *variant,
-                   const char *options);
+                   const char *options,
+                   unsigned int repeat_delay,
+                   unsigned int repeat_rate);
 void uterm_input_ref(struct uterm_input *input);
 void uterm_input_unref(struct uterm_input *input);
 
index 083d4fb..2198c82 100644 (file)
@@ -166,8 +166,6 @@ static void input_new_dev(struct uterm_input *input,
        dev->input = input;
        dev->rfd = -1;
        dev->features = features;
-       dev->repeat_rate = 25;
-       dev->repeat_delay = 250;
 
        dev->node = strdup(node);
        if (!dev->node)
@@ -235,7 +233,9 @@ int uterm_input_new(struct uterm_input **out,
                    struct ev_eloop *eloop,
                    const char *layout,
                    const char *variant,
-                   const char *options)
+                   const char *options,
+                   unsigned int repeat_delay,
+                   unsigned int repeat_rate)
 {
        struct uterm_input *input;
        int ret;
@@ -243,12 +243,23 @@ int uterm_input_new(struct uterm_input **out,
        if (!out || !eloop)
                return -EINVAL;
 
+       if (!repeat_delay)
+               repeat_delay = 250;
+       if (repeat_delay >= 1000)
+               repeat_delay = 999;
+       if (!repeat_rate)
+               repeat_rate = 25;
+       if (repeat_rate >= 1000)
+               repeat_rate = 999;
+
        input = malloc(sizeof(*input));
        if (!input)
                return -ENOMEM;
        memset(input, 0, sizeof(*input));
        input->ref = 1;
        input->eloop = eloop;
+       input->repeat_delay = repeat_delay;
+       input->repeat_rate = repeat_rate;
        shl_dlist_init(&input->devices);
 
        ret = shl_hook_new(&input->hook);
index eed5b46..9c126e4 100644 (file)
@@ -51,8 +51,6 @@ struct uterm_input_dev {
        struct uterm_input_event event;
        struct uterm_input_event repeat_event;
 
-       unsigned int repeat_rate;
-       unsigned int repeat_delay;
        struct ev_timer *repeat_timer;
 };
 
@@ -60,6 +58,8 @@ struct uterm_input {
        unsigned long ref;
        struct ev_eloop *eloop;
        int awake;
+       unsigned int repeat_rate;
+       unsigned int repeat_delay;
 
        struct shl_hook *hook;
        struct xkb_context *ctx;
index 0d40274..a89b59e 100644 (file)
@@ -233,9 +233,9 @@ int uxkb_dev_process(struct uterm_input_dev *dev,
                }
 
                spec.it_interval.tv_sec = 0;
-               spec.it_interval.tv_nsec = dev->repeat_rate * 1000000;
+               spec.it_interval.tv_nsec = dev->input->repeat_rate * 1000000;
                spec.it_value.tv_sec = 0;
-               spec.it_value.tv_nsec = dev->repeat_delay * 1000000;
+               spec.it_value.tv_nsec = dev->input->repeat_delay * 1000000;
                ev_timer_update(dev->repeat_timer, &spec);
        }