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

Marc-André Lureau marcandre.lureau at gmail.com
Tue Mar 22 18:27:40 UTC 2016


Since spice-gtk 57df040cc, the SpiceDisplay no longer forces its own
window. Get allocation instead of window size.

Signed-off-by: Marc-André Lureau <marcandre.lureau at gmail.com>
---
 src/Makefile.am          |  1 -
 src/gtk-compat.h         | 31 -------------------------------
 src/spice-gtk-session.c  |  1 -
 src/spice-widget-cairo.c |  6 ++++--
 src/spice-widget-egl.c   |  1 -
 src/spice-widget.c       | 11 ++++++-----
 src/vncdisplaykeymap.c   |  1 -
 7 files changed, 10 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..6a8afda 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,10 @@ 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);
+    GtkAllocation allocation;
+    gtk_widget_get_allocation(GTK_WIDGET(display), &allocation);
+    ww = allocation.width;
+    wh = allocation.height;
 
     /* 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 5fcdcaa..7a9ba73 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 e45513e..b409063 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 */
 
 /**
@@ -2410,9 +2408,12 @@ 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))) {
+        GtkAllocation allocation;
+        gtk_widget_get_allocation(GTK_WIDGET(display), &allocation);
+        ww = allocation.width;
+        wh = allocation.height;
+    } 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"
-- 
2.5.5



More information about the Spice-devel mailing list