Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Williams2018-01-04 20:00:01 +0000
committerEric Williams2018-01-05 17:10:39 +0000
commitac74a09868e8b5887cede3661179712181968312 (patch)
tree4af47cf5e6d838312a628b07b724e2e08464e04b
parentabf72f506e4a5fe10de601017e1872d66ffa6a8e (diff)
downloadeclipse.platform.swt-ac74a09868e8b5887cede3661179712181968312.tar.gz
eclipse.platform.swt-ac74a09868e8b5887cede3661179712181968312.tar.xz
eclipse.platform.swt-ac74a09868e8b5887cede3661179712181968312.zip
Bug 528155: [GTK] Table/Tree forgets to set SWT.SELECTED bit on
PaintItem Modifying the SWT.SELECTED bit in an EraseItem listener causes the SWT.SELECTED bit to not be sent to the PaintListener. This affects PaintListeners that draw based on Table/Tree selection state. The fix is to cache the SWT.SELECTED bit using the existing boolean "wasSelected", and set the SWT.SELECTED later on before firing the PaintEvent. Change-Id: I161452695b3041a37a66eca5e3de75035a56f9a7 Signed-off-by: Eric Williams <ericwill@redhat.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java9
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java9
2 files changed, 16 insertions, 2 deletions
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 e3f873b043..5b6728bd60 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
@@ -2890,6 +2890,7 @@ long /*int*/ rendererRenderProc (long /*int*/ cell, long /*int*/ window, long /*
void rendererRender (long /*int*/ cell, long /*int*/ cr, long /*int*/ window, long /*int*/ widget, long /*int*/ background_area, long /*int*/ cell_area, long /*int*/ expose_area, long /*int*/ flags) {
TableItem item = null;
+ boolean wasSelected = false;
long /*int*/ iter = OS.g_object_get_qdata (cell, Display.SWT_OBJECT_INDEX2);
if (iter != 0) {
long /*int*/ path = OS.gtk_tree_model_get_path (modelHandle, iter);
@@ -2968,7 +2969,12 @@ void rendererRender (long /*int*/ cell, long /*int*/ cr, long /*int*/ window, lo
if (hooks (SWT.EraseItem)) {
- boolean wasSelected = (drawState & SWT.SELECTED) != 0;
+ /*
+ * Cache the selection state so that it is not lost if a
+ * PaintListener wants to draw custom selection foregrounds.
+ * See bug 528155.
+ */
+ wasSelected = (drawState & SWT.SELECTED) != 0;
if (wasSelected) {
Control control = findBackgroundControl ();
if (control == null) control = this;
@@ -3082,6 +3088,7 @@ void rendererRender (long /*int*/ cell, long /*int*/ cr, long /*int*/ window, lo
if (item != null) {
if (OS.GTK_IS_CELL_RENDERER_TEXT (cell)) {
if (hooks (SWT.PaintItem)) {
+ if (wasSelected) drawState |= SWT.SELECTED;
GdkRectangle rect = new GdkRectangle ();
long /*int*/ path = OS.gtk_tree_model_get_path (modelHandle, iter);
OS.gtk_tree_view_get_background_area (handle, path, columnHandle, rect);
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 130ec4bed2..d81078a6b9 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
@@ -2946,6 +2946,7 @@ long /*int*/ rendererRenderProc (long /*int*/ cell, long /*int*/ window, long /*
void rendererRender (long /*int*/ cell, long /*int*/ cr, long /*int*/ window, long /*int*/ widget, long /*int*/ background_area, long /*int*/ cell_area, long /*int*/ expose_area, long /*int*/ flags) {
TreeItem item = null;
+ boolean wasSelected = false;
long /*int*/ iter = OS.g_object_get_qdata (cell, Display.SWT_OBJECT_INDEX2);
if (iter != 0) item = _getItem (iter);
long /*int*/ columnHandle = OS.g_object_get_qdata (cell, Display.SWT_OBJECT_INDEX1);
@@ -3016,7 +3017,12 @@ void rendererRender (long /*int*/ cell, long /*int*/ cr, long /*int*/ window, lo
if (textRenderer != 0) gtk_cell_renderer_get_preferred_size (textRenderer, handle, null, null);
if (hooks (SWT.EraseItem)) {
- boolean wasSelected = (drawState & SWT.SELECTED) != 0;
+ /*
+ * Cache the selection state so that it is not lost if a
+ * PaintListener wants to draw custom selection foregrounds.
+ * See bug 528155.
+ */
+ wasSelected = (drawState & SWT.SELECTED) != 0;
if (wasSelected) {
Control control = findBackgroundControl ();
if (control == null) control = this;
@@ -3120,6 +3126,7 @@ void rendererRender (long /*int*/ cell, long /*int*/ cr, long /*int*/ window, lo
if (item != null) {
if (OS.GTK_IS_CELL_RENDERER_TEXT (cell)) {
if (hooks (SWT.PaintItem)) {
+ if (wasSelected) drawState |= SWT.SELECTED;
GdkRectangle rect = new GdkRectangle ();
long /*int*/ path = OS.gtk_tree_model_get_path (modelHandle, iter);
OS.gtk_tree_view_get_cell_area (handle, path, columnHandle, rect);

Back to the top