[Xfce4-commits] [panel-plugins/xfce4-pulseaudio-plugin] 01/01: Do not increase volume beyond 100% when using keyboard or mouse scroll

noreply at xfce.org noreply at xfce.org
Sat Apr 18 15:58:58 CEST 2015


This is an automated email from the git hooks/post-receive script.

andrzejr pushed a commit to branch master
in repository panel-plugins/xfce4-pulseaudio-plugin.

commit 18ef95f8ae3f591386a5110816618042d68c8bff
Author: Andrzej <ndrwrdck at gmail.com>
Date:   Sat Apr 18 14:58:47 2015 +0100

    Do not increase volume beyond 100% when using keyboard or mouse scroll
---
 panel-plugin/pulseaudio-button.c |    8 +++++++-
 panel-plugin/pulseaudio-plugin.c |    2 +-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/panel-plugin/pulseaudio-button.c b/panel-plugin/pulseaudio-button.c
index b094b7d..032b128 100644
--- a/panel-plugin/pulseaudio-button.c
+++ b/panel-plugin/pulseaudio-button.c
@@ -229,7 +229,13 @@ pulseaudio_button_scroll_event (GtkWidget *widget, GdkEventScroll *event)
   gdouble           new_volume;
 
 
-  new_volume = volume + (1.0 - 2.0 * event->direction) * volume_step;
+  if (event->direction == 1) // decrease volume
+    new_volume = volume - volume_step;
+  else if (event->direction == 0) // increase volume
+    new_volume = MIN (volume + volume_step, MAX (volume, 1.0));
+  else
+    new_volume = volume;
+
   pulseaudio_volume_set_volume (button->volume, new_volume);
   //g_debug ("dir: %d %f -> %f", event->direction, volume, new_volume);
 
diff --git a/panel-plugin/pulseaudio-plugin.c b/panel-plugin/pulseaudio-plugin.c
index a434853..b357aa9 100644
--- a/panel-plugin/pulseaudio-plugin.c
+++ b/panel-plugin/pulseaudio-plugin.c
@@ -294,7 +294,7 @@ pulseaudio_plugin_volume_key_pressed (const char            *keystring,
   pulseaudio_debug ("%s pressed", keystring);
 
   if (strcmp (keystring, PULSEAUDIO_PLUGIN_RAISE_VOLUME_KEY) == 0)
-    pulseaudio_volume_set_volume (pulseaudio_plugin->volume, volume + volume_step);
+    pulseaudio_volume_set_volume (pulseaudio_plugin->volume, MIN (volume + volume_step, MAX (volume, 1.0)));
   else if (strcmp (keystring, PULSEAUDIO_PLUGIN_LOWER_VOLUME_KEY) == 0)
     pulseaudio_volume_set_volume (pulseaudio_plugin->volume, volume - volume_step);
 }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list