Skip to content

Commit 28bb9b4

Browse files
committed
[Gtk] Ignore transparency when setting Combo popup color
Ensures no transparency is set for Combo's popup (which generally makes UI harder to read). Fixes #2794
1 parent 77b61df commit 28bb9b4

File tree

1 file changed

+12
-1
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets

1 file changed

+12
-1
lines changed

bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2695,14 +2695,25 @@ void updateCss() {
26952695
// Deal with background
26962696
if (background != null) {
26972697
final String colorString = display.gtk_rgba_to_css_string(background);
2698+
GdkRGBA menuBackground = new GdkRGBA();
2699+
menuBackground.red = background.red;
2700+
menuBackground.green = background.green;
2701+
menuBackground.blue = background.blue;
2702+
menuBackground.alpha = 1.0;
2703+
/* Ensures that the popup menu is not transparent and as a result unreadable
2704+
* This way effects like "light" transparency (alpha > 0.85) can not be achieved.
2705+
* Having any transparency of the popup is generally unwanted as it hurts visibility so
2706+
* if such a feature is usable to anyone it would need new dedicated API.
2707+
*/
2708+
final String menuColorString = display.gtk_rgba_to_css_string(menuBackground);
26982709

26992710
/*
27002711
* Use 'background:' instead of 'background-color:' to also override
27012712
* any 'background-image:'. For example, Ubuntu's Yaru theme has
27022713
* 'background-image:' for 'GtkToggleButton' used in READ_ONLY combo.
27032714
*/
27042715
css.append("* {background: " + colorString + ";}\n");
2705-
css.append("menu {background: " + colorString + ";}\n");
2716+
css.append("menu {background: " + menuColorString + ";}\n");
27062717

27072718
/*
27082719
* Setting background color for '*' also affects selection background,

0 commit comments

Comments
 (0)