| Summary: | [GTK3] [GTK3.8] combo too small in vertical direction | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Michelle Murray <mmurray> | ||||||||
| Component: | SWT | Assignee: | Snjezana Peco <snjezana.peco> | ||||||||
| Status: | CLOSED WONTFIX | QA Contact: | |||||||||
| Severity: | normal | ||||||||||
| Priority: | P3 | CC: | adietish, akurtakov, arunkumar.thondapu, bfitzpat, ericwill, jonny.lamb, malaperle, manderse, snjezana.peco, wayne.beaton | ||||||||
| Version: | 4.4 | Keywords: | triaged | ||||||||
| Target Milestone: | --- | ||||||||||
| Hardware: | PC | ||||||||||
| OS: | Linux | ||||||||||
| See Also: | https://git.eclipse.org/r/47472 | ||||||||||
| Whiteboard: | |||||||||||
| Bug Depends on: | |||||||||||
| Bug Blocks: | 437850 | ||||||||||
| Attachments: |
|
||||||||||
Can you provide a pure swt reproducer for this code to test? This should reproduce it (not tested):
public class Snippet {
public static void main (String [] args) {
Display display = new Display ();
Shell shell = new Shell (display);
shell.setSize (200, 200);
Composite parent = new Composite(shell, SWT.NONE);
GridLayoutFactory.fillDefaults().applyTo(parent);
Combo combo = new Combo(parent, SWT.READ_ONLY);
combo.setItems (new String [] {"Alpha", "Bravo", "Charlie"});
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(combo);
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
}
My guess is that what's causing it is SWT.CENTER for the griddata that's applied to the combo. In GTK2 (which I'm running, I cant use GTK3) the combo has a preferred height that allows it to show the full item text. In GTK3 the item text is cropped (as shown in the screenshot.
I tried the snippet but it doesn't show anything in the shell until I set some layout to it and after doing this the combo looks just fine. Michelle, Would you please test with final Luna release? Just to let you know the issue is still present in final luna. we will try get plain SWT sample. This problem exists in the Mars builds (I'm currently using M6). I see it manifest in a bunch of different places. AFAICT, it happens when the widget is created but not given content before opening. If I provide content after opening and then resize the window, it makes everything right. When I emptied the combo--the one that had previously had content and was sized correctly--and resized; the emptied combo box resized too small. I modified Snippet 26 to provide an example. I'll also post a screenshot. /******************************************************************************* * Copyright (c) 2000, 2004 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 * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package stuff; /* * Combo example snippet: create a combo box (non-editable) * * For a list of all SWT example snippets see * http://www.eclipse.org/swt/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.Shell; public class Snippet26 { public static void main (String [] args) { Display display = new Display (); Shell shell = new Shell (display); shell.setLayout(new GridLayout(1, true)); Combo combo = new Combo (shell, SWT.READ_ONLY); GridData data = new GridData(SWT.FILL, SWT.TOP, true, false); combo.setLayoutData(data); combo.setItems (new String [] {"Alpha", "Bravo", "Charlie"}); Combo combo2 = new Combo (shell, SWT.READ_ONLY); GridData data2 = new GridData(SWT.FILL, SWT.TOP, true, false); combo2.setLayoutData(data2); shell.setSize(300, 100); shell.open (); combo.setItems(new String[0]); combo2.setItems (new String [] {"Alpha", "Bravo", "Charlie"}); while (!shell.isDisposed ()) { if (!display.readAndDispatch ()) display.sleep (); } display.dispose (); } } Created attachment 252091 [details]
The second one has no content.
Created attachment 252092 [details]
After resizing; the first one has no content
I'm not sure if this is related (perhaps it's the same or similar code), but I'm seeing the same thing with a text field. Except that it initially sizes short and--whether I add content to it or not--it changes to the expected dimensions when I resize the window. Text text = new Text(shell, SWT.BORDER); text.setLayoutData(data2); For completeness, I tried adding a pack() statement. It did not fix the problem (though, as expected, resizing did). But wait... there's more. This only seems to be an issue when the style is SWT.READ_ONLY. Setting it to SWT.NONE results in a correctly-sized combo. So I did a little digging, and it seems that GTK really wants the widget to be sized the way it is. I created a similar example in Python with the same result (except that the widget resized when I clicked it). I can't imagine that this is desired behaviour. Is this a GTK bug? Is it version specific? gtk3-3.10.9-2.fc20.x86_64 New Gerrit change created: https://git.eclipse.org/r/47472 The issue described in comment #0 can't be reproduced anymore. As to the issue described in comment #6, it happens because GTK3 calculates the height of a combo that doesn't have any items differently from a combo that does them. The patch fixes the issue by calling the Combo.getParent().layout() when the combo's items are changed. The patch https://git.eclipse.org/r/47472 also fixes bug 465023. *** Bug 465023 has been marked as a duplicate of this bug. *** (In reply to Snjezana Peco from comment #13) > The issue described in comment #0 can't be reproduced anymore. > As to the issue described in comment #6, it happens because > GTK3 calculates the height of a combo that doesn't have any items > differently from a combo that does them. > The patch fixes the issue by calling the Combo.getParent().layout() when the > combo's items are changed. > > The patch https://git.eclipse.org/r/47472 also fixes bug 465023. Re layouting the parent can be quite expensive operation so another approach would be needed. (In reply to Alexander Kurtakov from comment #15) > > Re layouting the parent can be quite expensive operation so another approach > would be needed. The operation is called only when combo's items have been changed which doesn't happen often. I have refactored the patch so that the operation is called only when the number of items changes from 0 to 1+ items. I'm still not completely sure if this patch is the right fix for this bug, moving to M4 as it would need to be looked at more closely... Does this problem still exist in the latest Neon builds? Also, if it still exists but is specific to GTK 3.8 and below and fixed in later versions of GTK, I wouldn't bother fixing it on our side anymore... (In reply to Arun Thondapu from comment #18) > Does this problem still exist in the latest Neon builds? > > Also, if it still exists but is specific to GTK 3.8 and below and fixed in > later versions of GTK, I wouldn't bother fixing it on our side anymore... The issue still exists on Neon and it is GTK 3.8 specific. See https://issues.jboss.org/browse/JBDS-3574 (In reply to Snjezana Peco from comment #19) > (In reply to Arun Thondapu from comment #18) > > Does this problem still exist in the latest Neon builds? > > > > Also, if it still exists but is specific to GTK 3.8 and below and fixed in > > later versions of GTK, I wouldn't bother fixing it on our side anymore... > > The issue still exists on Neon and it is GTK 3.8 specific. See > https://issues.jboss.org/browse/JBDS-3574 Bugs specific to older GTK3 versions (especially something as old as 3.8) are no longer being fixed as the time investment is not worth it. GTK3.22 is the stable and final release of GTK3, and eventually all systems will ship with that version (most do already). |
Created attachment 241352 [details] Too short combo boxes Using Eclipse M6 and GTK3, combo boxes are too short in vertical direction when using GTK3 - see attached screen cap. But those same boxes are the correct size when using same version of Eclipse but with GTK2.