[mutter] tests/test-client: Make 'resize' client command include the titlebar



commit 2ee3d5392b5d37e08499787d8943bcfe86d32b99
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Thu Apr 2 16:03:47 2020 +0200

    tests/test-client: Make 'resize' client command include the titlebar
    
    To get some kind of consistency between what 'resize' means for the
    compositor and the client, make the size correspond to the "frame rect"
    of the window, i.e. the window geometry in the Wayland case, and the
    window size including the titlebar in the X11 case.
    
    This is so that the window size later can be reliably compared both in
    the compositor and in the client using the same expected dimensions.
    
    https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1171

 src/tests/test-client.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
---
diff --git a/src/tests/test-client.c b/src/tests/test-client.c
index 5687204bf..2c19d9a36 100644
--- a/src/tests/test-client.c
+++ b/src/tests/test-client.c
@@ -242,6 +242,18 @@ handle_take_focus (GtkWidget *window,
     }
 }
 
+static int
+calculate_titlebar_height (GtkWindow *window)
+{
+  GtkWidget *titlebar;
+
+  titlebar = gtk_window_get_titlebar (window);
+  if (!titlebar)
+    return 0;
+
+  return gtk_widget_get_allocated_height (titlebar);
+}
+
 static void
 process_line (const char *line)
 {
@@ -565,7 +577,10 @@ process_line (const char *line)
 
       int width = atoi (argv[2]);
       int height = atoi (argv[3]);
-      gtk_window_resize (GTK_WINDOW (window), width, height);
+      int titlebar_height = calculate_titlebar_height (GTK_WINDOW (window));
+      gtk_window_resize (GTK_WINDOW (window),
+                         width,
+                         height - titlebar_height);
     }
   else if (strcmp (argv[0], "raise") == 0)
     {


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