Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Williams2019-07-22 14:33:48 +0000
committerEric Williams2019-07-29 19:13:40 +0000
commit78c36186152307c5ba7409e0e24e450dd99b7d9f (patch)
tree8ad586899a516814c12fedd454f2116e80134201
parentc9725dc0293f1f469c1956be6fab7b8a5ffd6362 (diff)
downloadeclipse.platform.swt-78c36186152307c5ba7409e0e24e450dd99b7d9f.tar.gz
eclipse.platform.swt-78c36186152307c5ba7409e0e24e450dd99b7d9f.tar.xz
eclipse.platform.swt-78c36186152307c5ba7409e0e24e450dd99b7d9f.zip
Bug 547811: [GTK] DateTime drop-down popup shell does not hiding on focus lost
Remove the FocusIn filters from DateTime.handleEvent() as it causes issues with Shell destruction/unfocusing. Tested on X11 on GTK3.22 and 3.24, Fedora 30. No AllNonBrowser JUnit tests fail. Change-Id: I7f25c05b5aa26db315feb02725e0c92c6d1af051 Signed-off-by: Eric Williams <ericwill@redhat.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java2
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug547811_DateTimePopup.java57
2 files changed, 57 insertions, 2 deletions
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 faecb1ab9b..464a6618c9 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
@@ -1238,7 +1238,6 @@ void handleFocus (int type) {
shell.addListener (SWT.Deactivate, popupListener);
Display display = getDisplay ();
display.removeFilter (SWT.FocusIn, popupFilter);
- display.addFilter (SWT.FocusIn, popupFilter);
Event e = new Event ();
notifyListeners (SWT.FocusIn, e);
break;
@@ -1251,7 +1250,6 @@ void handleFocus (int type) {
Shell shell = getShell ();
shell.removeListener (SWT.Deactivate, popupListener);
Display display = getDisplay ();
- display.removeFilter (SWT.FocusIn, popupFilter);
display.removeFilter (SWT.MouseDown, mouseEventListener);
Event e = new Event ();
notifyListeners (SWT.FocusOut, e);
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug547811_DateTimePopup.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug547811_DateTimePopup.java
new file mode 100644
index 0000000000..1a5c4f9554
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug547811_DateTimePopup.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Ilnur Zalyaev and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Ilnur Zalyaev - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.DateTime;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug547811_DateTimePopup {
+
+ public static void main(String[] args) {
+ Display d = Display.getDefault();
+ Shell sh = new Shell(d);
+ sh.setSize(500, 400);
+ sh.setLayout(new GridLayout(2, true));
+
+ Button btn = new Button(sh, SWT.PUSH);
+ btn.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
+ btn.setText("Open sub shell");
+ btn.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
+ Shell ssh = new Shell(sh, SWT.ON_TOP);
+ ssh.setLayout(new GridLayout(2, true));
+ new DateTime(ssh, SWT.DATE | SWT.DROP_DOWN);
+ new DateTime(ssh, SWT.DATE | SWT.DROP_DOWN);
+ ssh.setSize(500, 400);
+ ssh.setLocation(600, 100);
+ ssh.open();
+ }));
+
+ new DateTime(sh, SWT.DATE | SWT.DROP_DOWN);
+ new DateTime(sh, SWT.DATE | SWT.DROP_DOWN);
+
+ sh.open();
+ while (!sh.isDisposed()) {
+ if (!d.readAndDispatch()) {
+ d.sleep();
+ }
+ }
+ }
+
+} \ No newline at end of file

Back to the top