mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-16 05:30:28 +00:00
wayland: Throttle system bell requests
If a bad behaving application tries to make the window/display beep too often, throttle the beep requests so that we don't end up filling the Wayland socket queue. The throttle is set to 50 beeps per second, which far more beeps than will ever make any sense from a user experience point of view, but will avoid terminating due to an excessive amount of requests. https://bugzilla.gnome.org/show_bug.cgi?id=778188
This commit is contained in:
parent
f78585b7c3
commit
376ff1ae60
@ -80,6 +80,8 @@
|
||||
* ]|
|
||||
*/
|
||||
|
||||
#define MIN_SYSTEM_BELL_DELAY_MS 20
|
||||
|
||||
static void _gdk_wayland_display_load_cursor_theme (GdkWaylandDisplay *display_wayland);
|
||||
|
||||
G_DEFINE_TYPE (GdkWaylandDisplay, gdk_wayland_display, GDK_TYPE_DISPLAY)
|
||||
@ -662,6 +664,7 @@ gdk_wayland_display_system_bell (GdkDisplay *display,
|
||||
{
|
||||
GdkWaylandDisplay *display_wayland;
|
||||
struct gtk_surface1 *gtk_surface;
|
||||
gint64 now_ms;
|
||||
|
||||
g_return_if_fail (GDK_IS_DISPLAY (display));
|
||||
|
||||
@ -675,6 +678,12 @@ gdk_wayland_display_system_bell (GdkDisplay *display,
|
||||
else
|
||||
gtk_surface = NULL;
|
||||
|
||||
now_ms = g_get_monotonic_time () / 1000;
|
||||
if (now_ms - display_wayland->last_bell_time_ms < MIN_SYSTEM_BELL_DELAY_MS)
|
||||
return;
|
||||
|
||||
display_wayland->last_bell_time_ms = now_ms;
|
||||
|
||||
gtk_shell1_system_bell (display_wayland->gtk_shell, gtk_surface);
|
||||
}
|
||||
|
||||
|
@ -110,6 +110,8 @@ struct _GdkWaylandDisplay
|
||||
|
||||
GPtrArray *monitors;
|
||||
|
||||
gint64 last_bell_time_ms;
|
||||
|
||||
/* egl info */
|
||||
EGLDisplay egl_display;
|
||||
int egl_major_version;
|
||||
|
Loading…
Reference in New Issue
Block a user