Re: [PATCH 00/11] WPrefs: fixes for stuff reported by Coverity

2014-06-07 Thread David Maciejak
On Sunday, June 8, 2014, Christophe  wrote:

>
>
> The only detail I'd see there being that using %f for float is likely to
> loose accuracy in the value stored if the number is more than a basic
> number, but as this function is not used anywhere it does not really
> matter...
>
>
Yes that's what I saw afterwards.

Thanks for the feedback,
David



>
>
>

>
> > On Sun, Jun 1, 2014 at 1:58 AM, Christophe  > wrote:
> > > From: Christophe CURIS >
> > >
> > > Hello,
> > >
> > > This serie of patch fixes the code in WPrefs that are related
> > > to these 13 bugs pointed by Coverity:
> > >
> > >  #50031: Unchecked return value
> > >  #50073: Explicit null dereferenced
> > >  #50098: Dereference null return value
> > >  #50105: Resource leak
> > >  #50107: Resource leak
> > >  #50130: Resource leak
> > >  #50140: Resource leak
> > >  #50150: Resource leak
> > >  #50156: Resource leak
> > >  #50157: Resource leak
> > >  #50158: Resource leak
> > >  #50159: Resource leak
> > >  #50200: Dereference before null check
> > >
> > > Christophe.
> > >
> > >
> > >  WPrefs.app/Appearance.c | 18 +-
> > >  WPrefs.app/Docks.c  |  7 ++-
> > >  WPrefs.app/Focus.c  |  1 +
> > >  WPrefs.app/Menu.c   | 15 ++-
> > >  WPrefs.app/MouseSettings.c  |  4 +++-
> > >  WPrefs.app/Paths.c  |  8 +---
> > >  WPrefs.app/TexturePanel.c   |  4 ++--
> > >  WPrefs.app/WindowHandling.c | 13 +
> > >  WPrefs.app/editmenu.c   |  6 +-
> > >  WPrefs.app/xmodifier.c  | 11 ---
> > >  10 files changed, 58 insertions(+), 29 deletions(-)
> > >
> > > --
> > > 1.9.2
> > >
> > >
> > > --
> > > To unsubscribe, send mail to
> wmaker-dev-unsubscr...@lists.windowmaker.org .
>
>
> --
> To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org
> .
>


Re: [PATCH dockapps 10/28] wmix: fixed makefile to use PREFIX in a standard way (and with the standard default path)

2014-06-07 Thread BALATON Zoltan

On Sat, 7 Jun 2014, Christophe wrote:

From: Christophe CURIS 

Signed-off-by: Christophe CURIS 
---
wmix/Makefile | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/wmix/Makefile b/wmix/Makefile
index 3ef4f3a..ffc1d5f 100644
--- a/wmix/Makefile
+++ b/wmix/Makefile
@@ -5,8 +5,7 @@ LIBS= -lXpm -lXext -lX11 -lm
OBJECTS = misc.o mixer-oss.o ui_x.o wmix.o

# where to install this program (also for packaging stuff)
-DESTDIR=
-PREFIX = $(DESTDIR)/usr/X11R6


DESTDIR is usually there so that distributions can install stuff in a 
build root during packaging like this:


build with PREFIX=/usr/X11R6
make install DESTDIR=/tmp/build-root

Does your change break this or is there another way to do the same? (If 
PREFIX is not compiled in the program but only used for installing stuff 
it may be OK.)


Regards,
BALATON Zoltan


+PREFIX = /usr/local
INSTALL_BIN = -m 755
INSTALL_DATA= -m 644

--
1.9.2


--
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.





--
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH dockapps 25/28] wmix: added an option to disable grabbing the volume control keys

2014-06-07 Thread Christophe
From: Christophe CURIS 

There may be some case where user would like to fall back to the original
behaviour, for example if grabbing these keys could get in conflict with
other applications.

Signed-off-by: Christophe CURIS 
---
 wmix/config.c |  8 +++-
 wmix/include/config.h |  1 +
 wmix/wmix.1x  | 11 +++
 wmix/wmix.c   |  4 +++-
 4 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/wmix/config.c b/wmix/config.c
index 6a3c822..0414ea4 100644
--- a/wmix/config.c
+++ b/wmix/config.c
@@ -41,6 +41,7 @@
"  -e  exclude channel, can be used many times\n" \
"  -f  parse this config [~/.wmixrc]\n" \
"  -hprint this help\n" \
+   "  -kdisable grabing volume control keys\n" \
"  -m   mixer device [/dev/mixer]\n" \
"  -vverbose -> id, long name, name\n" \
 
@@ -64,6 +65,7 @@ void config_init(void)
config.mixer_device = (char *) default_mixer_device;
config.mousewheel = 1;
config.scrolltext = 1;
+   config.mmkeys = 1;
config.wheel_button_up = 4;
config.wheel_button_down = 5;
config.scrollstep = 0.03;
@@ -117,7 +119,7 @@ void parse_cli_options(int argc, char **argv)
config.verbose = false;
error_found = false;
for (;;) {
-   opt = getopt(argc, argv, ":d:e:f:hm:v");
+   opt = getopt(argc, argv, ":d:e:f:hkm:v");
if (opt == -1)
break;
 
@@ -158,6 +160,10 @@ void parse_cli_options(int argc, char **argv)
exit(0);
break;
 
+   case 'k':
+   config.mmkeys = false;
+   break;
+
case 'm':
if (config.mixer_device != default_mixer_device)
free(config.mixer_device);
diff --git a/wmix/include/config.h b/wmix/include/config.h
index 702a382..ee632f4 100644
--- a/wmix/include/config.h
+++ b/wmix/include/config.h
@@ -34,6 +34,7 @@ extern struct _Config {
unsigned int osd: 1;/* show OSD? */
unsigned int mousewheel : 1;/* mousewheel enabled? */
unsigned int scrolltext : 1;/* scroll channel names? */
+   unsigned int mmkeys : 1;/* grab multimedia keys for volume 
control */
 
unsigned int wheel_button_up;   /* up button */
unsigned int wheel_button_down; /* down button */
diff --git a/wmix/wmix.1x b/wmix/wmix.1x
index 8e4cf68..9b6f650 100644
--- a/wmix/wmix.1x
+++ b/wmix/wmix.1x
@@ -40,6 +40,12 @@ Use config file instead of
 \fB\-h\fR
 Display list of command\-line options
 .TP
+\fB\-k\fR
+Disable grabbing the audio volume control keys on keyboard (see
+.SM
+.B BUGS
+below)
+.TP
 \fB\-m\fR <\fIdevice\fP>
 Use specified mixer device instead of
 .I /dev/mixer
@@ -137,6 +143,11 @@ that a channel has been muted.
 The X server allows only one application at a time to place a grab on a key,
 so if another application already claimed the volume control keys then 
\fBwmix\fP
 will warn you about it and continue without the functionality.
+If on the other hand you encounter problem with applications that do
+not work because they could not grab these keys (a typical symptom is
+an X Error of type \fIBadAccess\fP with major opcode 33 \fIX_GrabKey\fP),
+you can ask \fBwmix\fP to not grab them using the command line option
+\fB-k\fP.
 .LP
 If you modify the configuration file, do not expect \fBwmix\fP to reload
 it automatically, this is considered a too costly feature for such a
diff --git a/wmix/wmix.c b/wmix/wmix.c
index ae8bce5..a992987 100644
--- a/wmix/wmix.c
+++ b/wmix/wmix.c
@@ -93,7 +93,9 @@ int main(int argc, char **argv)
 dockapp_init(display);
 new_window("wmix", 64, 64);
 new_osd(DisplayWidth(display, DefaultScreen(display)) - 200, 60);
-mmkey_install(display);
+
+if (config.mmkeys)
+   mmkey_install(display);
 
 config_release();
 
-- 
1.9.2


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH dockapps 27/28] wmix: do not count space padding in channel short name when comparing names for exclusion

2014-06-07 Thread Christophe
From: Christophe CURIS 

The names for channels provided by  have a padding with
space when their name is shorter than 6 characters, and this cause
excluding them difficult.
The new comparison code makes sure this padding is properly handled during
the match search.

Took the opportunity to bring light changes to try to improve the
readability of the channel listing code.

Signed-off-by: Christophe CURIS 
---
 wmix/mixer-oss.c | 57 +---
 1 file changed, 42 insertions(+), 15 deletions(-)

diff --git a/wmix/mixer-oss.c b/wmix/mixer-oss.c
index e561608..3f0ca8f 100644
--- a/wmix/mixer-oss.c
+++ b/wmix/mixer-oss.c
@@ -262,12 +262,15 @@ void mixer_init(const char *mixer_device, bool verbose, 
const char * exclude[])
 }
 
 if (verbose) {
-   printf("%s (%s)\n", m_info.name, m_info.id);
+   printf("Sound card: %s (%s)\n", m_info.name, m_info.id);
puts("Supported channels:");
 }
 for (count = 0; count < SOUND_MIXER_NRDEVICES; count++) {
mask = 1 << count;
-   if ((mask & devmask) && (!is_exclude((short_names[count]),exclude))) {
+   if (!(mask & devmask))
+   continue;
+
+   if (!is_exclude(short_names[count], exclude)) {
mixer[n_channels].name = channel_names[count];
mixer[n_channels].sname = short_names[count];
mixer[n_channels].dev = count;
@@ -278,12 +281,9 @@ void mixer_init(const char *mixer_device, bool verbose, 
const char * exclude[])
mixer[n_channels].is_muted = false;
++n_channels;
if (verbose)
-   printf("  %d: %s \t(%s)\n", n_channels, 
-  channel_names[count],
-  short_names[count]);
-   } else if ((mask & devmask) && verbose)
- printf("  x: %s \t(%s) - disabled\n", channel_names[count],
-short_names[count]);
+   printf("  %d: %s \t(%s)\n", n_channels, channel_names[count], 
short_names[count]);
+   } else if (verbose)
+   printf("  x: %s \t(%s) - disabled\n", channel_names[count], 
short_names[count]);
 }
 get_mixer_state();
 }
@@ -414,11 +414,38 @@ bool mixer_can_rec(void)
 
 bool is_exclude(const char *short_name, const char *exclude[])
 {
-  int count = 0;
-  while (count < SOUND_MIXER_NRDEVICES && exclude[count] != NULL){
-if ( strcmp(short_name, exclude[count]) == 0 )
-  return true;
-count++;
-  }
-  return false;
+   int count;
+   int len;
+
+   for (count = 0; count < SOUND_MIXER_NRDEVICES; count++) {
+   if (exclude[count] == NULL)
+   break;
+
+   /*
+* Short names may be padded with spaces, because apparently 
there is a minimum
+* length requirement of 6 characters for the name, and we do 
not want to
+* include this padding in the match
+*/
+   len = strlen(short_name);
+   while (len > 0) {
+   if (short_name[len - 1] == ' ')
+   len--;
+   else
+   break;
+   }
+
+   if (strncmp(short_name, exclude[count], len) != 0)
+   continue;
+
+   if (exclude[count][len] != '\0')
+   continue;
+
+   /* Check the remaining in short name is only space */
+   while (short_name[len] == ' ')
+   len++;
+
+   if (short_name[len] == '\0')
+   return true;
+   }
+   return false;
 }
-- 
1.9.2


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH dockapps 26/28] wmix: allow to choose device and exclude channels from the config file

2014-06-07 Thread Christophe
From: Christophe CURIS 

Because that's the kind of option that could deserve to be saved in the
file. A device specified on the command line will take precedence; the
list of channel to exclude will be merged.

Signed-off-by: Christophe CURIS 
---
 wmix/config.c | 19 ++-
 wmix/wmix.1x  | 11 ++-
 2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/wmix/config.c b/wmix/config.c
index 0414ea4..7034271 100644
--- a/wmix/config.c
+++ b/wmix/config.c
@@ -288,7 +288,24 @@ void config_read(void)
*ptr = '\0';
 
/* Check what keyword we have */
-   if (strcmp(keyword, "mousewheel") == 0) {
+   if (strcmp(keyword, "device") == 0) {
+   if (config.mixer_device == default_mixer_device)
+   config.mixer_device = strdup(value);
+   /* If not the default, keep the previous value because 
it was provided in the command-line */
+
+   } else if (strcmp(keyword, "exclude") == 0) {
+   int i;
+
+   for (i = 0; i < SOUND_MIXER_NRDEVICES; i++) {
+   if (config.exclude_channel[i] == NULL) {
+   config.exclude_channel[i] = 
strdup(value);
+   break;
+   }
+
+   if (strcmp(value, config.exclude_channel[i]) == 
0)
+   break;
+   }
+   } else if (strcmp(keyword, "mousewheel") == 0) {
config.mousewheel = atoi(value);
 
} else if (strcmp(keyword, "osd") == 0) {
diff --git a/wmix/wmix.1x b/wmix/wmix.1x
index 9b6f650..a749fb0 100644
--- a/wmix/wmix.1x
+++ b/wmix/wmix.1x
@@ -58,6 +58,15 @@ If readable, the file \fI~/.wmixrc\fP (or the file specified 
through \fB\-f\fR o
 is read on startup.
 It may contains one configuration command per line:
 .TP
+device=<\fImixer_device\fP>
+defines the device file to use instead of \fB/dev/mixer\fP
+.TP
+exclude=<\fIchannel_name\fP>
+exclude the specified channel from control, you can use it as many times as 
needed (see
+.SM
+.B "CHANNEL NAMES"
+below)
+.TP
 mousewheel=<\fI0\fP|\fI1\fP>
 when set to \fI0\fP, disable the volume control through mouse wheel 
(default=\fI1\fP)
 .TP
@@ -127,7 +136,7 @@ volume control
 .TP
 .I /dev/mixer
 Device used for controlling volume (change with option
-.BR \-m )
+.BR \-m " or with command " device " in the config file)"
 .TP
 .I /usr/share/doc/wmix/README
 More information on the user interface
-- 
1.9.2


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH dockapps 28/28] wmix: increased version number to 3.2 after the recent changes

2014-06-07 Thread Christophe
From: Christophe CURIS 

Signed-off-by: Christophe CURIS 
---
 wmix/NEWS | 5 +
 wmix/README   | 8 
 wmix/include/config.h | 2 +-
 wmix/wmix.1x  | 2 +-
 wmix/wmix.c   | 2 +-
 5 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/wmix/NEWS b/wmix/NEWS
index bea62a5..427423d 100644
--- a/wmix/NEWS
+++ b/wmix/NEWS
@@ -1,3 +1,8 @@
+3.2 NEWS:
+Added support for volume control keys found on all modern keyboards.
+Added plenty of information to the man page on invocation and configuration.
+Made wmix more verbose when something is not right in the configuration.
+
 3.1 NEWS:
 Fixed a 3 years old bug about volume level showing up as "0" when it's
 actually set to 10. Thank to all 20 or so people who e-mailed me about this.
diff --git a/wmix/README b/wmix/README
index 7941eda..ca8c295 100644
--- a/wmix/README
+++ b/wmix/README
@@ -1,8 +1,8 @@
 __  ___  
-__  ___ __ ___ (_)_  __ |___ / / _ \time...@japan.co.jp
-\ \ /\ / / '_ ` _ \| \ \/ /   |_ \| | | |   sk...@mit.edu
- \ V  V /| | | | | | |>  <   ___) | |_| |
-  \_/\_/ |_| |_| |_|_/_/\_\ |(_)___/ 
+__  ___ __ ___ (_)_  __ |___ / /__ \time...@japan.co.jp
+\ \ /\ / / '_ ` _ \| \ \/ /   |_ \   _| |   sk...@mit.edu
+ \ V  V /| | | | | | |>  <   ___) | / _/
+  \_/\_/ |_| |_| |_|_/_/\_\ |(_)|
 __
 
 * This is a complete dockapp mixer utilizing the OSS mixer API
diff --git a/wmix/include/config.h b/wmix/include/config.h
index ee632f4..1f45fc9 100644
--- a/wmix/include/config.h
+++ b/wmix/include/config.h
@@ -49,7 +49,7 @@ extern struct _Config {
 extern const char default_osd_color[];
 
 /* Current version of WMixer */
-#define VERSION "3.0"
+#define VERSION "3.2"
 
 /* Sets the default values in the config */
 void config_init(void);
diff --git a/wmix/wmix.1x b/wmix/wmix.1x
index a749fb0..1b2d54e 100644
--- a/wmix/wmix.1x
+++ b/wmix/wmix.1x
@@ -1,4 +1,4 @@
-.TH wmix 1x "2.2" "Fredrik Steen"
+.TH wmix 1x "3.2" "Fredrik Steen"
 .SH NAME
 wmix \- Dockapp mixer for OSS or ALSA
 .
diff --git a/wmix/wmix.c b/wmix/wmix.c
index a992987..9289f55 100644
--- a/wmix/wmix.c
+++ b/wmix/wmix.c
@@ -99,7 +99,7 @@ int main(int argc, char **argv)
 
 config_release();
 
-blit_string("wmix 3.0");
+blit_string("wmix " VERSION);
 scroll_text(3, 4, 57, true);
 ui_update();
 
-- 
1.9.2


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH dockapps 22/28] wmix: always display the version information when verbose is asked

2014-06-07 Thread Christophe
From: Christophe CURIS 

Signed-off-by: Christophe CURIS 
---
 wmix/config.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/wmix/config.c b/wmix/config.c
index ee0a024..6a3c822 100644
--- a/wmix/config.c
+++ b/wmix/config.c
@@ -32,8 +32,10 @@
 #include "include/config.h"
 
 
-#define HELP_TEXT\
-   "WMixer " VERSION " by time...@japan.co.jp + sk...@mit.edu\n" \
+#define VERSION_TEXT \
+   "WMixer " VERSION " by time...@japan.co.jp + sk...@mit.edu\n"
+
+#define HELP_TEXT \
"usage:\n" \
"  -d   connect to remote X display\n" \
"  -e  exclude channel, can be used many times\n" \
@@ -151,6 +153,7 @@ void parse_cli_options(int argc, char **argv)
break;
 
case 'h':
+   fputs(VERSION_TEXT, stdout);
fputs(HELP_TEXT, stdout);
exit(0);
break;
@@ -178,6 +181,9 @@ void parse_cli_options(int argc, char **argv)
 
if (error_found)
exit(EXIT_FAILURE);
+
+   if (config.verbose)
+   fputs(VERSION_TEXT, stdout);
 }
 
 /*
-- 
1.9.2


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH dockapps 24/28] wmix: added error catch for XGrabKey on multimedia keys

2014-06-07 Thread Christophe
From: Christophe CURIS 

If another application has already set a grab on these keys then the call
would fail (BadAccess) and wmix stop. With the X error handler, we can
display a warning to user and continue anyway.

Signed-off-by: Christophe CURIS 
---
 wmix/mmkeys.c | 55 +++
 wmix/wmix.1x  |  4 
 2 files changed, 59 insertions(+)

diff --git a/wmix/mmkeys.c b/wmix/mmkeys.c
index bc22625..2dae788 100644
--- a/wmix/mmkeys.c
+++ b/wmix/mmkeys.c
@@ -23,6 +23,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 
@@ -59,8 +60,19 @@ typedef struct {
unsigned int list[1 << lengthof(modifier_symbol)];
 } modifier_masks;
 
+/* The structure to track grab installation for errors */
+static struct mmkey_track {
+   XErrorHandler previous_handler;
+   struct {
+   const char *key_name;
+   unsigned long serial[1 << lengthof(modifier_symbol)];
+   Bool displayed;
+   } request[lengthof(key_list)];
+} *track_install = NULL;
+
 /* Local functions */
 static void mmkey_build_modifier_list(Display *display, modifier_masks 
*result);
+static int  mmkey_catch_grab_error(Display *display, XErrorEvent *event);
 
 
 /*
@@ -73,6 +85,7 @@ static void mmkey_build_modifier_list(Display *display, 
modifier_masks *result);
 void mmkey_install(Display *display)
 {
modifier_masks mod_masks;
+   struct mmkey_track install_info;
Window root_window;
int i, j;
 
@@ -80,6 +93,9 @@ void mmkey_install(Display *display)
 
root_window = DefaultRootWindow(display);
 
+   memset(&install_info, 0, sizeof(install_info));
+   install_info.previous_handler = 
XSetErrorHandler(mmkey_catch_grab_error);
+   track_install = &install_info;
for (i = 0; i < lengthof(key_list); i++) {
KeyCode key;
 
@@ -89,13 +105,21 @@ void mmkey_install(Display *display)
if (key == None)
continue;
 
+   install_info.request[i].key_name = key_list[i].name;
+   install_info.request[i].displayed = False;
for (j = 0; j < mod_masks.count; j++) {
+   install_info.request[i].serial[j] = 
NextRequest(display);
XGrabKey(display, key, mod_masks.list[j], root_window,
 False, GrabModeAsync, GrabModeAsync);
}
if (config.verbose)
printf("Found multimedia key: %s\n", key_list[i].name);
}
+
+   /* The grab may fail, so make sure it is reported now */
+   XSync(display, False);
+   XSetErrorHandler(install_info.previous_handler);
+   track_install = NULL;
 }
 
 /*
@@ -166,3 +190,34 @@ static void mmkey_build_modifier_list(Display *display, 
modifier_masks *result)
}
}
 }
+
+/*
+ * Callback when X11 reports an error
+ *
+ * We only track errors from XGrabKey and display them to user, instead of
+ * letting the default error handler exit
+ */
+static int mmkey_catch_grab_error(Display *display, XErrorEvent *event)
+{
+   int i, j;
+
+   if ((event->error_code == BadAccess) && (event->request_code == 
X_GrabKey)) {
+   for (i = 0; i < lengthof(track_install->request); i++) {
+   for (j = 0; j < 
lengthof(track_install->request[i].serial); j++) {
+   if (track_install->request[i].serial[j] == 0L)
+   break;
+   if (event->serial == 
track_install->request[i].serial[j]) {
+   if 
(!track_install->request[i].displayed) {
+   fprintf(stderr, "wmix:warning: 
could not grab key %s, is another application using it?\n",
+   
track_install->request[i].key_name);
+   
track_install->request[i].displayed = True;
+   }
+   return 0;
+   }
+   }
+   }
+   }
+
+   /* That's not an XGrabKey known issue, let the default handler manage 
this */
+   return track_install->previous_handler(display, event);
+}
diff --git a/wmix/wmix.1x b/wmix/wmix.1x
index 117f42e..8e4cf68 100644
--- a/wmix/wmix.1x
+++ b/wmix/wmix.1x
@@ -134,6 +134,10 @@ if you have other application controlling the volume, and 
possibly
 implementing mute in similar ways, because there is no way to know
 that a channel has been muted.
 .LP
+The X server allows only one application at a time to place a grab on a key,
+so if another application already claimed the volume control keys then 
\fBwmix\fP
+will warn you about it and continue without the functionality.
+.LP
 If you modify the configuration file, do not expect \fBwmix\fP to reload
 it automaticall

[PATCH dockapps 23/28] wmix: added function to handle Multimedia keys related to volume

2014-06-07 Thread Christophe
From: Christophe CURIS 

We can handle the keys AudioRaiseVolume, AudioLowerVolume and AudioMute,
so we ask the X server to send the key press event for them to us and
update the volume appropriately.

Signed-off-by: Christophe CURIS 
---
 wmix/Makefile |   2 +-
 wmix/include/common.h |   8 +++
 wmix/include/mmkeys.h |  34 ++
 wmix/mmkeys.c | 168 ++
 wmix/wmix.1x  |   4 +-
 wmix/wmix.c   |  37 +++
 6 files changed, 251 insertions(+), 2 deletions(-)
 create mode 100644 wmix/include/mmkeys.h
 create mode 100644 wmix/mmkeys.c

diff --git a/wmix/Makefile b/wmix/Makefile
index f7a44b7..8f9a2eb 100644
--- a/wmix/Makefile
+++ b/wmix/Makefile
@@ -2,7 +2,7 @@ CC  = gcc
 CFLAGS = -O3 -W -Wall
 LDFLAGS= -L/usr/X11R6/lib
 LIBS   = -lXpm -lXext -lX11 -lm
-OBJECTS= misc.o config.o mixer-oss.o ui_x.o wmix.o
+OBJECTS= misc.o config.o mixer-oss.o ui_x.o mmkeys.o wmix.o
 
 # where to install this program (also for packaging stuff)
 PREFIX = /usr/local
diff --git a/wmix/include/common.h b/wmix/include/common.h
index 8d9b303..6d6e895 100644
--- a/wmix/include/common.h
+++ b/wmix/include/common.h
@@ -33,3 +33,11 @@ typedef unsigned int bool;
 #define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) 
: (x)))
 
 #define MAX_DOUBLE_CLICK_TIME 0.5
+
+/*
+ * Get the number of element in a static array
+ *
+ * Do not use on an allocated array, it will not work
+ */
+#define lengthof(arr)  \
+   ((ssize_t)(sizeof( arr ) / sizeof( arr[0] )))
diff --git a/wmix/include/mmkeys.h b/wmix/include/mmkeys.h
new file mode 100644
index 000..2d0fc99
--- /dev/null
+++ b/wmix/include/mmkeys.h
@@ -0,0 +1,34 @@
+/* WMix -- a mixer using the OSS mixer API
+ * Copyright (C)2014 Christophe CURIS for the WindowMaker Team
+ *
+ * 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 of the License, or
+ * (at your option) any later 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 Street, Fifth Floor, Boston, MA 02110-1301 
USA.
+ */
+/* include/mmkeys.h: functions related to handling Multimedia keys */
+
+#ifndef WMIX_MMKEYS_H
+#define WMIX_MMKEYS_H
+
+
+/* Global Configuration */
+extern struct multimedia_keys {
+   KeyCode raise_volume;
+   KeyCode lower_volume;
+   KeyCode mute;
+} mmkeys;
+
+/* Grab the multimedia keys */
+void mmkey_install(Display *display);
+
+#endif /* WMIX_MMKEYS_H */
diff --git a/wmix/mmkeys.c b/wmix/mmkeys.c
new file mode 100644
index 000..bc22625
--- /dev/null
+++ b/wmix/mmkeys.c
@@ -0,0 +1,168 @@
+/* WMix -- a mixer using the OSS mixer API.
+ * Copyright (C) 2014 Christophe CURIS for the WindowMaker Team
+ *
+ * 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 of the License, or
+ * (at your option) any later 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 Street, Fifth Floor, Boston, MA 02110-1301 
USA.
+ */
+/*
+ * mmkeys.c: functions related to grabing the Multimedia Keys on keyboard
+ */
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include "include/common.h"
+#include "include/config.h"
+#include "include/mmkeys.h"
+
+
+/* The global configuration */
+struct multimedia_keys mmkeys;
+
+/* The list of keys we're interrested in */
+static const struct {
+   KeySym  symbol;
+   KeyCode *store;
+   const char *name;
+} key_list[] = {
+   { XF86XK_AudioRaiseVolume, &mmkeys.raise_volume, "AudioRaiseVolume" },
+   { XF86XK_AudioLowerVolume, &mmkeys.lower_volume, "AudioLowerVolume" },
+   { XF86XK_AudioMute,&mmkeys.mute, "AudioMute"}
+};
+
+/* The modifiers that should not have impact on the key grabbed */
+static const struct {
+   KeySym symbol;
+   const char *name;
+} modifier_symbol[] = {
+   { XK_Caps_Lock, "CapsLock" },
+   { XK_Num_Lock,  "NumLock"  }
+};
+
+typedef struct {
+   in

[PATCH dockapps 14/28] wmix: created new file config.c to contain configuration related stuff

2014-06-07 Thread Christophe
From: Christophe CURIS 

Management of the configuration is split in many places, the goal is to
regroup stuff together, starting with the loading from file stuff.

Signed-off-by: Christophe CURIS 
---
 wmix/Makefile |  2 +-
 wmix/config.c | 95 +++
 wmix/include/common.h | 13 ---
 wmix/include/config.h | 41 ++
 wmix/include/misc.h   |  1 -
 wmix/misc.c   | 56 --
 wmix/ui_x.c   |  4 +--
 wmix/wmix.c   |  2 +-
 8 files changed, 140 insertions(+), 74 deletions(-)
 create mode 100644 wmix/config.c
 create mode 100644 wmix/include/config.h

diff --git a/wmix/Makefile b/wmix/Makefile
index ffc1d5f..f7a44b7 100644
--- a/wmix/Makefile
+++ b/wmix/Makefile
@@ -2,7 +2,7 @@ CC  = gcc
 CFLAGS = -O3 -W -Wall
 LDFLAGS= -L/usr/X11R6/lib
 LIBS   = -lXpm -lXext -lX11 -lm
-OBJECTS= misc.o mixer-oss.o ui_x.o wmix.o
+OBJECTS= misc.o config.o mixer-oss.o ui_x.o wmix.o
 
 # where to install this program (also for packaging stuff)
 PREFIX = /usr/local
diff --git a/wmix/config.c b/wmix/config.c
new file mode 100644
index 000..9823949
--- /dev/null
+++ b/wmix/config.c
@@ -0,0 +1,95 @@
+/* WMix -- a mixer using the OSS mixer API.
+ * Copyright (C) 2014 Christophe CURIS for the WindowMaker Team
+ *
+ * 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 of the License, or
+ * (at your option) any later 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 Street, Fifth Floor, Boston, MA 02110-1301 
USA.
+ */
+/*
+ * config.c: functions related to loading the configuration from file
+ */
+
+#include 
+#include 
+#include 
+
+#include 
+
+#include "include/common.h"
+#include "include/config.h"
+
+
+/* The global configuration */
+struct _Config config;
+
+
+/*
+ * Read configuration from a file
+ *
+ * The file name is taken from CLI if available, of falls back to
+ * a default name.
+ */
+void config_read(void)
+{
+   FILE *fp;
+   char buf[512];
+   char *ptr;
+
+   if (config.file == NULL)
+   return;
+
+   fp = fopen(config.file, "r");
+   if (!fp)
+   return;
+
+   while (fgets(buf, 512, fp)) {
+   if ((ptr = strstr(buf, "mousewheel="))) {
+   ptr += 11;
+   config.mousewheel = atoi(ptr);
+   }
+   if ((ptr = strstr(buf, "scrolltext="))) {
+   ptr += 11;
+   config.scrolltext = atoi(ptr);
+   }
+   if ((ptr = strstr(buf, "osd="))) {
+   ptr += 4;
+   config.osd = atoi(ptr);
+   }
+   if ((ptr = strstr(buf, "osdcolor="))) {
+   char *end;
+   ptr += 9;
+   end = strchr(ptr, '\n');
+   ptr[end - ptr] = '\0';
+   if (config.osd_color)
+   free(config.osd_color);
+   config.osd_color = strdup(ptr);
+   }
+   if ((ptr = strstr(buf, "wheelstep="))) {
+   ptr += 10;
+   /* detect old style config */
+   if (atoi(ptr) > 1)
+   config.scrollstep = (float)atoi(ptr) / 100.0;
+   else
+   config.scrollstep = atof(ptr);
+   }
+   if ((ptr = strstr(buf, "wheelbtn1="))) {
+   ptr += 10;
+   config.wheel_button_up = atoi(ptr);
+   }
+   if ((ptr = strstr(buf, "wheelbtn2="))) {
+   ptr += 10;
+   config.wheel_button_down = atoi(ptr);
+   }
+   }
+   fclose(fp);
+}
diff --git a/wmix/include/common.h b/wmix/include/common.h
index 71aa8e6..4fdc857 100644
--- a/wmix/include/common.h
+++ b/wmix/include/common.h
@@ -35,16 +35,3 @@ typedef unsigned int bool;
 #define MAX_DOUBLE_CLICK_TIME 0.5
 #define BUTTON_WHEEL_UP 4
 #define BUTTON_WHEEL_DOWN 5
-
-typedef struct _Config Config;
-
-struct _Config {
-char   *file;  /* full path to config file name */
-unsigned int osd: 1;   /* show OSD? */
-unsigned int mousewheel : 1;   /* mousewheel enabled? */
-unsigned int scrollt

[PATCH dockapps 18/28] wmix: changed command line parsing code to report properly incorrect options

2014-06-07 Thread Christophe
From: Christophe CURIS 

The original code did not abort when an invalid option was provided
or if there was non-options arguments on the command line.
The new code will report all problems found and stop to have the user
fix his command. It also remove some unnecessary pointer checks.

Signed-off-by: Christophe CURIS 
---
 wmix/config.c | 38 ++
 1 file changed, 30 insertions(+), 8 deletions(-)

diff --git a/wmix/config.c b/wmix/config.c
index 42f9e6c..ffd2b60 100644
--- a/wmix/config.c
+++ b/wmix/config.c
@@ -71,13 +71,29 @@ void parse_cli_options(int argc, char **argv)
 {
int opt;
int count_exclude = 0;
+   bool error_found;
 
+   opterr = 0; /* We take charge of printing the error message */
config.verbose = false;
-   while ((opt = getopt(argc, argv, "d:e:f:hm:v")) != EOF) {
+   error_found = false;
+   for (;;) {
+   opt = getopt(argc, argv, ":d:e:f:hm:v");
+   if (opt == -1)
+   break;
+
switch (opt) {
+   case '?':
+   fprintf(stderr, "wmix:error: unknow option '-%c'\n", 
optopt);
+   error_found = true;
+   break;
+
+   case ':':
+   fprintf(stderr, "wmix:error: missing argument for 
option '-%c'\n", optopt);
+   error_found = true;
+   break;
+
case 'd':
-   if (optarg != NULL)
-   config.display_name = strdup(optarg);
+   config.display_name = strdup(optarg);
break;
 
case 'e':
@@ -89,9 +105,8 @@ void parse_cli_options(int argc, char **argv)
break;
 
case 'f':
-   if (optarg != NULL)
-   if (config.file != NULL)
-   free(config.file);
+   if (config.file != NULL)
+   free(config.file);
config.file = strdup(optarg);
break;
 
@@ -101,8 +116,7 @@ void parse_cli_options(int argc, char **argv)
break;
 
case 'm':
-   if (optarg != NULL)
-   config.mixer_device = strdup(optarg);
+   config.mixer_device = strdup(optarg);
break;
 
case 'v':
@@ -114,6 +128,14 @@ void parse_cli_options(int argc, char **argv)
}
}
config.exclude_channel[count_exclude] = NULL;
+
+   if (optind < argc) {
+   fprintf(stderr, "wmix:error: argument '%s' not understood\n", 
argv[optind]);
+   error_found = true;
+   }
+
+   if (error_found)
+   exit(EXIT_FAILURE);
 }
 
 /*
-- 
1.9.2


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH dockapps 17/28] wmix: be more verbose about the configuration file in use

2014-06-07 Thread Christophe
From: Christophe CURIS 

If the config file was set by user with '-f', it would be a good idea to
report him if we're not able to load it.
Took opportunity to report to user that the config file is loaded if he
asked for verbose operations, so he can see if the default file loaded
is the one he expected.

Signed-off-by: Christophe CURIS 
---
 wmix/config.c | 39 ++-
 1 file changed, 26 insertions(+), 13 deletions(-)

diff --git a/wmix/config.c b/wmix/config.c
index 9252657..42f9e6c 100644
--- a/wmix/config.c
+++ b/wmix/config.c
@@ -50,17 +50,8 @@ struct _Config config;
  */
 void config_init(void)
 {
-   char *home;
-
memset(&config, 0, sizeof(config));
 
-   /* we can theoretically live without a config file */
-   home = getenv("HOME");
-   if (home) {
-   config.file = calloc(1, strlen(home) + 9);
-   sprintf(config.file, "%s/.wmixrc", home);
-   }
-
config.mousewheel = 1;
config.scrolltext = 1;
config.wheel_button_up = 4;
@@ -133,16 +124,38 @@ void parse_cli_options(int argc, char **argv)
  */
 void config_read(void)
 {
+   const char *filename;
+   char buffer_fname[512];
FILE *fp;
char buf[512];
char *ptr;
 
-   if (config.file == NULL)
-   return;
+   if (config.file != NULL) {
+   filename = config.file;
+   } else {
+   const char *home;
 
-   fp = fopen(config.file, "r");
-   if (!fp)
+   home = getenv("HOME");
+   if (home == NULL) {
+   fprintf(stderr, "wmix: warning, could not get $HOME, 
can't load configuration file\n");
+   return;
+   }
+   snprintf(buffer_fname, sizeof(buffer_fname), "%s/.wmixrc", 
home);
+   filename = buffer_fname;
+   }
+
+   fp = fopen(filename, "r");
+   if (fp == NULL) {
+   if (config.file != NULL) {
+   /* The config file was explicitely specified by user, 
tell him there's a problem */
+   fprintf(stderr, "wmix: error, could not load 
configuration file \"%s\"\n", filename);
+   exit(EXIT_FAILURE);
+   }
+   /* Otherwise, it is acceptable if the file does not exist */
return;
+   }
+   if (config.verbose)
+   printf("Using configuration file: %s\n", filename);
 
while (fgets(buf, 512, fp)) {
if ((ptr = strstr(buf, "mousewheel="))) {
-- 
1.9.2


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH dockapps 16/28] wmix: moved the initialisation of the config to the related file

2014-06-07 Thread Christophe
From: Christophe CURIS 

Signed-off-by: Christophe CURIS 
---
 wmix/config.c | 25 +
 wmix/include/common.h |  2 --
 wmix/include/config.h |  3 +++
 wmix/wmix.c   | 20 +---
 4 files changed, 29 insertions(+), 21 deletions(-)

diff --git a/wmix/config.c b/wmix/config.c
index 8a0419c..9252657 100644
--- a/wmix/config.c
+++ b/wmix/config.c
@@ -46,6 +46,31 @@ struct _Config config;
 
 
 /*
+ * Sets the default values in configuration
+ */
+void config_init(void)
+{
+   char *home;
+
+   memset(&config, 0, sizeof(config));
+
+   /* we can theoretically live without a config file */
+   home = getenv("HOME");
+   if (home) {
+   config.file = calloc(1, strlen(home) + 9);
+   sprintf(config.file, "%s/.wmixrc", home);
+   }
+
+   config.mousewheel = 1;
+   config.scrolltext = 1;
+   config.wheel_button_up = 4;
+   config.wheel_button_down = 5;
+   config.scrollstep = 0.03;
+   config.osd = 1;
+   config.osd_color = strdup("green");
+}
+
+/*
  * Parse Command-Line options
  *
  * Supposed to be called before reading config file, as there's an
diff --git a/wmix/include/common.h b/wmix/include/common.h
index 4fdc857..8d9b303 100644
--- a/wmix/include/common.h
+++ b/wmix/include/common.h
@@ -33,5 +33,3 @@ typedef unsigned int bool;
 #define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) 
: (x)))
 
 #define MAX_DOUBLE_CLICK_TIME 0.5
-#define BUTTON_WHEEL_UP 4
-#define BUTTON_WHEEL_DOWN 5
diff --git a/wmix/include/config.h b/wmix/include/config.h
index 71a79d4..72e4cc4 100644
--- a/wmix/include/config.h
+++ b/wmix/include/config.h
@@ -47,6 +47,9 @@ extern struct _Config {
 /* Current version of WMixer */
 #define VERSION "3.0"
 
+/* Sets the default values in the config */
+void config_init(void);
+
 /* Sets configuration from command line */
 void parse_cli_options(int argc, char **argv);
 
diff --git a/wmix/wmix.c b/wmix/wmix.c
index 94b3422..e8cb6c6 100644
--- a/wmix/wmix.c
+++ b/wmix/wmix.c
@@ -61,26 +61,8 @@ static void motion_event(XMotionEvent *event);
 int main(int argc, char **argv)
 {
 XEvent event;
-char *home;
-
-memset(&config, 0, sizeof(config));
-
-/* we can theoretically live without a config file */
-home = getenv("HOME");
-if (home) {
-   config.file = calloc(1, strlen(home) + 9);
-   sprintf(config.file, "%s/.wmixrc", home);
-}
-
-/* default values */
-config.mousewheel = 1;
-config.scrolltext = 1;
-config.wheel_button_up = 4;
-config.wheel_button_down = 5;
-config.scrollstep = 0.03;
-config.osd = 1;
-config.osd_color = strdup("green");
 
+config_init();
 parse_cli_options(argc, argv);
 config_read();
 
-- 
1.9.2


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH dockapps 15/28] wmix: moved parsing of Command-Line options to the config handling file

2014-06-07 Thread Christophe
From: Christophe CURIS 

Took opportunity to re-order them alphabetically so they are easier to
work with, both for devs and for users.

Signed-off-by: Christophe CURIS 
---
 wmix/config.c | 69 -
 wmix/include/config.h | 15 +++
 wmix/wmix.c   | 71 +--
 3 files changed, 89 insertions(+), 66 deletions(-)

diff --git a/wmix/config.c b/wmix/config.c
index 9823949..8a0419c 100644
--- a/wmix/config.c
+++ b/wmix/config.c
@@ -16,12 +16,14 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
USA.
  */
 /*
- * config.c: functions related to loading the configuration from file
+ * config.c: functions related to loading the configuration, both from
+ * command line options and from file
  */
 
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -29,11 +31,76 @@
 #include "include/config.h"
 
 
+#define HELP_TEXT\
+   "WMixer " VERSION " by time...@japan.co.jp + sk...@mit.edu\n" \
+   "usage:\n" \
+   "  -d   connect to remote X display\n" \
+   "  -e  exclude channel, can be used many times\n" \
+   "  -f  parse this config [~/.wmixrc]\n" \
+   "  -hprint this help\n" \
+   "  -m   mixer device [/dev/mixer]\n" \
+   "  -vverbose -> id, long name, name\n" \
+
 /* The global configuration */
 struct _Config config;
 
 
 /*
+ * Parse Command-Line options
+ *
+ * Supposed to be called before reading config file, as there's an
+ * option to change its name
+ */
+void parse_cli_options(int argc, char **argv)
+{
+   int opt;
+   int count_exclude = 0;
+
+   config.verbose = false;
+   while ((opt = getopt(argc, argv, "d:e:f:hm:v")) != EOF) {
+   switch (opt) {
+   case 'd':
+   if (optarg != NULL)
+   config.display_name = strdup(optarg);
+   break;
+
+   case 'e':
+   if (count_exclude < SOUND_MIXER_NRDEVICES) {
+   config.exclude_channel[count_exclude] = 
strdup(optarg);
+   count_exclude++;
+   } else
+   fprintf(stderr, "Warning: You can't exclude 
this many channels\n");
+   break;
+
+   case 'f':
+   if (optarg != NULL)
+   if (config.file != NULL)
+   free(config.file);
+   config.file = strdup(optarg);
+   break;
+
+   case 'h':
+   fputs(HELP_TEXT, stdout);
+   exit(0);
+   break;
+
+   case 'm':
+   if (optarg != NULL)
+   config.mixer_device = strdup(optarg);
+   break;
+
+   case 'v':
+   config.verbose = true;
+   break;
+
+   default:
+   break;
+   }
+   }
+   config.exclude_channel[count_exclude] = NULL;
+}
+
+/*
  * Read configuration from a file
  *
  * The file name is taken from CLI if available, of falls back to
diff --git a/wmix/include/config.h b/wmix/include/config.h
index 5d84ae9..71a79d4 100644
--- a/wmix/include/config.h
+++ b/wmix/include/config.h
@@ -20,10 +20,17 @@
 #ifndef WMIX_CONFIG_H
 #define WMIX_CONFIG_H
 
+/* Needed for SOUND_MIXER_NRDEVICES */
+#include 
+
+
 /* Global Configuration */
 extern struct _Config {
char*file;  /* full path to config 
file name */
+   char*display_name;  /* X Display to connect to */
+   char*mixer_device;  /* device file to use for 
controlling Mixer volumes */
 
+   unsigned int verbose: 1;/* be Verbose when starting */
unsigned int osd: 1;/* show OSD? */
unsigned int mousewheel : 1;/* mousewheel enabled? */
unsigned int scrolltext : 1;/* scroll channel names? */
@@ -33,8 +40,16 @@ extern struct _Config {
 
floatscrollstep;/* scroll mouse step adjustment 
*/
char*osd_color; /* osd color */
+
+   char*exclude_channel[SOUND_MIXER_NRDEVICES + 1];/* 
Devices to exclude from GUI's list */
 } config;
 
+/* Current version of WMixer */
+#define VERSION "3.0"
+
+/* Sets configuration from command line */
+void parse_cli_options(int argc, char **argv);
+
 /* Read configuration from file */
 void config_read(void);
 
diff --git a/wmix/wmix.c b/wmix/wmix.c
index 331c3b9..94b3422 100644
--- a/wmix/wmix.c
+++ b/wmix/wmix.c
@@ -39,11 +39,8 @@
 #include "include/ui_x.h"
 #include "include/config.h"
 
-#define VERSION "3.0"
 
 static Display *display;
-static char *display_name = NULL;
-static

[PATCH dockapps 21/28] wmix: release memory for startup-only configuration stuff after startup

2014-06-07 Thread Christophe
From: Christophe CURIS 

A number of configuration options are useful only during the startup, so it
is possible to free them when ready.

Signed-off-by: Christophe CURIS 
---
 wmix/config.c | 38 ++
 wmix/include/config.h |  3 +++
 wmix/wmix.c   |  6 +++---
 3 files changed, 44 insertions(+), 3 deletions(-)

diff --git a/wmix/config.c b/wmix/config.c
index f335df9..ee0a024 100644
--- a/wmix/config.c
+++ b/wmix/config.c
@@ -45,6 +45,9 @@
 /* The global configuration */
 struct _Config config;
 
+/* The default device used for Mixer control */
+static const char default_mixer_device[] = "/dev/mixer";
+
 /* Default color for OSD */
 const char default_osd_color[] = "green";
 
@@ -56,6 +59,7 @@ void config_init(void)
 {
memset(&config, 0, sizeof(config));
 
+   config.mixer_device = (char *) default_mixer_device;
config.mousewheel = 1;
config.scrolltext = 1;
config.wheel_button_up = 4;
@@ -66,6 +70,36 @@ void config_init(void)
 }
 
 /*
+ * Release memory associated with configuration
+ *
+ * This does not concern the complete configuration, only the parameters
+ * that are needed during startup but are not useful during run-time
+ */
+void config_release(void)
+{
+   int i;
+
+   if (config.file)
+   free(config.file);
+
+   if (config.display_name)
+   free(config.display_name);
+
+   if (config.mixer_device != default_mixer_device)
+   free(config.mixer_device);
+
+   if (config.osd_color != default_osd_color)
+   free(config.osd_color);
+
+   for (i = 0; i < SOUND_MIXER_NRDEVICES; i++) {
+   if (config.exclude_channel[i])
+   free(config.exclude_channel[i]);
+   else
+   break;
+   }
+}
+
+/*
  * Parse Command-Line options
  *
  * Supposed to be called before reading config file, as there's an
@@ -97,6 +131,8 @@ void parse_cli_options(int argc, char **argv)
break;
 
case 'd':
+   if (config.display_name)
+   free(config.display_name);
config.display_name = strdup(optarg);
break;
 
@@ -120,6 +156,8 @@ void parse_cli_options(int argc, char **argv)
break;
 
case 'm':
+   if (config.mixer_device != default_mixer_device)
+   free(config.mixer_device);
config.mixer_device = strdup(optarg);
break;
 
diff --git a/wmix/include/config.h b/wmix/include/config.h
index 602d400..702a382 100644
--- a/wmix/include/config.h
+++ b/wmix/include/config.h
@@ -53,6 +53,9 @@ extern const char default_osd_color[];
 /* Sets the default values in the config */
 void config_init(void);
 
+/* Release memory associated with configuration (this concern only stuff 
needed during startup) */
+void config_release(void);
+
 /* Sets configuration from command line */
 void parse_cli_options(int argc, char **argv);
 
diff --git a/wmix/wmix.c b/wmix/wmix.c
index e8cb6c6..1f7ddab 100644
--- a/wmix/wmix.c
+++ b/wmix/wmix.c
@@ -66,9 +66,6 @@ int main(int argc, char **argv)
 parse_cli_options(argc, argv);
 config_read();
 
-if (config.mixer_device == NULL)
-   config.mixer_device = "/dev/mixer";
-
 mixer_init(config.mixer_device, config.verbose, (const char 
**)config.exclude_channel);
 mixer_set_channel(0);
 
@@ -94,6 +91,9 @@ int main(int argc, char **argv)
 dockapp_init(display);
 new_window("wmix", 64, 64);
 new_osd(DisplayWidth(display, DefaultScreen(display)) - 200, 60);
+
+config_release();
+
 blit_string("wmix 3.0");
 scroll_text(3, 4, 57, true);
 ui_update();
-- 
1.9.2


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH dockapps 20/28] wmix: added appropriate message and fall back if user's color for OSD failed

2014-06-07 Thread Christophe
From: Christophe CURIS 

It is generally not considered a good behaviour to leave user puzzled on
non-working request. With a little message at least he will know where to
look at.

Signed-off-by: Christophe CURIS 

Conflicts:
wmix/config.c
---
 wmix/config.c |  7 +--
 wmix/include/config.h |  3 +++
 wmix/ui_x.c   | 12 ++--
 3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/wmix/config.c b/wmix/config.c
index 317033a..f335df9 100644
--- a/wmix/config.c
+++ b/wmix/config.c
@@ -45,6 +45,9 @@
 /* The global configuration */
 struct _Config config;
 
+/* Default color for OSD */
+const char default_osd_color[] = "green";
+
 
 /*
  * Sets the default values in configuration
@@ -59,7 +62,7 @@ void config_init(void)
config.wheel_button_down = 5;
config.scrollstep = 0.03;
config.osd = 1;
-   config.osd_color = strdup("green");
+   config.osd_color = (char *) default_osd_color;
 }
 
 /*
@@ -242,7 +245,7 @@ void config_read(void)
config.osd = atoi(value);
 
} else if (strcmp(keyword, "osdcolor") == 0) {
-   if (config.osd_color)
+   if (config.osd_color != default_osd_color)
free(config.osd_color);
config.osd_color = strdup(value);
 
diff --git a/wmix/include/config.h b/wmix/include/config.h
index 72e4cc4..602d400 100644
--- a/wmix/include/config.h
+++ b/wmix/include/config.h
@@ -44,6 +44,9 @@ extern struct _Config {
char*exclude_channel[SOUND_MIXER_NRDEVICES + 1];/* 
Devices to exclude from GUI's list */
 } config;
 
+/* Default color for OSD */
+extern const char default_osd_color[];
+
 /* Current version of WMixer */
 #define VERSION "3.0"
 
diff --git a/wmix/ui_x.c b/wmix/ui_x.c
index 31a818a..1425f5c 100644
--- a/wmix/ui_x.c
+++ b/wmix/ui_x.c
@@ -589,12 +589,20 @@ unsigned long get_color(Display *display, char 
*color_name)
 {
 XColor color;
 XWindowAttributes winattr;
+Status status;
 
 XGetWindowAttributes(display,
RootWindow(display, DefaultScreen(display)), &winattr);
 
-color.pixel = 0;
-XParseColor(display, winattr.colormap, color_name, &color);
+status = XParseColor(display, winattr.colormap, color_name, &color);
+if (status == 0) {
+   fprintf(stderr, "wmix:warning: Could not get color \"%s\" for OSD, 
falling back to default\n", color_name);
+
+   if (color_name != default_osd_color)
+   status = XParseColor(display, winattr.colormap, 
default_osd_color, &color);
+   if (status == 0)
+   return WhitePixel(display, DefaultScreen(display));
+}
 
 color.flags = DoRed | DoGreen | DoBlue;
 XAllocColor(display, winattr.colormap, &color);
-- 
1.9.2


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH dockapps 07/28] wmix: added description of channel naming in the man page

2014-06-07 Thread Christophe
From: Christophe CURIS 

It may not be easy to understand how channels are names, particularly
when user wants to use a name to exclude a channel from the GUI. This
new sections answers all those questions.

Signed-off-by: Christophe CURIS 
---
 wmix/wmix.1x | 28 +++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/wmix/wmix.1x b/wmix/wmix.1x
index d030cba..a12bd38 100644
--- a/wmix/wmix.1x
+++ b/wmix/wmix.1x
@@ -27,7 +27,10 @@ Keeps a simple configuration file for user\-defined settings.
 Connect to remote X display
 .TP
 \fB\-e\fR <\fIname\fP>
-Exclude channel from control
+Exclude channel from control (see
+.SM
+.B "CHANNEL NAMES"
+below)
 .TP
 \fB\-f\fR <\fIfile\fP>
 Use config file instead of
@@ -79,6 +82,29 @@ default=\fI3\fP)
 For compatibility, values between 0.0 and 1.0 will be considered as a raw 
percentage
 .LP
 .
+.SH CHANNEL NAMES
+The names for the different channels are provided by ALSA/OSS as short names, 
for which
+.B wmix
+provides a long name match for readability.
+The default behavior is to scroll the long name of the current channel
+in the text line of the dockapp, but if you disable the scroll text
+then the short name will be displayed instead.
+.LP
+If you want to exclude a channel from the list of channels controlled by
+the dockapp you have to use the short name.
+You can get the list of all the channels available in your sound card with
+.B wmix -v
+and the short name will be between parentheses, here is an example:
+.LP
+.EX
+Supported channels:
+  1: Master volume  (Vol  )
+  2: PC Speaker (Spkr )
+  3: PCM Wave 2 volume  (Pcm2 )
+  4: Input gain (IGain)
+  5: Phone output   (PhoneOut)
+.EE
+.
 .SH FILES
 .TP
 .I ~/.wmixrc
-- 
1.9.2


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH dockapps 09/28] wmix: changed the makefile to use the standard practice LIBS variable for libraries

2014-06-07 Thread Christophe
From: Christophe CURIS 

Signed-off-by: Christophe CURIS 
---
 wmix/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/wmix/Makefile b/wmix/Makefile
index bc7bc3c..3ef4f3a 100644
--- a/wmix/Makefile
+++ b/wmix/Makefile
@@ -1,6 +1,7 @@
 CC = gcc
 CFLAGS = -O3 -W -Wall
 LDFLAGS= -L/usr/X11R6/lib
+LIBS   = -lXpm -lXext -lX11 -lm
 OBJECTS= misc.o mixer-oss.o ui_x.o wmix.o
 
 # where to install this program (also for packaging stuff)
@@ -10,7 +11,7 @@ INSTALL_BIN   = -m 755
 INSTALL_DATA   = -m 644
 
 wmix: $(OBJECTS)
-   $(CC) -o $@ $(LDFLAGS) $(OBJECTS) -lXpm -lXext -lX11 -lm
+   $(CC) -o $@ $(LDFLAGS) $(OBJECTS) $(LIBS)
 
 clean:
rm -rf *.o wmix *~
-- 
1.9.2


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH dockapps 12/28] wmix: removed unused variable because a pixmap's mask is not used

2014-06-07 Thread Christophe
From: Christophe CURIS 

The bitmap mask associated to the Led image on the knob was not used,
probably because the visual gain is negligible compared to the added
complexity to handle it.
So, as compiler warned about it, remove the variable.

Signed-off-by: Christophe CURIS 
---
 wmix/ui_x.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/wmix/ui_x.c b/wmix/ui_x.c
index 3d64329..2b993bf 100644
--- a/wmix/ui_x.c
+++ b/wmix/ui_x.c
@@ -531,7 +531,7 @@ static void draw_knob(float volume)
 {
 float bearing, led_x, led_y;
 int led_topleft_x, led_topleft_y;
-Pixmap led_pixmap, led_mask;
+Pixmap led_pixmap;
 
 bearing = (1.25 * PI) - (1.5 * PI) * volume;
 
@@ -544,13 +544,11 @@ static void draw_knob(float volume)
 /* clear previous knob picture */
 copy_xpm_area(87, 0, 26, 26, 36, 35);
 
-if (mixer_is_muted()) {
+if (mixer_is_muted())
led_pixmap = led_off_pixmap;
-   led_mask = led_off_mask;
-} else {
+else
led_pixmap = led_on_pixmap;
-   led_mask = led_on_mask;
-}
+
 XCopyArea(display, led_pixmap, dockapp.pixmap, dockapp.gc,
0, 0, LED_WIDTH, LED_HEIGHT, led_topleft_x, led_topleft_y);
 draw_percent();
-- 
1.9.2


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH dockapps 19/28] wmix: rewrote parser of config file to report problems to user

2014-06-07 Thread Christophe
From: Christophe CURIS 

The original parser would not say anything if the user had misspelled
something in the file which can be annoying. Now the parser will report
warnings for everything not understood with a message trying to be more
helpful to debug and fix.

Signed-off-by: Christophe CURIS 
---
 wmix/config.c | 118 +++---
 wmix/wmix.1x  |   2 +
 2 files changed, 89 insertions(+), 31 deletions(-)

diff --git a/wmix/config.c b/wmix/config.c
index ffd2b60..317033a 100644
--- a/wmix/config.c
+++ b/wmix/config.c
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -149,8 +150,8 @@ void config_read(void)
const char *filename;
char buffer_fname[512];
FILE *fp;
+   int line;
char buf[512];
-   char *ptr;
 
if (config.file != NULL) {
filename = config.file;
@@ -179,43 +180,98 @@ void config_read(void)
if (config.verbose)
printf("Using configuration file: %s\n", filename);
 
+   line = 0;
while (fgets(buf, 512, fp)) {
-   if ((ptr = strstr(buf, "mousewheel="))) {
-   ptr += 11;
-   config.mousewheel = atoi(ptr);
+   char *ptr;
+   char *keyword;
+   char *value;
+
+   line++;
+
+   ptr = buf;
+   while (isspace(*ptr))
+   ptr++;
+
+   if ((*ptr == '\0') || (*ptr == '#'))
+   continue;
+
+   /* Isolate the keyword */
+   keyword = ptr;
+   if (*ptr == '=') {
+   fprintf(stderr, "wmix:warning: syntax error at line %d 
in \"%s\", no keyword before '='\n",
+   line, filename);
+   continue;
}
-   if ((ptr = strstr(buf, "scrolltext="))) {
-   ptr += 11;
-   config.scrolltext = atoi(ptr);
+   value = NULL;
+   while (*ptr) {
+   if (*ptr == '=') {
+   value = ptr + 1;
+   break;
+   }
+   if (*ptr == '#')
+   break;
+   ptr++;
}
-   if ((ptr = strstr(buf, "osd="))) {
-   ptr += 4;
-   config.osd = atoi(ptr);
+   if (value == NULL) {
+   fprintf(stderr, "wmix:warning: syntax error at line %d 
in \"%s\", missing '='\n",
+   line, filename);
+   continue;
}
-   if ((ptr = strstr(buf, "osdcolor="))) {
-   char *end;
-   ptr += 9;
-   end = strchr(ptr, '\n');
-   ptr[end - ptr] = '\0';
+   while (isspace(ptr[-1]))
+   ptr--;
+   *ptr = '\0';
+
+   /* Isolate the value */
+   while (isspace(*value))
+   value++;
+   ptr = value;
+   while (*ptr) {
+   if (*ptr == '#')
+   break;
+   ptr++;
+   }
+   while (isspace(ptr[-1]))
+   ptr--;
+   *ptr = '\0';
+
+   /* Check what keyword we have */
+   if (strcmp(keyword, "mousewheel") == 0) {
+   config.mousewheel = atoi(value);
+
+   } else if (strcmp(keyword, "osd") == 0) {
+   config.osd = atoi(value);
+
+   } else if (strcmp(keyword, "osdcolor") == 0) {
if (config.osd_color)
free(config.osd_color);
-   config.osd_color = strdup(ptr);
-   }
-   if ((ptr = strstr(buf, "wheelstep="))) {
-   ptr += 10;
-   /* detect old style config */
-   if (atoi(ptr) > 1)
-   config.scrollstep = (float)atoi(ptr) / 100.0;
+   config.osd_color = strdup(value);
+
+   } else if (strcmp(keyword, "scrolltext") == 0) {
+   config.scrolltext = atoi(value);
+
+   } else if (strcmp(keyword, "wheelbtn1") == 0) {
+   config.wheel_button_up = atoi(value);
+
+   } else if (strcmp(keyword, "wheelbtn2") == 0) {
+   config.wheel_button_down = atoi(value);
+
+   } else if (strcmp(keyword, "wheelstep") == 0) {
+   double val;
+
+   val = atof(value);
+   if (val < 0.0 || val > 100.0)
+   fprintf(stderr, "wmix:error: value %f is out of 

[PATCH dockapps 13/28] wmix: create the PID file only after successful initialisation

2014-06-07 Thread Christophe
From: Christophe CURIS 

The PID file was created at the early beginning, but wmix can abort later
if something is not ok. It is better to create it at the end, so it will
be created only if wmix will actually be running.

Took the opportunity to move the code to a dedicated function to keep main
simple, and added a check to fix possible crash on startup if environment
variable $HOME does not exist.

Signed-off-by: Christophe CURIS 
---
 wmix/include/misc.h |  1 +
 wmix/misc.c | 23 +++
 wmix/wmix.c | 13 +
 3 files changed, 25 insertions(+), 12 deletions(-)

diff --git a/wmix/include/misc.h b/wmix/include/misc.h
index 5a70664..7794111 100644
--- a/wmix/include/misc.h
+++ b/wmix/include/misc.h
@@ -24,3 +24,4 @@ doubleget_current_time(void);
 void   add_region  (int index, int x, int y, int width, int 
height);
 intcheck_region(int x, int y);
 void   config_read (void);
+void   create_pid_file (void);
diff --git a/wmix/misc.c b/wmix/misc.c
index 3c7e854..544a6e9 100644
--- a/wmix/misc.c
+++ b/wmix/misc.c
@@ -22,10 +22,12 @@
 #include "config.h"
 #endif
 
+#include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "include/common.h"
@@ -161,3 +163,24 @@ void config_read(void)
 }
 fclose(fp);
 }
+
+/* handle writing PID file, silently ignore if we can't do it */
+void create_pid_file(void)
+{
+char *home;
+char *pid;
+FILE *fp;
+
+home = getenv("HOME");
+if (home == NULL)
+   return;
+
+pid = calloc(1, strlen(home) + 10);
+sprintf(pid, "%s/.wmix.pid", home);
+fp = fopen(pid, "w");
+if (fp) {
+   fprintf(fp, "%d\n", getpid());
+   fclose(fp);
+}
+free(pid);
+}
diff --git a/wmix/wmix.c b/wmix/wmix.c
index eed28b6..84b1e42 100644
--- a/wmix/wmix.c
+++ b/wmix/wmix.c
@@ -121,8 +121,6 @@ int main(int argc, char **argv)
 {
 XEvent event;
 char *home;
-char *pid;
-FILE *fp;
 
 memset(&config, 0, sizeof(config));
 
@@ -133,16 +131,6 @@ int main(int argc, char **argv)
sprintf(config.file, "%s/.wmixrc", home);
 }
 
-/* handle writing PID file, silently ignore if we can't do it */
-pid = calloc(1, strlen(home) + 10);
-sprintf(pid, "%s/.wmix.pid", home);
-fp = fopen(pid, "w");
-if (fp) {
-   fprintf(fp, "%d\n", getpid());
-   fclose(fp);
-}
-free(pid);
-
 /* default values */
 config.mousewheel = 1;
 config.scrolltext = 1;
@@ -197,6 +185,7 @@ int main(int argc, char **argv)
 add_region(10, 3, 4, 56, 7);   /* re-scroll current channel name */
 
 /* setup up/down signal handler */
+create_pid_file();
 signal(SIGUSR1, (void *) signal_catch);
 signal(SIGUSR2, (void *) signal_catch);
 
-- 
1.9.2


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH dockapps 11/28] wmix: do not risk a crash (null-pointer-dereference) if $DISPLAY is not set

2014-06-07 Thread Christophe
From: Christophe CURIS 

The original code merely assumed that an XOpenDisplay failure was caused
only by incapacity to connect to the X server, but if $DISPLAY was not set
then the fprintf would be given a NULL pointer which it may not appreciate
(depending on the libc in use).
Let's avoid that case and try to provide more info to help the user.

Signed-off-by: Christophe CURIS 
---
 wmix/wmix.c | 16 ++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/wmix/wmix.c b/wmix/wmix.c
index 5e31b5d..eed28b6 100644
--- a/wmix/wmix.c
+++ b/wmix/wmix.c
@@ -161,8 +161,20 @@ int main(int argc, char **argv)
 mixer_init(mixer_device, verbose, (const char **)exclude);
 mixer_set_channel(0);
 
-if ((display = XOpenDisplay(display_name)) == NULL) {
-   fprintf(stderr, "Unable to open display \"%s\"\n", display_name);
+display = XOpenDisplay(display_name);
+if (display == NULL) {
+   const char *name;
+
+   if (display_name) {
+   name = display_name;
+   } else {
+   name = getenv("DISPLAY");
+   if (name == NULL) {
+   fprintf(stderr, "wmix:error: Unable to open display, variable 
$DISPLAY not set\n");
+   return EXIT_FAILURE;
+   }
+   }
+   fprintf(stderr, "wmix:error: Unable to open display \"%s\"\n", name);
return EXIT_FAILURE;
 }
 display_width = (float)DisplayWidth(display, DefaultScreen(display)) / 4.0;
-- 
1.9.2


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH dockapps 10/28] wmix: fixed makefile to use PREFIX in a standard way (and with the standard default path)

2014-06-07 Thread Christophe
From: Christophe CURIS 

Signed-off-by: Christophe CURIS 
---
 wmix/Makefile | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/wmix/Makefile b/wmix/Makefile
index 3ef4f3a..ffc1d5f 100644
--- a/wmix/Makefile
+++ b/wmix/Makefile
@@ -5,8 +5,7 @@ LIBS= -lXpm -lXext -lX11 -lm
 OBJECTS= misc.o mixer-oss.o ui_x.o wmix.o
 
 # where to install this program (also for packaging stuff)
-DESTDIR=
-PREFIX = $(DESTDIR)/usr/X11R6
+PREFIX = /usr/local
 INSTALL_BIN= -m 755
 INSTALL_DATA   = -m 644
 
-- 
1.9.2


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH dockapps 08/28] wmix: install the man page at the same time as the program

2014-06-07 Thread Christophe
From: Christophe CURIS 

---
 wmix/Makefile | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/wmix/Makefile b/wmix/Makefile
index 6ec329a..bc7bc3c 100644
--- a/wmix/Makefile
+++ b/wmix/Makefile
@@ -6,7 +6,8 @@ OBJECTS = misc.o mixer-oss.o ui_x.o wmix.o
 # where to install this program (also for packaging stuff)
 DESTDIR=
 PREFIX = $(DESTDIR)/usr/X11R6
-INSTALL= -m 755
+INSTALL_BIN= -m 755
+INSTALL_DATA   = -m 644
 
 wmix: $(OBJECTS)
$(CC) -o $@ $(LDFLAGS) $(OBJECTS) -lXpm -lXext -lX11 -lm
@@ -15,4 +16,5 @@ clean:
rm -rf *.o wmix *~
 
 install: wmix
-   install $(INSTALL) wmix $(PREFIX)/bin
+   install $(INSTALL_BIN)  wmix$(PREFIX)/bin
+   install $(INSTALL_DATA) wmix.1x $(PREFIX)/man/man1
-- 
1.9.2


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH dockapps 06/28] wmix: added new BUGS section in the man page

2014-06-07 Thread Christophe
From: Christophe CURIS 

This is handy to let the user know about the possible strange behaviour he
may encounter and some limitations.

Signed-off-by: Christophe CURIS 
---
 wmix/wmix.1x | 12 
 1 file changed, 12 insertions(+)

diff --git a/wmix/wmix.1x b/wmix/wmix.1x
index 50d5c20..d030cba 100644
--- a/wmix/wmix.1x
+++ b/wmix/wmix.1x
@@ -97,6 +97,18 @@ Device used for controlling volume (change with option
 .I /usr/share/doc/wmix/README
 More information on the user interface
 .
+.SH BUGS
+The \fImute\fP functionality is implemented by setting the volume to 0
+and remembering the previous volume to restore it when unmuting.
+While this is perfectly ok, you may encounter strange looking behavior
+if you have other application controlling the volume, and possibly
+implementing mute in similar ways, because there is no way to know
+that a channel has been muted.
+.LP
+If you modify the configuration file, do not expect \fBwmix\fP to reload
+it automatically, this is considered a too costly feature for such a
+small application.
+.
 .SH AUTHORS
 This man page was written by Fredrik Steen  for the Debian
 distribution.
-- 
1.9.2


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH dockapps 05/28] wmix: more small improvements to the man page

2014-06-07 Thread Christophe
From: Christophe CURIS 

This includes detailing more files of interest to user, spell-checking and
appearance, and few other things.

Signed-off-by: Christophe CURIS 
---
 wmix/wmix.1x | 28 +---
 1 file changed, 21 insertions(+), 7 deletions(-)

diff --git a/wmix/wmix.1x b/wmix/wmix.1x
index 5892422..50d5c20 100644
--- a/wmix/wmix.1x
+++ b/wmix/wmix.1x
@@ -10,12 +10,15 @@ wmix \- Dockapp mixer for OSS or ALSA
 .I \-h
 .
 .SH DESCRIPTION
-Dockapp mixer for OSS or ALSA. Allows toggling record source,
+Docked application to control audio mixer for OSS or ALSA.
+Allows toggling record source,
 muting individual channels, adjusting volume and balance, all in a
 compact dockapp size, with TV\-like on\-screen\-display for volume levels.
 .LP
-Supports mousewheel to adjust current channelvolume
-and can be controlled remotely with SIGUSR1 / SIGUSR2 to adjust the volume.
+Supports mouse wheel to adjust current channel's volume
+and can be controlled remotely with unix signals
+.IR SIGUSR1 / SIGUSR2
+to raise/lower the volume.
 Keeps a simple configuration file for user\-defined settings.
 .
 .SH OPTIONS
@@ -81,12 +84,23 @@ For compatibility, values between 0.0 and 1.0 will be 
considered as a raw percen
 .I ~/.wmixrc
 User configuration file (change with option
 .BR \-f )
-.LP
-See \fI/usr/share/doc/wmix/README.gz\fP for more information
+.TP
+.I ~/.wmix.pid
+Contains process id of wmix, in case you'd need it for
+.IR SIGUSR1 / SIGUSR2
+volume control
+.TP
+.I /dev/mixer
+Device used for controlling volume (change with option
+.BR \-m )
+.TP
+.I /usr/share/doc/wmix/README
+More information on the user interface
 .
 .SH AUTHORS
 This man page was written by Fredrik Steen  for the Debian
 distribution.
+It was expanded by Christophe CURIS for the Window Maker Dev Team.
 .PP
-wmix was written by Tim,
-timecop 
+wmix was written by Tim, timecop ,
+with some code by Daniel Richard G. 
-- 
1.9.2


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH dockapps 03/28] wmix: added missing command line options to the man page

2014-06-07 Thread Christophe
From: Christophe CURIS 

Signed-off-by: Christophe CURIS 
---
 wmix/wmix.1x | 26 ++
 1 file changed, 22 insertions(+), 4 deletions(-)

diff --git a/wmix/wmix.1x b/wmix/wmix.1x
index 90a86b0..31cb555 100644
--- a/wmix/wmix.1x
+++ b/wmix/wmix.1x
@@ -3,9 +3,11 @@
 wmix \- Dockapp mixer for OSS or ALSA
 .
 .SH SYNOPSIS
-wmix [\fI\-h\fP]
+.B wmix
+.RI [ options... ]
 .br
-wmix \fI\-f\fP <\fIfile\fP>
+.B wmix
+.I \-h
 .
 .SH DESCRIPTION
 Dockapp mixer for OSS or ALSA. Allows toggling record source,
@@ -18,9 +20,25 @@ Keeps a simple configuration file for user\-defined settings.
 .
 .SH OPTIONS
 .TP
-\fB\-h\fR Display list of command\-line options.
+\fB\-d\fR <\fIdisplay\fP>
+Connect to remote X display
 .TP
-\fB\-f\fR <\fIfile\fP> use alternate config file
+\fB\-e\fR <\fIname\fP>
+Exclude channel from control
+.TP
+\fB\-f\fR <\fIfile\fP>
+Use config file instead of
+.I ~/.wmixrc
+.TP
+\fB\-h\fR
+Display list of command\-line options
+.TP
+\fB\-m\fR <\fIdevice\fP>
+Use specified mixer device instead of
+.I /dev/mixer
+.TP
+\fB\-v\fR
+Verbose start, report detected channels
 .
 .SH FILES
 .LP
-- 
1.9.2


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH dockapps 01/28] wmix: replaced man page with uncompressed version

2014-06-07 Thread Christophe
From: Christophe CURIS 

This allows easier review/fix/patches. Furthermore, not all man tools
support compression and some distribution may use other compression
algorithm (bzip2, ...), so this should be handled at install time.

Signed-off-by: Christophe CURIS 
---
 wmix/wmix.1x|  36 
 wmix/wmix.1x.gz | Bin 584 -> 0 bytes
 2 files changed, 36 insertions(+)
 create mode 100644 wmix/wmix.1x
 delete mode 100644 wmix/wmix.1x.gz

diff --git a/wmix/wmix.1x b/wmix/wmix.1x
new file mode 100644
index 000..5b51ef7
--- /dev/null
+++ b/wmix/wmix.1x
@@ -0,0 +1,36 @@
+..TH "wmix" "1" "2.2" "Fredrik Steen"
+..SH "NAME"
+..LP
+wmix \- Dockapp mixer for OSS or ALSA
+..SH "SYNTAX"
+..LP
+wmix [\fI\-h\fP]
+..br
+wmix \fI\-f\fP <\fIfile\fP>
+..SH "DESCRIPTION"
+..LP
+Dockapp mixer for OSS or ALSA. Allows toggling record source,
+muting individual channels, adjusting volume and balance, all in a
+compact dockapp size, with TV\-like on\-screen\-display for volume levels.
+..LP
+Supports mousewheel to adjust current channelvolume
+and can be controlled remotely with SIGUSR1 / SIGUSR2 to adjust the volume.
+Keeps a simple configuration file for user\-defined settings.
+
+..SH "OPTIONS"
+..LP
+..TP
+\fB\-h\fR Display list of command\-line options.
+..TP
+\fB\-f\fR <\fIfile\fP> use alternate config file
+..SH "FILES"
+..LP
+See \fI/usr/share/doc/wmix/README.gz\fP for more information
+
+
+..SH "AUTHORS"
+This man page was written by Fredrik Steen  for the Debian
+distribution.
+..PP
+wmix was written by Tim,
+timecop 
diff --git a/wmix/wmix.1x.gz b/wmix/wmix.1x.gz
deleted file mode 100644
index 
df0feb4508d3614b8a595e097d1a4660318d7e41..
GIT binary patch
literal 0
HcmV?d1

literal 584
zcmV-O0=NAiiwFp9*y=h019xp{crGz`0DV(UZ<|06z4I$ZKHF=>=O_xToyKZnTZTlf
zN)KxoVB`JL?qWCj^_|5KB|Y>23OxwSyA=%6+Zwpj-BNFTCvsLOtC^7O~2%3npjE@o{}
z?|xJI;6}ihttkuF6xKo_#Ww@Ya+Q7EuXp)+yBV?m+nqrwr8#>DrfHn>(
zC_Cp+hmq$6A&JyVuHk@C8XcUG5-Sp`OhEa1VUw-DJ!ShVm=Dq718Qh-Aj6XHh}Huq
zA

[PATCH dockapps 04/28] wmix: added description of the syntax of the config file in the man page

2014-06-07 Thread Christophe
From: Christophe CURIS 

Signed-off-by: Christophe CURIS 
---
 wmix/INSTALL   |  5 +++--
 wmix/README|  4 ++--
 wmix/sample.wmixrc |  2 +-
 wmix/wmix.1x   | 40 
 4 files changed, 46 insertions(+), 5 deletions(-)

diff --git a/wmix/INSTALL b/wmix/INSTALL
index 6301f0d..46f0d2d 100644
--- a/wmix/INSTALL
+++ b/wmix/INSTALL
@@ -5,7 +5,8 @@ Since your reading this, you are probably done with the tar 
zxvf part.
 3. make install
 4. wmix
 
-pretty easy.  See README for instructions on how to use the mixer and about
-some information on the programming involved.
+pretty easy. See README for instructions on how to use the mixer and about
+some information on the programming involved. See the man page (man wmix)
+for invocation and configuration information.
 
 timecop [time...@japan.co.jp]
diff --git a/wmix/README b/wmix/README
index 82446f3..7941eda 100644
--- a/wmix/README
+++ b/wmix/README
@@ -87,7 +87,7 @@ wheelstep=3   # the step for mousewheel 
adjustment
 
 Most defaults are good for normal use, and if there is no config file,
 the settings you see above are used. If you want to hack on a config file,
-copy sample.wmixrc to ~/.wmixrc and change it around. Comments are ignored,
-but don't put comments at the end of line like I did here.
+copy sample.wmixrc to ~/.wmixrc and change it around. You can find
+complete description of the format in than man page.
 
 timecop [time...@japan.co.jp]
diff --git a/wmix/sample.wmixrc b/wmix/sample.wmixrc
index a22fb9a..d87bc3c 100644
--- a/wmix/sample.wmixrc
+++ b/wmix/sample.wmixrc
@@ -6,7 +6,7 @@ mousewheel=1
 scrolltext=1
 # display OSD
 osd=1
-# color of the OSD (from rgb.txt or #xx)
+# color of the OSD (from rgb.txt or rgb:xx/xx/xx)
 osdcolor=green
 # which mousewheel button is "up"
 wheelbtn1=4
diff --git a/wmix/wmix.1x b/wmix/wmix.1x
index 31cb555..5892422 100644
--- a/wmix/wmix.1x
+++ b/wmix/wmix.1x
@@ -40,7 +40,47 @@ Use specified mixer device instead of
 \fB\-v\fR
 Verbose start, report detected channels
 .
+.SH CONFIGURATION FILE
+If readable, the file \fI~/.wmixrc\fP (or the file specified through \fB\-f\fR 
option)
+is read on startup.
+It may contains one configuration command per line:
+.TP
+mousewheel=<\fI0\fP|\fI1\fP>
+when set to \fI0\fP, disable the volume control through mouse wheel 
(default=\fI1\fP)
+.TP
+osd=<\fI0\fP|\fI1\fP>
+when set to \fI0\fP, disable display of the volume in an OSD like fashion 
(default=\fI1\fP)
+.TP
+osdcolor=<\fIcolor\fP>
+specify the color to use for OSD volume display.
+It can be the name of a color (see \fI/usr/share/X11/rgb.txt\fP)
+or an RGB specification (as \fBrgb:\fP<\fIred\fP>/<\fIgreen\fP>/<\fIblue\fP>
+with hexadecimal numbers) as expected by X11 (default=\fIgreen\fP)
+.TP
+scrolltext=<\fI0\fP|\fI1\fP>
+when set to \fI0\fP, disable text scrolling to display the name of current 
selected
+channel, use static short name instead (default=\fI1\fP)
+.TP
+wheelbtn1=<\fIbutton\fP>
+.TQ
+wheelbtn2=<\fIbutton\fP>
+defines the buttons events associated in X11 to the mouse wheel,
+with \fIbtn1\fP for up and \fIbtn2\fP for down
+(default: btn1=\fI4\fP and btn2=\fI5\fP)
+.TP
+wheelstep=<\fIpercentage\fP>
+sets the volume change step when using the mouse wheel,
+specified as a percentage of the total volume range (i.e.: 
1\~<\~\fIvalue\fP\~<\~100,
+default=\fI3\fP)
+.br
+For compatibility, values between 0.0 and 1.0 will be considered as a raw 
percentage
+.LP
+.
 .SH FILES
+.TP
+.I ~/.wmixrc
+User configuration file (change with option
+.BR \-f )
 .LP
 See \fI/usr/share/doc/wmix/README.gz\fP for more information
 .
-- 
1.9.2


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH dockapps 02/28] wmix: fixed syntax of groff macros in the man page

2014-06-07 Thread Christophe
From: Christophe CURIS 

Signed-off-by: Christophe CURIS 
---
 wmix/wmix.1x | 38 ++
 1 file changed, 18 insertions(+), 20 deletions(-)

diff --git a/wmix/wmix.1x b/wmix/wmix.1x
index 5b51ef7..90a86b0 100644
--- a/wmix/wmix.1x
+++ b/wmix/wmix.1x
@@ -1,36 +1,34 @@
-..TH "wmix" "1" "2.2" "Fredrik Steen"
-..SH "NAME"
-..LP
+.TH wmix 1x "2.2" "Fredrik Steen"
+.SH NAME
 wmix \- Dockapp mixer for OSS or ALSA
-..SH "SYNTAX"
-..LP
+.
+.SH SYNOPSIS
 wmix [\fI\-h\fP]
-..br
+.br
 wmix \fI\-f\fP <\fIfile\fP>
-..SH "DESCRIPTION"
-..LP
+.
+.SH DESCRIPTION
 Dockapp mixer for OSS or ALSA. Allows toggling record source,
 muting individual channels, adjusting volume and balance, all in a
 compact dockapp size, with TV\-like on\-screen\-display for volume levels.
-..LP
+.LP
 Supports mousewheel to adjust current channelvolume
 and can be controlled remotely with SIGUSR1 / SIGUSR2 to adjust the volume.
 Keeps a simple configuration file for user\-defined settings.
-
-..SH "OPTIONS"
-..LP
-..TP
+.
+.SH OPTIONS
+.TP
 \fB\-h\fR Display list of command\-line options.
-..TP
+.TP
 \fB\-f\fR <\fIfile\fP> use alternate config file
-..SH "FILES"
-..LP
+.
+.SH FILES
+.LP
 See \fI/usr/share/doc/wmix/README.gz\fP for more information
-
-
-..SH "AUTHORS"
+.
+.SH AUTHORS
 This man page was written by Fredrik Steen  for the Debian
 distribution.
-..PP
+.PP
 wmix was written by Tim,
 timecop 
-- 
1.9.2


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH dockapps 00/28] wmix: Add support for Multimedia keys

2014-06-07 Thread Christophe
From: Christophe CURIS 

Hello,

These more or less 3 patches add the ability to control the volume
using the multimedia keys that are present on most modern keyboards,
and that happen to be supported by X:

 - patch 23 introduces the support in wmix;
 - patch 24 makes sure user knows if the feature does not work as expected
 - patch 25 brings possibility to disable it, for those case where it could be 
conflicting with other program

The other patches are just collateral damages. I swear. Commit messages
speak for themselves. If they don't, that's a bug: complain.

Christophe.


 wmix/INSTALL  |   5 +-
 wmix/Makefile |  14 +-
 wmix/NEWS |   5 +
 wmix/README   |  12 +-
 wmix/config.c | 348 ++
 wmix/include/common.h |  21 +--
 wmix/include/config.h |  66 ++
 wmix/include/misc.h   |   2 +-
 wmix/include/mmkeys.h |  34 +
 wmix/misc.c   |  63 +++--
 wmix/mixer-oss.c  |  57 ++---
 wmix/mmkeys.c | 223 
 wmix/sample.wmixrc|   2 +-
 wmix/ui_x.c   |  26 ++--
 wmix/wmix.1x  | 172 +
 wmix/wmix.1x.gz   | Bin 584 -> 0 bytes
 wmix/wmix.c   | 159 +--
 17 files changed, 1008 insertions(+), 201 deletions(-)
 create mode 100644 wmix/config.c
 create mode 100644 wmix/include/config.h
 create mode 100644 wmix/include/mmkeys.h
 create mode 100644 wmix/mmkeys.c
 create mode 100644 wmix/wmix.1x
 delete mode 100644 wmix/wmix.1x.gz

-- 
1.9.2


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


Re: [PATCH 00/11] WPrefs: fixes for stuff reported by Coverity

2014-06-07 Thread Christophe

- David Maciejak  a écrit :
> Thanks Christophe for all these patches!
> 
> On a side note, i saw yesterday that WPrefs is using some fcts from
> WINGs/userdefaults.c, at least these 2:
> WMSetUDIntegerForKey and WMSetUDFloatForkey
> 
> The code looks the same for both fcts and are defining a buffer[128]
> and then use sprintf.
> It would be cleaner to adjust the size of the buffer and use snprintf
> instead. What's your thought ?

Hi,

Sorry for the late answer.

I had a look at the code you mentioned, and although it is true that it is not 
perfect, I'd tend to think it uses the best compromise in term of performance 
and simplicity, and the size of buffers may not be a problem: they are not 
really big, and not too small either (a reason why Coverity does not report 
anything there).

The only detail I'd see there being that using %f for float is likely to loose 
accuracy in the value stored if the number is more than a basic number, but as 
this function is not used anywhere it does not really matter...

Christophe.


> 
> regards,
> david
> 
> On Sun, Jun 1, 2014 at 1:58 AM, Christophe  wrote:
> > From: Christophe CURIS 
> >
> > Hello,
> >
> > This serie of patch fixes the code in WPrefs that are related
> > to these 13 bugs pointed by Coverity:
> >
> >  #50031: Unchecked return value
> >  #50073: Explicit null dereferenced
> >  #50098: Dereference null return value
> >  #50105: Resource leak
> >  #50107: Resource leak
> >  #50130: Resource leak
> >  #50140: Resource leak
> >  #50150: Resource leak
> >  #50156: Resource leak
> >  #50157: Resource leak
> >  #50158: Resource leak
> >  #50159: Resource leak
> >  #50200: Dereference before null check
> >
> > Christophe.
> >
> >
> >  WPrefs.app/Appearance.c | 18 +-
> >  WPrefs.app/Docks.c  |  7 ++-
> >  WPrefs.app/Focus.c  |  1 +
> >  WPrefs.app/Menu.c   | 15 ++-
> >  WPrefs.app/MouseSettings.c  |  4 +++-
> >  WPrefs.app/Paths.c  |  8 +---
> >  WPrefs.app/TexturePanel.c   |  4 ++--
> >  WPrefs.app/WindowHandling.c | 13 +
> >  WPrefs.app/editmenu.c   |  6 +-
> >  WPrefs.app/xmodifier.c  | 11 ---
> >  10 files changed, 58 insertions(+), 29 deletions(-)
> >
> > --
> > 1.9.2
> >
> >
> > --
> > To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


--
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.