[Spice-devel,spice-gtk,v1] spice-widget: keypress-delay set by env var

Submitted by Victor Toso on June 18, 2015, 10:14 a.m.

Details

Message ID 1434622452-8117-1-git-send-email-victortoso@redhat.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Victor Toso June 18, 2015, 10:14 a.m.
---
 src/spice-widget.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/src/spice-widget.c b/src/spice-widget.c
index 260fda5..6541e0b 100644
--- a/src/spice-widget.c
+++ b/src/spice-widget.c
@@ -1209,8 +1209,14 @@  static void send_key(SpiceDisplay *display, int scancode, SendKeyType type, gboo
         if (press_delayed &&
             d->keypress_delay != 0 &&
             !(d->key_state[i] & m)) {
+            const gchar *env = g_getenv("SPICE_KEYPRESS_DELAY");
+            guint delay = d->keypress_delay;
             g_warn_if_fail(d->key_delayed_id == 0);
-            d->key_delayed_id = g_timeout_add(d->keypress_delay, key_press_delayed, display);
+            if (env != NULL)
+                delay = (guint) g_ascii_strtoull(env, NULL, 10);
+
+            SPICE_DEBUG ("keypress-delay is: %u ms", delay);
+            d->key_delayed_id = g_timeout_add(delay, key_press_delayed, display);
             d->key_delayed_scancode = scancode;
         } else
             spice_inputs_key_press(d->inputs, scancode);

Comments

hi

----- Original Message -----
> ---
>  src/spice-widget.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/src/spice-widget.c b/src/spice-widget.c
> index 260fda5..6541e0b 100644
> --- a/src/spice-widget.c
> +++ b/src/spice-widget.c
> @@ -1209,8 +1209,14 @@ static void send_key(SpiceDisplay *display, int
> scancode, SendKeyType type, gboo
>          if (press_delayed &&
>              d->keypress_delay != 0 &&
>              !(d->key_state[i] & m)) {
> +            const gchar *env = g_getenv("SPICE_KEYPRESS_DELAY");
> +            guint delay = d->keypress_delay;
>              g_warn_if_fail(d->key_delayed_id == 0);
> -            d->key_delayed_id = g_timeout_add(d->keypress_delay,
> key_press_delayed, display);
> +            if (env != NULL)
> +                delay = (guint) g_ascii_strtoull(env, NULL, 10);
> +
> +            SPICE_DEBUG ("keypress-delay is: %u ms", delay);
> +            d->key_delayed_id = g_timeout_add(delay, key_press_delayed,
> display);
>              d->key_delayed_scancode = scancode;

look fine, 
but I think it should rather be set in spice_display_set_property(), so
it can be use even if keypress-delay is 0
Hey,

On Thu, Jun 18, 2015 at 06:42:04AM -0400, Marc-André Lureau wrote:
> hi
> 
> ----- Original Message -----
> > ---
> >  src/spice-widget.c | 8 +++++++-
> >  1 file changed, 7 insertions(+), 1 deletion(-)
> > 
> > diff --git a/src/spice-widget.c b/src/spice-widget.c
> > index 260fda5..6541e0b 100644
> > --- a/src/spice-widget.c
> > +++ b/src/spice-widget.c
> > @@ -1209,8 +1209,14 @@ static void send_key(SpiceDisplay *display, int
> > scancode, SendKeyType type, gboo
> >          if (press_delayed &&
> >              d->keypress_delay != 0 &&
> >              !(d->key_state[i] & m)) {
> > +            const gchar *env = g_getenv("SPICE_KEYPRESS_DELAY");
> > +            guint delay = d->keypress_delay;
> >              g_warn_if_fail(d->key_delayed_id == 0);
> > -            d->key_delayed_id = g_timeout_add(d->keypress_delay,
> > key_press_delayed, display);
> > +            if (env != NULL)
> > +                delay = (guint) g_ascii_strtoull(env, NULL, 10);
> > +
> > +            SPICE_DEBUG ("keypress-delay is: %u ms", delay);
> > +            d->key_delayed_id = g_timeout_add(delay, key_press_delayed,
> > display);
> >              d->key_delayed_scancode = scancode;
>
> look fine,
> but I think it should rather be set in spice_display_set_property(), so
> it can be use even if keypress-delay is 0

Thanks, will send a v2 for this patch then.