From 9b62a56cbed4ffc7a1a014cf15f1e0ed767cd928 Mon Sep 17 00:00:00 2001 From: Alexei Sorokin Date: Thu, 2 Feb 2017 18:52:49 +0300 Subject: eel: GdkRGBA related fixes --- eel/eel-background.c | 21 +++++++++++---------- eel/eel-gdk-extensions.c | 7 ++++--- 2 files changed, 15 insertions(+), 13 deletions(-) (limited to 'eel') diff --git a/eel/eel-background.c b/eel/eel-background.c index 2734cdce..c1ef5c6c 100644 --- a/eel/eel-background.c +++ b/eel/eel-background.c @@ -137,20 +137,20 @@ eel_background_unrealize (EelBackground *self) self->details->bg_entire_width = 0; self->details->bg_entire_height = 0; - self->details->default_color.red = 0xffff; - self->details->default_color.green = 0xffff; - self->details->default_color.blue = 0xffff; + self->details->default_color.red = 1.0; + self->details->default_color.green = 1.0; + self->details->default_color.blue = 1.0; + self->details->default_color.alpha = 1.0; } -#define CLAMP_COLOR(v) (t = (v), CLAMP (t, 0, G_MAXUSHORT)) +#define CLAMP_COLOR(v) (CLAMP ((v), 0, 1)) #define SATURATE(v) ((1.0 - saturation) * intensity + saturation * (v)) static void make_color_inactive (EelBackground *self, - GdkRGBA *color) + GdkRGBA *color) { double intensity, saturation; - gushort t; if (!self->details->is_active) { saturation = 0.7; @@ -159,7 +159,7 @@ make_color_inactive (EelBackground *self, color->green = SATURATE (color->green); color->blue = SATURATE (color->blue); - if (intensity > G_MAXUSHORT / 2) + if (intensity > 0.5) { color->red *= 0.9; color->green *= 0.9; @@ -785,9 +785,10 @@ eel_background_init (EelBackground *self) EelBackgroundDetails); self->details->bg = mate_bg_new (); - self->details->default_color.red = 0xffff; - self->details->default_color.green = 0xffff; - self->details->default_color.blue = 0xffff; + self->details->default_color.red = 1.0; + self->details->default_color.green = 1.0; + self->details->default_color.blue = 1.0; + self->details->default_color.alpha = 1.0; self->details->is_active = TRUE; g_signal_connect (self->details->bg, "changed", diff --git a/eel/eel-gdk-extensions.c b/eel/eel-gdk-extensions.c index 0a4d62c8..1bd367fb 100644 --- a/eel/eel-gdk-extensions.c +++ b/eel/eel-gdk-extensions.c @@ -342,6 +342,7 @@ eel_gdk_rgba_parse_with_white_default (GdkRGBA *color, color->red = 1.0; color->green = 1.0; color->blue = 1.0; + color->alpha = 1.0; } } @@ -422,9 +423,9 @@ eel_gdk_rgba_is_dark (const GdkRGBA *color) { int intensity; - intensity = ((((int) (color->red) >> 8) * 77) - + (((int) (color->green) >> 8) * 150) - + (((int) (color->blue) >> 8) * 28)) >> 8; + intensity = (((guint) (color->red * 0xff) * 77) + + ((guint) (color->green * 0xff) * 150) + + ((guint) (color->blue * 0xff) * 28)) >> 8; return intensity < 128; } -- cgit v1.2.1