From 8e66480c6c15c569dec3f38273e7d22d15b0e98a Mon Sep 17 00:00:00 2001 From: Richard Hult Date: Wed, 13 Feb 2008 14:20:51 +0000 Subject: [PATCH] Fix the return value (return number of colors that failed), and handle 2008-02-13 Richard Hult * gdk/quartz/gdkcolor-quartz.c: (gdk_colormap_alloc_colors): Fix the return value (return number of colors that failed), and handle RGBA colormap. (gdk_colormap_free_colors): Fix typo in comment. svn path=/trunk/; revision=19557 --- ChangeLog | 7 +++++++ gdk/quartz/gdkcolor-quartz.c | 26 +++++++++++++++++--------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index c02c922a2a..d208e845ff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-02-13 Richard Hult + + * gdk/quartz/gdkcolor-quartz.c: (gdk_colormap_alloc_colors): Fix + the return value (return number of colors that failed), and handle + RGBA colormap. + (gdk_colormap_free_colors): Fix typo in comment. + 2008-02-13 Kristian Rietveld * gtk/gtktreeview.c (gtk_tree_view_stop_rubber_band): only diff --git a/gdk/quartz/gdkcolor-quartz.c b/gdk/quartz/gdkcolor-quartz.c index a2772e6fed..7b15a9e8df 100644 --- a/gdk/quartz/gdkcolor-quartz.c +++ b/gdk/quartz/gdkcolor-quartz.c @@ -137,9 +137,7 @@ gdk_colormap_free_colors (GdkColormap *colormap, const GdkColor *colors, gint n_colors) { - /* This function shouldn't do anything since - * colors are neve allocated. - */ + /* This function shouldn't do anything since colors are never allocated. */ } gint @@ -151,18 +149,28 @@ gdk_colormap_alloc_colors (GdkColormap *colormap, gboolean *success) { int i; + int alpha; + + g_return_val_if_fail (GDK_IS_COLORMAP (colormap), ncolors); + g_return_val_if_fail (colors != NULL, ncolors); + g_return_val_if_fail (success != NULL, ncolors); + + if (gdk_colormap_get_visual (colormap)->depth == 32) + alpha = 0xff; + else + alpha = 0; for (i = 0; i < ncolors; i++) { - colors[i].pixel = ((colors[i].red >> 8) & 0xff) << 16 | - ((colors[i].green >> 8) & 0xff) << 8 | - ((colors[i].blue >> 8) & 0xff); + colors[i].pixel = alpha << 24 | + ((colors[i].red >> 8) & 0xff) << 16 | + ((colors[i].green >> 8) & 0xff) << 8 | + ((colors[i].blue >> 8) & 0xff); } - if (success) - *success = TRUE; + *success = TRUE; - return ncolors; + return 0; } void