Revert "Bug 525763: [GTK3] [dark theme] Vertical bar to the left of line numbers is not dark"
This reverts commit dbb0707aaf394479cecab65956b04e6677e546d3.
Change-Id: I4a492459a0d8940418efeed43d65ac0d9667f4e9
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
index 0f6e9d4..8eb2682 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
@@ -2727,14 +2727,8 @@
checkWidget();
Color color;
if (OS.GTK3) {
- if (backgroundAlpha == 0) {
- color = Color.gtk_new (display, this.getBackgroundGdkRGBA (), 0);
- return color;
- } else {
- Control control = findBackgroundControl ();
- if (control == null) control = this;
- return Color.gtk_new (display, control.getBackgroundGdkRGBA(), backgroundAlpha);
- }
+ color = Color.gtk_new (display, this.getBackgroundGdkRGBA (), backgroundAlpha);
+ return color;
} else {
if (backgroundAlpha == 0) {
color = Color.gtk_new (display, this.getBackgroundGdkColor (), 0);
@@ -2780,9 +2774,6 @@
GdkRGBA getContextBackgroundGdkRGBA () {
assert OS.GTK3 : "GTK3 code was run by GTK2";
long /*int*/ fontHandle = fontHandle ();
- if ((state & BACKGROUND) == 0) {
- return display.COLOR_WIDGET_BACKGROUND_RGBA;
- }
if (OS.GTK_VERSION >= OS.VERSION(3, 14, 0)) {
if (provider != 0) {
return display.gtk_css_parse_background (provider, null);
@@ -2793,6 +2784,9 @@
long /*int*/ context = OS.gtk_widget_get_style_context (fontHandle);
GdkRGBA rgba = new GdkRGBA ();
OS.gtk_style_context_get_background_color (context, OS.GTK_STATE_FLAG_NORMAL, rgba);
+ if ((state & BACKGROUND) == 0) {
+ return display.COLOR_WIDGET_BACKGROUND_RGBA;
+ }
return rgba;
}
}
@@ -4448,21 +4442,6 @@
}
}
-/**
- * This method determines whether or not a background color should be set.
- *
- * Since bug 421836, the default behavior on GTK3 is to always set the background
- * color (and this method still reflects that). However, if a widget needs to implement
- * different behavior, this method can be overridden on a per widget basis.
- *
- * @param color the color which is to be set as the background color
- *
- * @return true if the background color needs to be changed, false otherwise
- */
-boolean backgroundChangeNeeded (Color color) {
- return true;
-}
-
private void _setBackground (Color color) {
if (((state & BACKGROUND) == 0) && color == null) return;
boolean set = false;
@@ -4470,11 +4449,8 @@
GdkRGBA rgba = null;
if (color != null) {
rgba = color.handleRGBA;
- backgroundAlpha = color.getAlpha();
- } else {
- rgba = defaultBackground();
}
- set = backgroundChangeNeeded(color);
+ set = true;
if (set) {
if (color == null) {
state &= ~BACKGROUND;
@@ -4498,6 +4474,7 @@
set = oldColor.pixel != gdkColor.pixel;
}
if (set) {
+
if (color == null) {
state &= ~BACKGROUND;
} else {
@@ -4605,18 +4582,20 @@
void setBackgroundGdkRGBA (long /*int*/ handle, GdkRGBA rgba) {
assert OS.GTK3 : "GTK3 code was run by GTK2";
- double alpha = 1.0;
+ backgroundAlpha = 255;
if (rgba == null) {
if ((state & PARENT_BACKGROUND) != 0) {
- alpha = 0;
+ backgroundAlpha = 0;
Control control = findBackgroundControl();
if (control == null) control = this;
- rgba = control.getBackgroundGdkRGBA();
+ rgba = control == this ? null : control.getBackgroundGdkRGBA();
+ } else {
+ rgba = defaultBackground ();
}
} else {
- alpha = backgroundAlpha;
+ backgroundAlpha = (int) (rgba.alpha * 255);
}
- if (rgba != null) rgba.alpha = alpha / (float)255;
+ if (rgba != null) rgba.alpha = (float) backgroundAlpha / 255;
long /*int*/ context = OS.gtk_widget_get_style_context (handle);
setBackgroundGdkRGBA (context, handle, rgba);
OS.gtk_style_context_invalidate (context);
@@ -5346,8 +5325,7 @@
void setParentBackground () {
if (OS.GTK3) {
- setBackgroundGdkRGBA (handle, null);
- if (fixedHandle != 0) setBackgroundGdkRGBA (fixedHandle, null);
+ backgroundAlpha = 0;
} else {
setBackgroundGdkColor (handle, null);
if (fixedHandle != 0) setBackgroundGdkColor (fixedHandle, null);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java
index 45a97a4..131a0d0 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java
@@ -12,7 +12,6 @@
import org.eclipse.swt.*;
-import org.eclipse.swt.custom.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.gtk.*;
@@ -544,23 +543,6 @@
}
@Override
-boolean backgroundChangeNeeded(Color color) {
- /*
- * CTabFolder has two different background colors depending on whether it
- * has focus or not. However, calling getBackground() on CTabFolder only reports one
- * of the colors, which causes its children (usually ToolBar) to have mismatching
- * backgrounds in certain scenarios.
- *
- * Fix: only set the background if necessary (i.e. not all the time).
- */
- if (parent != null && parent instanceof CTabFolder) {
- return !getBackground().equals(color);
- } else {
- return super.backgroundChangeNeeded(color);
- }
-}
-
-@Override
void releaseChildren (boolean destroy) {
ToolItem [] items = getItems ();
for (int i=0; i<items.length; i++) {
@@ -630,6 +612,14 @@
}
@Override
+void setParentBackground () {
+ if (OS.GTK3) {
+ setBackgroundGdkRGBA (handle, display.getSystemColor(SWT.COLOR_TRANSPARENT).handleRGBA);
+ }
+ super.setParentBackground();
+}
+
+@Override
void setForegroundGdkRGBA (long /*int*/ handle, GdkRGBA rgba) {
assert OS.GTK3 : "GTK3 code was run by GTK2";
if (OS.GTK_VERSION >= OS.VERSION(3, 14, 0)) {