diff options
author | Zhang Xianwei <[email protected]> | 2018-11-27 14:17:58 +0800 |
---|---|---|
committer | raveit65 <[email protected]> | 2018-12-03 11:40:50 +0100 |
commit | b2f3af26e460b0cdf5adac22f43bfca11b5832db (patch) | |
tree | 5a46624102eca82036c6a78e47d5398878f1cae4 /plugins | |
parent | 0fdb1cd1c3b2e2e2ce042414a493c27e4a51f9c5 (diff) | |
download | mate-settings-daemon-b2f3af26e460b0cdf5adac22f43bfca11b5832db.tar.bz2 mate-settings-daemon-b2f3af26e460b0cdf5adac22f43bfca11b5832db.tar.xz |
media-keys: Make sound changes quiet with Alt
<Alt>+volume control keys will change the sound, without
playing a notification sound, which can be useful when things
need to be quiet. This uses the settings stored in GSettings
for those audio keys.
Signed-off-by: Zhang Xianwei <[email protected]>
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/media-keys/acme.h | 6 | ||||
-rw-r--r-- | plugins/media-keys/msd-media-keys-manager.c | 31 |
2 files changed, 32 insertions, 5 deletions
diff --git a/plugins/media-keys/acme.h b/plugins/media-keys/acme.h index 8ab55fe..8d6aba2 100644 --- a/plugins/media-keys/acme.h +++ b/plugins/media-keys/acme.h @@ -32,6 +32,9 @@ enum { MUTE_KEY, VOLUME_DOWN_KEY, VOLUME_UP_KEY, + MUTE_QUIET_KEY, + VOLUME_DOWN_QUIET_KEY, + VOLUME_UP_QUIET_KEY, POWER_KEY, EJECT_KEY, HOME_KEY, @@ -74,6 +77,9 @@ static struct { { MUTE_KEY, "volume-mute", NULL, NULL }, { VOLUME_DOWN_KEY, "volume-down", NULL, NULL }, { VOLUME_UP_KEY, "volume-up", NULL, NULL }, + { MUTE_QUIET_KEY, "volume-mute-quiet", NULL, NULL }, + { VOLUME_DOWN_QUIET_KEY, "volume-down-quiet", NULL, NULL }, + { VOLUME_UP_QUIET_KEY, "volume-up-quiet", NULL, NULL }, { POWER_KEY, "power", NULL, NULL }, { EJECT_KEY, "eject", NULL, NULL }, { HOME_KEY, "home", NULL, NULL }, diff --git a/plugins/media-keys/msd-media-keys-manager.c b/plugins/media-keys/msd-media-keys-manager.c index a4e958a..33ac891 100644 --- a/plugins/media-keys/msd-media-keys-manager.c +++ b/plugins/media-keys/msd-media-keys-manager.c @@ -634,7 +634,8 @@ static void update_dialog (MsdMediaKeysManager *manager, guint volume, gboolean muted, - gboolean sound_changed) + gboolean sound_changed, + gboolean quiet) { if (muted) volume = 0.0; @@ -651,7 +652,7 @@ update_dialog (MsdMediaKeysManager *manager, dialog_show (manager); #ifdef HAVE_LIBCANBERRA - if (sound_changed != FALSE && muted == FALSE) + if (quiet == FALSE && sound_changed != FALSE && muted == FALSE) ca_gtk_play_for_widget (manager->priv->dialog, 0, CA_PROP_EVENT_ID, "audio-volume-change", CA_PROP_EVENT_DESCRIPTION, "Volume changed through key press", @@ -663,7 +664,9 @@ update_dialog (MsdMediaKeysManager *manager, } static void -do_sound_action (MsdMediaKeysManager *manager, int type) +do_sound_action (MsdMediaKeysManager *manager, + int type, + gboolean quiet) { gboolean muted; gboolean muted_last; @@ -735,7 +738,8 @@ do_sound_action (MsdMediaKeysManager *manager, int type) update_dialog (manager, CLAMP (100 * volume / (volume_max - volume_min), 0, 100), muted, - sound_changed); + sound_changed, + quiet); } static void @@ -1099,7 +1103,22 @@ do_action (MsdMediaKeysManager *manager, case VOLUME_DOWN_KEY: case VOLUME_UP_KEY: #ifdef HAVE_LIBMATEMIXER - do_sound_action (manager, type); + do_sound_action (manager, type, FALSE); +#endif + break; + case MUTE_QUIET_KEY: +#ifdef HAVE_LIBMATEMIXER + do_sound_action (manager, MUTE_KEY, TRUE); +#endif + break; + case VOLUME_DOWN_QUIET_KEY: +#ifdef HAVE_LIBMATEMIXER + do_sound_action (manager, VOLUME_DOWN_KEY, TRUE); +#endif + break; + case VOLUME_UP_QUIET_KEY: +#ifdef HAVE_LIBMATEMIXER + do_sound_action (manager, VOLUME_UP_KEY, TRUE); #endif break; case POWER_KEY: @@ -1250,6 +1269,8 @@ acme_filter_events (GdkXEvent *xevent, switch (keys[i].key_type) { case VOLUME_DOWN_KEY: case VOLUME_UP_KEY: + case VOLUME_DOWN_QUIET_KEY: + case VOLUME_UP_QUIET_KEY: /* auto-repeatable keys */ if (xev->type != KeyPress) { return GDK_FILTER_CONTINUE; |