[Spice-devel] [PATCH v2 spice-gtk 2/2] widget: use allocation instead of window size

Pavel Grunt pgrunt at redhat.com
Wed Mar 23 12:15:13 UTC 2016


On Wed, 2016-03-23 at 12:25 +0100, Marc-André Lureau wrote:
> Since spice-gtk 57df040cc, the SpiceDisplay no longer forces its own
> window. Get allocation instead of window size.  This fixes a "top
> border" issue in spicy with gtk+ >= 3.19.8.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau at gmail.com>
Acked-by: Pavel Grunt <pgrunt at redhat.com>

Thanks,
Pavel
> ---
>  src/Makefile.am          |  1 -
>  src/gtk-compat.h         | 31 -------------------------------
>  src/spice-gtk-session.c  |  1 -
>  src/spice-widget-cairo.c |  4 ++--
>  src/spice-widget-egl.c   |  1 -
>  src/spice-widget.c       |  9 ++++-----
>  src/vncdisplaykeymap.c   |  1 -
>  7 files changed, 6 insertions(+), 42 deletions(-)
>  delete mode 100644 src/gtk-compat.h
> 
> diff --git a/src/Makefile.am b/src/Makefile.am
> index 66ba58b..330c85d 100644
> --- a/src/Makefile.am
> +++ b/src/Makefile.am
> @@ -122,7 +122,6 @@ SPICE_GTK_LIBADD_COMMON =		\
>  	$(NULL)
>  
>  SPICE_GTK_SOURCES_COMMON =		\
> -	gtk-compat.h			\
>  	spice-util.c			\
>  	spice-util-priv.h		\
>  	spice-gtk-session.c		\
> diff --git a/src/gtk-compat.h b/src/gtk-compat.h
> deleted file mode 100644
> index 39438f9..0000000
> --- a/src/gtk-compat.h
> +++ /dev/null
> @@ -1,31 +0,0 @@
> -/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
> -/*
> -   Copyright (C) 2012-2014 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
> -   License as published by the Free Software Foundation; either
> -   version 2.1 of the License, or (at your option) any later
> version.
> -
> -   This library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with this library; if not, see <http://www.gnu.org/
> licenses/>.
> -*/
> -#ifndef GTK_COMPAT_H
> -#define GTK_COMPAT_H
> -
> -#include "config.h"
> -
> -#include <gtk/gtk.h>
> -
> -static inline void gdk_drawable_get_size(GdkWindow *w, gint *ww,
> gint *wh)
> -{
> -    *ww = gdk_window_get_width(w);
> -    *wh = gdk_window_get_height(w);
> -}
> -
> -#endif /* GTK_COMPAT_H */
> diff --git a/src/spice-gtk-session.c b/src/spice-gtk-session.c
> index 4201ee0..380b0bb 100644
> --- a/src/spice-gtk-session.c
> +++ b/src/spice-gtk-session.c
> @@ -38,7 +38,6 @@
>  #include <gtk/gtk.h>
>  #include <spice/vd_agent.h>
>  #include "desktop-integration.h"
> -#include "gtk-compat.h"
>  #include "spice-common.h"
>  #include "spice-gtk-session.h"
>  #include "spice-gtk-session-priv.h"
> diff --git a/src/spice-widget-cairo.c b/src/spice-widget-cairo.c
> index c92d4ec..8c45524 100644
> --- a/src/spice-widget-cairo.c
> +++ b/src/spice-widget-cairo.c
> @@ -17,7 +17,6 @@
>  */
>  #include "config.h"
>  
> -#include "gtk-compat.h"
>  #include "spice-widget.h"
>  #include "spice-widget-priv.h"
>  #include "spice-gtk-session-priv.h"
> @@ -78,7 +77,8 @@ void spicex_draw_event(SpiceDisplay *display,
> cairo_t *cr)
>  
>      spice_display_get_scaling(display, &s, &x, &y, &w, &h);
>  
> -    gdk_drawable_get_size(gtk_widget_get_window(GTK_WIDGET(display))
> , &ww, &wh);
> +    ww = gtk_widget_get_allocated_width(GTK_WIDGET(display));
> +    wh = gtk_widget_get_allocated_height(GTK_WIDGET(display));
>  
>      /* We need to paint the bg color around the image */
>      rect.x = 0;
> diff --git a/src/spice-widget-egl.c b/src/spice-widget-egl.c
> index 5d839a3..4254628 100644
> --- a/src/spice-widget-egl.c
> +++ b/src/spice-widget-egl.c
> @@ -22,7 +22,6 @@
>  #define EGL_EGLEXT_PROTOTYPES
>  #define GL_GLEXT_PROTOTYPES
>  
> -#include "gtk-compat.h"
>  #include "spice-widget.h"
>  #include "spice-widget-priv.h"
>  #include "spice-gtk-session-priv.h"
> diff --git a/src/spice-widget.c b/src/spice-widget.c
> index 12be7c2..a9387ad 100644
> --- a/src/spice-widget.c
> +++ b/src/spice-widget.c
> @@ -42,8 +42,6 @@
>  #include "vncdisplaykeymap.h"
>  #include "spice-grabsequence-priv.h"
>  
> -#include "gtk-compat.h"
> -
>  /* Some compatibility defines to let us build on both Gtk2 and Gtk3
> */
>  
>  /**
> @@ -2411,9 +2409,10 @@ void spice_display_get_scaling(SpiceDisplay
> *display,
>      int x, y, w, h;
>      double s;
>  
> -    if (gtk_widget_get_realized (GTK_WIDGET(display)))
> -        gdk_drawable_get_size(gtk_widget_get_window(GTK_WIDGET(displ
> ay)), &ww, &wh);
> -    else {
> +    if (gtk_widget_get_realized (GTK_WIDGET(display))) {
> +        ww = gtk_widget_get_allocated_width(GTK_WIDGET(display));
> +        wh = gtk_widget_get_allocated_height(GTK_WIDGET(display));
> +    } else {
>          ww = fbw;
>          wh = fbh;
>      }
> diff --git a/src/vncdisplaykeymap.c b/src/vncdisplaykeymap.c
> index 6bf351f..9ee501d 100644
> --- a/src/vncdisplaykeymap.c
> +++ b/src/vncdisplaykeymap.c
> @@ -12,7 +12,6 @@
>  #include <gtk/gtk.h>
>  #include <gdk/gdk.h>
>  #include <gdk/gdkkeysyms.h>
> -#include "gtk-compat.h"
>  #include "vncdisplaykeymap.h"
>  
>  #include "spice-util.h"


More information about the Spice-devel mailing list