|
Debarshi Ray |
f97543b |
From f78585b7c35cbe07b5cf921a871d59299dcfa355 Mon Sep 17 00:00:00 2001
|
|
Debarshi Ray |
f97543b |
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
|
|
Debarshi Ray |
f97543b |
Date: Mon, 13 Mar 2017 14:33:06 +0800
|
|
Debarshi Ray |
f97543b |
Subject: [PATCH 1/2] wayland: Make beep requests go through the GdkDisplay
|
|
Debarshi Ray |
f97543b |
|
|
Debarshi Ray |
f97543b |
This way we can add things like throttling.
|
|
Debarshi Ray |
f97543b |
|
|
Debarshi Ray |
f97543b |
https://bugzilla.gnome.org/show_bug.cgi?id=778188
|
|
Debarshi Ray |
f97543b |
---
|
|
Debarshi Ray |
f97543b |
gdk/wayland/gdkdisplay-wayland.c | 19 ++++++++++++++++---
|
|
Debarshi Ray |
f97543b |
gdk/wayland/gdkprivate-wayland.h | 5 +++++
|
|
Debarshi Ray |
f97543b |
gdk/wayland/gdkwindow-wayland.c | 18 +++++++++---------
|
|
Debarshi Ray |
f97543b |
3 files changed, 30 insertions(+), 12 deletions(-)
|
|
Debarshi Ray |
f97543b |
|
|
Debarshi Ray |
f97543b |
diff --git a/gdk/wayland/gdkdisplay-wayland.c b/gdk/wayland/gdkdisplay-wayland.c
|
|
Debarshi Ray |
f97543b |
index 784cfbecc411..d7fb684bd69b 100644
|
|
Debarshi Ray |
f97543b |
--- a/gdk/wayland/gdkdisplay-wayland.c
|
|
Debarshi Ray |
f97543b |
+++ b/gdk/wayland/gdkdisplay-wayland.c
|
|
Debarshi Ray |
f97543b |
@@ -656,10 +656,12 @@ gdk_wayland_display_get_default_screen (GdkDisplay *display)
|
|
Debarshi Ray |
f97543b |
return GDK_WAYLAND_DISPLAY (display)->screen;
|
|
Debarshi Ray |
f97543b |
}
|
|
Debarshi Ray |
f97543b |
|
|
Debarshi Ray |
f97543b |
-static void
|
|
Debarshi Ray |
f97543b |
-gdk_wayland_display_beep (GdkDisplay *display)
|
|
Debarshi Ray |
f97543b |
+void
|
|
Debarshi Ray |
f97543b |
+gdk_wayland_display_system_bell (GdkDisplay *display,
|
|
Debarshi Ray |
f97543b |
+ GdkWindow *window)
|
|
Debarshi Ray |
f97543b |
{
|
|
Debarshi Ray |
f97543b |
GdkWaylandDisplay *display_wayland;
|
|
Debarshi Ray |
f97543b |
+ struct gtk_surface1 *gtk_surface;
|
|
Debarshi Ray |
f97543b |
|
|
Debarshi Ray |
f97543b |
g_return_if_fail (GDK_IS_DISPLAY (display));
|
|
Debarshi Ray |
f97543b |
|
|
Debarshi Ray |
f97543b |
@@ -668,7 +670,18 @@ gdk_wayland_display_beep (GdkDisplay *display)
|
|
Debarshi Ray |
f97543b |
if (!display_wayland->gtk_shell)
|
|
Debarshi Ray |
f97543b |
return;
|
|
Debarshi Ray |
f97543b |
|
|
Debarshi Ray |
f97543b |
- gtk_shell1_system_bell (display_wayland->gtk_shell, NULL);
|
|
Debarshi Ray |
f97543b |
+ if (window)
|
|
Debarshi Ray |
f97543b |
+ gtk_surface = gdk_wayland_window_get_gtk_surface (window);
|
|
Debarshi Ray |
f97543b |
+ else
|
|
Debarshi Ray |
f97543b |
+ gtk_surface = NULL;
|
|
Debarshi Ray |
f97543b |
+
|
|
Debarshi Ray |
f97543b |
+ gtk_shell1_system_bell (display_wayland->gtk_shell, gtk_surface);
|
|
Debarshi Ray |
f97543b |
+}
|
|
Debarshi Ray |
f97543b |
+
|
|
Debarshi Ray |
f97543b |
+static void
|
|
Debarshi Ray |
f97543b |
+gdk_wayland_display_beep (GdkDisplay *display)
|
|
Debarshi Ray |
f97543b |
+{
|
|
Debarshi Ray |
f97543b |
+ gdk_wayland_display_system_bell (display, NULL);
|
|
Debarshi Ray |
f97543b |
}
|
|
Debarshi Ray |
f97543b |
|
|
Debarshi Ray |
f97543b |
static void
|
|
Debarshi Ray |
f97543b |
diff --git a/gdk/wayland/gdkprivate-wayland.h b/gdk/wayland/gdkprivate-wayland.h
|
|
Debarshi Ray |
f97543b |
index a95c925ca138..fde7632d38f5 100644
|
|
Debarshi Ray |
f97543b |
--- a/gdk/wayland/gdkprivate-wayland.h
|
|
Debarshi Ray |
f97543b |
+++ b/gdk/wayland/gdkprivate-wayland.h
|
|
Debarshi Ray |
f97543b |
@@ -83,6 +83,9 @@ void _gdk_wayland_display_get_maximal_cursor_size (GdkDisplay *display,
|
|
Debarshi Ray |
f97543b |
gboolean _gdk_wayland_display_supports_cursor_alpha (GdkDisplay *display);
|
|
Debarshi Ray |
f97543b |
gboolean _gdk_wayland_display_supports_cursor_color (GdkDisplay *display);
|
|
Debarshi Ray |
f97543b |
|
|
Debarshi Ray |
f97543b |
+void gdk_wayland_display_system_bell (GdkDisplay *display,
|
|
Debarshi Ray |
f97543b |
+ GdkWindow *window);
|
|
Debarshi Ray |
f97543b |
+
|
|
Debarshi Ray |
f97543b |
struct wl_buffer *_gdk_wayland_cursor_get_buffer (GdkCursor *cursor,
|
|
Debarshi Ray |
f97543b |
guint image_index,
|
|
Debarshi Ray |
f97543b |
int *hotspot_x,
|
|
Debarshi Ray |
f97543b |
@@ -271,6 +274,8 @@ EGLSurface gdk_wayland_window_get_egl_surface (GdkWindow *window,
|
|
Debarshi Ray |
f97543b |
EGLSurface gdk_wayland_window_get_dummy_egl_surface (GdkWindow *window,
|
|
Debarshi Ray |
f97543b |
EGLConfig config);
|
|
Debarshi Ray |
f97543b |
|
|
Debarshi Ray |
f97543b |
+struct gtk_surface1 * gdk_wayland_window_get_gtk_surface (GdkWindow *window);
|
|
Debarshi Ray |
f97543b |
+
|
|
Debarshi Ray |
f97543b |
void gdk_wayland_seat_set_global_cursor (GdkSeat *seat,
|
|
Debarshi Ray |
f97543b |
GdkCursor *cursor);
|
|
Debarshi Ray |
f97543b |
|
|
Debarshi Ray |
f97543b |
diff --git a/gdk/wayland/gdkwindow-wayland.c b/gdk/wayland/gdkwindow-wayland.c
|
|
Debarshi Ray |
f97543b |
index ffc9f94a009c..1f93f6c9c598 100644
|
|
Debarshi Ray |
f97543b |
--- a/gdk/wayland/gdkwindow-wayland.c
|
|
Debarshi Ray |
f97543b |
+++ b/gdk/wayland/gdkwindow-wayland.c
|
|
Debarshi Ray |
f97543b |
@@ -958,15 +958,8 @@ gdk_window_impl_wayland_end_paint (GdkWindow *window)
|
|
Debarshi Ray |
f97543b |
static gboolean
|
|
Debarshi Ray |
f97543b |
gdk_window_impl_wayland_beep (GdkWindow *window)
|
|
Debarshi Ray |
f97543b |
{
|
|
Debarshi Ray |
f97543b |
- GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
|
Debarshi Ray |
f97543b |
- GdkWaylandDisplay *display_wayland =
|
|
Debarshi Ray |
f97543b |
- GDK_WAYLAND_DISPLAY (gdk_window_get_display (window));
|
|
Debarshi Ray |
f97543b |
-
|
|
Debarshi Ray |
f97543b |
- if (!display_wayland->gtk_shell)
|
|
Debarshi Ray |
f97543b |
- return FALSE;
|
|
Debarshi Ray |
f97543b |
-
|
|
Debarshi Ray |
f97543b |
- gtk_shell1_system_bell (display_wayland->gtk_shell,
|
|
Debarshi Ray |
f97543b |
- impl->display_server.gtk_surface);
|
|
Debarshi Ray |
f97543b |
+ gdk_wayland_display_system_bell (gdk_window_get_display (window),
|
|
Debarshi Ray |
f97543b |
+ window);
|
|
Debarshi Ray |
f97543b |
|
|
Debarshi Ray |
f97543b |
return TRUE;
|
|
Debarshi Ray |
f97543b |
}
|
|
Debarshi Ray |
f97543b |
@@ -3891,6 +3884,13 @@ gdk_wayland_window_get_dummy_egl_surface (GdkWindow *window,
|
|
Debarshi Ray |
f97543b |
return impl->dummy_egl_surface;
|
|
Debarshi Ray |
f97543b |
}
|
|
Debarshi Ray |
f97543b |
|
|
Debarshi Ray |
f97543b |
+struct gtk_surface1 *
|
|
Debarshi Ray |
f97543b |
+gdk_wayland_window_get_gtk_surface (GdkWindow *window)
|
|
Debarshi Ray |
f97543b |
+{
|
|
Debarshi Ray |
f97543b |
+ g_return_val_if_fail (GDK_IS_WAYLAND_WINDOW (window), NULL);
|
|
Debarshi Ray |
f97543b |
+
|
|
Debarshi Ray |
f97543b |
+ return GDK_WINDOW_IMPL_WAYLAND (window->impl)->display_server.gtk_surface;
|
|
Debarshi Ray |
f97543b |
+}
|
|
Debarshi Ray |
f97543b |
|
|
Debarshi Ray |
f97543b |
/**
|
|
Debarshi Ray |
f97543b |
* gdk_wayland_window_set_use_custom_surface:
|
|
Debarshi Ray |
f97543b |
--
|
|
Debarshi Ray |
f97543b |
2.9.4
|
|
Debarshi Ray |
f97543b |
|
|
Debarshi Ray |
f97543b |
|
|
Debarshi Ray |
f97543b |
From 376ff1ae607db3e3ae47e8caeb8e8bce98c56f54 Mon Sep 17 00:00:00 2001
|
|
Debarshi Ray |
f97543b |
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
|
|
Debarshi Ray |
f97543b |
Date: Mon, 13 Mar 2017 14:42:38 +0800
|
|
Debarshi Ray |
f97543b |
Subject: [PATCH 2/2] wayland: Throttle system bell requests
|
|
Debarshi Ray |
f97543b |
|
|
Debarshi Ray |
f97543b |
If a bad behaving application tries to make the window/display beep too
|
|
Debarshi Ray |
f97543b |
often, throttle the beep requests so that we don't end up filling the
|
|
Debarshi Ray |
f97543b |
Wayland socket queue.
|
|
Debarshi Ray |
f97543b |
|
|
Debarshi Ray |
f97543b |
The throttle is set to 50 beeps per second, which far more beeps than
|
|
Debarshi Ray |
f97543b |
will ever make any sense from a user experience point of view, but will
|
|
Debarshi Ray |
f97543b |
avoid terminating due to an excessive amount of requests.
|
|
Debarshi Ray |
f97543b |
|
|
Debarshi Ray |
f97543b |
https://bugzilla.gnome.org/show_bug.cgi?id=778188
|
|
Debarshi Ray |
f97543b |
---
|
|
Debarshi Ray |
f97543b |
gdk/wayland/gdkdisplay-wayland.c | 9 +++++++++
|
|
Debarshi Ray |
f97543b |
gdk/wayland/gdkdisplay-wayland.h | 2 ++
|
|
Debarshi Ray |
f97543b |
2 files changed, 11 insertions(+)
|
|
Debarshi Ray |
f97543b |
|
|
Debarshi Ray |
f97543b |
diff --git a/gdk/wayland/gdkdisplay-wayland.c b/gdk/wayland/gdkdisplay-wayland.c
|
|
Debarshi Ray |
f97543b |
index d7fb684bd69b..3c8eedbfdae8 100644
|
|
Debarshi Ray |
f97543b |
--- a/gdk/wayland/gdkdisplay-wayland.c
|
|
Debarshi Ray |
f97543b |
+++ b/gdk/wayland/gdkdisplay-wayland.c
|
|
Debarshi Ray |
f97543b |
@@ -80,6 +80,8 @@
|
|
Debarshi Ray |
f97543b |
* ]|
|
|
Debarshi Ray |
f97543b |
*/
|
|
Debarshi Ray |
f97543b |
|
|
Debarshi Ray |
f97543b |
+#define MIN_SYSTEM_BELL_DELAY_MS 20
|
|
Debarshi Ray |
f97543b |
+
|
|
Debarshi Ray |
f97543b |
static void _gdk_wayland_display_load_cursor_theme (GdkWaylandDisplay *display_wayland);
|
|
Debarshi Ray |
f97543b |
|
|
Debarshi Ray |
f97543b |
G_DEFINE_TYPE (GdkWaylandDisplay, gdk_wayland_display, GDK_TYPE_DISPLAY)
|
|
Debarshi Ray |
f97543b |
@@ -662,6 +664,7 @@ gdk_wayland_display_system_bell (GdkDisplay *display,
|
|
Debarshi Ray |
f97543b |
{
|
|
Debarshi Ray |
f97543b |
GdkWaylandDisplay *display_wayland;
|
|
Debarshi Ray |
f97543b |
struct gtk_surface1 *gtk_surface;
|
|
Debarshi Ray |
f97543b |
+ gint64 now_ms;
|
|
Debarshi Ray |
f97543b |
|
|
Debarshi Ray |
f97543b |
g_return_if_fail (GDK_IS_DISPLAY (display));
|
|
Debarshi Ray |
f97543b |
|
|
Debarshi Ray |
f97543b |
@@ -675,6 +678,12 @@ gdk_wayland_display_system_bell (GdkDisplay *display,
|
|
Debarshi Ray |
f97543b |
else
|
|
Debarshi Ray |
f97543b |
gtk_surface = NULL;
|
|
Debarshi Ray |
f97543b |
|
|
Debarshi Ray |
f97543b |
+ now_ms = g_get_monotonic_time () / 1000;
|
|
Debarshi Ray |
f97543b |
+ if (now_ms - display_wayland->last_bell_time_ms < MIN_SYSTEM_BELL_DELAY_MS)
|
|
Debarshi Ray |
f97543b |
+ return;
|
|
Debarshi Ray |
f97543b |
+
|
|
Debarshi Ray |
f97543b |
+ display_wayland->last_bell_time_ms = now_ms;
|
|
Debarshi Ray |
f97543b |
+
|
|
Debarshi Ray |
f97543b |
gtk_shell1_system_bell (display_wayland->gtk_shell, gtk_surface);
|
|
Debarshi Ray |
f97543b |
}
|
|
Debarshi Ray |
f97543b |
|
|
Debarshi Ray |
f97543b |
diff --git a/gdk/wayland/gdkdisplay-wayland.h b/gdk/wayland/gdkdisplay-wayland.h
|
|
Debarshi Ray |
f97543b |
index a9fd4831a49c..3ae114e048fb 100644
|
|
Debarshi Ray |
f97543b |
--- a/gdk/wayland/gdkdisplay-wayland.h
|
|
Debarshi Ray |
f97543b |
+++ b/gdk/wayland/gdkdisplay-wayland.h
|
|
Debarshi Ray |
f97543b |
@@ -110,6 +110,8 @@ struct _GdkWaylandDisplay
|
|
Debarshi Ray |
f97543b |
|
|
Debarshi Ray |
f97543b |
GPtrArray *monitors;
|
|
Debarshi Ray |
f97543b |
|
|
Debarshi Ray |
f97543b |
+ gint64 last_bell_time_ms;
|
|
Debarshi Ray |
f97543b |
+
|
|
Debarshi Ray |
f97543b |
/* egl info */
|
|
Debarshi Ray |
f97543b |
EGLDisplay egl_display;
|
|
Debarshi Ray |
f97543b |
int egl_major_version;
|
|
Debarshi Ray |
f97543b |
--
|
|
Debarshi Ray |
f97543b |
2.9.4
|
|
Debarshi Ray |
f97543b |
|