[Spice-commits] 2 commits - src/gtk-compat.h src/Makefile.am src/spice-gtk-session.c src/spice-widget.c src/spice-widget-cairo.c src/spice-widget-egl.c src/vncdisplaykeymap.c

Marc-André Lureau elmarco at kemper.freedesktop.org
Wed Mar 23 16:18:53 UTC 2016


 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       |   40 +++++++++++++++++++++++++++-------------
 src/vncdisplaykeymap.c   |    1 -
 7 files changed, 29 insertions(+), 50 deletions(-)

New commits:
commit 3390203021174ceb9bd5cd3f95c5a84c7f6ea7ef
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Tue Mar 22 19:21:05 2016 +0100

    widget: use allocation instead of window size
    
    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>

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 883983e..3bdc806 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 7522c7a..08040d3 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 */
 
 /**
@@ -2393,9 +2391,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(display)), &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"
commit 8d10969828a0e2a465f0bf25c0c3f3850f9b2fbc
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Tue Mar 22 19:18:01 2016 +0100

    widget: offset draw updates by widget allocation if necessary
    
    According to gtk_widget_queue_draw_area() documentation:
    
    "The region here is specified in widget coordinates. Widget coordinates
    are a bit odd; for historical reasons, they are defined as
    widget->window coordinates for widgets that return TRUE for
    gtk_widget_get_has_window(), and are relative to widget->allocation.x ,
    widget->allocation.y otherwise."
    
    Since spice-gtk 57df040cc, the SpiceDisplay no longer forces its own
    window. During gtk+ 3.19.8, gtk stack also no longer use its own
    window (commit 9d0e8401). In order to make drawing update resilient to
    such changes, add a function applying offset if necessary.
    
    This solves drawing glitches and perceived slowness with spice-gtk git
    and gtk+ >= 3.19.8.
    
    Signed-off-by: Marc-André Lureau <marcandre.lureau at gmail.com>
    Acked-by: Pavel Grunt <pgrunt at redhat.com>

diff --git a/src/spice-widget.c b/src/spice-widget.c
index c2204ed..7522c7a 100644
--- a/src/spice-widget.c
+++ b/src/spice-widget.c
@@ -2249,6 +2249,21 @@ static void primary_destroy(SpiceChannel *channel, gpointer data)
     set_monitor_ready(display, false);
 }
 
+static void queue_draw_area(SpiceDisplay *display, gint x, gint y,
+                            gint width, gint height)
+{
+    if (!gtk_widget_get_has_window(GTK_WIDGET(display))) {
+        GtkAllocation allocation;
+
+        gtk_widget_get_allocation(GTK_WIDGET(display), &allocation);
+        x += allocation.x;
+        y += allocation.y;
+    }
+
+    gtk_widget_queue_draw_area(GTK_WIDGET(display),
+                               x, y, width, height);
+}
+
 static void invalidate(SpiceChannel *channel,
                        gint x, gint y, gint w, gint h, gpointer data)
 {
@@ -2286,9 +2301,9 @@ static void invalidate(SpiceChannel *channel,
     x2 = ceil ((rect.x - d->area.x + rect.width) * s);
     y2 = ceil ((rect.y - d->area.y + rect.height) * s);
 
-    gtk_widget_queue_draw_area(GTK_WIDGET(display),
-                               display_x + x1, display_y + y1,
-                               x2 - x1, y2-y1);
+    queue_draw_area(display,
+                    display_x + x1, display_y + y1,
+                    x2 - x1, y2 - y1);
 }
 
 static void mark(SpiceDisplay *display, gint mark)
@@ -2439,11 +2454,11 @@ static void cursor_invalidate(SpiceDisplay *display)
 
     spice_display_get_scaling(display, &s, &x, &y, NULL, NULL);
 
-    gtk_widget_queue_draw_area(GTK_WIDGET(display),
-                               floor ((d->mouse_guest_x - d->mouse_hotspot.x - d->area.x) * s) + x,
-                               floor ((d->mouse_guest_y - d->mouse_hotspot.y - d->area.y) * s) + y,
-                               ceil (gdk_pixbuf_get_width(d->mouse_pixbuf) * s),
-                               ceil (gdk_pixbuf_get_height(d->mouse_pixbuf) * s));
+    queue_draw_area(display,
+                    floor ((d->mouse_guest_x - d->mouse_hotspot.x - d->area.x) * s) + x,
+                    floor ((d->mouse_guest_y - d->mouse_hotspot.y - d->area.y) * s) + y,
+                    ceil (gdk_pixbuf_get_width(d->mouse_pixbuf) * s),
+                    ceil (gdk_pixbuf_get_height(d->mouse_pixbuf) * s));
 }
 
 static void cursor_move(SpiceCursorChannel *channel, gint x, gint y, gpointer data)


More information about the Spice-commits mailing list