Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Williams2017-12-19 16:56:01 +0000
committerAlexander Kurtakov2018-01-04 11:50:29 +0000
commit655b31c499816e2a0b21c8f8f215c8b1a4f7920d (patch)
tree593b4700f81ef0a7dce23e3b977fc557cce0b92c
parent0a2fac8213a37315c20128a7320d37ca5c476d42 (diff)
downloadeclipse.platform.swt-655b31c499816e2a0b21c8f8f215c8b1a4f7920d.tar.gz
eclipse.platform.swt-655b31c499816e2a0b21c8f8f215c8b1a4f7920d.tar.xz
eclipse.platform.swt-655b31c499816e2a0b21c8f8f215c8b1a4f7920d.zip
Bug 483791: [GTK3] setBackground overrides GC drawing in PaintListener
This bug happens on GTK 3.9+, due to the fact that the GTK drawing events are connected to the wrong widget. Changing the background color on those widgets does not trigger the proper re-drawing. As far as I can tell this has been a bug for awhile and is not a regression. Only Button and Label are affected. Solution: connect the paint signal/GTK drawing events to the appropriate handles in Button and Label. Change-Id: Ib6b513493cbb74680facd6ebc81569c3fa066379 Signed-off-by: Eric Williams <ericwill@redhat.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java19
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java20
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java19
3 files changed, 50 insertions, 8 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java
index f844454ccb..ad13b3ec5f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java
@@ -176,6 +176,25 @@ public void addSelectionListener (SelectionListener listener) {
}
@Override
+void connectPaint () {
+ /*
+ * Feature in GTK3.10+: when attaching a paint listener to a Button
+ * widget, re-drawing happens on GtkButton and not the GtkBox.
+ * This causes issues when setting a background color, as whatever
+ * is drawn on the Button is not re-drawn. See bug 483791.
+ */
+ if (OS.GTK_VERSION >= OS.VERSION (3, 9, 0) && boxHandle != 0) {
+ int paintMask = OS.GDK_EXPOSURE_MASK;
+ OS.gtk_widget_add_events (boxHandle, paintMask);
+
+ OS.g_signal_connect_closure_by_id (boxHandle, display.signalIds [DRAW], 0, display.getClosure (EXPOSE_EVENT_INVERSE), false);
+ OS.g_signal_connect_closure_by_id (boxHandle, display.signalIds [DRAW], 0, display.getClosure (DRAW), true);
+ } else {
+ super.connectPaint();
+ }
+}
+
+@Override
Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
checkWidget ();
if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
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 a217a5948e..430a4855ed 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
@@ -131,6 +131,16 @@ public Control (Composite parent, int style) {
createWidget (0);
}
+void connectPaint () {
+ long /*int*/ paintHandle = paintHandle ();
+ int paintMask = OS.GDK_EXPOSURE_MASK;
+ OS.gtk_widget_add_events (paintHandle, paintMask);
+
+ OS.g_signal_connect_closure_by_id (paintHandle, display.signalIds [DRAW], 0, display.getClosure (EXPOSE_EVENT_INVERSE), false);
+
+ OS.g_signal_connect_closure_by_id (paintHandle, display.signalIds [DRAW], 0, display.getClosure (DRAW), true);
+}
+
Font defaultFont () {
return display.getSystemFont ();
}
@@ -381,13 +391,7 @@ void hookEvents () {
}
/* Connect the paint signal */
- long /*int*/ paintHandle = paintHandle ();
- int paintMask = OS.GDK_EXPOSURE_MASK;
- OS.gtk_widget_add_events (paintHandle, paintMask);
-
- OS.g_signal_connect_closure_by_id (paintHandle, display.signalIds [EXPOSE_EVENT], 0, display.getClosure (EXPOSE_EVENT_INVERSE), false);
-
- OS.g_signal_connect_closure_by_id (paintHandle, display.signalIds [EXPOSE_EVENT], 0, display.getClosure (EXPOSE_EVENT), true);
+ connectPaint ();
/* Connect the Input Method signals */
OS.g_signal_connect_closure_by_id (handle, display.signalIds [REALIZE], 0, display.getClosure (REALIZE), true);
@@ -398,7 +402,7 @@ void hookEvents () {
OS.g_signal_connect_closure (imHandle, OS.preedit_changed, display.getClosure (PREEDIT_CHANGED), false);
}
- OS.g_signal_connect_closure_by_id (paintHandle, display.signalIds [STYLE_SET], 0, display.getClosure (STYLE_SET), false);
+ OS.g_signal_connect_closure_by_id (paintHandle (), display.signalIds [STYLE_SET], 0, display.getClosure (STYLE_SET), false);
long /*int*/ topHandle = topHandle ();
OS.g_signal_connect_closure_by_id (topHandle, display.signalIds [MAP], 0, display.getClosure (MAP), true);
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 2d4109b8a8..9bdcbc8874 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
@@ -114,6 +114,25 @@ void addRelation (Control control) {
}
@Override
+void connectPaint () {
+ /*
+ * Feature in GTK3.10+: when attaching a paint listener to a Label
+ * widget, re-drawing happens on GtkEventBox and not the GtkLabel.
+ * This causes issues when setting a background color, as whatever
+ * is drawn on the Label is not re-drawn. See bug 483791.
+ */
+ if (OS.GTK_VERSION >= OS.VERSION (3, 9, 0) && labelHandle != 0) {
+ int paintMask = OS.GDK_EXPOSURE_MASK;
+ OS.gtk_widget_add_events (labelHandle, paintMask);
+
+ OS.g_signal_connect_closure_by_id (labelHandle, display.signalIds [DRAW], 0, display.getClosure (EXPOSE_EVENT_INVERSE), false);
+ OS.g_signal_connect_closure_by_id (labelHandle, display.signalIds [DRAW], 0, display.getClosure (DRAW), true);
+ } else {
+ super.connectPaint();
+ }
+}
+
+@Override
Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
checkWidget ();
if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;

Back to the top