[Spice-devel] [PATCH v2 2/8] gtk: replace configure-event for size-allocate

Victor Toso lists at victortoso.com
Wed Feb 3 18:05:11 CET 2016


Hi,

On Mon, Jan 11, 2016 at 01:40:40PM +0100, Marc-André Lureau wrote:
> For size-allocate, it's simpler to connect to the signal rather than
> override the default signal handler since there is no automatic chaining
> to parent handler otherwise. Doing this removes the need to have a
> window.

Not sure if this is 100% correct. The function deals also with
grab/ungrab of mouse.

I think you want to connect to configure-event signal, no?

>
> Signed-off-by: Marc-André Lureau <marcandre.lureau at gmail.com>
> ---
>  src/spice-widget.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/src/spice-widget.c b/src/spice-widget.c
> index 614d93e..77f663f 100644
> --- a/src/spice-widget.c
> +++ b/src/spice-widget.c
> @@ -116,6 +116,7 @@ static void channel_destroy(SpiceSession *s, SpiceChannel *channel, gpointer dat
>  static void cursor_invalidate(SpiceDisplay *display);
>  static void update_area(SpiceDisplay *display, gint x, gint y, gint width, gint height);
>  static void release_keys(SpiceDisplay *display);
> +static void size_allocate(GtkWidget *widget, GtkAllocation *conf, gpointer data);
>
>  /* ---------------------------------------------------------------- */
>
> @@ -560,9 +561,9 @@ static void spice_display_init(SpiceDisplay *display)
>      gtk_drag_dest_set(widget, GTK_DEST_DEFAULT_ALL, &targets, 1, GDK_ACTION_COPY);
>      g_signal_connect(display, "drag-data-received",
>                       G_CALLBACK(drag_data_received_callback), NULL);
> +    g_signal_connect(display, "size-allocate", G_CALLBACK(size_allocate), NULL);
>
>      gtk_widget_add_events(widget,
> -                          GDK_STRUCTURE_MASK |
>                            GDK_POINTER_MOTION_MASK |
>                            GDK_BUTTON_PRESS_MASK |
>                            GDK_BUTTON_RELEASE_MASK |
> @@ -577,7 +578,6 @@ static void spice_display_init(SpiceDisplay *display)
>      gtk_widget_set_double_buffered(widget, true);
>  #endif
>      gtk_widget_set_can_focus(widget, true);
> -    gtk_widget_set_has_window(widget, true);
>      d->grabseq = spice_grab_sequence_new_from_string("Control_L+Alt_L");
>      d->activeseq = g_new0(gboolean, d->grabseq->nkeysyms);
>
> @@ -1746,7 +1746,7 @@ static gboolean button_event(GtkWidget *widget, GdkEventButton *button)
>      return true;
>  }
>
> -static gboolean configure_event(GtkWidget *widget, GdkEventConfigure *conf)
> +static void size_allocate(GtkWidget *widget, GtkAllocation *conf, gpointer data)
>  {
>      SpiceDisplay *display = SPICE_DISPLAY(widget);
>      SpiceDisplayPrivate *d = display->priv;

The size_allocate function still has a return true that needs to be
removed.

Cheers,
  toso

> @@ -1771,8 +1771,6 @@ static gboolean configure_event(GtkWidget *widget, GdkEventConfigure *conf)
>          try_mouse_grab(display);
>      }
>  #endif
> -
> -    return true;
>  }
>
>  static void update_image(SpiceDisplay *display)
> @@ -1826,7 +1824,6 @@ static void spice_display_class_init(SpiceDisplayClass *klass)
>      gtkwidget_class->motion_notify_event = motion_event;
>      gtkwidget_class->button_press_event = button_event;
>      gtkwidget_class->button_release_event = button_event;
> -    gtkwidget_class->configure_event = configure_event;
>      gtkwidget_class->scroll_event = scroll_event;
>      gtkwidget_class->realize = realize;
>      gtkwidget_class->unrealize = unrealize;
> --
> 2.5.0
>
> _______________________________________________
> 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