[Pkg-wmaker-commits] [wmix] 23/44: wmix: added appropriate message and fall back if user's color for OSD failed

Doug Torrance dtorrance-guest at moszumanska.debian.org
Fri Sep 29 10:40:13 UTC 2017


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

dtorrance-guest pushed a commit to branch upstream
in repository wmix.

commit 5dea83e830e29455824ca1d6d19b9f2a524e5aa6
Author: Christophe CURIS <christophe.curis at free.fr>
Date:   Sat Jun 7 21:21:51 2014 +0200

    wmix: added appropriate message and fall back if user's color for OSD failed
    
    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 <christophe.curis at free.fr>
    
    Conflicts:
    	wmix/config.c
---
 config.c         |  7 +++++--
 include/config.h |  3 +++
 ui_x.c           | 12 ++++++++++--
 3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/config.c b/config.c
index 317033a..f335df9 100644
--- a/config.c
+++ b/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/include/config.h b/include/config.h
index 72e4cc4..602d400 100644
--- a/include/config.h
+++ b/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/ui_x.c b/ui_x.c
index 31a818a..1425f5c 100644
--- a/ui_x.c
+++ b/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);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmix.git



More information about the Pkg-wmaker-commits mailing list