Fix virt-viewer window gradually getting bigger and bigger

This commit is contained in:
Christophe Fergeau 2016-10-05 11:44:29 +02:00
parent 926a661a8e
commit 9ffca9153d
2 changed files with 55 additions and 1 deletions

View File

@ -0,0 +1,48 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jonathon Jongsma <jjongsma@redhat.com>
Date: Fri, 22 Jul 2016 16:43:41 -0500
Subject: [virt-viewer] Fix resizing problem with recent gtk versions
When using client-side decorations, as well as in certain other
situations (wayland, and windows in some cases), the window gradually
resizes larger and larger.
This is caused by a change in how gtk interprets the sizes passed to
gtk_window_resize(), particularly when client-side decorations (CSD) are
involved. For example, In the past this size was assumed to include the
size of the CSD, but now it it assumes that the sizes only represent the
size of the window's content, without any decorations. However,
gtk_widget_get_preferred_size() (when called on a GtkWindow*), returns a
size that includes the size of the CSD. So
virt_viewer_window_queue_resize() was essentially growing the window by
the size of the CSD every time it was called.
To work around this issue, we need to calculate the preferred size of
the window's child, not the size of the entire window (including CSD).
Then we add the width of the window's border (just to be safe) and pass
those values to gtk_window_resize().
---
src/virt-viewer-window.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
index 7e6b93f..99fd102 100644
--- a/src/virt-viewer-window.c
+++ b/src/virt-viewer-window.c
@@ -411,10 +411,14 @@ virt_viewer_window_queue_resize(VirtViewerWindow *self)
{
VirtViewerWindowPrivate *priv = self->priv;
GtkRequisition nat;
+ GtkWidget *child;
+ guint border;
+ border = gtk_container_get_border_width(GTK_CONTAINER(priv->window));
+ child = gtk_bin_get_child(GTK_BIN(priv->window));
gtk_window_set_default_size(GTK_WINDOW(priv->window), -1, -1);
- gtk_widget_get_preferred_size(priv->window, NULL, &nat);
- gtk_window_resize(GTK_WINDOW(priv->window), nat.width, nat.height);
+ gtk_widget_get_preferred_size(child, NULL, &nat);
+ gtk_window_resize(GTK_WINDOW(priv->window), nat.width + border, nat.height + border);
}
static void

View File

@ -17,12 +17,13 @@
Name: virt-viewer Name: virt-viewer
Version: 4.0 Version: 4.0
Release: 1%{?dist}%{?extra_release} Release: 2%{?dist}%{?extra_release}
Summary: Virtual Machine Viewer Summary: Virtual Machine Viewer
Group: Applications/System Group: Applications/System
License: GPLv2+ License: GPLv2+
URL: http://virt-manager.org/ URL: http://virt-manager.org/
Source0: http://virt-manager.org/download/sources/%{name}/%{name}-%{version}.tar.gz Source0: http://virt-manager.org/download/sources/%{name}/%{name}-%{version}.tar.gz
Patch0: 0001-Fix-resizing-problem-with-recent-gtk-versions.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Requires: openssh-clients Requires: openssh-clients
Requires(post): %{_sbindir}/update-alternatives Requires(post): %{_sbindir}/update-alternatives
@ -65,6 +66,7 @@ the display, and libvirt for looking up VNC/SPICE server details.
%prep %prep
%setup -q %setup -q
%patch0 -p1
%build %build
@ -133,6 +135,10 @@ fi
%{_mandir}/man1/remote-viewer.1* %{_mandir}/man1/remote-viewer.1*
%changelog %changelog
* Wed Oct 05 2016 Christophe Fergeau <cfergeau@redhat.com> 4.0-2
- Add upstream patch fixing virt-viewer window gradually getting bigger and
bigger
* Thu Jun 30 2016 Daniel P. Berrange <berrange@redhat.com> - 4.0-1 * Thu Jun 30 2016 Daniel P. Berrange <berrange@redhat.com> - 4.0-1
- Update to 4.0 release - Update to 4.0 release