summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--net-misc/spice-gtk/files/spice-gtk-0.37-adjust-to-window-scaling.patch132
-rw-r--r--net-misc/spice-gtk/spice-gtk-0.37-r2.ebuild1
2 files changed, 133 insertions, 0 deletions
diff --git a/net-misc/spice-gtk/files/spice-gtk-0.37-adjust-to-window-scaling.patch b/net-misc/spice-gtk/files/spice-gtk-0.37-adjust-to-window-scaling.patch
new file mode 100644
index 000000000000..504cb7c4848b
--- /dev/null
+++ b/net-misc/spice-gtk/files/spice-gtk-0.37-adjust-to-window-scaling.patch
@@ -0,0 +1,132 @@
+From 262c84081fbd3cfc3d92e6ae9a60a780549d6c2f Mon Sep 17 00:00:00 2001
+From: Snir Sheriber <ssheribe@redhat.com>
+Date: Thu, 28 Feb 2019 11:44:34 +0200
+Subject: [PATCH] Adjust to window scaling
+
+When GDK_SCALE is != 1 and egl is used, the image presented does not
+fit to the window (scale of 2 is often used with hidpi monitors).
+Usually this is not a problem since all components are adjusted by
+gdk/gtk but with egl, pixel-based data is not being scaled. In this
+case window's scale value can be used in order to determine whether
+to use a pixel resource with higher resolution data.
+
+In order to reproduce the problem set spice with virgl/Intel-vGPU
+and run spice-gtk with GDK_SCALE=2
+
+This issue was also reported at freedesktop gitlab repo:
+https://gitlab.freedesktop.org/spice/spice-gtk/issues/99
+
+Signed-off-by: Snir Sheriber <ssheribe@redhat.com>
+Acked-by: Victor Toso <victortoso@redhat.com>
+---
+ src/spice-widget-egl.c | 7 ++++---
+ src/spice-widget.c | 27 +++++++++++++++++++--------
+ 2 files changed, 23 insertions(+), 11 deletions(-)
+
+diff --git a/src/spice-widget-egl.c b/src/spice-widget-egl.c
+index 43fccd7..7bae4e5 100644
+--- a/src/spice-widget-egl.c
++++ b/src/spice-widget-egl.c
+@@ -360,9 +360,9 @@ gboolean spice_egl_realize_display(SpiceDisplay *display, GdkWindow *win, GError
+ DISPLAY_DEBUG(display, "egl realize");
+ if (!spice_widget_init_egl_win(display, win, err))
+ return FALSE;
+-
+- spice_egl_resize_display(display, gdk_window_get_width(win),
+- gdk_window_get_height(win));
++ gint scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(display));
++ spice_egl_resize_display(display, gdk_window_get_width(win) * scale_factor,
++ gdk_window_get_height(win) * scale_factor);
+
+ return TRUE;
+ }
+@@ -426,6 +426,7 @@ void spice_egl_unrealize_display(SpiceDisplay *display)
+ #endif
+ }
+
++/* w and h should be adjusted to gdk scaling */
+ G_GNUC_INTERNAL
+ void spice_egl_resize_display(SpiceDisplay *display, int w, int h)
+ {
+diff --git a/src/spice-widget.c b/src/spice-widget.c
+index 1f2a154..a9ba1f1 100644
+--- a/src/spice-widget.c
++++ b/src/spice-widget.c
+@@ -1382,7 +1382,8 @@ static void set_egl_enabled(SpiceDisplay *display, bool enabled)
+ }
+
+ if (enabled && d->egl.context_ready) {
+- spice_egl_resize_display(display, d->ww, d->wh);
++ gint scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(display));
++ spice_egl_resize_display(display, d->ww * scale_factor, d->wh * scale_factor);
+ }
+
+ d->egl.enabled = enabled;
+@@ -1978,11 +1979,14 @@ static void transform_input(SpiceDisplay *display,
+ SpiceDisplayPrivate *d = display->priv;
+ int display_x, display_y, display_w, display_h;
+ double is;
++ gint scale_factor = 1;
+
+ spice_display_get_scaling(display, NULL,
+ &display_x, &display_y,
+ &display_w, &display_h);
+-
++ if (egl_enabled(d)) {
++ scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(display));
++ }
+ /* For input we need a different scaling factor in order to
+ be able to reach the full width of a display. For instance, consider
+ a display of 100 pixels showing in a window 10 pixels wide. The normal
+@@ -1998,7 +2002,7 @@ static void transform_input(SpiceDisplay *display,
+ coordinates in the inverse direction (window -> display) as the fb size
+ (display -> window).
+ */
+- is = (double)(d->area.width-1) / (double)(display_w-1);
++ is = ((double)(d->area.width-1) / (double)(display_w-1)) * scale_factor;
+
+ window_x -= display_x;
+ window_y -= display_y;
+@@ -2183,8 +2187,10 @@ static void size_allocate(GtkWidget *widget, GtkAllocation *conf, gpointer data)
+ d->wh = conf->height;
+ recalc_geometry(widget);
+ #if HAVE_EGL
+- if (egl_enabled(d))
+- spice_egl_resize_display(display, conf->width, conf->height);
++ if (egl_enabled(d)) {
++ gint scale_factor = gtk_widget_get_scale_factor(widget);
++ spice_egl_resize_display(display, conf->width * scale_factor, conf->height * scale_factor);
++ }
+ #endif
+ }
+
+@@ -2942,10 +2948,14 @@ void spice_display_get_scaling(SpiceDisplay *display,
+ int ww, wh;
+ int x, y, w, h;
+ double s;
++ gint scale_factor = 1;
+
+ 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));
++ if (egl_enabled(d)) {
++ scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(display));
++ }
++ ww = gtk_widget_get_allocated_width(GTK_WIDGET(display)) * scale_factor;
++ wh = gtk_widget_get_allocated_height(GTK_WIDGET(display)) * scale_factor;
+ } else {
+ ww = fbw;
+ wh = fbh;
+@@ -3091,7 +3101,8 @@ void spice_display_widget_gl_scanout(SpiceDisplay *display)
+ g_clear_error(&err);
+ }
+
+- spice_egl_resize_display(display, d->ww, d->wh);
++ gint scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(display));
++ spice_egl_resize_display(display, d->ww * scale_factor, d->wh * scale_factor);
+ }
+ #endif
+
+--
+2.21.0
+
diff --git a/net-misc/spice-gtk/spice-gtk-0.37-r2.ebuild b/net-misc/spice-gtk/spice-gtk-0.37-r2.ebuild
index 264775d79265..cb24fbda3a85 100644
--- a/net-misc/spice-gtk/spice-gtk-0.37-r2.ebuild
+++ b/net-misc/spice-gtk/spice-gtk-0.37-r2.ebuild
@@ -74,6 +74,7 @@ DEPEND="${RDEPEND}
"
PATCHES=(
+ "${FILESDIR}"/${P}-adjust-to-window-scaling.patch
)
src_prepare() {