[gtk+/matthiasc/wayland/beep: 3/3] wayland: Use libcanberra to implement beeping



commit 24361d288f5b067ec7b946ef2be58cba8e8eb80c
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Mar 2 12:45:02 2016 -0500

    wayland: Use libcanberra to implement beeping
    
    The ability to beep in certain situations is a requirement
    for some accessibility features. Since there is no Wayland
    protocol for this (and it is not sure if there should be),
    use libcanberra for this.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=763001

 gdk/wayland/gdkdisplay-wayland.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/gdk/wayland/gdkdisplay-wayland.c b/gdk/wayland/gdkdisplay-wayland.c
index c811f19..5b49d17 100644
--- a/gdk/wayland/gdkdisplay-wayland.c
+++ b/gdk/wayland/gdkdisplay-wayland.c
@@ -27,7 +27,9 @@
 #include <sys/syscall.h>
 
 #include <glib.h>
+#include "gdkintl.h"
 #include "gdkwayland.h"
+#include "gdkprivate-wayland.h"
 #include "gdkdisplay.h"
 #include "gdkdisplay-wayland.h"
 #include "gdkscreen.h"
@@ -39,6 +41,8 @@
 #include "gdkglcontext-wayland.h"
 #include "pointer-gestures-unstable-v1-client-protocol.h"
 
+#include <canberra.h>
+
 /**
  * SECTION:wayland_interaction
  * @Short_description: Wayland backend-specific functions
@@ -522,7 +526,25 @@ gdk_wayland_display_get_default_screen (GdkDisplay *display)
 static void
 gdk_wayland_display_beep (GdkDisplay *display)
 {
+  ca_context *c;
+  ca_proplist *p;
+
   g_return_if_fail (GDK_IS_DISPLAY (display));
+
+  c = gdk_wayland_screen_get_ca_context (gdk_display_get_default_screen (display));
+  if (!c)
+    return;
+
+  ca_proplist_create (&p);
+  ca_proplist_sets (p, CA_PROP_EVENT_ID, "bell-window-system");
+  ca_proplist_sets (p, CA_PROP_EVENT_DESCRIPTION, _("Bell event"));
+  ca_proplist_sets (p, CA_PROP_CANBERRA_CACHE_CONTROL, "permanent");
+
+  ca_proplist_setf (p, CA_PROP_APPLICATION_PROCESS_ID, "%d", getpid ());
+
+  ca_context_play_full (c, 1, p, NULL, NULL);
+
+  ca_proplist_destroy (p);
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]