mirror of
https://gitlab.com/virt-viewer/virt-viewer.git
synced 2025-03-11 16:58:16 +03:00
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().
This commit is contained in:
parent
5d53583684
commit
21054f9685
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user