Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Williams2016-01-12 18:41:28 +0000
committerEric Williams2016-02-11 21:14:00 +0000
commitb32e6b93f9f20497aefb1aafcabe5599e6ab946a (patch)
tree2867df19d267b3e20aa7e52f8617c988f803f1e3
parentf2df2060979ba4c8ef9b181dc2b52ef3840b2444 (diff)
downloadeclipse.platform.swt-b32e6b93f9f20497aefb1aafcabe5599e6ab946a.tar.gz
eclipse.platform.swt-b32e6b93f9f20497aefb1aafcabe5599e6ab946a.tar.xz
eclipse.platform.swt-b32e6b93f9f20497aefb1aafcabe5599e6ab946a.zip
Bug 483096: [GTK3.16+] gtk_widget_override_background_color is
deprecated Bug 479998 introduced CSS background colors to Composite. This meant setBackgroundColor() needed to be overridden in Composite to implement this functionality. Since this patch implements CSS backgrounds for all widgets in SWT, we can remove setBackgroundColor() from Composite. A summary of fixes in this patch: -widgets that are Composite only (i.e. SwtFixed containers) now have functioning background colors by overriding the gtk_draw() method (Link and Sash) -Combo.setBackgrondColor() has been refactored/simplified -some specific widgets with malfunctioning backgrounds have been fixed (Group, DateTime, ExpandBar, and Label) -NullPointerException fixed in Table/Tree -tweaking of background code in ToolBar -fixed background image issues in ExpandBar and Label This patch cleans up the setBackground() code and ensures background color functionality for all widgets. Tested on GTK3.18, 3.16, 3.14, and 2.24. AllNonBrowser JUnit tests pass on GTK3 and GTK2. Change-Id: I6f781541efbdbe5c27f6fbc5d441e5e24f782134 Signed-off-by: Eric Williams <ericwill@redhat.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java56
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java30
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java10
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandBar.java10
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java15
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java10
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java15
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java15
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java3
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java26
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java19
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java3
14 files changed, 136 insertions, 89 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java
index 921aa03393..af1af31bdb 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java
@@ -66,6 +66,7 @@ public class Combo extends Composite {
String [] items = new String [0];
boolean selectionAdded;
int indexSelected;
+ GdkRGBA background;
/**
* the operating system limit for the number of characters
* that the text field in an instance of this class can hold
@@ -889,6 +890,23 @@ public int getCaretPosition () {
}
@Override
+GdkColor getContextBackground () {
+ if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) {
+ if (background != null) {
+ GdkColor color = new GdkColor ();
+ color.red = (short)(background.red * 0xFFFF);
+ color.green = (short)(background.green * 0xFFFF);
+ color.blue = (short)(background.blue * 0xFFFF);
+ return color;
+ } else {
+ return display.COLOR_WIDGET_BACKGROUND;
+ }
+ } else {
+ return super.getContextBackground();
+ }
+}
+
+@Override
GdkColor getForegroundColor () {
return getTextColor ();
}
@@ -1855,30 +1873,28 @@ public void select (int index) {
@Override
void setBackgroundColor (long /*int*/ context, long /*int*/ handle, GdkRGBA rgba) {
- //Note, in Gtk3's CSS, we can't access all of the sub-widgets inside GtkComboBox.
- //Some have to be themed by the global system theme.
-
+ // CSS to be parsed for various widgets within Combo
+ background = rgba;
+ String css = "* {\n";
+ if (rgba != null) {
+ String color = gtk_rgba_to_css_string (rgba);
+ css += "background: " + color + ";}";
+ }
if (entryHandle == 0 || (style & SWT.READ_ONLY) != 0) {
- long /*int*/ buttonHandle = findButtonHandle (); //get's the GtkEntry handle.
- //TODO Refactor this and Button#setBackground, they have similar CSS construction code.
- String css = "* {\n";
- if (rgba != null) {
- String color = gtk_rgba_to_css_string (rgba);
- css += "background: " + color + ";\n";
- }
- css += "}\n";
- gtk_css_provider_load_from_css (OS.gtk_widget_get_style_context(buttonHandle), css); //Apply to Entry
+ // For read only Combos, we can just apply the background CSS to the GtkToggleButton.
+ gtk_css_provider_load_from_css (OS.gtk_widget_get_style_context(buttonHandle), css);
} else {
- setBackgroundColorGradient (OS.gtk_widget_get_style_context (entryHandle), handle, rgba);
- super.setBackgroundColor (OS.gtk_widget_get_style_context (entryHandle), entryHandle, rgba);
- //Note, we can't get to the GtkToggleButton inside GtkComboBoxText, as it's in a private stuct.
- //We thus rely on global theme to style it via: GtkToggleButton { background: red}
+ if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) {
+ // For GTK3.16+, only the GtkEntry needs to be themed.
+ gtk_css_provider_load_from_css (OS.gtk_widget_get_style_context(entryHandle), css);
+ } else {
+ // Maintain GTK3.14- functionality
+ setBackgroundColorGradient (OS.gtk_widget_get_style_context (entryHandle), handle, rgba);
+ super.setBackgroundColor (OS.gtk_widget_get_style_context (entryHandle), entryHandle, rgba);
+ }
}
-
- //Set the background color of the text of the drop down menu.
+ // Set the background color of the text of the drop down menu.
OS.g_object_set (textRenderer, OS.background_rgba, rgba, 0);
- //NOTE: We can't get to the actual menu background, beacuse it is in a private struct in GtkComboBoxText.
- //Thus we rely for the underlying theme to theme the menu via : GtkComboBoxText * { background: xzy }
}
@Override
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java
index f45f78e801..463fab0d94 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java
@@ -64,7 +64,6 @@ public class Composite extends Scrollable {
Layout layout;
Control[] tabList;
int layoutCount, backgroundMode;
- GdkRGBA background;
static final String NO_INPUT_METHOD = "org.eclipse.swt.internal.gtk.noInputMethod"; //$NON-NLS-1$
@@ -666,23 +665,6 @@ public Rectangle getClientArea () {
return super.getClientArea();
}
-@Override
-GdkColor getContextBackground () {
- if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) {
- if (background != null) {
- GdkColor color = new GdkColor ();
- color.red = (short)(background.red * 0xFFFF);
- color.green = (short)(background.green * 0xFFFF);
- color.blue = (short)(background.blue * 0xFFFF);
- return color;
- } else {
- return display.COLOR_WIDGET_BACKGROUND;
- }
- } else {
- return super.getContextBackground();
- }
-}
-
/**
* Returns layout which is associated with the receiver, or
* null if one has not been set.
@@ -1500,18 +1482,6 @@ public void setBackgroundMode (int mode) {
}
@Override
-void setBackgroundColor (long /*int*/ context, long /*int*/ handle, GdkRGBA rgba) {
- if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) {
- background = rgba;
- String color = gtk_rgba_to_css_string(background);
- String css = "SwtFixed {background-color: " + color + "}";
- gtk_css_provider_load_from_css(context, css);
- } else {
- super.setBackgroundColor(context, handle, rgba);
- }
-}
-
-@Override
int setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
int result = super.setBounds (x, y, width, height, move, resize);
if ((result & RESIZED) != 0 && layout != null) {
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 ad48e21ae0..b6b173d4b6 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
@@ -2610,8 +2610,12 @@ public Image getBackgroundImage () {
GdkColor getContextBackground () {
long /*int*/ fontHandle = fontHandle ();
- if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0) && provider != 0) {
- return gtk_css_parse_background (provider);
+ if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) {
+ if (provider != 0) {
+ return gtk_css_parse_background (provider);
+ } else {
+ return display.COLOR_WIDGET_BACKGROUND;
+ }
} else {
long /*int*/ context = OS.gtk_widget_get_style_context (fontHandle);
int styleState = OS.gtk_widget_get_state_flags(handle);
@@ -4221,7 +4225,7 @@ GdkRGBA gtk_css_property_to_rgba(String property) {
void setBackgroundColor (long /*int*/ handle, GdkColor color) {
if (OS.GTK3) {
GdkRGBA rgba = null;
- double alpha = 1;
+ double alpha = 1.0;
if (color == null) {
if ((state & PARENT_BACKGROUND) != 0) {
alpha = 0;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java
index 1ca93260c5..41481a4c65 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java
@@ -1369,7 +1369,12 @@ void setBackgroundColor (GdkColor color) {
if (isCalendar () && !OS.GTK3) {
OS.gtk_widget_modify_base (containerHandle, 0, color);
} else {
- super.setBackgroundColor (color);
+ if (isCalendar() && (OS.GTK_VERSION >= OS.VERSION(3, 16, 0))) {
+ super.setBackgroundColor (calendarHandle, color);
+ } else {
+ super.setBackgroundColor (color);
+ }
+
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandBar.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandBar.java
index adb91ef55f..1d11275f1b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandBar.java
@@ -427,6 +427,16 @@ void reskinChildren (int flags) {
}
@Override
+void setWidgetBackground () {
+ if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) {
+ GdkColor color = (state & BACKGROUND) != 0 ? getBackgroundColor () : null;
+ super.setBackgroundColor (color);
+ } else {
+ super.setWidgetBackground();
+ }
+}
+
+@Override
void setFontDescription (long /*int*/ font) {
super.setFontDescription (font);
for (int i = 0; i < itemCount; i++) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java
index d9ba4938f7..9eb61201cd 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java
@@ -294,10 +294,17 @@ void releaseWidget () {
@Override
void setBackgroundColor (GdkColor color) {
- super.setBackgroundColor (color);
- setBackgroundColor (fixedHandle, color);
- // Bug 453827 - client handle should also be painted as it's visible to the user now.
- setBackgroundColor (clientHandle, color);
+ if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) {
+ // With CSS theming we only need to set the background color
+ // of the parent SwtFixed container.
+ setBackgroundColor (fixedHandle, color);
+ return;
+ } else {
+ super.setBackgroundColor (color);
+ setBackgroundColor (fixedHandle, color);
+ // Bug 453827 - client handle should also be painted as it's visible to the user now.
+ setBackgroundColor (clientHandle, color);
+ }
}
@Override
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java
index 073c88bdd1..e9dbbe8269 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java
@@ -660,6 +660,16 @@ public void setText (String string) {
}
@Override
+void setWidgetBackground () {
+ if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) {
+ GdkColor color = (state & BACKGROUND) != 0 ? getBackgroundColor () : null;
+ super.setBackgroundColor (color);
+ } else {
+ super.setWidgetBackground();
+ }
+}
+
+@Override
void showWidget () {
super.showWidget ();
if (frameHandle != 0) OS.gtk_widget_show (frameHandle);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java
index 08d7c5cc3a..d558dea7f6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java
@@ -378,6 +378,21 @@ long /*int*/ gtk_button_release_event (long /*int*/ widget, long /*int*/ event)
}
@Override
+long /*int*/ gtk_draw (long /*int*/ widget, long /*int*/ cairo) {
+ if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) {
+ long /*int*/ context = OS.gtk_widget_get_style_context(widget);
+ GtkAllocation allocation = new GtkAllocation();
+ OS.gtk_widget_get_allocation (widget, allocation);
+ int width = (state & ZERO_WIDTH) != 0 ? 0 : allocation.width;
+ int height = (state & ZERO_HEIGHT) != 0 ? 0 : allocation.height;
+ // We specify a 0 value for x & y as we want the whole widget to be
+ // colored, not some portion of it.
+ OS.gtk_render_background(context, cairo, 0, 0, width, height);
+ }
+ return super.gtk_draw(widget, cairo);
+}
+
+@Override
long /*int*/ gtk_event_after (long /*int*/ widget, long /*int*/ gdkEvent) {
long /*int*/ result = super.gtk_event_after (widget, gdkEvent);
GdkEvent event = new GdkEvent ();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java
index 0d786adf1f..58406f749a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java
@@ -251,6 +251,21 @@ long /*int*/ gtk_button_release_event (long /*int*/ widget, long /*int*/ eventPt
}
@Override
+long /*int*/ gtk_draw (long /*int*/ widget, long /*int*/ cairo) {
+ if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) {
+ long /*int*/ context = OS.gtk_widget_get_style_context(widget);
+ GtkAllocation allocation = new GtkAllocation();
+ OS.gtk_widget_get_allocation (widget, allocation);
+ int width = (state & ZERO_WIDTH) != 0 ? 0 : allocation.width;
+ int height = (state & ZERO_HEIGHT) != 0 ? 0 : allocation.height;
+ // We specify a 0 value for x & y as we want the whole widget to be
+ // colored, not some portion of it.
+ OS.gtk_render_background(context, cairo, 0, 0, width, height);
+ }
+ return super.gtk_draw(widget, cairo);
+}
+
+@Override
long /*int*/ gtk_focus_in_event (long /*int*/ widget, long /*int*/ event) {
long /*int*/ result = super.gtk_focus_in_event (widget, event);
if (result != 0) return result;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
index 41821004af..0a5f9fee5d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
@@ -732,7 +732,11 @@ void createHandle (int index) {
if ((style & (SWT.NO_TRIM | SWT.BORDER | SWT.SHELL_TRIM)) == 0) {
OS.gtk_container_set_border_width (shellHandle, 1);
if (OS.GTK3) {
- OS.gtk_widget_override_background_color (shellHandle, OS.GTK_STATE_FLAG_NORMAL, new GdkRGBA());
+ if (OS.GTK_VERSION >= OS.VERSION (3, 16, 0)) {
+ setBackgroundColor (OS.gtk_widget_get_style_context(shellHandle), shellHandle, new GdkRGBA());
+ } else {
+ OS.gtk_widget_override_background_color (shellHandle, OS.GTK_STATE_FLAG_NORMAL, new GdkRGBA());
+ }
} else {
GdkColor color = new GdkColor ();
OS.gtk_style_get_black (OS.gtk_widget_get_style (shellHandle), color);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java
index e35814a3f2..14a1b688cc 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java
@@ -3135,7 +3135,8 @@ void setBackgroundColor (long /*int*/ context, long /*int*/ handle, GdkRGBA rgba
*/
if (rgba == null) {
GdkColor temp = getDisplay().COLOR_LIST_BACKGROUND;
- background.alpha = 1;
+ GdkRGBA background = new GdkRGBA ();
+ background.alpha = 1.0;
background.red = (temp.red & 0xFFFF) / (float)0xFFFF;
background.green = (temp.green & 0xFFFF) / (float)0xFFFF;
background.blue = (temp.blue & 0xFFFF) / (float)0xFFFF;
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 acc271e7e0..fa5807ba6a 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
@@ -54,12 +54,6 @@ public class ToolBar extends Composite {
menuItemSelectedFunc = new Callback(ToolBar.class, "MenuItemSelectedProc", 2);
if (menuItemSelectedFunc.getAddress() == 0) SWT.error(SWT.ERROR_NO_MORE_CALLBACKS);
}
- /*
- * We need to keep track of the background color ourselves, otherwise ToolBars will
- * sometimes have the background color of their parent Composite. Also, ToolBars on
- * GTK are called GtkToolbar-swt-toolbar-flat which can cause issues with CSS theming.
- */
- GdkRGBA background;
/**
* Constructs a new instance of this class given its parent
@@ -138,7 +132,7 @@ void createHandle (int index) {
handle = OS.gtk_toolbar_new ();
if (handle == 0) error (SWT.ERROR_NO_HANDLES);
OS.gtk_container_add (fixedHandle, handle);
- if ((style & SWT.FLAT) != 0) {
+ if ((style & SWT.FLAT) != 0 && !OS.GTK3) {
byte [] swt_toolbar_flat = Converter.wcsToMbcs (null, "swt-toolbar-flat", true);
OS.gtk_widget_set_name (handle, swt_toolbar_flat);
}
@@ -266,23 +260,6 @@ boolean forceFocus (long /*int*/ focusHandle) {
return super.forceFocus (focusHandle);
}
-@Override
-GdkColor getContextBackground () {
- if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) {
- if (background != null) {
- GdkColor color = new GdkColor ();
- color.red = (short)(background.red * 0xFFFF);
- color.green = (short)(background.green * 0xFFFF);
- color.blue = (short)(background.blue * 0xFFFF);
- return color;
- } else {
- return display.COLOR_WIDGET_BACKGROUND;
- }
- } else {
- return super.getContextBackground ();
- }
-}
-
/**
* Returns the item at the given, zero-relative index in the
* receiver. Throws an exception if the index is out of range.
@@ -611,7 +588,6 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize
@Override
void setBackgroundColor (long /*int*/ context, long /*int*/ handle, GdkRGBA rgba) {
- background = rgba;
if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) {
String css = "GtkToolbar {background-color: " + gtk_rgba_to_css_string(rgba) + "}";
gtk_css_provider_load_from_css(context, css);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java
index ddbef7dbb9..1870a87315 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java
@@ -12,9 +12,10 @@ package org.eclipse.swt.widgets;
import org.eclipse.swt.*;
-import org.eclipse.swt.internal.gtk.*;
-import org.eclipse.swt.graphics.*;
import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
/**
* Instances of this class implement rubber banding rectangles that are
@@ -754,7 +755,19 @@ public boolean open () {
OS.gtk_widget_realize (overlay);
long /*int*/ overlayWindow = OS.gtk_widget_get_window (overlay);
OS.gdk_window_set_override_redirect (overlayWindow, true);
- OS.gtk_widget_override_background_color (overlay, OS.GTK_STATE_FLAG_NORMAL, new GdkRGBA());
+ if (OS.GTK_VERSION < OS.VERSION (3, 16, 0)) {
+ OS.gtk_widget_override_background_color (overlay, OS.GTK_STATE_FLAG_NORMAL, new GdkRGBA());
+ } else {
+ String css = "GtkWindow {background-color: rgb(0,0,0);}";
+ long /*int*/ provider = 0;
+ long /*int*/ context = OS.gtk_widget_get_style_context (overlay);
+ if (provider == 0) {
+ provider = OS.gtk_css_provider_new ();
+ OS.gtk_style_context_add_provider (context, provider, OS.GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ OS.g_object_unref (provider);
+ }
+ OS.gtk_css_provider_load_from_data (provider, Converter.wcsToMbcs (null, css, true), -1, null);
+ }
long /*int*/ region = OS.gdk_region_new ();
OS.gtk_widget_shape_combine_region (overlay, region);
OS.gtk_widget_input_shape_combine_region (overlay, region);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java
index 23cf3dc0c0..ea8823d0d9 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java
@@ -3119,7 +3119,8 @@ void setBackgroundColor (long /*int*/ context, long /*int*/ handle, GdkRGBA rgba
*/
if (rgba == null) {
GdkColor temp = getDisplay().COLOR_LIST_BACKGROUND;
- background.alpha = 1;
+ GdkRGBA background = new GdkRGBA ();
+ background.alpha = 1.0;
background.red = (temp.red & 0xFFFF) / (float)0xFFFF;
background.green = (temp.green & 0xFFFF) / (float)0xFFFF;
background.blue = (temp.blue & 0xFFFF) / (float)0xFFFF;

Back to the top