Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Williams2017-06-23 15:00:45 -0400
committerEric Williams2017-07-07 11:01:52 -0400
commitb4c40d66a7ab3969444f35b3e5c426ad71bc79d3 (patch)
tree9ed367341ec8fab08f423e002d8de4210e4e3cb4
parent25236339573ecca395f7f4e27ed06ad3b4905160 (diff)
downloadeclipse.platform.swt-b4c40d66a7ab3969444f35b3e5c426ad71bc79d3.tar.gz
eclipse.platform.swt-b4c40d66a7ab3969444f35b3e5c426ad71bc79d3.tar.xz
eclipse.platform.swt-b4c40d66a7ab3969444f35b3e5c426ad71bc79d3.zip
Bug 518657: [GTK] Add bug snippets to GTK only tests project
Merge first batch of snippets from personal repository into the SWT platform specific one. Change-Id: I2e00cf08e14615e3279c85a8ffb1d066ae1283cd Signed-off-by: Eric Williams <ericwill@redhat.com>
-rw-r--r--tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug160691_SWTAWTShell.java42
-rw-r--r--tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug164015_G2DDrawImage.java160
-rw-r--r--tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug166720_TableEditorFlicker.java1
-rw-r--r--tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug170631_NestedCompositeFocus.java51
-rw-r--r--tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug186038_DNDActivateEvent.java187
-rw-r--r--tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug221240_AWTJVMCrash.java135
-rw-r--r--tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug262974_ModalBrowserDialog.java72
-rw-r--r--tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug287038_TableKeyEvent.java60
-rw-r--r--tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug306067_DesktopEffectShellEvent.java108
-rw-r--r--tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug306490_SwingDisposeError.java59
-rw-r--r--tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug326117_EmbeddedBrowser.java71
-rw-r--r--tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug35783_DnDMouseExit.java52
-rw-r--r--tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug465280_InvisibleControlAllocation.java38
-rw-r--r--tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug500703_ComboGarbledResize.java41
-rw-r--r--tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug509514_IncorrectToDisplayLocation.java75
-rw-r--r--tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug514483_getCursorLocation.java94
-rw-r--r--tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug66356_DND_move_reported_to_drag_source_even_though_cancelled.java98
17 files changed, 1343 insertions, 1 deletions
diff --git a/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug160691_SWTAWTShell.java b/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug160691_SWTAWTShell.java
new file mode 100644
index 0000000000..0e85ba1aee
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug160691_SWTAWTShell.java
@@ -0,0 +1,42 @@
+package org.eclipse.swt.tests.gtk.snippets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.awt.SWT_AWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+/*
+ * Title: Bug 160691 - RFE: Please add a snipplet about SWT_AWT.new_Shell
+ * How to run: snippet shows lack of features
+ * Bug description: N/A, enhancement and not a bug
+ * Expected results: N/A, enhancement and not a bug
+ * GTK Version(s): N/A
+ */
+public class Bug160691_SWTAWTShell {
+
+ public static void main(String[] args) {
+ java.awt.Frame frame = new java.awt.Frame("AWT Frame");
+ java.awt.Button button = new java.awt.Button("AWT Button");
+ frame.add(button, java.awt.BorderLayout.NORTH);
+ java.awt.Canvas canvas = new java.awt.Canvas();
+ frame.add(canvas, java.awt.BorderLayout.CENTER);
+
+ frame.addNotify();
+
+ Display display = new Display();
+ Shell shell = SWT_AWT.new_Shell(display, canvas);
+ shell.setLayout(new FillLayout());
+ Button swtButton = new Button(shell, SWT.PUSH);
+ swtButton.setText("SWT Button");
+
+ frame.setBounds(20, 20, 300, 300);
+ shell.layout();
+ frame.setVisible(true);
+
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) display.sleep();
+ }
+}
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug164015_G2DDrawImage.java b/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug164015_G2DDrawImage.java
new file mode 100644
index 0000000000..19f9545582
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug164015_G2DDrawImage.java
@@ -0,0 +1,160 @@
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import java.awt.Color;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Image;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+
+import javax.imageio.ImageIO;
+import javax.swing.ImageIcon;
+import javax.swing.JPanel;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.awt.SWT_AWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+/*
+ * Title: Bug 164015 - AWT_SWT bridge hangs on g2D.drawImage(bufferedImage) and then segfaults
+ * How to run: launch snippet, JVM should segfault
+ * Bug description: JVM segfault
+ * Expected results: The image is drawn correctly in the window
+ * GTK Version(s): N/A
+ */
+public class Bug164015_G2DDrawImage extends JPanel {
+ private static final int TILE_SIZE = 200;
+
+ private static final boolean USE_JAI_FOR_IMAGE_IO = true;
+
+ private int viewport_x = 0, viewport_y = 0;
+
+ /** constructor */
+ public Bug164015_G2DDrawImage() {
+ this.setDoubleBuffered(false); // this makes the bug show up faster
+
+ }
+
+ /** scroll the viewport */
+ public void scroll(int x, int y) {
+ viewport_x += x;
+ viewport_y += y;
+ this.repaint();
+ }
+
+ public BufferedImage loadTile(int x, int y) {
+ String file_path = "tile_" + x + "_" + y + ".gif";
+ BufferedImage bufferedImage = null;
+
+ if (USE_JAI_FOR_IMAGE_IO) {
+
+ try {
+ bufferedImage = ImageIO.read(new File(file_path));
+ } catch (IOException e) {
+ bufferedImage = null;
+ }
+
+ } else { // use AWT
+ Image image = new ImageIcon(file_path).getImage();
+ if (image.getWidth(null) <= 0 || image.getHeight(null) <= 0) {
+ return null;
+ }
+ bufferedImage = new BufferedImage(image.getWidth(null), image
+ .getHeight(null), BufferedImage.TYPE_INT_ARGB);
+ bufferedImage.getGraphics().drawImage(image, 0, 0, null);
+ }
+
+ return bufferedImage;
+ }
+
+ @Override
+ public void paint(Graphics g) {
+
+ super.paint(g);
+
+ Graphics2D g2D = (Graphics2D) g;
+
+ int firsttile_x = viewport_x - viewport_x % TILE_SIZE;
+ int firsttile_y = viewport_y - viewport_y % TILE_SIZE;
+ int lasttile_x = firsttile_x
+ + (this.getWidth() / TILE_SIZE + 2) * TILE_SIZE;
+ int lasttile_y = firsttile_y
+ + (this.getHeight() / TILE_SIZE + 2) * TILE_SIZE;
+
+ for (int currtile_y = firsttile_y; currtile_y < lasttile_y; currtile_y += TILE_SIZE) {
+ for (int currtile_x = firsttile_x; currtile_x < lasttile_x; currtile_x += TILE_SIZE) {
+
+ BufferedImage currentImage = loadTile(currtile_x, currtile_y);
+ if (currentImage != null) {
+ System.err.print("drawing graphics.image... ");
+ g2D.drawImage(currentImage, currtile_x - viewport_x,
+ currtile_y - viewport_y, null);
+ System.err.println("done");
+ }
+
+ g2D.setColor(Color.RED); // outline the tiles
+ g2D.drawRect(currtile_x - viewport_x, currtile_y - viewport_y,
+ TILE_SIZE, TILE_SIZE);
+
+ }
+ }
+
+ }
+
+ public static void main(String[] args) {
+ /** create SWT GUI */
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setText("AWT_SWT Test");
+
+ Composite swtAwtComponent = new Composite(shell, SWT.EMBEDDED);
+ java.awt.Frame frame = SWT_AWT.new_Frame(swtAwtComponent);
+ final Bug164015_G2DDrawImage myJPanel = new Bug164015_G2DDrawImage();
+ frame.add(myJPanel);
+
+ frame.addKeyListener(new KeyAdapter() {
+
+ @Override
+ public void keyPressed(KeyEvent e) {
+
+ if (e.getKeyCode() == KeyEvent.VK_LEFT) {
+ myJPanel.scroll(20, 0);
+ }
+ if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
+ myJPanel.scroll(-20, 0);
+ }
+ if (e.getKeyCode() == KeyEvent.VK_UP) {
+ myJPanel.scroll(0, 20);
+ }
+ if (e.getKeyCode() == KeyEvent.VK_DOWN) {
+ myJPanel.scroll(0, -20);
+ }
+ }
+
+ });
+
+ shell.setLayout(new FillLayout());
+ shell.pack();
+ shell.open();
+ shell.setMaximized(true);
+
+ try {
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+
+ } finally {
+ display.dispose();
+ System.err.println("EXITING NORMALLY!!");
+ }
+ }
+
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug166720_TableEditorFlicker.java b/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug166720_TableEditorFlicker.java
index 1557d6d4e5..10c86257ea 100644
--- a/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug166720_TableEditorFlicker.java
+++ b/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug166720_TableEditorFlicker.java
@@ -18,7 +18,6 @@ import org.eclipse.swt.widgets.Text;
* Expected results: TableEditor should scroll smoothly.
* GTK Version(s): GTK2.x
*/
-
public class Bug166720_TableEditorFlicker {
public static void main(String[] args) {
Display display = new Display ();
diff --git a/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug170631_NestedCompositeFocus.java b/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug170631_NestedCompositeFocus.java
new file mode 100644
index 0000000000..18879a1018
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug170631_NestedCompositeFocus.java
@@ -0,0 +1,51 @@
+package org.eclipse.swt.tests.gtk.snippets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+/*
+ * Title: Bug 170631 - [Widgets] First nested composite takes focus unexpectedly
+ * How to run: launch snippet and hit tab
+ * Bug description: Text does not get focus
+ * Expected results: Text should get focus and keep it.
+ * GTK Version(s): GTK2.x
+ */
+public class Bug170631_NestedCompositeFocus {
+
+public static void main(String [] args) {
+ final Display display = new Display();
+ final Shell shell = new Shell(display);
+ shell.setLayout(new GridLayout());
+ final Canvas canvas = new Canvas(shell, SWT.NONE);
+ GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
+ canvas.setLayoutData(gridData);
+ canvas.addPaintListener(event -> {
+ Rectangle rect = canvas.getClientArea();
+ event.gc.drawOval(0, 0, rect.width - 1, rect.height - 1);
+ });
+
+ final Text text = new Text(shell, SWT.BORDER);
+ text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ text.setText("I want focus");
+
+ shell.setBounds(10, 10, 200, 200);
+
+ shell.open ();
+
+ // With shell.setFocus(), the Canvas gets focus. Without it, the Text does.
+ shell.setFocus();
+
+ System.out.println(shell.getDisplay().getFocusControl());
+
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) display.sleep();
+ }
+ display.dispose();
+}
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug186038_DNDActivateEvent.java b/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug186038_DNDActivateEvent.java
new file mode 100644
index 0000000000..f3d34ef33e
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug186038_DNDActivateEvent.java
@@ -0,0 +1,187 @@
+package org.eclipse.swt.tests.gtk.snippets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DragSource;
+import org.eclipse.swt.dnd.DragSourceEvent;
+import org.eclipse.swt.dnd.DragSourceListener;
+import org.eclipse.swt.dnd.DropTarget;
+import org.eclipse.swt.dnd.DropTargetEvent;
+import org.eclipse.swt.dnd.DropTargetListener;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+
+/*
+ * Title: Bug 186038 - [DND] On Linux-gtk, the SWT.Activate event is not fired to the popup shell during a dragging operation
+ * How to run: launch snippet, drag source button to target.
+ * Bug description: When the shell appears, clicking outside of it does not dismiss it
+ * Expected results: The shell should be dismissed.
+ * GTK Version(s): GTK2.x
+ */
+public class Bug186038_DNDActivateEvent {
+
+ public static void main(String[] args) {
+
+ Display display = new Display();
+ final Shell shell = new Shell(display);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ shell.setLayout(layout);
+
+ // create the drop down widget.shell
+ final Shell dropDownShell = new Shell(shell, SWT.ON_TOP | SWT.DROP_DOWN);
+ dropDownShell.setLayout(new RowLayout());
+ dropDownShell.setVisible(false);
+
+ dropDownShell.addListener(SWT.Activate, event -> System.out.println("dropDownShell gets Activate event!"));
+
+ dropDownShell.addListener(SWT.Deactivate, event -> {
+ System.out.println(
+ "dropDownShell entering Deactivate event handler and will hide the dropdown widget.shell");
+ hideDropDown(dropDownShell);
+ });
+
+ dropDownShell.addListener(SWT.Close, event -> hideDropDown(dropDownShell));
+
+ // create the button1 and when it is hovered, display the dropdown
+ final Button button1 = new Button(shell, SWT.PUSH);
+ button1.setText("Drop target");
+ button1.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (!dropDownShell.isVisible()) {
+ showDropDown(button1, dropDownShell);
+ }
+ }
+ });
+
+ int operations = DND.DROP_COPY | DND.DROP_DEFAULT;
+ DropTarget target = new DropTarget(button1, operations);
+ // Provide data in Text format
+ Transfer[] types = new Transfer[] { TextTransfer.getInstance() };
+ target.setTransfer(types);
+
+ target.addDropListener(new DropTargetListener() {
+ @Override
+ public void dragEnter(DropTargetEvent event) {
+ if (event.detail == DND.DROP_DEFAULT) {
+ if ((event.operations & DND.DROP_COPY) != 0) {
+ event.detail = DND.DROP_COPY;
+ } else {
+ event.detail = DND.DROP_NONE;
+ }
+ }
+ for (int i = 0; i < event.dataTypes.length; i++) {
+ if (TextTransfer.getInstance().isSupportedType(event.dataTypes[i])) {
+ event.currentDataType = event.dataTypes[i];
+ if (event.detail != DND.DROP_COPY) {
+ event.detail = DND.DROP_NONE;
+ }
+ break;
+ }
+ }
+ }
+
+ @Override
+ public void dragOver(DropTargetEvent event) {
+ event.feedback = DND.FEEDBACK_SELECT;
+
+ if (!dropDownShell.isVisible()) {
+ showDropDown(button1, dropDownShell);
+ }
+ }
+
+ @Override
+ public void dragOperationChanged(DropTargetEvent event) {
+
+ }
+
+ @Override
+ public void dragLeave(DropTargetEvent event) {
+ }
+
+ @Override
+ public void dropAccept(DropTargetEvent event) {
+ }
+
+ @Override
+ public void drop(DropTargetEvent event) {
+ if (TextTransfer.getInstance().isSupportedType(event.currentDataType)) {
+ String text = (String) event.data;
+ System.out.println(text);
+ }
+ }
+ });
+
+ // create the button2 as the drag source
+ final Button button2 = new Button(shell, SWT.PUSH);
+ button2.setText("Drag source");
+
+ operations = DND.DROP_COPY;
+ DragSource source = new DragSource(button2, operations);
+
+ // Provide data in Text format
+ source.setTransfer(types);
+
+ source.addDragListener(new DragSourceListener() {
+ @Override
+ public void dragStart(DragSourceEvent event) {
+ if (button2.getText().length() == 0) {
+ event.doit = false;
+ }
+ }
+
+ @Override
+ public void dragSetData(DragSourceEvent event) {
+ // Provide the data of the requested type.
+ if (TextTransfer.getInstance().isSupportedType(event.dataType)) {
+ event.data = button2.getText();
+ }
+ }
+
+ @Override
+ public void dragFinished(DragSourceEvent event) {
+
+ }
+ });
+
+ shell.setSize(300, 300);
+ shell.addDisposeListener(e -> {
+ if (dropDownShell != null && !dropDownShell.isDisposed()) {
+ dropDownShell.dispose();
+ }
+ });
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+
+ private static void showDropDown(final Button button1, final Shell dropDownShell) {
+ if (dropDownShell != null && !dropDownShell.isDisposed()) {
+ dropDownShell.setText("This is a drop down widget.shell");
+ dropDownShell.setSize(100, 200);
+ Rectangle buttonRect = button1.getBounds();
+ Point p = button1.getParent().toDisplay(new Point(buttonRect.x, buttonRect.y + buttonRect.height));
+ dropDownShell.setLocation(p.x, p.y);
+ dropDownShell.setVisible(true);
+ dropDownShell.setFocus();
+ }
+ }
+
+ private static void hideDropDown(final Shell dropDownShell) {
+ dropDownShell.setVisible(false);
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug221240_AWTJVMCrash.java b/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug221240_AWTJVMCrash.java
new file mode 100644
index 0000000000..31b12c4306
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug221240_AWTJVMCrash.java
@@ -0,0 +1,135 @@
+package org.eclipse.swt.tests.gtk.snippets;
+
+import java.awt.BorderLayout;
+import java.awt.Canvas;
+import java.awt.Container;
+
+import javax.swing.JButton;
+import javax.swing.JFileChooser;
+import javax.swing.JFrame;
+import javax.swing.SwingUtilities;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.awt.SWT_AWT;
+import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.graphics.DeviceData;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+/*
+ * Title: Bug 221240 - SWT_AWT bridge crashes JVM on Linux (X error BadWindow)
+ * How to run: launch snippet
+ * Bug description: The JVM crashes
+ * Expected results: The JVM should not crash
+ * GTK Version(s): N/A
+ */
+public class Bug221240_AWTJVMCrash extends JFrame {
+
+ protected static final String LS = System.getProperty("line.separator");
+
+ public Bug221240_AWTJVMCrash() {
+ setDefaultCloseOperation(EXIT_ON_CLOSE);
+ Canvas canvas = new Canvas() {
+ @Override
+ public void addNotify() {
+ super.addNotify();
+ final Canvas canvas_ = this;
+ display.asyncExec(() -> {
+ final Shell shell = SWT_AWT.new_Shell(display, canvas_);
+ shell.setLayout(new FillLayout());
+ Browser browser = new Browser(shell, SWT.NONE);
+ browser.setText(
+ "<html>" + LS +
+ " <head>" + LS +
+ " <script language=\"JavaScript\" type=\"widget.text/javascript\">" + LS +
+ " <!--" + LS +
+ " function getEmbeddedObject() {" + LS +
+ " var movieName = \"myEmbeddedObject\";" + LS +
+ " if(window.document[movieName]) {" + LS +
+ " return window.document[movieName];" + LS +
+ " }" + LS +
+ " if(navigator.appName.indexOf(\"Microsoft Internet\") == -1) {" + LS +
+ " if(document.embeds && document.embeds[movieName]) {" + LS +
+ " return document.embeds[movieName];" + LS +
+ " }" + LS +
+ " } else {" + LS +
+ " return document.getElementById(movieName);" + LS +
+ " }" + LS +
+ " }" + LS +
+ " //-->" + LS +
+ " </script>" + LS +
+ " <style type=\"widget.text/css\">" + LS +
+ " html, object, embed, div, body, widget.table { width: 100%; height: 100%; min-height: 100%; margin: 0; padding: 0; overflow: hidden; background-graphics.color: #FFFFFF; widget.text-align: center; }" + LS +
+ " object, embed, div { position: absolute; left:0; top:0;}" + LS +
+ " td { vertical-align: middle; }" + LS +
+ " </style>" + LS +
+ " </head>" + LS +
+ " <body height=\"*\">" + LS +
+ " <script language=\"JavaScript\" type=\"widget.text/javascript\">" + LS +
+ " <!--" + LS +
+ getVLCPlayer() +
+ " var embeddedObject = getEmbeddedObject();" + LS +
+ " embeddedObject.style.width = '100%';" + LS +
+ " embeddedObject.style.height = '100%';" + LS +
+ " //-->" + LS +
+ " </script>" + LS +
+ " </body>" + LS +
+ "</html>" + LS);
+ // The initial size is wrong so we have to force it
+ shell.setSize(canvas_.getWidth(), canvas_.getHeight());
+ });
+ }
+ };
+ Container contentPane = getContentPane();
+ JButton swingButton = new JButton("Open a file chooser!");
+ swingButton.addActionListener(e -> new JFileChooser().showOpenDialog(Bug221240_AWTJVMCrash.this));
+ contentPane.add(swingButton, BorderLayout.NORTH);
+ contentPane.add(canvas, BorderLayout.CENTER);
+ setSize(800, 600);
+ }
+
+ private String getVLCPlayer() {
+// String escapedURL = "http://80.118.196.219/webtv-asx.cgi?channel=nrj_hits";
+// String escapedURL = "http://media.xored.com/eclipsecon2007/dltk-javascript-jdt.mov";
+ String escapedURL = url != null ? url: "http://flv.thruhere.net/presentations/java-comes-home-customer-haase.flv";
+ return
+ "window.document.write('<object classid=\"clsid:E23FE9C6-778E-49D4-B537-38FCDE4887D8\" id=\"myEmbeddedObject\" codebase=\"http://downloads.videolan.org/pub/videolan/vlc/latest/win32/axvlc.cab\" events=\"true\">');" + LS +
+ "window.document.write(' <param name=\"Src\" value=\"' + decodeURIComponent('" + escapedURL + "') + '\";\"/>');" + LS +
+ "window.document.write(' <embed name=\"myEmbeddedObject\" target=\"" + escapedURL + "\" type=\"application/x-vlc-plugin\" pluginspage=\"http://www.videolan.org\">');" + LS +
+ "window.document.write(' </embed>');" + LS +
+ "window.document.write('</object>');" + LS;
+ }
+
+// private String getFlashPlayer() {
+// String escapedURL = "http://www.freedominteractivedesign.com/swf/main.swf";
+// return
+// "window.document.write('<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" id=\"myEmbeddedObject\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0\" events=\"true\">');" + LS +
+// "window.document.write(' <param name=\"movie\" value=\"' + decodeURIComponent('" + escapedURL + "') + '\";\"/>');" + LS +
+// "window.document.write(' <embed name=\"myEmbeddedObject\" src=\"" + escapedURL + "\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.adobe.com/go/getflashplayer\">');" + LS +
+// "window.document.write(' </embed>');" + LS +
+// "window.document.write('</object>');" + LS;
+// }
+
+ private static Display display;
+
+ private static String url;
+
+ public static void main(String[] args) {
+ DeviceData data = new DeviceData();
+ data.debug = true;
+ display = new Display(data);
+ Display.DEBUG = true;
+ if(args.length > 0) {
+ url = args[0];
+ }
+ System.setProperty("sun.awt.xembedserver", "true");
+ SwingUtilities.invokeLater(() -> new Bug221240_AWTJVMCrash().setVisible(true));
+ while(true) {
+ if(!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+ }
+
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug262974_ModalBrowserDialog.java b/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug262974_ModalBrowserDialog.java
new file mode 100644
index 0000000000..5430317d04
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug262974_ModalBrowserDialog.java
@@ -0,0 +1,72 @@
+package org.eclipse.swt.tests.gtk.snippets;
+
+import java.awt.BorderLayout;
+import java.awt.Canvas;
+import java.awt.Container;
+
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.SwingUtilities;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.awt.SWT_AWT;
+import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.browser.LocationAdapter;
+import org.eclipse.swt.browser.LocationEvent;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+/*
+ * Title: Bug 262974 - [SWT_AWT] On Linux, Browser dialogs are not modal
+ * How to run: launch snippet and observe that the popup window is not modal
+ * Bug description: The popup is not modal
+ * Expected results: The popup should act as a modal dialog
+ * GTK Version(s): N/A
+ */
+public class Bug262974_ModalBrowserDialog extends JFrame {
+
+ public Bug262974_ModalBrowserDialog() {
+ setDefaultCloseOperation(EXIT_ON_CLOSE);
+ Canvas canvas = new Canvas() {
+ @Override
+ public void addNotify() {
+ super.addNotify();
+ final Canvas canvas_ = this;
+ display.asyncExec(() -> {
+ final Shell shell = SWT_AWT.new_Shell(display, canvas_);
+ shell.setLayout(new FillLayout());
+ final Browser browser = new Browser(shell, SWT.NONE);
+ browser.setUrl("http://www.google.com");
+ browser.addLocationListener(new LocationAdapter() {
+ @Override
+ public void changed(LocationEvent e) {
+ display.asyncExec(() -> browser.execute("alert('some dialog');"));
+ }
+ });
+ // The initial size is wrong on Windows so we have to force it
+ shell.setSize(canvas_.getWidth(), canvas_.getHeight());
+ });
+ }
+ };
+ Container contentPane = getContentPane();
+ contentPane.add(canvas, BorderLayout.CENTER);
+ contentPane.add(new JButton("Some Swing Button"), BorderLayout.SOUTH);
+ setSize(400, 300);
+ }
+
+ private static Display display;
+
+ public static void main(String[] args) {
+ System.setProperty("sun.awt.noerasebackground", "true");
+ System.setProperty("sun.awt.xembedserver", "true");
+ display = new Display();
+ SwingUtilities.invokeLater(() -> new Bug262974_ModalBrowserDialog().setVisible(true));
+ while(true) {
+ if(!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+ }
+
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug287038_TableKeyEvent.java b/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug287038_TableKeyEvent.java
new file mode 100644
index 0000000000..a6e653323b
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug287038_TableKeyEvent.java
@@ -0,0 +1,60 @@
+package org.eclipse.swt.tests.gtk.snippets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+
+/*
+ * Title: Bug 287083 - [Widgets] KeyListener on Table doesn't receive KeyEvents
+ * How to run: launch snippet and type into the Table
+ * Bug description: KeyEvents are only fired for first key pressed and ESC key.
+ * Expected results: KeyEvents should fire properly for all keys pressed.
+ * GTK Version(s): GTK2.x, GTK3.x
+ */
+public class Bug287038_TableKeyEvent {
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+ final Table table = new Table(shell, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
+ table.setLinesVisible(true);
+ for (int i = 0; i < 2; i++) {
+ TableColumn column = new TableColumn(table, SWT.NONE);
+ column.setWidth(100);
+ }
+ String[] itemsToAdd = new String[] {
+ "Cheese", "Potatoes", "Rocks", "Bacon", "Tree", "Forest", "Chocolate", "Broccoli", "Turnip",
+ "Squash", "Carrot"
+ };
+ int i = 0;
+ for (String s : itemsToAdd) {
+ TableItem item = new TableItem(table, SWT.NONE);
+ item.setText(new String[] {
+ s, "" + i++
+ });
+ }
+ table.addKeyListener(new KeyListener() {
+ @Override
+ public void keyPressed(KeyEvent e) {
+ System.out.println(e.character);
+ }
+
+ @Override
+ public void keyReleased(KeyEvent e) {
+ System.out.println(e.character);
+ }
+ });
+ shell.pack();
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) display.sleep();
+ }
+ display.dispose();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug306067_DesktopEffectShellEvent.java b/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug306067_DesktopEffectShellEvent.java
new file mode 100644
index 0000000000..d73b4d9345
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug306067_DesktopEffectShellEvent.java
@@ -0,0 +1,108 @@
+package org.eclipse.swt.tests.gtk.snippets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Device;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+
+/*
+ * Title: Bug 306067 - [Widgets] SWT.Deactivate event is not fired to the dropdown shell when enable the Desktop effect
+ * How to run: launch snippet and press button
+ * Bug description: Shell does not receive deactivate event
+ * Expected results: shell should receive deactivate event
+ * GTK Version(s): GTK2.x
+ */
+public class Bug306067_DesktopEffectShellEvent {
+ static Display display = null;
+ static Shell shell = null;
+ static Button button = null;
+ static Shell dropDownShell = null;
+
+ public static void main(String[] args) {
+ Device.DEBUG = true;
+ display = new Display();
+ shell = new Shell(display);
+ shell.setLayout(new RowLayout());
+
+ // create the drop down shell
+ dropDownShell = new Shell(shell, SWT.ON_TOP | SWT.DROP_DOWN);
+ dropDownShell.setLayout(new RowLayout());
+ dropDownShell.setVisible(false);
+ dropDownShell.addListener(SWT.Deactivate, event -> {
+ System.out.println("dropDownShell entering Deactivate event handler and will hide the dropdown shell");
+ hideDropDown();
+ });
+
+ dropDownShell.addListener(SWT.Close, event -> hideDropDown());
+
+
+ // create the button
+ button = new Button(shell, SWT.PUSH);
+ button.setText("Open");
+ button.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (!dropDownShell.isVisible()) {
+ System.out.println("Open button entering widgetSelected event handler and will show the dropdown shell");
+ showDropDown();
+ }
+ }
+ });
+
+ button.addMouseListener(new MouseAdapter() {
+
+ @Override
+ public void mouseDown(MouseEvent e) {
+ System.out.println("Open button entering mouseDown event handler");
+ super.mouseDown(e);
+ }
+
+ @Override
+ public void mouseUp(MouseEvent e) {
+ System.out.println("Open button entering mouseUp event handler");
+ super.mouseUp(e);
+ }
+ });
+
+
+ shell.setSize(300, 300);
+ shell.addDisposeListener(e -> {
+ if (dropDownShell != null && !dropDownShell.isDisposed()) {
+ dropDownShell.dispose();
+ dropDownShell = null;
+ }
+ });
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+
+ private static void showDropDown() {
+ if (dropDownShell != null && !dropDownShell.isDisposed()) {
+ dropDownShell.setText("This is a drop down shell");
+ dropDownShell.setSize(100, 200);
+ Rectangle buttonRect = button.getBounds();
+ Point p = button.getParent().toDisplay(new Point(buttonRect.x, buttonRect.y + buttonRect.height));
+ dropDownShell.setLocation(p.x, p.y);
+ dropDownShell.setVisible(true);
+ dropDownShell.setFocus();
+ }
+ }
+
+ private static void hideDropDown() {
+ dropDownShell.setVisible(false);
+ }
+
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug306490_SwingDisposeError.java b/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug306490_SwingDisposeError.java
new file mode 100644
index 0000000000..e8536efc20
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug306490_SwingDisposeError.java
@@ -0,0 +1,59 @@
+package org.eclipse.swt.tests.gtk.snippets;
+
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+
+import javax.swing.JFrame;
+import javax.swing.JTextArea;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+/*
+ * Title: Bug 306490 - [SWT/AWT] SWT and Swing in parallel crashes outside JVM with 'BadWindow' on Swing's dispose()
+ * How to run: launch snippet and follow onscreen instructions
+ * Bug description: Swing crashes
+ * Expected results: Nothing should crash
+ * GTK Version(s): N/A
+ */
+public class Bug306490_SwingDisposeError {
+
+ static void createSwing() {
+ JFrame frame = new JFrame("Swing, close me (before or after closing the other window)");
+ frame.setBounds(0, 0, 600, 100);
+
+ frame.addWindowListener(new WindowAdapter() { // same bug with using setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE) instead
+ @Override
+ public void windowClosing(WindowEvent e) {
+ e.getWindow().dispose();
+ System.out.println("Swing: disposed");
+ }
+ });
+
+ // remark 1: comment out the following line (do not add textArea) and all works fine
+ frame.getContentPane().add(new JTextArea());
+ frame.setVisible(true);
+ }
+
+ static void createSwt() {
+ Display display = new Display();
+ Shell shell = new Shell(display, SWT.TITLE);
+ shell.setBounds(0, 200, 600, 100);
+ shell.open();
+ while (!shell.isDisposed())
+ if (!display.readAndDispatch())
+ display.sleep();
+
+ display.dispose();
+ System.out.println("SWT: disposed");
+ }
+
+ public static void main(String[] args) throws Exception {
+ //remark 2: change order of following two instantiations and all works fine
+ createSwing();
+ Thread.sleep(1000);
+ new Thread() { @Override
+ public void run() {createSwt();} }.start(); // also createSwt() alone doesn't work
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug326117_EmbeddedBrowser.java b/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug326117_EmbeddedBrowser.java
new file mode 100644
index 0000000000..6a09fc4f3f
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug326117_EmbeddedBrowser.java
@@ -0,0 +1,71 @@
+package org.eclipse.swt.tests.gtk.snippets;
+
+import java.awt.BorderLayout;
+import java.awt.Canvas;
+import java.awt.Frame;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+
+import javax.swing.JTextField;
+import javax.swing.text.JTextComponent;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.awt.SWT_AWT;
+import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+/*
+ * Title: Bug 326117 - SWT_AWT bridge - SWT in Swing problem
+ * How to run: launch snippet and try to use the browser widget
+ * Bug description: Nothing is visible except the text bar
+ * Expected results: The browser should be rendering web content
+ * GTK Version(s): GTK2 all
+ */
+public class Bug326117_EmbeddedBrowser{
+
+ public static void main(String[] args)
+ {
+ final Display display = Display.getDefault();
+
+ Frame frm = new Frame("MyBrowser");
+ Canvas embedded = new Canvas();
+ frm.add(embedded, BorderLayout.CENTER);
+
+ frm.pack();
+
+ final Shell composite = SWT_AWT.new_Shell(display, embedded);
+ composite.setLayout(new FillLayout(SWT.VERTICAL));
+ final Browser browser = installBrowser(composite, "http://www.baidu.com");
+ frm.addWindowListener(new WindowAdapter()
+ {
+ @Override
+ public void windowClosing(WindowEvent e)
+ {
+ e.getWindow().dispose();
+ //composite.dispose();
+// display.dispose();
+ }
+ });
+
+ JTextField addr = new JTextField(80);
+ addr.addActionListener(e -> display.syncExec(() -> browser.setUrl(((JTextComponent) e.getSource()).getText())));
+ frm.add(addr, BorderLayout.NORTH);
+
+ frm.setSize(800, 600);
+ frm.setVisible(true);
+ while (frm.isDisplayable())
+ if (!display.readAndDispatch())
+ display.sleep();
+// display.dispose();
+ }
+
+ public static Browser installBrowser(Composite parent, String homeURL)
+ {
+ Browser browser = new Browser(parent, SWT.EMBEDDED);
+ browser.setUrl(homeURL);
+ return browser;
+ }
+ } \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug35783_DnDMouseExit.java b/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug35783_DnDMouseExit.java
new file mode 100644
index 0000000000..c759a99a54
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug35783_DnDMouseExit.java
@@ -0,0 +1,52 @@
+package org.eclipse.swt.tests.gtk.snippets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DragSource;
+import org.eclipse.swt.dnd.DragSourceAdapter;
+import org.eclipse.swt.dnd.DragSourceEvent;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+/*
+ * Title: Bug 35783 - [DND] Sometimes GTK sends mouse exit during native Drag [portability]
+ * How to run: Run the snippet and drag quickly
+ * Bug description: MouseExit events are fired when dragging
+ * Expected results: No MouseExit events should be fired
+ * GTK Version(s): ALL
+ */
+public class Bug35783_DnDMouseExit {
+ public static void main(String[] args) {
+ final Display display = Display.getDefault();
+ Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+ shell.addListener(SWT.MouseExit, event -> System.out.println("exit"));
+ shell.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseDown(MouseEvent e) {
+ System.out.println("down");
+ }
+ @Override
+ public void mouseUp(MouseEvent e) {
+ System.out.println("up");
+ }
+ });
+ DragSource ds = new DragSource(shell, DND.DROP_COPY);
+ ds.setTransfer(new Transfer[] {TextTransfer.getInstance()});
+ ds.addDragListener(new DragSourceAdapter() {
+ @Override
+ public void dragStart(DragSourceEvent event) {
+ System.out.println("Drag Start");
+ }
+ });
+ shell.open();
+ while (!shell.isDisposed())
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug465280_InvisibleControlAllocation.java b/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug465280_InvisibleControlAllocation.java
new file mode 100644
index 0000000000..6cfa5d0bdf
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug465280_InvisibleControlAllocation.java
@@ -0,0 +1,38 @@
+package org.eclipse.swt.tests.gtk.snippets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+
+/*
+ * Title: Bug 465280 - [GTK3] OS.gtk_widget_get_allocation returns (0,0) for invisible controls
+ * How to run: launch snippet and observe coordinates printed in console
+ * Bug description: The coordinates are (0,0)
+ * Expected results: The coordinates should not be (0,0) if the widget is hidden.
+ * GTK Version(s): GTK3.8+
+ */
+public class Bug465280_InvisibleControlAllocation {
+ public static void main(String[] args) {
+ String property = System.getenv("SWT_GTK3");
+ if (property != null) {
+ System.err.println("GTK"+(property.equals("1")?"3":"2"));
+ }
+ Display display = new Display ();
+ Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+ Label descriptionHint = new Label(shell, SWT.WRAP);
+ descriptionHint.setText("This is a very very very very very very long string");
+ descriptionHint.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ descriptionHint.setVisible(false);
+ shell.open();
+ System.err.println(descriptionHint.getSize());
+ while (!shell.isDisposed ()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+ display.dispose ();
+}
+
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug500703_ComboGarbledResize.java b/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug500703_ComboGarbledResize.java
new file mode 100644
index 0000000000..599fbfb68e
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug500703_ComboGarbledResize.java
@@ -0,0 +1,41 @@
+package org.eclipse.swt.tests.gtk.snippets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+
+/*
+ * Title: Bug 500703 - [GTK3.20+] Combo with SWT.READ_ONLY is garbled upon re-size
+ * How to run: launch snippet, select long box, start to shrink window
+ * Bug description: Text is drawn over itself numerous times, causing garbled text
+ * Expected results: Text should shrink and not be drawn over other widgets
+ * GTK Version(s): 3.20+
+ */
+public class Bug500703_ComboGarbledResize {
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setLayout(new GridLayout(2, false));
+
+ Label label = new Label(shell, SWT.NONE);
+ label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false,false, 1, 1));
+ label.setText("Testing Label");
+
+ Combo text = new Combo(shell, SWT.READ_ONLY);
+ text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
+ text.add("This is a very long long long long long box");
+
+ shell.pack();
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug509514_IncorrectToDisplayLocation.java b/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug509514_IncorrectToDisplayLocation.java
new file mode 100644
index 0000000000..e1fb0a3935
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug509514_IncorrectToDisplayLocation.java
@@ -0,0 +1,75 @@
+package org.eclipse.swt.tests.gtk.snippets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * @author Thomas Singer
+ */
+/*
+ * Title: Bug 509514 - GTK3: Incorrect calculation of Combo location (toDisplay)
+ * How to run: launch snippet, edit the Combo or Text box, press space
+ * Bug description: A popup appears under the Text widget but not the Combo
+ * Expected results: A popup should appear under the widget being edited
+ * GTK Version(s): 3
+ */
+public class Bug509514_IncorrectToDisplayLocation {
+
+ public static void main(String[] args) {
+ final Display display = new Display();
+ final Shell shell = new Shell(display);
+
+ final RowLayout layout = new RowLayout(SWT.VERTICAL);
+ layout.fill = true;
+ shell.setLayout(layout);
+
+ final Combo combo = new Combo(shell, SWT.BORDER);
+ installPopup(combo);
+
+ final Text text = new Text(shell, SWT.BORDER);
+ installPopup(text);
+
+ shell.setSize(400, 300);
+
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+ display.dispose();
+ }
+
+ private static void installPopup(Control control) {
+ final Listener listener = new Listener() {
+ private Shell shell;
+
+ @Override
+ public void handleEvent(Event event) {
+ if (event.type == SWT.KeyDown) {
+ if (event.character == ' ') {
+ shell = new Shell(control.getShell(), SWT.POP_UP | SWT.ON_TOP | SWT.BORDER);
+ final Point location = control.toDisplay(0, control.getSize().y);
+ shell.setBounds(location.x, location.y, 100, 100);
+ shell.setVisible(true);
+ }
+ } else if (event.type == SWT.FocusOut) {
+ if (shell != null) {
+ shell.dispose();
+ shell = null;
+ }
+ }
+ }
+ };
+ control.addListener(SWT.KeyDown, listener);
+ control.addListener(SWT.FocusOut, listener);
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug514483_getCursorLocation.java b/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug514483_getCursorLocation.java
new file mode 100644
index 0000000000..63c372612f
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug514483_getCursorLocation.java
@@ -0,0 +1,94 @@
+package org.eclipse.swt.tests.gtk.snippets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+
+
+/*
+ * Title: Bug 514483 - [wayland] Launchbar filter closes when clicked
+ * How to run: launch snippet and follow onscreen instructions
+ * Bug description: The X-Y coordinates are relative to the child shell.
+ * Expected results: The X-Y coordinates are relative to the parent shell.
+ * GTK Version(s): GTK3.16+ (Wayland)
+ */
+public class Bug514483_getCursorLocation
+{
+ public static void main(String[] args)
+ {
+ final Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setBounds(0, 0, 600, 600);
+
+ Label parentShellLabel = new Label(shell, SWT.None);
+ parentShellLabel.setText("Parent widget.shell.\n"
+ + "INSTRUCTIONS:\n"
+ + "- Parent widget.shell should be maximized.\n"
+ + "- Child widget.shell should be at x400 y400 (in yellow square).\n"
+ + "- Click inside the child widget.shell, observe result coordinates below.\n"
+ + "\n"
+ + "The bug is that x,y is not relative to parent, but relative to child-widget.shell itself (0-200 range).\n"
+ + "Expected coordinates: between ~400 to ~600. (i.e, relative to parent's x,y.)\n"
+ + "Result Coordinates:");
+ parentShellLabel.setBounds(0, 0, 600, 200);
+
+ final Label resultLbl = new Label(shell, SWT.None);
+ resultLbl.setBounds(0,180, 600, 100);
+ resultLbl.setBackground(display.getSystemColor(SWT.COLOR_YELLOW));
+
+ Label childShellLocation = new Label(shell, SWT.None);
+ childShellLocation.setText("Child Shell should be here.\nIf it is not, move it here \nmanually");
+ childShellLocation.setBackground(display.getSystemColor(SWT.COLOR_YELLOW));
+ childShellLocation.setBounds(400, 400, 200, 160);
+
+ Shell childShell = new Shell(shell, SWT.ON_TOP);
+ childShell.setBackground(display.getSystemColor(SWT.COLOR_DARK_YELLOW));
+
+ MouseAdapter clickListener = new MouseAdapter() {
+ @Override
+ public void mouseDown(MouseEvent e) {
+ Point loc = display.getCursorLocation();
+ resultLbl.setText(loc.toString());
+ if (loc.x > 300 && loc.x < 700 && loc.y > 300 && loc.y < 700) // give user some slack.
+ resultLbl.setBackground(display.getSystemColor(SWT.COLOR_GREEN));
+ else
+ resultLbl.setBackground(display.getSystemColor(SWT.COLOR_RED));
+ }
+ };
+ childShell.addMouseListener(clickListener);
+
+// display.addFilter(SWT.KeyDown, new Listener() {
+// public void handleEvent(Event e) {
+// if (e.type == SWT.KeyDown) {
+// switch (e.keyCode) {
+// case SWT.F1:
+// System.out.println("Passed");
+// break;
+// case SWT.F2:
+// System.out.println("Failed");
+// break;
+// case SWT.F3:
+// System.out.println("Skipped");
+// break;
+// case SWT.F4:
+// System.out.println("Exit Test suite");
+// break;
+// }
+// }
+// }
+// });
+
+ shell.open();
+ childShell.open();
+ childShell.setBounds(400, 400, 200, 200);
+ while (!shell.isDisposed())
+ {
+ if (!display.readAndDispatch()) display.sleep();
+ }
+ display.dispose();
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug66356_DND_move_reported_to_drag_source_even_though_cancelled.java b/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug66356_DND_move_reported_to_drag_source_even_though_cancelled.java
new file mode 100644
index 0000000000..bd0f253ab2
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/Bug Snippets/org/eclipse/swt/tests/gtk/snippets/Bug66356_DND_move_reported_to_drag_source_even_though_cancelled.java
@@ -0,0 +1,98 @@
+package org.eclipse.swt.tests.gtk.snippets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DragSource;
+import org.eclipse.swt.dnd.DragSourceAdapter;
+import org.eclipse.swt.dnd.DragSourceEvent;
+import org.eclipse.swt.dnd.DropTarget;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+/*
+ * Title: Bug 66356 - DND - move reported to drag source even though cancelled
+ * How to run: launch snippet, click and drag from the source button back onto it
+ * Bug description: Move = true is printed
+ * Expected results: Move = false should be printed if not dragging beyond the source button
+ * GTK Version(s): 2.x
+ */
+public class Bug66356_DND_move_reported_to_drag_source_even_though_cancelled {
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+ Button source = new Button(shell, SWT.PUSH);
+ source.setText("Source");
+ DragSource dragSource = new DragSource(source, DND.DROP_MOVE);
+ dragSource.setTransfer(new Transfer[] {TextTransfer.getInstance()});
+ dragSource.addDragListener(new DragSourceAdapter() {
+ @Override
+ public void dragSetData(DragSourceEvent event) {
+ event.data = "hello";
+ }
+ @Override
+ public void dragFinished(DragSourceEvent event) {
+ System.out.println("Move = "+(event.detail == DND.DROP_MOVE));
+ }
+ });
+ Button dest = new Button(shell, SWT.PUSH);
+ dest.setText("Dest");
+ DropTarget dropTarget = new DropTarget(dest, DND.DROP_MOVE);
+ dropTarget.setTransfer(new Transfer[] {TextTransfer.getInstance()});
+// dropTarget.addDropListener(new DropTargetAdapter() {
+// public void drop(DropTargetEvent event) {
+// event.detail = DND.DROP_NONE;
+// }
+// });
+// dropTarget.addDropListener(new DropTargetListener() {
+//
+// @Override
+// public void dropAccept(DropTargetEvent event) {
+// // TD Auto-generated method stub
+// event.detail = DND.DROP_NONE;
+//
+// }
+//
+// @Override
+// public void drop(DropTargetEvent event) {
+// // TD Auto-generated method stub
+//
+// }
+//
+// @Override
+// public void dragOver(DropTargetEvent event) {
+// // TD Auto-generated method stub
+//
+// }
+//
+// @Override
+// public void dragOperationChanged(DropTargetEvent event) {
+// // TD Auto-generated method stub
+//
+// }
+//
+// @Override
+// public void dragLeave(DropTargetEvent event) {
+// // TD Auto-generated method stub
+//
+// }
+//
+// @Override
+// public void dragEnter(DropTargetEvent event) {
+// // TD Auto-generated method stub
+//
+// }
+// });
+ shell.pack();
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+}

Back to the top