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
This commit is contained in:
Jonas Ådahl 2020-02-21 21:03:16 +01:00
parent f9326cfa3d
commit 2da27720ca
4 changed files with 91 additions and 9 deletions

View File

@ -137,6 +137,16 @@
</description> </description>
</key> </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"/> <child name="keybindings" schema="org.gnome.mutter.keybindings"/>
</schema> </schema>

View File

@ -2002,12 +2002,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: * meta_display_ping_timeout:
* @data: All the information about this ping. It is a #MetaPingData * @data: All the information about this ping. It is a #MetaPingData
@ -2066,6 +2060,11 @@ meta_display_ping_window (MetaWindow *window,
GSList *l; GSList *l;
MetaDisplay *display = window->display; MetaDisplay *display = window->display;
MetaPingData *ping_data; 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) if (serial == 0)
{ {
@ -2101,7 +2100,8 @@ meta_display_ping_window (MetaWindow *window,
ping_data = g_new (MetaPingData, 1); ping_data = g_new (MetaPingData, 1);
ping_data->window = window; ping_data->window = window;
ping_data->serial = serial; ping_data->serial = serial;
ping_data->ping_timeout_id = g_timeout_add (PING_TIMEOUT_DELAY, ping_data->ping_timeout_id =
g_timeout_add (check_alive_timeout,
meta_display_ping_timeout, meta_display_ping_timeout,
ping_data); ping_data);
g_source_set_name_by_id (ping_data->ping_timeout_id, "[mutter] meta_display_ping_timeout"); g_source_set_name_by_id (ping_data->ping_timeout_id, "[mutter] meta_display_ping_timeout");

View File

@ -102,6 +102,7 @@ static gboolean bell_is_audible = TRUE;
static gboolean gnome_accessibility = FALSE; static gboolean gnome_accessibility = FALSE;
static gboolean gnome_animations = TRUE; static gboolean gnome_animations = TRUE;
static gboolean locate_pointer_is_enabled = FALSE; static gboolean locate_pointer_is_enabled = FALSE;
static unsigned int check_alive_timeout = 5000;
static char *cursor_theme = NULL; static char *cursor_theme = NULL;
/* cursor_size will, when running as an X11 compositing window manager, be the /* cursor_size will, when running as an X11 compositing window manager, be the
* actual cursor size, multiplied with the global window scaling factor. On * actual cursor size, multiplied with the global window scaling factor. On
@ -218,6 +219,12 @@ typedef struct
gint *target; gint *target;
} MetaIntPreference; } MetaIntPreference;
typedef struct
{
MetaBasePreference base;
unsigned int *target;
} MetaUintPreference;
/* All preferences that are not keybindings must be listed here, /* All preferences that are not keybindings must be listed here,
* plus in the GSettings schemas and the MetaPreference enum. * plus in the GSettings schemas and the MetaPreference enum.
@ -511,6 +518,18 @@ static MetaIntPreference preferences_int[] =
{ { NULL, 0, 0 }, NULL }, { { 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 static void
handle_preference_init_enum (void) handle_preference_init_enum (void)
{ {
@ -633,6 +652,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 static void
handle_preference_update_enum (GSettings *settings, handle_preference_update_enum (GSettings *settings,
gchar *key) gchar *key)
@ -808,6 +842,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. */ /* Listeners. */
@ -986,6 +1042,7 @@ meta_prefs_init (void)
handle_preference_init_string (); handle_preference_init_string ();
handle_preference_init_string_array (); handle_preference_init_string_array ();
handle_preference_init_int (); handle_preference_init_int ();
handle_preference_init_uint ();
init_bindings (); init_bindings ();
} }
@ -1039,6 +1096,8 @@ settings_changed (GSettings *settings,
handle_preference_update_bool (settings, key); handle_preference_update_bool (settings, key);
else if (g_variant_type_equal (type, G_VARIANT_TYPE_INT32)) else if (g_variant_type_equal (type, G_VARIANT_TYPE_INT32))
handle_preference_update_int (settings, key); 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)) else if (g_variant_type_equal (type, G_VARIANT_TYPE_STRING_ARRAY))
handle_preference_update_string_array (settings, key); handle_preference_update_string_array (settings, key);
else if (g_variant_type_equal (type, G_VARIANT_TYPE_STRING)) else if (g_variant_type_equal (type, G_VARIANT_TYPE_STRING))
@ -1695,6 +1754,9 @@ meta_preference_to_string (MetaPreference pref)
case META_PREF_LOCATE_POINTER: case META_PREF_LOCATE_POINTER:
return "LOCATE_POINTER"; return "LOCATE_POINTER";
case META_PREF_CHECK_ALIVE_TIMEOUT:
return "CHECK_ALIVE_TIMEOUT";
} }
return "(unknown)"; return "(unknown)";
@ -2041,6 +2103,12 @@ meta_prefs_is_locate_pointer_enabled (void)
return locate_pointer_is_enabled; return locate_pointer_is_enabled;
} }
unsigned int
meta_prefs_get_check_alive_timeout (void)
{
return check_alive_timeout;
}
const char * const char *
meta_prefs_get_iso_next_group_option (void) meta_prefs_get_iso_next_group_option (void)
{ {

View File

@ -105,6 +105,7 @@ typedef enum
META_PREF_CENTER_NEW_WINDOWS, META_PREF_CENTER_NEW_WINDOWS,
META_PREF_DRAG_THRESHOLD, META_PREF_DRAG_THRESHOLD,
META_PREF_LOCATE_POINTER, META_PREF_LOCATE_POINTER,
META_PREF_CHECK_ALIVE_TIMEOUT,
} MetaPreference; } MetaPreference;
typedef void (* MetaPrefsChangedFunc) (MetaPreference pref, typedef void (* MetaPrefsChangedFunc) (MetaPreference pref,
@ -481,4 +482,7 @@ gboolean meta_prefs_bell_is_audible (void);
META_EXPORT META_EXPORT
GDesktopVisualBellType meta_prefs_get_visual_bell_type (void); GDesktopVisualBellType meta_prefs_get_visual_bell_type (void);
META_EXPORT
unsigned int meta_prefs_get_check_alive_timeout (void);
#endif #endif