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

180070
From 7f6f326a1bb96aad0b7aea9c4d7e257bf53c026c Mon Sep 17 00:00:00 2001
180070
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
180070
Date: Fri, 21 Feb 2020 21:03:16 +0100
180070
Subject: [PATCH] display: Make check-alive timeout configureable
180070
180070
The check-alive feature is there for the user to be able to terminate
180070
frozen applications more easily. However, sometimes applications are
180070
implemented in a way where they fail to be reply to ping requests in a
180070
timely manner, resulting in that, to the compositor, they are
180070
indistinguishable from clients that have frozen indefinitely.
180070
180070
When using an application that has these issues, the GUI showed in
180070
response to the failure to respond to ping requests can become annoying,
180070
as it disrupts the visual presentation of the application.
180070
180070
To allow users to work-around these issues, add a setting allowing them
180070
to configure the timeout waited until an application is considered
180070
frozen, or disabling the check completely.
180070
180070
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1080
180070
---
180070
 data/org.gnome.mutter.gschema.xml.in | 10 ++++
180070
 src/core/display.c                   | 18 ++++----
180070
 src/core/prefs.c                     | 68 ++++++++++++++++++++++++++++
180070
 src/meta/prefs.h                     |  3 ++
180070
 4 files changed, 90 insertions(+), 9 deletions(-)
180070
180070
diff --git a/data/org.gnome.mutter.gschema.xml.in b/data/org.gnome.mutter.gschema.xml.in
180070
index 6cbd9c1b5..4d37b1488 100644
180070
--- a/data/org.gnome.mutter.gschema.xml.in
180070
+++ b/data/org.gnome.mutter.gschema.xml.in
180070
@@ -123,6 +123,16 @@
180070
       </description>
180070
     </key>
180070
 
180070
+    <key name="check-alive-timeout" type="u">
180070
+      <default>5000</default>
180070
+      <summary>Timeout for check-alive ping</summary>
180070
+      <description>
180070
+        Number of milliseconds a client has to respond to a ping request in
180070
+        order to not be detected as frozen. Using 0 will disable the alive check
180070
+        completely.
180070
+      </description>
180070
+    </key>
180070
+
180070
     <child name="keybindings" schema="org.gnome.mutter.keybindings"/>
180070
 
180070
   </schema>
180070
diff --git a/src/core/display.c b/src/core/display.c
180070
index eb7dc43b6..c30a03385 100644
180070
--- a/src/core/display.c
180070
+++ b/src/core/display.c
180070
@@ -1923,12 +1923,6 @@ meta_set_syncing (gboolean setting)
180070
     }
180070
 }
180070
 
180070
-/*
180070
- * How long, in milliseconds, we should wait after pinging a window
180070
- * before deciding it's not going to get back to us.
180070
- */
180070
-#define PING_TIMEOUT_DELAY 5000
180070
-
180070
 /**
180070
  * meta_display_ping_timeout:
180070
  * @data: All the information about this ping. It is a #MetaPingData
180070
@@ -1986,6 +1980,11 @@ meta_display_ping_window (MetaWindow *window,
180070
 {
180070
   MetaDisplay *display = window->display;
180070
   MetaPingData *ping_data;
180070
+  unsigned int check_alive_timeout;
180070
+
180070
+  check_alive_timeout = meta_prefs_get_check_alive_timeout ();
180070
+  if (check_alive_timeout == 0)
180070
+    return;
180070
 
180070
   if (serial == 0)
180070
     {
180070
@@ -1999,9 +1998,10 @@ meta_display_ping_window (MetaWindow *window,
180070
   ping_data = g_new (MetaPingData, 1);
180070
   ping_data->window = window;
180070
   ping_data->serial = serial;
180070
-  ping_data->ping_timeout_id = g_timeout_add (PING_TIMEOUT_DELAY,
180070
-					      meta_display_ping_timeout,
180070
-					      ping_data);
180070
+  ping_data->ping_timeout_id =
180070
+    g_timeout_add (check_alive_timeout,
180070
+                   meta_display_ping_timeout,
180070
+                   ping_data);
180070
   g_source_set_name_by_id (ping_data->ping_timeout_id, "[mutter] meta_display_ping_timeout");
180070
 
180070
   display->pending_pings = g_slist_prepend (display->pending_pings, ping_data);
180070
diff --git a/src/core/prefs.c b/src/core/prefs.c
180070
index 3f0db8afc..4892406ce 100644
180070
--- a/src/core/prefs.c
180070
+++ b/src/core/prefs.c
180070
@@ -99,6 +99,7 @@ static gboolean bell_is_visible = FALSE;
180070
 static gboolean bell_is_audible = TRUE;
180070
 static gboolean gnome_accessibility = FALSE;
180070
 static gboolean gnome_animations = TRUE;
180070
+static unsigned int check_alive_timeout = 5000;
180070
 static char *cursor_theme = NULL;
180070
 /* cursor_size will, when running as an X11 compositing window manager, be the
180070
  * actual cursor size, multiplied with the global window scaling factor. On
180070
@@ -213,6 +214,12 @@ typedef struct
180070
   gint *target;
180070
 } MetaIntPreference;
180070
 
180070
+typedef struct
180070
+{
180070
+  MetaBasePreference base;
180070
+  unsigned int *target;
180070
+} MetaUintPreference;
180070
+
180070
 
180070
 /* All preferences that are not keybindings must be listed here,
180070
  * plus in the GSettings schemas and the MetaPreference enum.
180070
@@ -491,6 +498,18 @@ static MetaIntPreference preferences_int[] =
180070
     { { NULL, 0, 0 }, NULL },
180070
   };
180070
 
180070
+static MetaUintPreference preferences_uint[] =
180070
+  {
180070
+    {
180070
+      { "check-alive-timeout",
180070
+        SCHEMA_MUTTER,
180070
+        META_PREF_CHECK_ALIVE_TIMEOUT,
180070
+      },
180070
+      &check_alive_timeout,
180070
+    },
180070
+    { { NULL, 0, 0 }, NULL },
180070
+  };
180070
+
180070
 static void
180070
 handle_preference_init_enum (void)
180070
 {
180070
@@ -613,6 +632,21 @@ handle_preference_init_int (void)
180070
     }
180070
 }
180070
 
180070
+static void
180070
+handle_preference_init_uint (void)
180070
+{
180070
+  MetaUintPreference *cursor = preferences_uint;
180070
+
180070
+  while (cursor->base.key != NULL)
180070
+    {
180070
+      if (cursor->target)
180070
+        *cursor->target = g_settings_get_uint (SETTINGS (cursor->base.schema),
180070
+                                               cursor->base.key);
180070
+
180070
+      ++cursor;
180070
+    }
180070
+}
180070
+
180070
 static void
180070
 handle_preference_update_enum (GSettings *settings,
180070
                                gchar *key)
180070
@@ -788,6 +822,28 @@ handle_preference_update_int (GSettings *settings,
180070
     }
180070
 }
180070
 
180070
+static void
180070
+handle_preference_update_uint (GSettings *settings,
180070
+                               char *key)
180070
+{
180070
+  MetaUintPreference *cursor = preferences_uint;
180070
+  unsigned int new_value;
180070
+
180070
+  while (cursor->base.key && strcmp (key, cursor->base.key) != 0)
180070
+    ++cursor;
180070
+
180070
+  if (!cursor->base.key || !cursor->target)
180070
+    return;
180070
+
180070
+  new_value = g_settings_get_uint (SETTINGS (cursor->base.schema), key);
180070
+
180070
+  if (*cursor->target != new_value)
180070
+    {
180070
+      *cursor->target = new_value;
180070
+      queue_changed (cursor->base.pref);
180070
+    }
180070
+}
180070
+
180070
 
180070
 /****************************************************************************/
180070
 /* Listeners.                                                               */
180070
@@ -964,6 +1020,7 @@ meta_prefs_init (void)
180070
   handle_preference_init_string ();
180070
   handle_preference_init_string_array ();
180070
   handle_preference_init_int ();
180070
+  handle_preference_init_uint ();
180070
 
180070
   init_bindings ();
180070
 }
180070
@@ -1017,6 +1074,8 @@ settings_changed (GSettings *settings,
180070
     handle_preference_update_bool (settings, key);
180070
   else if (g_variant_type_equal (type, G_VARIANT_TYPE_INT32))
180070
     handle_preference_update_int (settings, key);
180070
+  else if (g_variant_type_equal (type, G_VARIANT_TYPE_UINT32))
180070
+    handle_preference_update_uint (settings, key);
180070
   else if (g_variant_type_equal (type, G_VARIANT_TYPE_STRING_ARRAY))
180070
     handle_preference_update_string_array (settings, key);
180070
   else if (g_variant_type_equal (type, G_VARIANT_TYPE_STRING))
180070
@@ -1640,6 +1699,9 @@ meta_preference_to_string (MetaPreference pref)
180070
 
180070
     case META_PREF_AUTO_MAXIMIZE:
180070
       return "AUTO_MAXIMIZE";
180070
+
180070
+    case META_PREF_CHECK_ALIVE_TIMEOUT:
180070
+      return "CHECK_ALIVE_TIMEOUT";
180070
     }
180070
 
180070
   return "(unknown)";
180070
@@ -1966,6 +2028,12 @@ meta_prefs_get_overlay_binding (MetaKeyCombo *combo)
180070
   *combo = overlay_key_combo;
180070
 }
180070
 
180070
+unsigned int
180070
+meta_prefs_get_check_alive_timeout (void)
180070
+{
180070
+  return check_alive_timeout;
180070
+}
180070
+
180070
 const char *
180070
 meta_prefs_get_iso_next_group_option (void)
180070
 {
180070
diff --git a/src/meta/prefs.h b/src/meta/prefs.h
180070
index 9664b5c07..f42d1c63c 100644
180070
--- a/src/meta/prefs.h
180070
+++ b/src/meta/prefs.h
180070
@@ -103,6 +103,7 @@ typedef enum
180070
   META_PREF_AUTO_MAXIMIZE,
180070
   META_PREF_CENTER_NEW_WINDOWS,
180070
   META_PREF_DRAG_THRESHOLD,
180070
+  META_PREF_CHECK_ALIVE_TIMEOUT,
180070
 } MetaPreference;
180070
 
180070
 typedef void (* MetaPrefsChangedFunc) (MetaPreference pref,
180070
@@ -475,4 +476,6 @@ gboolean           meta_prefs_bell_is_audible      (void);
180070
 META_EXPORT
180070
 GDesktopVisualBellType meta_prefs_get_visual_bell_type (void);
180070
 
180070
+unsigned int meta_prefs_get_check_alive_timeout (void);
180070
+
180070
 #endif
180070
-- 
180070
2.28.0
180070