diff options
Diffstat (limited to 'src/gui_gtk_x11.c')
-rw-r--r-- | src/gui_gtk_x11.c | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/src/gui_gtk_x11.c b/src/gui_gtk_x11.c index 5837c0b172..480b8d3b83 100644 --- a/src/gui_gtk_x11.c +++ b/src/gui_gtk_x11.c @@ -5606,16 +5606,34 @@ gui_mch_get_color(char_u *name) return name != NULL ? gui_get_color_cmn(name) : INVALCOLOR; #else guicolor_T color; - GdkColor gcolor; - int ret; color = (name != NULL) ? gui_get_color_cmn(name) : INVALCOLOR; if (color == INVALCOLOR) return INVALCOLOR; - gcolor.red = (guint16)(((color & 0xff0000) >> 16) / 255.0 * 65535 + 0.5); - gcolor.green = (guint16)(((color & 0xff00) >> 8) / 255.0 * 65535 + 0.5); - gcolor.blue = (guint16)((color & 0xff) / 255.0 * 65535 + 0.5); + return gui_mch_get_rgb_color( + (color & 0xff0000) >> 16, + (color & 0xff00) >> 8, + color & 0xff); +#endif +} + +/* + * Return the Pixel value (color) for the given RGB values. + * Return INVALCOLOR for error. + */ + guicolor_T +gui_mch_get_rgb_color(int r, int g, int b) +{ +#if GTK_CHECK_VERSION(3,0,0) + return gui_get_rgb_color_cmn(r, g, b); +#else + GdkColor gcolor; + int ret; + + gcolor.red = (guint16)(r / 255.0 * 65535 + 0.5); + gcolor.green = (guint16)(g / 255.0 * 65535 + 0.5); + gcolor.blue = (guint16)(b / 255.0 * 65535 + 0.5); ret = gdk_colormap_alloc_color(gtk_widget_get_colormap(gui.drawarea), &gcolor, FALSE, TRUE); |