[nautilus/gnome-42] compress-dialog-controller: Really fix the cropped popover on X11



commit e3955ef6be3e7ce93daf0556f03f678c0d6516e2
Author: Ondrej Holy <oholy redhat com>
Date:   Tue Aug 9 19:45:07 2022 +0000

    compress-dialog-controller: Really fix the cropped popover on X11
    
    The commit 441124c tried to fix the cropped popover on X11 with twice the
    height window. This is still not enough with some translations, or when the
    larger font is used. Let's resize the window using the preferred popover
    size to avoid those issues.
    
    Fixes: https://gitlab.gnome.org/GNOME/nautilus/-/issues/2018

 src/nautilus-compress-dialog-controller.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/src/nautilus-compress-dialog-controller.c b/src/nautilus-compress-dialog-controller.c
index 6c5b6964c..9de328f08 100644
--- a/src/nautilus-compress-dialog-controller.c
+++ b/src/nautilus-compress-dialog-controller.c
@@ -400,13 +400,20 @@ popover_on_show (GtkWidget *widget,
     }
 
 #ifdef GDK_WINDOWING_X11
+    /* Workaround for https://gitlab.gnome.org/GNOME/nautilus/-/issues/2018 */
     if (GDK_IS_X11_DISPLAY (gdk_display_get_default ()))
     {
-        int w, h;
+        GtkWidget *vbox;
+        int w, h, y;
 
-        /* Workaround for https://gitlab.gnome.org/GNOME/nautilus/-/issues/2018 */
-        gtk_window_get_default_size (GTK_WINDOW (self->compress_dialog), &w, &h);
-        gtk_window_resize (GTK_WINDOW (self->compress_dialog), w, h * 2);
+        /* The vbox child is used instead of the dialog itself to get size
+         * without the title bar, client side decorations etc. */
+        vbox = gtk_bin_get_child (GTK_BIN (self->compress_dialog));
+        gtk_widget_translate_coordinates (widget, vbox, 0, gtk_widget_get_margin_top (vbox), NULL, &y);
+
+        gtk_widget_get_preferred_width (widget, NULL, &w);
+        gtk_widget_get_preferred_height (widget, NULL, &h);
+        gtk_window_resize (GTK_WINDOW (self->compress_dialog), w, y + h);
     }
 #endif
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]