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

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