rendernode-tool: Add --undecorated to show command
authorBenjamin Otte <otte@redhat.com>
Wed, 25 Oct 2023 18:31:01 +0000 (20:31 +0200)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 17 Nov 2023 19:55:26 +0000 (14:55 -0500)
This is to get exactly just the rendernode drawn when testing, and not
any extra drawing code.

docs/reference/gtk/gtk4-rendernode-tool.rst
tools/gtk-rendernode-tool-show.c

index ae2e9a2869c8bf7a329cf85381cd5afa94c55b9c..a01b6b58e4d07997f1c9e9a9d027112151a0f86e 100644 (file)
@@ -35,6 +35,11 @@ Showing
 
 The ``show`` command displays the rendernode.
 
+``--undecorated``
+
+Removes window decorations. This is meant for rendering of exactly the rendernode
+without any titlebar.
+
 Rendering
 ^^^^^^^^^
 
index 99d1d0a4f67de69140f8b9fcfd5f2340725611db..2892869d9b9a3ab1e76451660f0b3e96a645810d 100644 (file)
@@ -53,7 +53,8 @@ quit_cb (GtkWidget *widget,
 }
 
 static void
-show_file (const char *filename)
+show_file (const char *filename,
+           gboolean    decorated)
 {
   GskRenderNode *node;
   GdkPaintable *paintable;
@@ -79,6 +80,7 @@ show_file (const char *filename)
   gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), picture);
 
   window = gtk_window_new ();
+  gtk_window_set_decorated (GTK_WINDOW (window), decorated);
   set_window_title (GTK_WINDOW (window), filename);
   gtk_window_set_child (GTK_WINDOW (window), sw);
 
@@ -98,7 +100,9 @@ do_show (int          *argc,
 {
   GOptionContext *context;
   char **filenames = NULL;
+  gboolean decorated = TRUE;
   const GOptionEntry entries[] = {
+    { "undecorated", 0, G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &decorated, N_("Don't add a titlebar"), NULL },
     { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &filenames, NULL, N_("FILE") },
     { NULL, }
   };
@@ -137,7 +141,7 @@ do_show (int          *argc,
       exit (1);
     }
 
-  show_file (filenames[0]);
+  show_file (filenames[0], decorated);
 
   g_strfreev (filenames);
 }