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

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