kathenas / rpms / mutter

Forked from rpms/mutter 5 years ago
Clone

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

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