diff options
author | Alexandr Miloslavskiy | 2019-03-21 18:23:04 +0000 |
---|---|---|
committer | Eric Williams | 2019-03-26 20:14:46 +0000 |
commit | 824d043c2b8ee492d849e78e2aa282b068bc357a (patch) | |
tree | 01583fb41a4aa105db012e82a47789deb5b9a6ee | |
parent | 4ce8a195ba3ace07f48c5d2da637f513a3e56db9 (diff) | |
download | eclipse.platform.swt-824d043c2b8ee492d849e78e2aa282b068bc357a.tar.gz eclipse.platform.swt-824d043c2b8ee492d849e78e2aa282b068bc357a.tar.xz eclipse.platform.swt-824d043c2b8ee492d849e78e2aa282b068bc357a.zip |
Bug 545587 - [GTK] Incorrect COLOR_INFO_FOREGROUND on Ubuntu 18.10
Fix 1:
------
Old approach no longer works, because GTK changed the way of specifying
CSS classes. I think it happened in this GTK commit:
6f6e5365 by Emmanuele Bassi at 2015-11-08 18:10:00
Use CSS node name for GtkTooltipWindow instead of a style class.
The new way is to use 'GtkWidgetPath' and set CSS name explicitly, see
'gtk_widget_class_set_css_name' in 'gtk_tooltip_window_class_init'.
Fix 2:
------
'styleContextGetBackgroundColor' now uses ARGB surface to obtain correct
alpha component of the color.
Fix 3:
------
'styleContextGetBackgroundColor' now correctly works around
premultiplied
colors in cairo.
Refactoring:
------------
1) Renamed 'getBackgroundColor' 'styleContextGetBackgroundColor' to
match
the other function, 'styleContextGetColor'
Change-Id: Ie93fa71addd16133989be81ebf8e0d0fb1e55e12
Signed-off-by: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
5 files changed, 293 insertions, 39 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c index 4a562b022d..8bb7f2fcae 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c @@ -6845,6 +6845,18 @@ JNIEXPORT jint JNICALL GTK_NATIVE(_1gtk_1label_1get_1mnemonic_1keyval) } #endif +#ifndef NO__1gtk_1label_1get_1type +JNIEXPORT jlong JNICALL GTK_NATIVE(_1gtk_1label_1get_1type) + (JNIEnv *env, jclass that) +{ + jlong rc = 0; + GTK_NATIVE_ENTER(env, that, _1gtk_1label_1get_1type_FUNC); + rc = (jlong)gtk_label_get_type(); + GTK_NATIVE_EXIT(env, that, _1gtk_1label_1get_1type_FUNC); + return rc; +} +#endif + #ifndef NO__1gtk_1label_1new JNIEXPORT jlong JNICALL GTK_NATIVE(_1gtk_1label_1new) (JNIEnv *env, jclass that, jbyteArray arg0) @@ -9332,6 +9344,18 @@ JNIEXPORT void JNICALL GTK_NATIVE(_1gtk_1style_1context_1invalidate) } #endif +#ifndef NO__1gtk_1style_1context_1new +JNIEXPORT jlong JNICALL GTK_NATIVE(_1gtk_1style_1context_1new) + (JNIEnv *env, jclass that) +{ + jlong rc = 0; + GTK_NATIVE_ENTER(env, that, _1gtk_1style_1context_1new_FUNC); + rc = (jlong)gtk_style_context_new(); + GTK_NATIVE_EXIT(env, that, _1gtk_1style_1context_1new_FUNC); + return rc; +} +#endif + #ifndef NO__1gtk_1style_1context_1remove_1class JNIEXPORT void JNICALL GTK_NATIVE(_1gtk_1style_1context_1remove_1class) (JNIEnv *env, jclass that, jlong arg0, jbyteArray arg1) @@ -9366,6 +9390,16 @@ JNIEXPORT void JNICALL GTK_NATIVE(_1gtk_1style_1context_1save) } #endif +#ifndef NO__1gtk_1style_1context_1set_1path +JNIEXPORT void JNICALL GTK_NATIVE(_1gtk_1style_1context_1set_1path) + (JNIEnv *env, jclass that, jlong arg0, jlong arg1) +{ + GTK_NATIVE_ENTER(env, that, _1gtk_1style_1context_1set_1path_FUNC); + gtk_style_context_set_path((GtkStyleContext *)arg0, (GtkWidgetPath *)arg1); + GTK_NATIVE_EXIT(env, that, _1gtk_1style_1context_1set_1path_FUNC); +} +#endif + #ifndef NO__1gtk_1style_1context_1set_1state JNIEXPORT void JNICALL GTK_NATIVE(_1gtk_1style_1context_1set_1state) (JNIEnv *env, jclass that, jlong arg0, jlong arg1) @@ -12348,6 +12382,64 @@ JNIEXPORT void JNICALL GTK_NATIVE(_1gtk_1widget_1override_1font) } #endif +#ifndef NO__1gtk_1widget_1path_1append_1type +JNIEXPORT jlong JNICALL GTK_NATIVE(_1gtk_1widget_1path_1append_1type) + (JNIEnv *env, jclass that, jlong arg0, jlong arg1) +{ + jlong rc = 0; + GTK_NATIVE_ENTER(env, that, _1gtk_1widget_1path_1append_1type_FUNC); + rc = (jlong)gtk_widget_path_append_type((GtkWidgetPath *)arg0, (GType)arg1); + GTK_NATIVE_EXIT(env, that, _1gtk_1widget_1path_1append_1type_FUNC); + return rc; +} +#endif + +#ifndef NO__1gtk_1widget_1path_1free +JNIEXPORT void JNICALL GTK_NATIVE(_1gtk_1widget_1path_1free) + (JNIEnv *env, jclass that, jlong arg0) +{ + GTK_NATIVE_ENTER(env, that, _1gtk_1widget_1path_1free_FUNC); + gtk_widget_path_free((GtkWidgetPath *)arg0); + GTK_NATIVE_EXIT(env, that, _1gtk_1widget_1path_1free_FUNC); +} +#endif + +#ifndef NO__1gtk_1widget_1path_1iter_1set_1object_1name +JNIEXPORT jlong JNICALL GTK_NATIVE(_1gtk_1widget_1path_1iter_1set_1object_1name) + (JNIEnv *env, jclass that, jlong arg0, jlong arg1, jbyteArray arg2) +{ + jbyte *lparg2=NULL; + jlong rc = 0; + GTK_NATIVE_ENTER(env, that, _1gtk_1widget_1path_1iter_1set_1object_1name_FUNC); + if (arg2) if ((lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL)) == NULL) goto fail; +/* + rc = (jlong)gtk_widget_path_iter_set_object_name((GtkWidgetPath *)arg0, (gint)arg1, (const char *)lparg2); +*/ + { + GTK_LOAD_FUNCTION(fp, gtk_widget_path_iter_set_object_name) + if (fp) { + rc = (jlong)((jlong (CALLING_CONVENTION*)(GtkWidgetPath *, gint, const char *))fp)((GtkWidgetPath *)arg0, (gint)arg1, (const char *)lparg2); + } + } +fail: + if (arg2 && lparg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0); + GTK_NATIVE_EXIT(env, that, _1gtk_1widget_1path_1iter_1set_1object_1name_FUNC); + return rc; +} +#endif + +#ifndef NO__1gtk_1widget_1path_1new +JNIEXPORT jlong JNICALL GTK_NATIVE(_1gtk_1widget_1path_1new) + (JNIEnv *env, jclass that) +{ + jlong rc = 0; + GTK_NATIVE_ENTER(env, that, _1gtk_1widget_1path_1new_FUNC); + rc = (jlong)gtk_widget_path_new(); + GTK_NATIVE_EXIT(env, that, _1gtk_1widget_1path_1new_FUNC); + return rc; +} +#endif + #ifndef NO__1gtk_1widget_1queue_1draw JNIEXPORT void JNICALL GTK_NATIVE(_1gtk_1widget_1queue_1draw) (JNIEnv *env, jclass that, jlong arg0) diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c index 8ea3bc8038..675554b9b1 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c @@ -552,6 +552,7 @@ char * GTK_nativeFunctionNames[] = { #endif "_1gtk_1label_1get_1layout", "_1gtk_1label_1get_1mnemonic_1keyval", + "_1gtk_1label_1get_1type", "_1gtk_1label_1new", "_1gtk_1label_1new_1with_1mnemonic", "_1gtk_1label_1set_1attributes", @@ -749,9 +750,11 @@ char * GTK_nativeFunctionNames[] = { "_1gtk_1style_1context_1get_1padding__JILorg_eclipse_swt_internal_gtk_GtkBorder_2", "_1gtk_1style_1context_1get_1padding__JLorg_eclipse_swt_internal_gtk_GtkBorder_2", "_1gtk_1style_1context_1invalidate", + "_1gtk_1style_1context_1new", "_1gtk_1style_1context_1remove_1class", "_1gtk_1style_1context_1restore", "_1gtk_1style_1context_1save", + "_1gtk_1style_1context_1set_1path", "_1gtk_1style_1context_1set_1state", "_1gtk_1target_1list_1new", "_1gtk_1target_1list_1unref", @@ -975,6 +978,10 @@ char * GTK_nativeFunctionNames[] = { "_1gtk_1widget_1override_1background_1color", "_1gtk_1widget_1override_1color", "_1gtk_1widget_1override_1font", + "_1gtk_1widget_1path_1append_1type", + "_1gtk_1widget_1path_1free", + "_1gtk_1widget_1path_1iter_1set_1object_1name", + "_1gtk_1widget_1path_1new", "_1gtk_1widget_1queue_1draw", "_1gtk_1widget_1queue_1resize", "_1gtk_1widget_1realize", diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h index 98a58f57ba..9714551869 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h @@ -550,6 +550,7 @@ typedef enum { #endif _1gtk_1label_1get_1layout_FUNC, _1gtk_1label_1get_1mnemonic_1keyval_FUNC, + _1gtk_1label_1get_1type_FUNC, _1gtk_1label_1new_FUNC, _1gtk_1label_1new_1with_1mnemonic_FUNC, _1gtk_1label_1set_1attributes_FUNC, @@ -747,9 +748,11 @@ typedef enum { _1gtk_1style_1context_1get_1padding__JILorg_eclipse_swt_internal_gtk_GtkBorder_2_FUNC, _1gtk_1style_1context_1get_1padding__JLorg_eclipse_swt_internal_gtk_GtkBorder_2_FUNC, _1gtk_1style_1context_1invalidate_FUNC, + _1gtk_1style_1context_1new_FUNC, _1gtk_1style_1context_1remove_1class_FUNC, _1gtk_1style_1context_1restore_FUNC, _1gtk_1style_1context_1save_FUNC, + _1gtk_1style_1context_1set_1path_FUNC, _1gtk_1style_1context_1set_1state_FUNC, _1gtk_1target_1list_1new_FUNC, _1gtk_1target_1list_1unref_FUNC, @@ -973,6 +976,10 @@ typedef enum { _1gtk_1widget_1override_1background_1color_FUNC, _1gtk_1widget_1override_1color_FUNC, _1gtk_1widget_1override_1font_FUNC, + _1gtk_1widget_1path_1append_1type_FUNC, + _1gtk_1widget_1path_1free_FUNC, + _1gtk_1widget_1path_1iter_1set_1object_1name_FUNC, + _1gtk_1widget_1path_1new_FUNC, _1gtk_1widget_1queue_1draw_FUNC, _1gtk_1widget_1queue_1resize_FUNC, _1gtk_1widget_1realize_FUNC, diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java index c6e05cfdba..250785978c 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java @@ -3743,6 +3743,15 @@ public class GTK extends OS { lock.unlock(); } } + public static final native long _gtk_label_get_type(); + public static final long gtk_label_get_type() { + lock.lock(); + try { + return _gtk_label_get_type(); + } finally { + lock.unlock(); + } + } /** @param label cast=(GtkLabel *) */ public static final native int _gtk_label_get_mnemonic_keyval(long label); public static final int gtk_label_get_mnemonic_keyval(long label) { @@ -4025,6 +4034,28 @@ public class GTK extends OS { lock.unlock(); } } + public static final native long _gtk_style_context_new (); + public static final long gtk_style_context_new() { + lock.lock(); + try { + return _gtk_style_context_new(); + } finally { + lock.unlock(); + } + } + /** + * @param context cast=(GtkStyleContext *) + * @param path cast=(GtkWidgetPath *) + */ + public static final native void _gtk_style_context_set_path (long context, long path); + public static final void gtk_style_context_set_path(long context, long path) { + lock.lock(); + try { + _gtk_style_context_set_path(context, path); + } finally { + lock.unlock(); + } + } /** * @param list_store cast=(GtkListStore *) * @param iter cast=(GtkTreeIter *) @@ -8858,6 +8889,56 @@ public class GTK extends OS { lock.unlock(); } } + /** + * @param path cast=(GtkWidgetPath *) + * @param type cast=(GType) + */ + public static final native long _gtk_widget_path_append_type (long path, long type); + public static final long gtk_widget_path_append_type(long path, long type) { + lock.lock(); + try { + return _gtk_widget_path_append_type(path, type); + } finally { + lock.unlock(); + } + } + /** + * @param path cast=(GtkWidgetPath *) + */ + public static final native void _gtk_widget_path_free (long path); + public static final void gtk_widget_path_free(long path) { + lock.lock(); + try { + _gtk_widget_path_free(path); + } finally { + lock.unlock(); + } + } + /** + * @method flags=dynamic + * @param path cast=(GtkWidgetPath *) + * @param pos cast=(gint) + * @param name cast=(const char *) + */ + public static final native long _gtk_widget_path_iter_set_object_name (long path, long pos, byte[] name); + /** [since 3.20] */ + public static final long gtk_widget_path_iter_set_object_name(long path, long pos, byte[] name) { + lock.lock(); + try { + return _gtk_widget_path_iter_set_object_name(path, pos, name); + } finally { + lock.unlock(); + } + } + public static final native long _gtk_widget_path_new (); + public static final long gtk_widget_path_new() { + lock.lock(); + try { + return _gtk_widget_path_new(); + } finally { + lock.unlock(); + } + } /** @param widget cast=(GtkWidget *) */ public static final native void _gtk_widget_queue_resize(long widget); public static final void gtk_widget_queue_resize(long widget) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java index 1d2ef21557..997bffac97 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java @@ -3174,28 +3174,50 @@ GdkRGBA toGdkRGBA (GdkRGBA rgba, double brightness) { return newRGBA; } -GdkRGBA getBackgroundColor (long context, int state) { +/** + * Calculates original color from RGBA with premultiplied alpha. + * + * NOTE: Calculating inverse gives a range of possible colors due to rounding that + * occurs with integer calculations. However, alpha-blend formula only has the + * multiplied component, so all of those inverses are equivalent. + */ +static int inversePremultipliedColor(int color, int alpha) { + return (255*color + alpha-1) / alpha; +} + +GdkRGBA styleContextGetBackgroundColor(long context, int state) { /* - * Draw the context background to an offset screen surface and get the color - * in the middle of the surface. + * Background in GTK theme can be more complex then just solid color: + * it can have 'background-image', 'background-position', 'background-repeat', etc. + * One example is 'tooltip' in 'Ambiance' theme, which doesn't have 'background-color'. + * The workaround is to draw the context background to a temporary image and + * get the color of the pixel in the middle. */ - GdkRGBA rgba = new GdkRGBA (); GTK.gtk_style_context_save (context); GTK.gtk_style_context_set_state (context, state); - long surface = Cairo.cairo_image_surface_create (Cairo.CAIRO_FORMAT_RGB24, 1, 1); + long surface = Cairo.cairo_image_surface_create (Cairo.CAIRO_FORMAT_ARGB32, 1, 1); long cairo = Cairo.cairo_create (surface); GTK.gtk_render_background (context, cairo, -50, -50, 100, 100); Cairo.cairo_fill (cairo); Cairo.cairo_surface_flush (surface); - byte[] buffer = new byte[3]; + byte[] buffer = new byte[4]; C.memmove (buffer, Cairo.cairo_image_surface_get_data(surface), buffer.length); - rgba.red = Byte.toUnsignedInt(buffer[2]) / 255f; - rgba.green = Byte.toUnsignedInt(buffer[1]) / 255f; - rgba.blue = Byte.toUnsignedInt(buffer[0]) / 255f; - rgba.alpha = 1.0; Cairo.cairo_surface_destroy (surface); Cairo.cairo_destroy (cairo); GTK.gtk_style_context_restore (context); + + int a = Byte.toUnsignedInt(buffer[3]); + int r = Byte.toUnsignedInt(buffer[2]); + int g = Byte.toUnsignedInt(buffer[1]); + int b = Byte.toUnsignedInt(buffer[0]); + + // NOTE: cairo uses premultiplied alpha (see CAIRO_FORMAT_ARGB32) + GdkRGBA rgba = new GdkRGBA (); + rgba.alpha = a / 255f; + rgba.red = inversePremultipliedColor(r, a) / 255f; + rgba.green = inversePremultipliedColor(g, a) / 255f; + rgba.blue = inversePremultipliedColor(b, a) / 255f; + return rgba; } @@ -3431,45 +3453,90 @@ private void initializeSystemColorsLink(String cssOutput) { } void initializeSystemColorsTooltip(String cssOutput) { - // Create a temporary Tooltip widget - long tooltipShellHandle = GTK.gtk_window_new (GTK.GTK_WINDOW_POPUP); - if (tooltipShellHandle == 0) error (SWT.ERROR_NO_HANDLES); - byte[] gtk_tooltip = Converter.wcsToMbcs ("gtk-tooltip", true); //$NON-NLS-1$ - GTK.gtk_widget_set_name (tooltipShellHandle, gtk_tooltip); - GTK.gtk_widget_realize (tooltipShellHandle); - - long context = GTK.gtk_widget_get_style_context (tooltipShellHandle); - GTK.gtk_style_context_add_class (context, GTK.GTK_STYLE_CLASS_TOOLTIP); - GTK.gtk_style_context_invalidate(context); + // gtk_widget_path_iter_set_object_name is available since 3.20 + if (GTK.GTK_VERSION >= OS.VERSION(3, 20, 0)) { + // NOTE: One other approach would be to create a temporary 'GtkTooltipWindow' + // widget, obtaining its GType with 'g_type_from_name'. See snippet + // attached to Bug 545587 for a demo. + + byte[] tooltipCssNode = Converter.javaStringToCString("tooltip"); //$NON-NLS-1$ + + // Separate style contexts are used to avoid complex state manipulations + { + // Foreground color is taken from 'tooltip label' css node + long labelType = GTK.gtk_label_get_type(); + long context = GTK.gtk_style_context_new(); + long widgetPath = GTK.gtk_widget_path_new(); + GTK.gtk_widget_path_append_type(widgetPath, 0); + GTK.gtk_widget_path_iter_set_object_name(widgetPath, -1, tooltipCssNode); + GTK.gtk_widget_path_append_type(widgetPath, labelType); + GTK.gtk_style_context_set_path(context, widgetPath); + GTK.gtk_widget_path_free(widgetPath); + + COLOR_INFO_FOREGROUND_RGBA = styleContextGetColor(context, GTK.GTK_STATE_FLAG_NORMAL); + + // Destroy temporary style context + OS.g_object_unref(context); + } - if (GTK.GTK_VERSION >= OS.VERSION(3, 14, 0)) { - String colorInfoForeground = gtk_css_default_theme_values(SWT.COLOR_INFO_FOREGROUND, cssOutput); - if (!colorInfoForeground.isEmpty()) { - if (colorInfoForeground != "parsed") { - COLOR_INFO_FOREGROUND_RGBA = gtk_css_property_to_rgba (colorInfoForeground); + // Separate style contexts are used to avoid complex state manipulations + { + // Background color is taken from 'tooltip.background' css node + byte[] backgroundClass = Converter.javaStringToCString("background"); //$NON-NLS-1$ + long context = GTK.gtk_style_context_new(); + long widgetPath = GTK.gtk_widget_path_new(); + GTK.gtk_widget_path_append_type(widgetPath, 0); + GTK.gtk_widget_path_iter_set_object_name(widgetPath, -1, tooltipCssNode); + GTK.gtk_style_context_set_path(context, widgetPath); + GTK.gtk_style_context_add_class(context, backgroundClass); + GTK.gtk_widget_path_free(widgetPath); + + COLOR_INFO_BACKGROUND_RGBA = styleContextGetBackgroundColor(context, GTK.GTK_STATE_FLAG_NORMAL); + + // Destroy temporary style context + OS.g_object_unref(context); + } + } else { + // Create a temporary Tooltip widget + long tooltipShellHandle = GTK.gtk_window_new (GTK.GTK_WINDOW_POPUP); + if (tooltipShellHandle == 0) error (SWT.ERROR_NO_HANDLES); + byte[] gtk_tooltip = Converter.wcsToMbcs ("gtk-tooltip", true); //$NON-NLS-1$ + GTK.gtk_widget_set_name (tooltipShellHandle, gtk_tooltip); + GTK.gtk_widget_realize (tooltipShellHandle); + + long context = GTK.gtk_widget_get_style_context (tooltipShellHandle); + GTK.gtk_style_context_add_class (context, GTK.GTK_STYLE_CLASS_TOOLTIP); + GTK.gtk_style_context_invalidate(context); + + if (GTK.GTK_VERSION >= OS.VERSION(3, 14, 0)) { + String colorInfoForeground = gtk_css_default_theme_values(SWT.COLOR_INFO_FOREGROUND, cssOutput); + if (!colorInfoForeground.isEmpty()) { + if (colorInfoForeground != "parsed") { + COLOR_INFO_FOREGROUND_RGBA = gtk_css_property_to_rgba (colorInfoForeground); + } + } else { + COLOR_INFO_FOREGROUND_RGBA = styleContextGetColor (context, GTK.GTK_STATE_FLAG_NORMAL); } } else { COLOR_INFO_FOREGROUND_RGBA = styleContextGetColor (context, GTK.GTK_STATE_FLAG_NORMAL); } - } else { - COLOR_INFO_FOREGROUND_RGBA = styleContextGetColor (context, GTK.GTK_STATE_FLAG_NORMAL); - } - if (GTK.GTK_VERSION >= OS.VERSION(3, 14, 0)) { - String colorInfoBackground = gtk_css_default_theme_values(SWT.COLOR_INFO_BACKGROUND, cssOutput); - if (!colorInfoBackground.isEmpty()) { - if (colorInfoBackground != "parsed") { - COLOR_INFO_BACKGROUND_RGBA = gtk_css_property_to_rgba (colorInfoBackground); + if (GTK.GTK_VERSION >= OS.VERSION(3, 14, 0)) { + String colorInfoBackground = gtk_css_default_theme_values(SWT.COLOR_INFO_BACKGROUND, cssOutput); + if (!colorInfoBackground.isEmpty()) { + if (colorInfoBackground != "parsed") { + COLOR_INFO_BACKGROUND_RGBA = gtk_css_property_to_rgba (colorInfoBackground); + } + } else { + COLOR_INFO_BACKGROUND_RGBA = styleContextGetBackgroundColor(context, GTK.GTK_STATE_FLAG_NORMAL); } } else { - COLOR_INFO_BACKGROUND_RGBA = getBackgroundColor (context, GTK.GTK_STATE_FLAG_NORMAL); + COLOR_INFO_BACKGROUND_RGBA = styleContextGetBackgroundColor(context, GTK.GTK_STATE_FLAG_NORMAL); } - } else { - COLOR_INFO_BACKGROUND_RGBA = getBackgroundColor (context, GTK.GTK_STATE_FLAG_NORMAL); - } - // Destroy temporary Tooltip widget - GTK.gtk_widget_destroy (tooltipShellHandle); + // Destroy temporary Tooltip widget + GTK.gtk_widget_destroy (tooltipShellHandle); + } } GdkRGBA styleContextGetColor(long context, int flag) { |