Blame SOURCES/0001-display-Make-check-alive-timeout-configureable.patch

066919
From 8bdcce5328a451c03e240f40a213e5afb11676ea Mon Sep 17 00:00:00 2001
8d879e
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
8d879e
Date: Fri, 21 Feb 2020 21:03:16 +0100
8d879e
Subject: [PATCH] display: Make check-alive timeout configureable
8d879e
8d879e
The check-alive feature is there for the user to be able to terminate
8d879e
frozen applications more easily. However, sometimes applications are
8d879e
implemented in a way where they fail to be reply to ping requests in a
8d879e
timely manner, resulting in that, to the compositor, they are
8d879e
indistinguishable from clients that have frozen indefinitely.
8d879e
8d879e
When using an application that has these issues, the GUI showed in
8d879e
response to the failure to respond to ping requests can become annoying,
8d879e
as it disrupts the visual presentation of the application.
8d879e
8d879e
To allow users to work-around these issues, add a setting allowing them
8d879e
to configure the timeout waited until an application is considered
8d879e
frozen, or disabling the check completely.
8d879e
8d879e
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1080
8d879e
---
8d879e
 data/org.gnome.mutter.gschema.xml.in | 10 ++++
8d879e
 src/core/display.c                   | 18 ++++----
8d879e
 src/core/prefs.c                     | 68 ++++++++++++++++++++++++++++
8d879e
 src/meta/prefs.h                     |  3 ++
8d879e
 4 files changed, 90 insertions(+), 9 deletions(-)
8d879e
8d879e
diff --git a/data/org.gnome.mutter.gschema.xml.in b/data/org.gnome.mutter.gschema.xml.in
8d879e
index bec5585bd..06f8288c8 100644
8d879e
--- a/data/org.gnome.mutter.gschema.xml.in
8d879e
+++ b/data/org.gnome.mutter.gschema.xml.in
8d879e
@@ -127,6 +127,16 @@
8d879e
       </description>
8d879e
     </key>
8d879e
 
8d879e
+    <key name="check-alive-timeout" type="u">
8d879e
+      <default>5000</default>
8d879e
+      <summary>Timeout for check-alive ping</summary>
8d879e
+      <description>
8d879e
+        Number of milliseconds a client has to respond to a ping request in
8d879e
+        order to not be detected as frozen. Using 0 will disable the alive check
8d879e
+        completely.
8d879e
+      </description>
8d879e
+    </key>
8d879e
+
8d879e
     <child name="keybindings" schema="org.gnome.mutter.keybindings"/>
8d879e
 
8d879e
   </schema>
8d879e
diff --git a/src/core/display.c b/src/core/display.c
8d879e
index d4775cec3..5b843fa51 100644
8d879e
--- a/src/core/display.c
8d879e
+++ b/src/core/display.c
8d879e
@@ -2197,12 +2197,6 @@ meta_set_syncing (gboolean setting)
8d879e
     }
8d879e
 }
8d879e
 
8d879e
-/*
8d879e
- * How long, in milliseconds, we should wait after pinging a window
8d879e
- * before deciding it's not going to get back to us.
8d879e
- */
8d879e
-#define PING_TIMEOUT_DELAY 5000
8d879e
-
8d879e
 /**
8d879e
  * meta_display_ping_timeout:
8d879e
  * @data: All the information about this ping. It is a #MetaPingData
8d879e
@@ -2260,6 +2254,11 @@ meta_display_ping_window (MetaWindow *window,
8d879e
 {
8d879e
   MetaDisplay *display = window->display;
8d879e
   MetaPingData *ping_data;
8d879e
+  unsigned int check_alive_timeout;
8d879e
+
8d879e
+  check_alive_timeout = meta_prefs_get_check_alive_timeout ();
8d879e
+  if (check_alive_timeout == 0)
8d879e
+    return;
8d879e
 
8d879e
   if (serial == 0)
8d879e
     {
8d879e
@@ -2273,9 +2272,10 @@ meta_display_ping_window (MetaWindow *window,
8d879e
   ping_data = g_new (MetaPingData, 1);
8d879e
   ping_data->window = window;
8d879e
   ping_data->serial = serial;
8d879e
-  ping_data->ping_timeout_id = g_timeout_add (PING_TIMEOUT_DELAY,
8d879e
-					      meta_display_ping_timeout,
8d879e
-					      ping_data);
8d879e
+  ping_data->ping_timeout_id =
8d879e
+    g_timeout_add (check_alive_timeout,
8d879e
+                   meta_display_ping_timeout,
8d879e
+                   ping_data);
8d879e
   g_source_set_name_by_id (ping_data->ping_timeout_id, "[mutter] meta_display_ping_timeout");
8d879e
 
8d879e
   display->pending_pings = g_slist_prepend (display->pending_pings, ping_data);
8d879e
diff --git a/src/core/prefs.c b/src/core/prefs.c
8d879e
index b6a8ab7bf..326db52d2 100644
8d879e
--- a/src/core/prefs.c
8d879e
+++ b/src/core/prefs.c
8d879e
@@ -95,6 +95,7 @@ static gboolean bell_is_visible = FALSE;
8d879e
 static gboolean bell_is_audible = TRUE;
8d879e
 static gboolean gnome_accessibility = FALSE;
8d879e
 static gboolean gnome_animations = TRUE;
8d879e
+static unsigned int check_alive_timeout = 5000;
8d879e
 static char *cursor_theme = NULL;
8d879e
 /* cursor_size will, when running as an X11 compositing window manager, be the
8d879e
  * actual cursor size, multiplied with the global window scaling factor. On
8d879e
@@ -225,6 +226,12 @@ typedef struct
8d879e
   gint *target;
8d879e
 } MetaIntPreference;
8d879e
 
8d879e
+typedef struct
8d879e
+{
8d879e
+  MetaBasePreference base;
8d879e
+  unsigned int *target;
8d879e
+} MetaUintPreference;
8d879e
+
8d879e
 
8d879e
 /* All preferences that are not keybindings must be listed here,
8d879e
  * plus in the GSettings schemas and the MetaPreference enum.
8d879e
@@ -496,6 +503,18 @@ static MetaIntPreference preferences_int[] =
8d879e
     { { NULL, 0, 0 }, NULL },
8d879e
   };
8d879e
 
8d879e
+static MetaUintPreference preferences_uint[] =
8d879e
+  {
8d879e
+    {
8d879e
+      { "check-alive-timeout",
8d879e
+        SCHEMA_MUTTER,
8d879e
+        META_PREF_CHECK_ALIVE_TIMEOUT,
8d879e
+      },
8d879e
+      &check_alive_timeout,
8d879e
+    },
8d879e
+    { { NULL, 0, 0 }, NULL },
8d879e
+  };
8d879e
+
8d879e
 /*
8d879e
  * This is used to keep track of override schemas used to
8d879e
  * override preferences from the "normal" metacity/mutter
8d879e
@@ -633,6 +652,21 @@ handle_preference_init_int (void)
8d879e
     }
8d879e
 }
8d879e
 
8d879e
+static void
8d879e
+handle_preference_init_uint (void)
8d879e
+{
8d879e
+  MetaUintPreference *cursor = preferences_uint;
8d879e
+
8d879e
+  while (cursor->base.key != NULL)
8d879e
+    {
8d879e
+      if (cursor->target)
8d879e
+        *cursor->target = g_settings_get_uint (SETTINGS (cursor->base.schema),
8d879e
+                                               cursor->base.key);
8d879e
+
8d879e
+      ++cursor;
8d879e
+    }
8d879e
+}
8d879e
+
8d879e
 static void
8d879e
 handle_preference_update_enum (GSettings *settings,
8d879e
                                gchar *key)
8d879e
@@ -808,6 +842,28 @@ handle_preference_update_int (GSettings *settings,
8d879e
     }
8d879e
 }
8d879e
 
8d879e
+static void
8d879e
+handle_preference_update_uint (GSettings *settings,
8d879e
+                               char *key)
8d879e
+{
8d879e
+  MetaUintPreference *cursor = preferences_uint;
8d879e
+  unsigned int new_value;
8d879e
+
8d879e
+  while (cursor->base.key && strcmp (key, cursor->base.key) != 0)
8d879e
+    ++cursor;
8d879e
+
8d879e
+  if (!cursor->base.key || !cursor->target)
8d879e
+    return;
8d879e
+
8d879e
+  new_value = g_settings_get_uint (SETTINGS (cursor->base.schema), key);
8d879e
+
8d879e
+  if (*cursor->target != new_value)
8d879e
+    {
8d879e
+      *cursor->target = new_value;
8d879e
+      queue_changed (cursor->base.pref);
8d879e
+    }
8d879e
+}
8d879e
+
8d879e
 
8d879e
 /****************************************************************************/
8d879e
 /* Listeners.                                                               */
8d879e
@@ -1003,6 +1059,7 @@ meta_prefs_init (void)
8d879e
   handle_preference_init_string ();
8d879e
   handle_preference_init_string_array ();
8d879e
   handle_preference_init_int ();
8d879e
+  handle_preference_init_uint ();
8d879e
 
8d879e
   update_cursor_size ();
8d879e
   shell_shows_app_menu_changed (gtk_settings_get_default (), NULL, NULL);
8d879e
@@ -1176,6 +1233,8 @@ settings_changed (GSettings *settings,
8d879e
     handle_preference_update_bool (settings, key);
8d879e
   else if (g_variant_type_equal (type, G_VARIANT_TYPE_INT32))
8d879e
     handle_preference_update_int (settings, key);
8d879e
+  else if (g_variant_type_equal (type, G_VARIANT_TYPE_UINT32))
8d879e
+    handle_preference_update_uint (settings, key);
8d879e
   else if (g_variant_type_equal (type, G_VARIANT_TYPE_STRING_ARRAY))
8d879e
     handle_preference_update_string_array (settings, key);
8d879e
   else if (g_variant_type_equal (type, G_VARIANT_TYPE_STRING))
8d879e
@@ -1851,6 +1910,9 @@ meta_preference_to_string (MetaPreference pref)
8d879e
 
8d879e
     case META_PREF_AUTO_MAXIMIZE:
8d879e
       return "AUTO_MAXIMIZE";
8d879e
+
8d879e
+    case META_PREF_CHECK_ALIVE_TIMEOUT:
8d879e
+      return "CHECK_ALIVE_TIMEOUT";
8d879e
     }
8d879e
 
8d879e
   return "(unknown)";
8d879e
@@ -2177,6 +2239,12 @@ meta_prefs_get_overlay_binding (MetaKeyCombo *combo)
8d879e
   *combo = overlay_key_combo;
8d879e
 }
8d879e
 
8d879e
+unsigned int
8d879e
+meta_prefs_get_check_alive_timeout (void)
8d879e
+{
8d879e
+  return check_alive_timeout;
8d879e
+}
8d879e
+
8d879e
 const char *
8d879e
 meta_prefs_get_iso_next_group_option (void)
8d879e
 {
8d879e
diff --git a/src/meta/prefs.h b/src/meta/prefs.h
8d879e
index df3cf6c97..f343925f8 100644
8d879e
--- a/src/meta/prefs.h
8d879e
+++ b/src/meta/prefs.h
8d879e
@@ -103,6 +103,7 @@ typedef enum
8d879e
   META_PREF_AUTO_MAXIMIZE,
8d879e
   META_PREF_CENTER_NEW_WINDOWS,
8d879e
   META_PREF_DRAG_THRESHOLD,
8d879e
+  META_PREF_CHECK_ALIVE_TIMEOUT,
8d879e
 } MetaPreference;
8d879e
 
8d879e
 typedef void (* MetaPrefsChangedFunc) (MetaPreference pref,
8d879e
@@ -406,4 +407,6 @@ gboolean           meta_prefs_get_visual_bell      (void);
8d879e
 gboolean           meta_prefs_bell_is_audible      (void);
8d879e
 GDesktopVisualBellType meta_prefs_get_visual_bell_type (void);
8d879e
 
8d879e
+unsigned int meta_prefs_get_check_alive_timeout (void);
8d879e
+
8d879e
 #endif
8d879e
-- 
8d879e
2.24.1
8d879e