[gtk/matthiasc/for-master: 11/16] main: Reshuffle debug code




commit 4b589b6afbe84ca24824a681d1bb089f3a60515d
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Sep 13 22:48:29 2020 -0400

    main: Reshuffle debug code
    
    Mode all the debug flags related code together,
    to make gtkmain.c a bit less messy.

 gtk/gtkmain.c | 164 +++++++++++++++++++++++++++++-----------------------------
 1 file changed, 82 insertions(+), 82 deletions(-)
---
diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c
index 8a9a0b12e8..a72801e8dd 100644
--- a/gtk/gtkmain.c
+++ b/gtk/gtkmain.c
@@ -162,6 +162,88 @@ DisplayDebugFlags debug_flags[N_DEBUG_DISPLAYS];
  * hot paths. */
 gboolean any_display_debug_flags_set = FALSE;
 
+GtkDebugFlags
+gtk_get_display_debug_flags (GdkDisplay *display)
+{
+  int i;
+
+  if (display == NULL)
+    display = gdk_display_get_default ();
+
+  for (i = 0; i < N_DEBUG_DISPLAYS; i++)
+    {
+      if (debug_flags[i].display == display)
+        return (GtkDebugFlags)debug_flags[i].flags;
+    }
+
+  return 0;
+}
+
+gboolean
+gtk_get_any_display_debug_flag_set (void)
+{
+  return any_display_debug_flags_set;
+}
+
+void
+gtk_set_display_debug_flags (GdkDisplay    *display,
+                             GtkDebugFlags  flags)
+{
+  int i;
+
+  for (i = 0; i < N_DEBUG_DISPLAYS; i++)
+    {
+      if (debug_flags[i].display == NULL)
+        debug_flags[i].display = display;
+
+      if (debug_flags[i].display == display)
+        {
+          debug_flags[i].flags = flags;
+          if (flags > 0)
+            any_display_debug_flags_set = TRUE;
+
+          return;
+        }
+    }
+}
+
+/**
+ * gtk_get_debug_flags:
+ *
+ * Returns the GTK debug flags that are currently active.
+ *
+ * This function is intended for GTK modules that want
+ * to adjust their debug output based on GTK debug flags.
+ *
+ * Returns: the GTK debug flags.
+ */
+GtkDebugFlags
+gtk_get_debug_flags (void)
+{
+  if (gtk_get_any_display_debug_flag_set ())
+    return gtk_get_display_debug_flags (gdk_display_get_default ());
+
+  return 0;
+}
+
+/**
+ * gtk_set_debug_flags:
+ * @flags: the debug flags to set
+ *
+ * Sets the GTK debug flags.
+ */
+void
+gtk_set_debug_flags (GtkDebugFlags flags)
+{
+  gtk_set_display_debug_flags (gdk_display_get_default (), flags);
+}
+
+gboolean
+gtk_simulate_touchscreen (void)
+{
+  return (gtk_get_debug_flags () & GTK_DEBUG_TOUCHSCREEN) != 0;
+}
+
 #ifdef G_ENABLE_DEBUG
 static const GdkDebugKey gtk_debug_keys[] = {
   { "keybindings", GTK_DEBUG_KEYBINDINGS, "Information about keyboard shortcuts" },
@@ -544,88 +626,6 @@ do_post_parse_initialization (void)
                     NULL);
 }
 
-GtkDebugFlags
-gtk_get_display_debug_flags (GdkDisplay *display)
-{
-  int i;
-
-  if (display == NULL)
-    display = gdk_display_get_default ();
-
-  for (i = 0; i < N_DEBUG_DISPLAYS; i++)
-    {
-      if (debug_flags[i].display == display)
-        return (GtkDebugFlags)debug_flags[i].flags;
-    }
-
-  return 0;
-}
-
-gboolean
-gtk_get_any_display_debug_flag_set (void)
-{
-  return any_display_debug_flags_set;
-}
-
-void
-gtk_set_display_debug_flags (GdkDisplay    *display,
-                             GtkDebugFlags  flags)
-{
-  int i;
-
-  for (i = 0; i < N_DEBUG_DISPLAYS; i++)
-    {
-      if (debug_flags[i].display == NULL)
-        debug_flags[i].display = display;
-
-      if (debug_flags[i].display == display)
-        {
-          debug_flags[i].flags = flags;
-          if (flags > 0)
-            any_display_debug_flags_set = TRUE;
-
-          return;
-        }
-    }
-}
-
-/**
- * gtk_get_debug_flags:
- *
- * Returns the GTK debug flags that are currently active.
- *
- * This function is intended for GTK modules that want
- * to adjust their debug output based on GTK debug flags.
- *
- * Returns: the GTK debug flags.
- */
-GtkDebugFlags
-gtk_get_debug_flags (void)
-{
-  if (gtk_get_any_display_debug_flag_set ())
-    return gtk_get_display_debug_flags (gdk_display_get_default ());
-
-  return 0;
-}
-
-/**
- * gtk_set_debug_flags:
- * @flags: the debug flags to set
- *
- * Sets the GTK debug flags.
- */
-void
-gtk_set_debug_flags (GtkDebugFlags flags)
-{
-  gtk_set_display_debug_flags (gdk_display_get_default (), flags);
-}
-
-gboolean
-gtk_simulate_touchscreen (void)
-{
-  return (gtk_get_debug_flags () & GTK_DEBUG_TOUCHSCREEN) != 0;
-}
-
 #ifdef G_PLATFORM_WIN32
 #undef gtk_init_check
 #endif


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