Re: [spice-gtk v2 3/4] gtk-deprecated: silence warn on gtk_widget_set_double_buffered()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 
> From: Victor Toso <me@xxxxxxxxxxxxxx>
> 
> To quote documentation:
>  | gtk_widget_set_double_buffered has been deprecated since version
>  | 3.14 and should not be used in newly-written code.
>  | This function does not work under non-X11 backends or with
>  | non-native windows. It should not be used in newly written code.
> 
> So be sure to only call this function on X11 backend and silence
> warnings with G_GNUC_BEGIN/END_IGNORE_DEPRECATIONS
> 
> Warnings fixed:
>  | spice-widget.c: In function ‘spice_display_init’:
>  | spice-widget.c:643:5: warning: ‘gtk_widget_set_double_buffered’ is
>  | deprecated
>  |
>  |     gtk_widget_set_double_buffered(area, true);
>  |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>  |
>  | spice-widget.c:661:5: warning: ‘gtk_widget_set_double_buffered’ is
>  | deprecated
>  |
>  |     gtk_widget_set_double_buffered(area, true);
>  |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>  |
>  | spice-widget.c: In function ‘set_egl_enabled’:
>  | spice-widget.c:1290:9: warning: ‘gtk_widget_set_double_buffered’ is
>  | deprecated
>  |     gtk_widget_set_double_buffered(GTK_WIDGET(area), !enabled);
>  |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Signed-off-by: Victor Toso <victortoso@xxxxxxxxxx>
> ---
>  src/spice-widget.c | 18 +++++++++++++++---
>  1 file changed, 15 insertions(+), 3 deletions(-)
> 
> diff --git a/src/spice-widget.c b/src/spice-widget.c
> index ce123bd..bf10a0b 100644
> --- a/src/spice-widget.c
> +++ b/src/spice-widget.c
> @@ -104,6 +104,18 @@ static guint signals[SPICE_DISPLAY_LAST_SIGNAL];
>  static HWND win32_window = NULL;
>  #endif
>  
> +#ifdef GDK_WINDOWING_X11
> +#define SET_DOUBLE_BUFFERED_ON_X11(widget, enabled) G_STMT_START { \
> +    if (GDK_IS_X11_DISPLAY(gdk_display_get_default())) {           \
> +        G_GNUC_BEGIN_IGNORE_DEPRECATIONS                           \
> +        gtk_widget_set_double_buffered(widget, enabled);           \
> +        G_GNUC_END_IGNORE_DEPRECATIONS                             \
> +    }                                                              \
> +} G_STMT_END
> +#else
> +#define SET_DOUBLE_BUFFERED_ON_X11(widget, enabled) G_STMT_START { }
> G_STMT_END
> +#endif
> +
>  static void update_keyboard_grab(SpiceDisplay *display);
>  static void try_keyboard_grab(SpiceDisplay *display);
>  static void try_keyboard_ungrab(SpiceDisplay *display);
> @@ -640,7 +652,7 @@ static void spice_display_init(SpiceDisplay *display)
>                       "signal::realize", drawing_area_realize, display,
>                       NULL);
>      gtk_stack_add_named(d->stack, area, "draw-area");
> -    gtk_widget_set_double_buffered(area, true);
> +    SET_DOUBLE_BUFFERED_ON_X11(area, true);
>      gtk_stack_set_visible_child(d->stack, area);
>  
>  #if HAVE_EGL
> @@ -658,7 +670,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS
>  #endif
>      area = gtk_drawing_area_new();
>      gtk_stack_add_named(d->stack, area, "gst-area");
> -    gtk_widget_set_double_buffered(area, true);
> +    SET_DOUBLE_BUFFERED_ON_X11(area, true);
>  
>      gtk_widget_show_all(widget);
>  
> @@ -1281,7 +1293,7 @@ static void set_egl_enabled(SpiceDisplay *display, bool
> enabled)
>           * only way I found to prevent glitches when the window is
>           * resized. */
>          GtkWidget *area = gtk_stack_get_child_by_name(d->stack,
>          "draw-area");
> -        gtk_widget_set_double_buffered(GTK_WIDGET(area), !enabled);
> +        SET_DOUBLE_BUFFERED_ON_X11(GTK_WIDGET(area), !enabled);
>      } else
>  #endif
>      {

I would go for a simpler

diff --git a/src/spice-widget.c b/src/spice-widget.c
index 00b9562..80be8d4 100644
--- a/src/spice-widget.c
+++ b/src/spice-widget.c
@@ -637,7 +637,6 @@ static void spice_display_init(SpiceDisplay *display)
                      "signal::realize", drawing_area_realize, display,
                      NULL);
     gtk_stack_add_named(d->stack, area, "draw-area");
-    gtk_widget_set_double_buffered(area, true);
     gtk_stack_set_visible_child(d->stack, area);

 #if HAVE_EGL
@@ -652,7 +651,6 @@ static void spice_display_init(SpiceDisplay *display)
 #endif
     area = gtk_drawing_area_new();
     gtk_stack_add_named(d->stack, area, "gst-area");
-    gtk_widget_set_double_buffered(area, true);

     gtk_widget_show_all(widget);

@@ -1275,7 +1273,9 @@ static void set_egl_enabled(SpiceDisplay *display, bool enabled)
          * only way I found to prevent glitches when the window is
          * resized. */
         GtkWidget *area = gtk_stack_get_child_by_name(d->stack, "draw-area");
+        G_GNUC_BEGIN_IGNORE_DEPRECATIONS
         gtk_widget_set_double_buffered(GTK_WIDGET(area), !enabled);
+        G_GNUC_END_IGNORE_DEPRECATIONS
     } else
 #endif
     {


As default is TRUE there's no effect setting TRUE again after widgets creation.

Frediano
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux Virtualization]     [Linux Virtualization]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]