Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java16
-rw-r--r--tests/org.eclipse.swt.tests/ManualTests/org/eclipse/swt/tests/manual/Bug528498_Combo_dropDownMenu_is_too_short.java70
3 files changed, 84 insertions, 3 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java
index 5d9e0f323f..a343cfef7f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java
@@ -208,6 +208,7 @@ public class GTK extends OS {
public static final byte[] gtk_menu_bar_accel = OS.ascii("gtk-menu-bar-accel");
public static final byte[] gtk_menu_images = OS.ascii("gtk-menu-images");
public static final byte[] gtk_theme_name = OS.ascii("gtk-theme-name");
+ public static final byte[] appears_as_list = OS.ascii("appears-as-list");
/** Misc **/
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java
index b2174e230c..06b9a1303f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -459,8 +459,18 @@ void createHandle (int index) {
if (handle == 0) error (SWT.ERROR_NO_HANDLES);
cellHandle = GTK.gtk_bin_get_child (handle);
if (cellHandle == 0) error (SWT.ERROR_NO_HANDLES);
- // Setting wrap width has the side effect of removing the whitespace on top in popup bug#438992
- GTK.gtk_combo_box_set_wrap_width(handle, 1);
+ /*
+ * For GTK 3.22.5 and above, we set -GtkComboBox-appears-as-list, see bug#528498.
+ * We cannot use this in earlier versions: due to a GTK bug the resulting drop-down list is not scrollable.
+ * The bug was fixed in GTK 3.22.5.
+ */
+ if (GTK.GTK_VERSION < OS.VERSION(3, 22, 5)) {
+ // Setting wrap width has the side effect of removing the whitespace on top in popup bug#438992
+ GTK.gtk_combo_box_set_wrap_width(handle, 1);
+ } else {
+ long /*int*/ context = GTK.gtk_widget_get_style_context(handle);
+ gtk_css_provider_load_from_css(context, "* { -GtkComboBox-appears-as-list: true; }");
+ }
} else {
handle = GTK.gtk_combo_box_text_new_with_entry();
if (handle == 0) error (SWT.ERROR_NO_HANDLES);
diff --git a/tests/org.eclipse.swt.tests/ManualTests/org/eclipse/swt/tests/manual/Bug528498_Combo_dropDownMenu_is_too_short.java b/tests/org.eclipse.swt.tests/ManualTests/org/eclipse/swt/tests/manual/Bug528498_Combo_dropDownMenu_is_too_short.java
new file mode 100644
index 0000000000..a0baae5d79
--- /dev/null
+++ b/tests/org.eclipse.swt.tests/ManualTests/org/eclipse/swt/tests/manual/Bug528498_Combo_dropDownMenu_is_too_short.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Simeon Andreev and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt). The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html. If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ *
+ * Contributors:
+ * Simeon Andreev - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.manual;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+
+/**
+ * Description: Combo box drop-down menu is narrower than combo itself, for read-only combos.
+ * Steps to reproduce:
+ * <ol>
+ * <li>click on main menu entry "Window"</li>
+ * <li>click on "Preferences"</li>
+ * <li>choose "Help"</li>
+ * <li>click on any combo in the preference page</li>
+ * </ol>
+ * Expected results: The drop down menu is as long as the combo.
+ * Actual results: The drop down menu is only as long as its longest entry.
+ */
+public class Bug528498_Combo_dropDownMenu_is_too_short {
+
+ public static void main (String [] args) {
+ Display display = new Display ();
+ final Shell shell = new Shell (display);
+ shell.setSize(200, 50);
+ shell.setLayout(new FillLayout());
+ shell.setLocation(center(display, shell));
+ shell.setText("Bug 528498");
+
+ Combo c = new Combo(shell, SWT.READ_ONLY);
+
+ for (int i = 0; i < 40; ++i) {
+ c.add("item " + i);
+ }
+
+ shell.open ();
+ while (!shell.isDisposed ()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+ display.dispose ();
+ }
+
+ private static Point center(Display display, Shell shell) {
+ Rectangle displayBounds = display.getPrimaryMonitor().getBounds();
+ Point shellBounds = shell.getSize();
+ Point center = new Point(
+ displayBounds.x + (displayBounds.width - shellBounds.x) / 2,
+ displayBounds.y + (displayBounds.height - shellBounds.y) / 2);
+
+ return center;
+ }
+}

Back to the top