[mutter/bilelmoussaoui/make-canberra-a-plugin: 25/25] core: Make sound player feature optional
- From: Bilal Elmoussaoui <bilelmoussaoui src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/bilelmoussaoui/make-canberra-a-plugin: 25/25] core: Make sound player feature optional
- Date: Tue, 26 Apr 2022 13:19:54 +0000 (UTC)
commit 8ab589428ed6d3d39a5f8dcb6096931008b68998
Author: Bilal Elmoussaoui <belmouss redhat com>
Date: Tue Apr 26 15:00:46 2022 +0200
core: Make sound player feature optional
Mutter can play sounds in some contexts and also provides an API
for libmutter users to do so using libcanberra internally.
In some specific use cases of Mutter, we would like to not depend
on libcanberra and not have any sound playing feature by default.
See https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2270
for relevant discussion
config.h.meson | 3 +++
meson.build | 8 +++++++-
meson_options.txt | 6 ++++++
src/core/bell.c | 6 ++++++
src/core/display-private.h | 2 ++
src/core/display.c | 14 +++++++++++++-
src/core/workspace.c | 15 ++++++++++-----
src/meson.build | 14 ++++++++++++--
src/meta/display.h | 7 ++++++-
src/meta/meson.build | 7 ++++++-
10 files changed, 71 insertions(+), 11 deletions(-)
---
diff --git a/config.h.meson b/config.h.meson
index 9119ad864e..0fadabb469 100644
--- a/config.h.meson
+++ b/config.h.meson
@@ -49,6 +49,9 @@
/* Defined if gnome-desktop is enabled */
#mesondefine HAVE_GNOME_DESKTOP
+/* Defined if sound player is enabled */
+#mesondefine HAVE_SOUND_PLAYER
+
/* Building with SM support */
#mesondefine HAVE_SM
diff --git a/meson.build b/meson.build
index a10232bbb7..38e74671e8 100644
--- a/meson.build
+++ b/meson.build
@@ -140,7 +140,6 @@ xinerama_dep = dependency('xinerama')
xau_dep = dependency('xau')
ice_dep = dependency('ice')
atk_dep = dependency('atk', version: atk_req)
-libcanberra_dep = dependency('libcanberra', version: libcanberra_req)
dbus_dep = dependency('dbus-1')
# For now always require X11 support
@@ -152,6 +151,11 @@ if have_gnome_desktop
gnome_desktop_dep = dependency('gnome-desktop-3.0')
endif
+have_sound_player = get_option('sound_player')
+if have_sound_player
+ libcanberra_dep = dependency('libcanberra', version: libcanberra_req)
+endif
+
have_gl = get_option('opengl')
if have_gl
gl_dep = dependency('gl')
@@ -459,6 +463,7 @@ cdata.set('HAVE_LIBSYSTEMD', have_libsystemd)
cdata.set('HAVE_NATIVE_BACKEND', have_native_backend)
cdata.set('HAVE_REMOTE_DESKTOP', have_remote_desktop)
cdata.set('HAVE_GNOME_DESKTOP', have_gnome_desktop)
+cdata.set('HAVE_SOUND_PLAYER', have_sound_player)
cdata.set('HAVE_EGL_DEVICE', have_egl_device)
cdata.set('HAVE_WAYLAND_EGLSTREAM', have_wayland_eglstream)
cdata.set('HAVE_LIBGUDEV', have_libgudev)
@@ -610,6 +615,7 @@ summary('Native Backend', have_native_backend, section: 'Options')
summary('EGL Device', have_egl_device, section: 'Options')
summary('Remote desktop', have_remote_desktop, section: 'Options')
summary('libgnome-desktop', have_gnome_desktop, section: 'Options')
+summary('Sound player', have_sound_player, section: 'Options')
summary('gudev', have_libgudev, section: 'Options')
summary('Wacom', have_libwacom, section: 'Options')
summary('SM', have_sm, section: 'Options')
diff --git a/meson_options.txt b/meson_options.txt
index da755393c7..dbdc71ab3e 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -93,6 +93,12 @@ option('libwacom',
description: 'Enable libwacom support'
)
+option('sound_player',
+ type: 'boolean',
+ value: true,
+ description: 'Enable sound player support using libcanberra',
+)
+
option('pango_ft2',
type: 'boolean',
value: true,
diff --git a/src/core/bell.c b/src/core/bell.c
index f0c6f94631..ea20bd48ae 100644
--- a/src/core/bell.c
+++ b/src/core/bell.c
@@ -180,6 +180,8 @@ bell_visual_notify (MetaDisplay *display,
}
}
+#ifdef HAVE_SOUND_PLAYER
+
static gboolean
bell_audible_notify (MetaDisplay *display,
MetaWindow *window)
@@ -194,6 +196,8 @@ bell_audible_notify (MetaDisplay *display,
return TRUE;
}
+#endif
+
gboolean
meta_bell_notify (MetaDisplay *display,
MetaWindow *window)
@@ -202,8 +206,10 @@ meta_bell_notify (MetaDisplay *display,
if (meta_prefs_get_visual_bell ())
bell_visual_notify (display, window);
+#ifdef HAVE_SOUND_PLAYER
if (meta_prefs_bell_is_audible ())
return bell_audible_notify (display, window);
+#endif
return TRUE;
}
diff --git a/src/core/display-private.h b/src/core/display-private.h
index e91d730352..717bb5cc84 100644
--- a/src/core/display-private.h
+++ b/src/core/display-private.h
@@ -229,7 +229,9 @@ struct _MetaDisplay
MetaBell *bell;
MetaWorkspaceManager *workspace_manager;
+#ifdef HAVE_SOUND_PLAYER
MetaSoundPlayer *sound_player;
+#endif
MetaSelectionSource *selection_source;
GBytes *saved_clipboard;
diff --git a/src/core/display.c b/src/core/display.c
index a1c5c2d912..8205d9630d 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -70,7 +70,6 @@
#include "meta/main.h"
#include "meta/meta-backend.h"
#include "meta/meta-enum-types.h"
-#include "meta/meta-sound-player.h"
#include "meta/meta-x11-errors.h"
#include "meta/prefs.h"
#include "x11/meta-startup-notification-x11.h"
@@ -78,6 +77,10 @@
#include "x11/window-x11.h"
#include "x11/xprops.h"
+#ifdef HAVE_SOUND_PLAYER
+#include "meta/meta-sound-player.h"
+#endif
+
#ifdef HAVE_WAYLAND
#include "compositor/meta-compositor-native.h"
#include "compositor/meta-compositor-server.h"
@@ -1001,7 +1004,9 @@ meta_display_new (MetaContext *context,
meta_display_unset_input_focus (display, timestamp);
}
+#ifdef HAVE_SOUND_PLAYER
display->sound_player = g_object_new (META_TYPE_SOUND_PLAYER, NULL);
+#endif
/* Done opening new display */
display->display_opening = FALSE;
@@ -1172,7 +1177,10 @@ meta_display_close (MetaDisplay *display,
g_clear_object (&display->bell);
g_clear_object (&display->startup_notification);
g_clear_object (&display->workspace_manager);
+
+#ifdef HAVE_SOUND_PLAYER
g_clear_object (&display->sound_player);
+#endif
meta_clipboard_manager_shutdown (display);
g_clear_object (&display->selection);
@@ -3932,12 +3940,16 @@ meta_display_generate_window_id (MetaDisplay *display)
*
* Returns: (transfer none): The sound player of the display
*/
+#ifdef HAVE_SOUND_PLAYER
+
MetaSoundPlayer *
meta_display_get_sound_player (MetaDisplay *display)
{
return display->sound_player;
}
+#endif
+
/**
* meta_display_get_selection:
* @display: a #MetaDisplay
diff --git a/src/core/workspace.c b/src/core/workspace.c
index 357e37d894..f9f28773d6 100644
--- a/src/core/workspace.c
+++ b/src/core/workspace.c
@@ -481,10 +481,8 @@ static void
workspace_switch_sound(MetaWorkspace *from,
MetaWorkspace *to)
{
- MetaSoundPlayer *player;
MetaWorkspaceLayout layout;
- int i, nw, x, y, fi, ti;
- const char *e;
+ int i, nw, fi, ti;
nw = meta_workspace_manager_get_n_workspaces (from->manager);
fi = meta_workspace_index(from);
@@ -505,8 +503,6 @@ workspace_switch_sound(MetaWorkspace *from,
goto finish;
}
- y = i / layout.cols;
- x = i % layout.cols;
/* We priorize horizontal over vertical movements here. The
rationale for this is that horizontal movements are probably more
@@ -515,6 +511,14 @@ workspace_switch_sound(MetaWorkspace *from,
spatial "Woosh!" effects will easily be able to encode horizontal
movement but not such much vertical movement. */
+#ifdef HAVE_SOUND_PLAYER
+ MetaSoundPlayer *player;
+ int x, y;
+ const char *e;
+
+ y = i / layout.cols;
+ x = i % layout.cols;
+
if (x < layout.current_col)
e = "desktop-switch-left";
else if (x > layout.current_col)
@@ -531,6 +535,7 @@ workspace_switch_sound(MetaWorkspace *from,
player = meta_display_get_sound_player (from->display);
meta_sound_player_play_from_theme (player, e, "Desktop switched", NULL);
+#endif
finish:
meta_workspace_manager_free_workspace_layout (&layout);
diff --git a/src/meson.build b/src/meson.build
index 7b456f524f..742457b16f 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -25,7 +25,6 @@ mutter_pkg_private_deps = [
gmodule_no_export_dep,
gnome_settings_daemon_dep,
json_glib_dep,
- libcanberra_dep,
xkbcommon_dep,
]
@@ -35,6 +34,12 @@ if have_gnome_desktop
]
endif
+if have_sound_player
+ mutter_pkg_private_deps += [
+ libcanberra_dep,
+ ]
+endif
+
if have_gl
mutter_pkg_deps += [
gl_dep,
@@ -401,7 +406,6 @@ mutter_sources = [
'core/meta-selection.c',
'core/meta-selection-source.c',
'core/meta-selection-source-memory.c',
- 'core/meta-sound-player.c',
'core/meta-workspace-manager.c',
'core/meta-workspace-manager-private.h',
'core/place.c',
@@ -804,6 +808,12 @@ if have_remote_desktop
]
endif
+if have_sound_player
+ mutter_sources += [
+ 'core/meta-sound-player.c',
+ ]
+endif
+
if have_native_backend
mutter_private_enum_sources += [
'backends/native/meta-backend-native-types.h',
diff --git a/src/meta/display.h b/src/meta/display.h
index e59bd03939..5dfe5e8216 100644
--- a/src/meta/display.h
+++ b/src/meta/display.h
@@ -27,9 +27,12 @@
#include <meta/prefs.h>
#include <meta/common.h>
#include <meta/workspace.h>
-#include <meta/meta-sound-player.h>
#include <meta/meta-startup-notification.h>
+#ifdef HAVE_SOUND_PLAYER
+#include <meta/meta-sound-player.h>
+#endif
+
/**
* MetaTabList:
* @META_TAB_LIST_NORMAL: Normal windows
@@ -300,8 +303,10 @@ MetaWorkspaceManager *meta_display_get_workspace_manager (MetaDisplay *display);
META_EXPORT
MetaStartupNotification * meta_display_get_startup_notification (MetaDisplay *display);
+#ifdef HAVE_SOUND_PLAYER
META_EXPORT
MetaSoundPlayer * meta_display_get_sound_player (MetaDisplay *display);
+#endif
META_EXPORT
MetaSelection * meta_display_get_selection (MetaDisplay *display);
diff --git a/src/meta/meson.build b/src/meta/meson.build
index 3076f75327..de7900e0d4 100644
--- a/src/meta/meson.build
+++ b/src/meta/meson.build
@@ -32,7 +32,6 @@ mutter_public_headers = [
'meta-settings.h',
'meta-shadow-factory.h',
'meta-shaped-texture.h',
- 'meta-sound-player.h',
'meta-stage.h',
'meta-startup-notification.h',
'meta-window-actor.h',
@@ -60,6 +59,12 @@ if have_x11
]
endif
+if have_sound_player
+ mutter_public_headers += [
+ 'meta-sound-player.h',
+ ]
+endif
+
install_headers(mutter_public_headers,
subdir: mutter_includesubdir
)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]