Bug 529126: [Wayland][GTK3] Tree does not notify SWT.MouseDown listeners

Added bug snippet to reproduce the issue.

Change-Id: Ib4bfdab5fb2230ea7a33898af7db069704548216
Signed-off-by: Eric Williams <ericwill@redhat.com>
diff --git a/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug529126_TreeMouseDown.java b/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug529126_TreeMouseDown.java
new file mode 100644
index 0000000..dece34c
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug529126_TreeMouseDown.java
@@ -0,0 +1,134 @@
+package org.eclipse.swt.tests.gtk.snippets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.graphics.Region;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.swt.widgets.TreeItem;
+
+/*
+ * Title: Bug 529126: [Wayland][GTK3] Tree does not notify SWT.MouseDown listeners
+ * How to run: launch snippet and click on TreeItems
+ * Bug description: No output is printed to the console
+ * Expected results: Output with event info should be printed to the console for each
+ * mouse down.
+ * GTK Version(s): GTK3 (Wayland only)
+ */
+public class Bug529126_TreeMouseDown {
+
+	// Static =================================================================
+
+	public static void main(String[] args) {
+		final Display display = new Display();
+		final Shell shell = new Shell(display);
+		shell.setText("Custom gradient selection for Tree");
+		shell.setLayout(new FillLayout());
+		final Tree tree = new Tree(shell, SWT.MULTI | SWT.FULL_SELECTION | SWT.VIRTUAL);
+		tree.setHeaderVisible(true);
+		tree.setLinesVisible(true);
+		final int columnCount = 4;
+		for (int i = 0; i < columnCount; i++) {
+			final TreeColumn column = new TreeColumn(tree, SWT.NONE);
+			column.setText("Column " + i);
+		}
+
+		final int itemCount = 5;
+		for (int i = 0; i < itemCount; i++) {
+			final TreeItem item1 = new TreeItem(tree, SWT.NONE);
+
+			for (int j = 0; j < i; j++) {
+				final TreeItem item2 = new TreeItem(item1, SWT.NONE);
+
+				for (int k = 0; k < j; k++) {
+					new TreeItem(item2, SWT.NONE);
+				}
+			}
+		}
+
+		tree.addListener(SWT.SetData, event -> {
+			final TreeItem item = (TreeItem)event.item;
+
+			final TreeItem parentItem = item.getParentItem();
+			final String text;
+
+			if (parentItem != null) {
+				final String parentText = (String)parentItem.getData();
+				text = parentText + event.index + "/";
+			}
+			else {
+				text = "/";
+			}
+
+			item.setData(text);
+		});
+
+		tree.addListener(SWT.PaintItem, event -> {
+			final TreeItem item = (TreeItem)event.item;
+			final String text = (String)item.getData();
+			event.gc.drawText(text + " [" + event.index + "]", event.x, event.y, true);
+		});
+
+		/*
+		 * NOTE: MeasureItem, PaintItem and EraseItem are called repeatedly.
+		 * Therefore, it is critical for performance that these methods be
+		 * as efficient as possible.
+		 */
+		tree.addListener(SWT.EraseItem, event -> {
+			event.detail &= ~SWT.HOT;
+			if ((event.detail & SWT.SELECTED) != 0) {
+				final GC gc = event.gc;
+				final Rectangle area = tree.getClientArea();
+				/*
+				 * If you wish to paint the selection beyond the end of
+				 * last column, you must change the clipping region.
+				 */
+				final int columnCount1 = tree.getColumnCount();
+				if (event.index == columnCount1 - 1 || columnCount1 == 0) {
+					final int width = area.x + area.width - event.x;
+					if (width > 0) {
+						final Region region = new Region();
+						gc.getClipping(region);
+						region.add(event.x, event.y, width, event.height);
+						gc.setClipping(region);
+						region.dispose();
+					}
+				}
+				gc.setAdvanced(true);
+				if (gc.getAdvanced()) {
+					gc.setAlpha(127);
+				}
+				final Rectangle rect = event.getBounds();
+				final Color foreground = gc.getForeground();
+				final Color background = gc.getBackground();
+				gc.setForeground(display.getSystemColor(SWT.COLOR_RED));
+				gc.setBackground(display.getSystemColor(SWT.COLOR_LIST_BACKGROUND));
+				gc.fillGradientRectangle(0, rect.y, 500, rect.height, false);
+				// restore colors for subsequent drawing
+				gc.setForeground(foreground);
+				gc.setBackground(background);
+				event.detail &= ~SWT.SELECTED;
+			}
+		});
+		tree.getColumn(0).setWidth(200);
+		for (int i = 1; i < columnCount; i++) {
+			tree.getColumn(i).pack();
+		}
+		tree.setSelection(tree.getItem(0));
+
+		tree.addListener(SWT.MouseDown, event -> System.out.println("event = " + event));
+		shell.setSize(500, 500);
+		shell.open();
+		while (!shell.isDisposed()) {
+			if (!display.readAndDispatch()) {
+				display.sleep();
+			}
+		}
+		display.dispose();
+	}
+}