[Spice-devel] [PATCH] spice-widget: Add spice_display_mouse_grab()

Marc-André Lureau mlureau at redhat.com
Tue Aug 27 10:50:51 PDT 2013


Hi

----- Mensaje original -----
> Similarly to spice_display_mouse_ungrab(), this is intedned to be used
> from outside code to force the display to grab the mouse (and
> keyboard).

That sounds reasonable, although we probably want the function to return whether it succeeded.

What should happen if you try to grab with mouse in client mode? fail silentely? warn?

> Signed-off-by: Martin Kletzander <mkletzan at redhat.com>
> ---
>  doc/reference/spice-gtk-sections.txt |  2 +-
>  gtk/map-file                         |  1 +
>  gtk/spice-gtk-sym-file               |  1 +
>  gtk/spice-widget.c                   | 16 ++++++++++++++--
>  gtk/spice-widget.h                   |  3 ++-
>  5 files changed, 19 insertions(+), 4 deletions(-)
> 
> diff --git a/doc/reference/spice-gtk-sections.txt
> b/doc/reference/spice-gtk-sections.txt
> index 8d61aa9..17f9d6c 100644
> --- a/doc/reference/spice-gtk-sections.txt
> +++ b/doc/reference/spice-gtk-sections.txt
> @@ -345,6 +345,7 @@ SpiceDisplayClass
>  SpiceDisplayKeyEvent
>  spice_display_new
>  spice_display_new_with_monitor
> +spice_display_mouse_grab
>  spice_display_mouse_ungrab
>  spice_display_copy_to_guest
>  spice_display_paste_from_guest
> @@ -428,4 +429,3 @@ SPICE_PORT_CHANNEL_GET_CLASS
>  <SUBSECTION Private>
>  SpicePortChannelPrivate
>  </SECTION>
> -
> diff --git a/gtk/map-file b/gtk/map-file
> index a69eb40..eb42049 100644
> --- a/gtk/map-file
> +++ b/gtk/map-file
> @@ -26,6 +26,7 @@ spice_display_get_grab_keys;
>  spice_display_get_pixbuf;
>  spice_display_get_type;
>  spice_display_key_event_get_type;
> +spice_display_mouse_grab;
>  spice_display_mouse_ungrab;
>  spice_display_new;
>  spice_display_new_with_monitor;
> diff --git a/gtk/spice-gtk-sym-file b/gtk/spice-gtk-sym-file
> index 1574e07..ef1b05b 100644
> --- a/gtk/spice-gtk-sym-file
> +++ b/gtk/spice-gtk-sym-file
> @@ -3,6 +3,7 @@ spice_display_get_grab_keys
>  spice_display_get_pixbuf
>  spice_display_get_type
>  spice_display_key_event_get_type
> +spice_display_mouse_grab
>  spice_display_mouse_ungrab
>  spice_display_new
>  spice_display_new_with_monitor
> diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c
> index d25edca..d18b39d 100644
> --- a/gtk/spice-widget.c
> +++ b/gtk/spice-widget.c
> @@ -1,6 +1,6 @@
>  /* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
>  /*
> -   Copyright (C) 2010 Red Hat, Inc.
> +   Copyright (C) 2010, 2013 Red Hat, Inc.
> 
>     This library is free software; you can redistribute it and/or
>     modify it under the terms of the GNU Lesser General Public
> @@ -83,7 +83,8 @@ static gboolean gtk_widget_get_realized(GtkWidget *widget)
>   * focused if the properties #SpiceDisplay:grab-keyboard and
>   * #SpiceDisplay:grab-mouse are #TRUE respectively.  It can be
>   * ungrabbed with spice_display_mouse_ungrab(), and by setting a key
> - * combination with spice_display_set_grab_keys().
> + * combination with spice_display_set_grab_keys().  The grab can be
> + * also forcefully initiated using spice_display_mouse_ungrab().
>   *
>   * Finally, spice_display_get_pixbuf() will take a screenshot of the
>   * current display and return an #GdkPixbuf (that you can then easily
> @@ -2492,6 +2493,17 @@ SpiceDisplay*
> spice_display_new_with_monitor(SpiceSession *session, gint channel
>  }
> 
>  /**
> + * spice_display_mouse_grab:
> + * @display:
> + *
> + * Grab the mouse.
> + **/
> +void spice_display_mouse_grab(SpiceDisplay *display)
> +{
> +    try_mouse_grab(display);
> +}
> +
> +/**
>   * spice_display_mouse_ungrab:
>   * @display:
>   *
> diff --git a/gtk/spice-widget.h b/gtk/spice-widget.h
> index d239ed2..b71aa53 100644
> --- a/gtk/spice-widget.h
> +++ b/gtk/spice-widget.h
> @@ -1,6 +1,6 @@
>  /* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
>  /*
> -   Copyright (C) 2010 Red Hat, Inc.
> +   Copyright (C) 2010, 2013 Red Hat, Inc.
> 
>     This library is free software; you can redistribute it and/or
>     modify it under the terms of the GNU Lesser General Public
> @@ -73,6 +73,7 @@ GType	        spice_display_get_type(void);
>  SpiceDisplay* spice_display_new(SpiceSession *session, int channel_id);
>  SpiceDisplay* spice_display_new_with_monitor(SpiceSession *session, gint
>  channel_id, gint monitor_id);
> 
> +void spice_display_mouse_grab(SpiceDisplay *display);
>  void spice_display_mouse_ungrab(SpiceDisplay *display);
>  void spice_display_set_grab_keys(SpiceDisplay *display, SpiceGrabSequence
>  *seq);
>  SpiceGrabSequence *spice_display_get_grab_keys(SpiceDisplay *display);
> --
> 1.8.3.2
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
> 


More information about the Spice-devel mailing list