mutter/SOURCES/0001-display-Make-check-ali...

249 lines
7.7 KiB
Diff

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