From c51af9eca529e3dda2694483240a6bbdf29a0c01 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Wed, 20 Oct 2021 12:53:19 +0200 Subject: [PATCH 1/3] mpris: Make the plugin builtin So it cannot be disabled. --- plugins/mpris/mpris.plugin.desktop.in | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/mpris/mpris.plugin.desktop.in b/plugins/mpris/mpris.plugin.desktop.in index 5059bf6e2..cdd1a1dac 100644 --- a/plugins/mpris/mpris.plugin.desktop.in +++ b/plugins/mpris/mpris.plugin.desktop.in @@ -1,6 +1,7 @@ [Plugin] Module=mpris IAge=2 +Builtin=true Name=MPRIS D-Bus interface Description=Provides an implementation of the MPRIS D-Bus interface specification Authors=Jonathan Matthew -- GitLab From a3bdeae5fa962f2523d36dbc91147a84ea82b6ae Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Wed, 17 Nov 2021 09:44:33 +0100 Subject: [PATCH 2/3] ci: Remove gnome-settings-daemon MediaKeys option --- .gitlab-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ba30c616f..2659b4dec 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -45,7 +45,6 @@ variables: -Dfm_radio=disabled -Dplugins_python=enabled -Dlibnotify=enabled - -Dmmkeys=enabled -Ddaap=enabled -Dgrilo=enabled -Dgudev=enabled -- GitLab From 0cdeb7cb7a47fe3008ade7aaeb6482652b9c9daa Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Wed, 20 Oct 2021 12:53:42 +0200 Subject: [PATCH 3/3] mmkeys: Remove gnome-settings-daemon MediaKeys plugin The server side has been obsoleted by MPRIS. See https://gitlab.gnome.org/GNOME/gnome-settings-daemon/-/merge_requests/268 --- meson.build | 10 +- meson_options.txt | 2 - plugins/meson.build | 1 - plugins/mmkeys/meson.build | 19 - plugins/mmkeys/mmkeys.plugin.desktop.in | 9 - plugins/mmkeys/rb-mmkeys-plugin.c | 480 ------------------------ 6 files changed, 1 insertion(+), 520 deletions(-) delete mode 100644 plugins/mmkeys/meson.build delete mode 100644 plugins/mmkeys/mmkeys.plugin.desktop.in delete mode 100644 plugins/mmkeys/rb-mmkeys-plugin.c diff --git a/meson.build b/meson.build index 7279198d1..4998389d8 100644 --- a/meson.build +++ b/meson.build @@ -126,13 +126,6 @@ if get_option('lirc').allowed() endif endif -enable_mmkeys = false -if get_option('mmkeys').allowed() - if cc.has_header('X11/XF86keysym.h', required: get_option('mmkeys')) - enable_mmkeys = true - endif -endif - have_libbrasero_media = false if get_option('brasero').allowed() brasero_media = dependency('libbrasero-media3', version: '>= 2.31.5', required: get_option('brasero')) @@ -276,8 +269,7 @@ summary({'Database': get_option('database'), 'Coherence check level': get_option('rhythmdb_debug'), 'Tests': enable_check}, section: 'General') -summary({'Multimedia keys': enable_mmkeys, - 'iPod integration': use_ipod, +summary({'iPod integration': use_ipod, 'MTP integration': use_mtp, 'CD burning support': have_libbrasero_media, 'DAAP (music sharing) support': have_libdmapsharing, diff --git a/meson_options.txt b/meson_options.txt index 4237bf141..13b754ef3 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -16,8 +16,6 @@ option('libsecret', type: 'feature', value: 'auto', description: 'Enable keyring support using libsecret') option('lirc', type: 'feature', value: 'auto', description: 'Enable lirc support') -option('mmkeys', type: 'feature', value: 'auto', - description: 'Enable multimedia keys support') option('mtp', type: 'feature', value: 'auto', description: 'Enable MTP support') option('plugins_python', type: 'feature', value: 'auto', diff --git a/plugins/meson.build b/plugins/meson.build index 439e578ba..281407554 100644 --- a/plugins/meson.build +++ b/plugins/meson.build @@ -20,7 +20,6 @@ subdir('audioscrobbler') subdir('dbus-media-server') subdir('generic-player') subdir('iradio') -subdir('mmkeys') subdir('mpris') subdir('power-manager') diff --git a/plugins/mmkeys/meson.build b/plugins/mmkeys/meson.build deleted file mode 100644 index abbe5fb7c..000000000 --- a/plugins/mmkeys/meson.build +++ /dev/null @@ -1,19 +0,0 @@ -mmkeys_plugin_dir = plugindir + '/mmkeys' - -mmkeys_sources = [ - 'rb-mmkeys-plugin.c'] - -shared_module('mmkeys', - mmkeys_sources, - dependencies: [rhythmbox_core_dep], - c_args: ['-DHAVE_CONFIG_H'], - include_directories: pluginsinc, - install: true, - install_dir: mmkeys_plugin_dir) - -mmkeys_plugin_descriptor = custom_target('mmkeys-plugin-descriptor', - input: 'mmkeys.plugin.desktop.in', - output: 'mmkeys.plugin', - command: msgfmt_plugin_cmd, - install: true, - install_dir: mmkeys_plugin_dir) diff --git a/plugins/mmkeys/mmkeys.plugin.desktop.in b/plugins/mmkeys/mmkeys.plugin.desktop.in deleted file mode 100644 index 78bbcb29a..000000000 --- a/plugins/mmkeys/mmkeys.plugin.desktop.in +++ /dev/null @@ -1,9 +0,0 @@ -[Plugin] -Module=mmkeys -IAge=2 -Builtin=true -Name=Media Player Keys -Description=Control Rhythmbox using key shortcuts -Authors=Rhythmbox authors -Copyright=Copyright © 2002-2007 Rhythmbox authors -Website=https://wiki.gnome.org/Apps/Rhythmbox diff --git a/plugins/mmkeys/rb-mmkeys-plugin.c b/plugins/mmkeys/rb-mmkeys-plugin.c deleted file mode 100644 index 00f10f85a..000000000 --- a/plugins/mmkeys/rb-mmkeys-plugin.c +++ /dev/null @@ -1,480 +0,0 @@ -/* - * rb-mmkeys-plugin.c - * - * Copyright (C) 2002, 2003 Jorn Baayen - * Copyright (C) 2002,2003 Colin Walters - * Copyright (C) 2007 James Livingston - * Copyright (C) 2007 Jonathan Matthew - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * The Rhythmbox authors hereby grant permission for non-GPL compatible - * GStreamer plugins to be used and distributed together with GStreamer - * and Rhythmbox. This permission is above and beyond the permissions granted - * by the GPL license by which Rhythmbox is covered. If you modify this code - * you may extend this exception to your version of the code, but you are not - * obligated to do so. If you do not wish to do so, delete this exception - * statement from your version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include /* For strlen */ -#include -#include -#include -#include -#include - -#include "rb-plugin-macros.h" -#include "rb-util.h" -#include "rb-debug.h" -#include "rb-shell.h" -#include "rb-shell-player.h" - -#ifdef HAVE_MMKEYS -#include -#include -#include -#endif /* HAVE_MMKEYS */ - -#define RB_TYPE_MMKEYS_PLUGIN (rb_mmkeys_plugin_get_type ()) -G_DECLARE_FINAL_TYPE (RBMMKeysPlugin, rb_mmkeys_plugin, RB, MMKEYS_PLUGIN, PeasExtensionBase) - -struct _RBMMKeysPlugin -{ - PeasExtensionBase parent; - - enum { - NONE = 0, - SETTINGS_DAEMON, - X_KEY_GRAB - } grab_type; - RBShell *shell; - RBShellPlayer *shell_player; - GDBusProxy *proxy; -} ; - -struct _RBMMKeysPluginClass -{ - PeasExtensionBaseClass parent_class; -}; - -RB_DEFINE_PLUGIN(RB_TYPE_MMKEYS_PLUGIN, RBMMKeysPlugin, rb_mmkeys_plugin,) - -G_MODULE_EXPORT void peas_register_types (PeasObjectModule *module); - -static void -rb_mmkeys_plugin_init (RBMMKeysPlugin *plugin) -{ - rb_debug ("RBMMKeysPlugin initialising"); -} - -static void -media_player_key_pressed (GDBusProxy *proxy, - const char *sender, - const char *signal, - GVariant *parameters, - RBMMKeysPlugin *plugin) -{ - char *key; - char *application; - - if (g_strcmp0 (signal, "MediaPlayerKeyPressed") != 0) { - rb_debug ("got unexpected signal '%s' from media player keys", signal); - return; - } - - g_variant_get (parameters, "(ss)", &application, &key); - - rb_debug ("got media key '%s' for application '%s'", - key, application); - - if (strcmp (application, "Rhythmbox")) { - rb_debug ("got media player key signal for unexpected application '%s'", application); - return; - } - - if (strcmp (key, "Play") == 0) { - rb_shell_player_playpause (plugin->shell_player, NULL); - } else if (strcmp (key, "Pause") == 0) { - rb_shell_player_pause (plugin->shell_player, NULL); - } else if (strcmp (key, "Stop") == 0) { - rb_shell_player_stop (plugin->shell_player); - } else if (strcmp (key, "Previous") == 0) { - rb_shell_player_do_previous (plugin->shell_player, NULL); - } else if (strcmp (key, "Next") == 0) { - rb_shell_player_do_next (plugin->shell_player, NULL); - } else if (strcmp (key, "Repeat") == 0) { - gboolean shuffle, repeat; - - if (rb_shell_player_get_playback_state (plugin->shell_player, &shuffle, &repeat)) { - rb_shell_player_set_playback_state (plugin->shell_player, shuffle, !repeat); - } - } else if (strcmp (key, "Shuffle") == 0) { - gboolean shuffle, repeat; - - if (rb_shell_player_get_playback_state (plugin->shell_player, &shuffle, &repeat)) { - rb_shell_player_set_playback_state (plugin->shell_player, !shuffle, repeat); - } - } else if (strcmp (key, "FastForward") == 0) { - rb_shell_player_seek (plugin->shell_player, FFWD_OFFSET, NULL); - } else if (strcmp (key, "Rewind") == 0) { - rb_shell_player_seek (plugin->shell_player, -RWD_OFFSET, NULL); - } - - g_free (key); - g_free (application); -} - -static void -grab_call_complete (GObject *proxy, GAsyncResult *res, RBMMKeysPlugin *plugin) -{ - GError *error = NULL; - GVariant *result; - - result = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, &error); - if (error != NULL) { - g_warning ("Unable to grab media player keys: %s", error->message); - g_clear_error (&error); - } else { - g_variant_unref (result); - } -} - -static gboolean -window_focus_cb (GtkWidget *window, - GdkEventFocus *event, - RBMMKeysPlugin *plugin) -{ - rb_debug ("window got focus, re-grabbing media keys"); - - g_dbus_proxy_call (plugin->proxy, - "GrabMediaPlayerKeys", - g_variant_new ("(su)", "Rhythmbox", 0), - G_DBUS_CALL_FLAGS_NONE, - -1, - NULL, - (GAsyncReadyCallback) grab_call_complete, - plugin); - return FALSE; -} - -#ifdef HAVE_MMKEYS - -static void -grab_mmkey (int key_code, - GdkWindow *root) -{ - Display *display; - gdk_error_trap_push (); - - display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()); - XGrabKey (display, key_code, - 0, - GDK_WINDOW_XID (root), True, - GrabModeAsync, GrabModeAsync); - XGrabKey (display, key_code, - Mod2Mask, - GDK_WINDOW_XID (root), True, - GrabModeAsync, GrabModeAsync); - XGrabKey (display, key_code, - Mod5Mask, - GDK_WINDOW_XID (root), True, - GrabModeAsync, GrabModeAsync); - XGrabKey (display, key_code, - LockMask, - GDK_WINDOW_XID (root), True, - GrabModeAsync, GrabModeAsync); - XGrabKey (display, key_code, - Mod2Mask | Mod5Mask, - GDK_WINDOW_XID (root), True, - GrabModeAsync, GrabModeAsync); - XGrabKey (display, key_code, - Mod2Mask | LockMask, - GDK_WINDOW_XID (root), True, - GrabModeAsync, GrabModeAsync); - XGrabKey (display, key_code, - Mod5Mask | LockMask, - GDK_WINDOW_XID (root), True, - GrabModeAsync, GrabModeAsync); - XGrabKey (display, key_code, - Mod2Mask | Mod5Mask | LockMask, - GDK_WINDOW_XID (root), True, - GrabModeAsync, GrabModeAsync); - - gdk_flush (); - if (gdk_error_trap_pop ()) { - rb_debug ("Error grabbing key"); - } -} - -static void -ungrab_mmkey (int key_code, - GdkWindow *root) -{ - Display *display; - gdk_error_trap_push (); - - display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()); - XUngrabKey (display, key_code, 0, GDK_WINDOW_XID (root)); - XUngrabKey (display, key_code, Mod2Mask, GDK_WINDOW_XID (root)); - XUngrabKey (display, key_code, Mod5Mask, GDK_WINDOW_XID (root)); - XUngrabKey (display, key_code, LockMask, GDK_WINDOW_XID (root)); - XUngrabKey (display, key_code, Mod2Mask | Mod5Mask, GDK_WINDOW_XID (root)); - XUngrabKey (display, key_code, Mod2Mask | LockMask, GDK_WINDOW_XID (root)); - XUngrabKey (display, key_code, Mod5Mask | LockMask, GDK_WINDOW_XID (root)); - XUngrabKey (display, key_code, Mod2Mask | Mod5Mask | LockMask, GDK_WINDOW_XID (root)); - - gdk_flush (); - if (gdk_error_trap_pop ()) { - rb_debug ("Error grabbing key"); - } -} - - -static GdkFilterReturn -filter_mmkeys (GdkXEvent *xevent, - GdkEvent *event, - gpointer data) -{ - XEvent *xev; - XKeyEvent *key; - Display *display; - RBShellPlayer *player; - xev = (XEvent *) xevent; - if (xev->type != KeyPress) { - return GDK_FILTER_CONTINUE; - } - - key = (XKeyEvent *) xevent; - - player = (RBShellPlayer *)data; - display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()); - - if (XKeysymToKeycode (display, XF86XK_AudioPlay) == key->keycode) { - rb_shell_player_playpause (player, NULL); - return GDK_FILTER_REMOVE; - } else if (XKeysymToKeycode (display, XF86XK_AudioPause) == key->keycode) { - rb_shell_player_pause (player, NULL); - return GDK_FILTER_REMOVE; - } else if (XKeysymToKeycode (display, XF86XK_AudioStop) == key->keycode) { - rb_shell_player_stop (player); - return GDK_FILTER_REMOVE; - } else if (XKeysymToKeycode (display, XF86XK_AudioPrev) == key->keycode) { - rb_shell_player_do_previous (player, NULL); - return GDK_FILTER_REMOVE; - } else if (XKeysymToKeycode (display, XF86XK_AudioNext) == key->keycode) { - rb_shell_player_do_next (player, NULL); - return GDK_FILTER_REMOVE; - } else { - return GDK_FILTER_CONTINUE; - } -} - -static void -mmkeys_grab (RBMMKeysPlugin *plugin, gboolean grab) -{ - gint keycodes[] = {0, 0, 0, 0, 0}; - GdkDisplay *display; - GdkScreen *screen; - GdkWindow *root; - guint j; - - display = gdk_display_get_default (); - keycodes[0] = XKeysymToKeycode (GDK_DISPLAY_XDISPLAY (display), XF86XK_AudioPlay); - keycodes[1] = XKeysymToKeycode (GDK_DISPLAY_XDISPLAY (display), XF86XK_AudioStop); - keycodes[2] = XKeysymToKeycode (GDK_DISPLAY_XDISPLAY (display), XF86XK_AudioPrev); - keycodes[3] = XKeysymToKeycode (GDK_DISPLAY_XDISPLAY (display), XF86XK_AudioNext); - keycodes[4] = XKeysymToKeycode (GDK_DISPLAY_XDISPLAY (display), XF86XK_AudioPause); - - screen = gdk_display_get_default_screen (display); - - if (screen != NULL) { - root = gdk_screen_get_root_window (screen); - - for (j = 0; j < G_N_ELEMENTS (keycodes) ; j++) { - if (keycodes[j] != 0) { - if (grab) - grab_mmkey (keycodes[j], root); - else - ungrab_mmkey (keycodes[j], root); - } - } - - if (grab) - gdk_window_add_filter (root, filter_mmkeys, - (gpointer) plugin->shell_player); - else - gdk_window_remove_filter (root, filter_mmkeys, - (gpointer) plugin->shell_player); - } -} - -#endif - -static void -first_call_complete (GObject *proxy, GAsyncResult *res, RBMMKeysPlugin *plugin) -{ - GVariant *result; - GError *error = NULL; - GtkWindow *window; - - result = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, &error); - if (error != NULL) { - g_warning ("Unable to grab media player keys: %s", error->message); - g_clear_error (&error); -#ifdef HAVE_MMKEYS - if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) { - mmkeys_grab (plugin, TRUE); - plugin->grab_type = X_KEY_GRAB; - } -#endif - return; - } - - rb_debug ("grabbed media player keys"); - - g_signal_connect_object (plugin->proxy, "g-signal", G_CALLBACK (media_player_key_pressed), plugin, 0); - - /* re-grab keys when the main window gains focus */ - g_object_get (plugin->shell, "window", &window, NULL); - g_signal_connect_object (window, "focus-in-event", - G_CALLBACK (window_focus_cb), - plugin, 0); - g_object_unref (window); - - g_variant_unref (result); -} - -static void -impl_activate (PeasActivatable *pplugin) -{ - GDBusConnection *bus; - RBMMKeysPlugin *plugin; - GError *error = NULL; - - rb_debug ("activating media player keys plugin"); - - plugin = RB_MMKEYS_PLUGIN (pplugin); - g_object_get (plugin, "object", &plugin->shell, NULL); - g_object_get (plugin->shell, "shell-player", &plugin->shell_player, NULL); - - bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); - if (plugin->grab_type == NONE && bus != NULL) { - GError *error = NULL; - - plugin->proxy = g_dbus_proxy_new_sync (bus, - G_DBUS_PROXY_FLAGS_NONE, - NULL, - "org.gnome.SettingsDaemon.MediaKeys", - "/org/gnome/SettingsDaemon/MediaKeys", - "org.gnome.SettingsDaemon.MediaKeys", - NULL, - &error); - if (error != NULL) { - g_warning ("Unable to grab media player keys: %s", error->message); - g_clear_error (&error); - } else { - g_dbus_proxy_call (plugin->proxy, - "GrabMediaPlayerKeys", - g_variant_new ("(su)", "Rhythmbox", 0), - G_DBUS_CALL_FLAGS_NONE, - -1, - NULL, - (GAsyncReadyCallback) first_call_complete, - plugin); - plugin->grab_type = SETTINGS_DAEMON; - } - } else { - g_warning ("couldn't get dbus session bus: %s", error->message); - g_clear_error (&error); - } - -#ifdef HAVE_MMKEYS - if (plugin->grab_type == NONE && GDK_IS_X11_DISPLAY (gdk_display_get_default ())) { - rb_debug ("attempting old-style key grabs"); - mmkeys_grab (plugin, TRUE); - plugin->grab_type = X_KEY_GRAB; - } -#endif -} - -static void -final_call_complete (GObject *proxy, GAsyncResult *res, gpointer nothing) -{ - GError *error = NULL; - GVariant *result; - - result = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, &error); - if (error != NULL) { - g_warning ("Unable to release media player keys: %s", error->message); - g_clear_error (&error); - } else { - g_variant_unref (result); - } -} - -static void -impl_deactivate (PeasActivatable *pplugin) -{ - RBMMKeysPlugin *plugin; - - plugin = RB_MMKEYS_PLUGIN (pplugin); - if (plugin->shell_player != NULL) { - g_object_unref (plugin->shell_player); - plugin->shell_player = NULL; - } - if (plugin->shell != NULL) { - g_object_unref (plugin->shell); - plugin->shell = NULL; - } - - if (plugin->proxy != NULL) { - if (plugin->grab_type == SETTINGS_DAEMON) { - g_dbus_proxy_call (plugin->proxy, - "ReleaseMediaPlayerKeys", - g_variant_new ("(s)", "Rhythmbox"), - G_DBUS_CALL_FLAGS_NONE, - -1, - NULL, - (GAsyncReadyCallback) final_call_complete, - NULL); - plugin->grab_type = NONE; - } - - g_object_unref (plugin->proxy); - plugin->proxy = NULL; - } - -#ifdef HAVE_MMKEYS - if (plugin->grab_type == X_KEY_GRAB) { - rb_debug ("undoing old-style key grabs"); - mmkeys_grab (plugin, FALSE); - plugin->grab_type = NONE; - } -#endif -} - -G_MODULE_EXPORT void -peas_register_types (PeasObjectModule *module) -{ - rb_mmkeys_plugin_register_type (G_TYPE_MODULE (module)); - peas_object_module_register_extension_type (module, - PEAS_TYPE_ACTIVATABLE, - RB_TYPE_MMKEYS_PLUGIN); -} -- GitLab