[gnome-settings-daemon] media-keys: Add a precise volume change shortcut
- From: Rui Matos <rtcm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon] media-keys: Add a precise volume change shortcut
- Date: Fri, 14 Jul 2017 09:21:26 +0000 (UTC)
commit e1179ada9b442acac0ee610c3bf6eed3e0e2271d
Author: Bastien Nocera <hadess hadess net>
Date: Sun Jun 25 13:09:27 2017 +0200
media-keys: Add a precise volume change shortcut
3 precise presses = 1 non-precise press
https://bugzilla.gnome.org/show_bug.cgi?id=650371
plugins/media-keys/gsd-media-keys-manager.c | 15 ++++++++++++++-
plugins/media-keys/media-keys.h | 2 ++
plugins/media-keys/shortcuts-list.h | 2 ++
3 files changed, 18 insertions(+), 1 deletions(-)
---
diff --git a/plugins/media-keys/gsd-media-keys-manager.c b/plugins/media-keys/gsd-media-keys-manager.c
index 9bb1c37..afb3656 100644
--- a/plugins/media-keys/gsd-media-keys-manager.c
+++ b/plugins/media-keys/gsd-media-keys-manager.c
@@ -109,6 +109,7 @@ static const gchar introspection_xml[] =
#define HIGH_CONTRAST "HighContrast"
#define VOLUME_STEP 6 /* percents for one volume button press */
+#define VOLUME_STEP_PRECISE 2
#define MAX_VOLUME 65536.0
#define SYSTEMD_DBUS_NAME "org.freedesktop.login1"
@@ -1264,6 +1265,7 @@ get_stream_for_device_id (GsdMediaKeysManager *manager,
typedef enum {
SOUND_ACTION_FLAG_IS_OUTPUT = 1 << 0,
SOUND_ACTION_FLAG_IS_QUIET = 1 << 1,
+ SOUND_ACTION_FLAG_IS_PRECISE = 1 << 2,
} SoundActionFlags;
static void
@@ -1295,7 +1297,10 @@ do_sound_action (GsdMediaKeysManager *manager,
if (stream == NULL)
return;
- norm_vol_step = PA_VOLUME_NORM * VOLUME_STEP / 100;
+ if (flags & SOUND_ACTION_FLAG_IS_PRECISE)
+ norm_vol_step = PA_VOLUME_NORM * VOLUME_STEP_PRECISE / 100;
+ else
+ norm_vol_step = PA_VOLUME_NORM * VOLUME_STEP / 100;
/* FIXME: this is racy */
new_vol = old_vol = gvc_mixer_stream_get_volume (stream);
@@ -2353,6 +2358,14 @@ do_action (GsdMediaKeysManager *manager,
do_sound_action (manager, deviceid, VOLUME_UP_KEY,
SOUND_ACTION_FLAG_IS_OUTPUT | SOUND_ACTION_FLAG_IS_QUIET);
break;
+ case VOLUME_DOWN_PRECISE_KEY:
+ do_sound_action (manager, deviceid, VOLUME_DOWN_KEY,
+ SOUND_ACTION_FLAG_IS_OUTPUT | SOUND_ACTION_FLAG_IS_PRECISE);
+ break;
+ case VOLUME_UP_PRECISE_KEY:
+ do_sound_action (manager, deviceid, VOLUME_UP_KEY,
+ SOUND_ACTION_FLAG_IS_OUTPUT | SOUND_ACTION_FLAG_IS_PRECISE);
+ break;
case LOGOUT_KEY:
gnome_session_shutdown (manager);
break;
diff --git a/plugins/media-keys/media-keys.h b/plugins/media-keys/media-keys.h
index c91cafc..ba37934 100644
--- a/plugins/media-keys/media-keys.h
+++ b/plugins/media-keys/media-keys.h
@@ -30,6 +30,8 @@ typedef enum {
MUTE_QUIET_KEY,
VOLUME_DOWN_QUIET_KEY,
VOLUME_UP_QUIET_KEY,
+ VOLUME_DOWN_PRECISE_KEY,
+ VOLUME_UP_PRECISE_KEY,
LOGOUT_KEY,
EJECT_KEY,
HOME_KEY,
diff --git a/plugins/media-keys/shortcuts-list.h b/plugins/media-keys/shortcuts-list.h
index 97026ff..88f80b7 100644
--- a/plugins/media-keys/shortcuts-list.h
+++ b/plugins/media-keys/shortcuts-list.h
@@ -53,6 +53,8 @@ static struct {
{ MUTE_QUIET_KEY, NULL, N_("Quiet Volume Mute"), "<Alt>XF86AudioMute", SHELL_ACTION_MODE_ALL },
{ VOLUME_DOWN_QUIET_KEY, NULL, N_("Quiet Volume Down"), "<Alt>XF86AudioLowerVolume",
SHELL_ACTION_MODE_ALL },
{ VOLUME_UP_QUIET_KEY, NULL, N_("Quiet Volume Up"), "<Alt>XF86AudioRaiseVolume",
SHELL_ACTION_MODE_ALL },
+ { VOLUME_DOWN_PRECISE_KEY, NULL, N_("Precise Volume Down"), "<Shift>XF86AudioLowerVolume",
SHELL_ACTION_MODE_ALL },
+ { VOLUME_UP_PRECISE_KEY, NULL, N_("Precise Volume Up"), "<Shift>XF86AudioRaiseVolume",
SHELL_ACTION_MODE_ALL },
{ LOGOUT_KEY, "logout", NULL, NULL, GSD_ACTION_MODE_LAUNCHER },
{ EJECT_KEY, "eject", NULL, NULL, SHELL_ACTION_MODE_ALL },
{ HOME_KEY, "home", NULL, NULL, GSD_ACTION_MODE_LAUNCHER },
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]