Bug 570732 - [GTK] SWT.WRAP isn't working on Toolbars on GTK 3.24.20
Summary: [GTK] SWT.WRAP isn't working on Toolbars on GTK 3.24.20
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.10   Edit
Hardware: PC Linux
: P3 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2021-01-28 19:45 EST by Tim CLA
Modified: 2022-05-30 07:59 EDT (History)
2 users (show)

See Also:


Attachments
Example of issue (8.29 KB, image/png)
2021-01-29 10:07 EST, Tim CLA
no flags Details
Originated from GTK (5.16 KB, image/png)
2021-01-29 11:12 EST, Tim CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tim CLA 2021-01-28 19:45:17 EST
Using a toolbar new'd using:

new ToolBar(mToolbarContainer, SWT.HORIZONTAL | SWT.FLAT | SWT.WRAP);


The items at the end of the line are cut off. Had a peek at the source for the ToolBar and it looks like the intended behaviour is to create an "overflow" menu but this is not occuring
Comment 1 Andrey Loskutov CLA 2021-01-29 01:58:03 EST
Please provide a simple self containing SWT snippet to demonstrate the problem. 

Is this a regression in GTK, or is this a regression in SWT? If later, which is the last working release for you?
Comment 2 Tim CLA 2021-01-29 10:07:07 EST
Created attachment 285416 [details]
Example of issue
Comment 3 Tim CLA 2021-01-29 10:11:11 EST
Many thanks for the quick response - much appreciated
 
Have included an example below, see the attached image.

Regarding the question around whether it is a SWT/GTK regression - not sure, this is the first time I've used this feature. I do have some older eclipse/linux combinations lying around, I'll try it to see whether this occurs on the earlier versions.


import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;

public class TestToolbarDialog extends Dialog {

	public TestToolbarDialog(Shell parent) {
		super(parent);
	}

	@Override
	protected Control createContents(Composite parent) {
		parent.setLayout(new GridLayout());
		ToolBar toolBar = new ToolBar(parent, SWT.HORIZONTAL | SWT.WRAP);
		GridData toolBarData = new GridData(SWT.FILL, SWT.NONE, true, false);
		toolBarData.widthHint = 400;
		toolBar.setLayoutData(toolBarData);
		for(int i = 0; i < 20; i++){
			ToolItem item = new ToolItem(toolBar, SWT.PUSH);
			item.setText(String.format("Test %s", i));
		}
		return parent;
	}
	

}
Comment 4 Tim CLA 2021-01-29 11:12:53 EST
Created attachment 285419 [details]
Originated from GTK

Looks like the problem originated from a change in GTK. 

When running on GTK 3.18.9 (Linux Mint Mate 18.1) using Eclipse 2020.03, the overflow was correctly shown (see attachment).

When running on GTK 3.24.20 (Linux Mint Mate 20) using Eclipse 2020.03, the overflow was no longer shown.
Comment 5 Andrey Loskutov CLA 2021-01-29 12:13:58 EST
(In reply to Tim from comment #4)
> Created attachment 285419 [details]
> Originated from GTK
> 
> Looks like the problem originated from a change in GTK. 
> 
> When running on GTK 3.18.9 (Linux Mint Mate 18.1) using Eclipse 2020.03, the
> overflow was correctly shown (see attachment).
> 
> When running on GTK 3.24.20 (Linux Mint Mate 20) using Eclipse 2020.03, the
> overflow was no longer shown.

GTK 3.18.9 is not more supported, so 3.24 should work, which isn't. I've also tried this on GTK 3.22 on RHEL 7.4 and it doesn't show the menu.

Could you change the code to not use the Dialog, but that can run on plain SWT & could you check if there was a version of Eclipse where it *was* working on GTK 3.24?

So far I assume that must be a regression in SWT here.
Comment 6 Tim CLA 2021-02-02 14:44:14 EST
Apologies for the delay in responding. Here is a pure SWT snippet:

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;

public class TestToolbar {

	public static void main(String[] args) {
		Display display = new Display();
		Shell shell = new Shell(display);
		shell.setSize(400, 400);
		shell.setLayout(new GridLayout());
		ToolBar toolBar = new ToolBar(shell, SWT.HORIZONTAL | SWT.WRAP);
		GridData toolBarData = new GridData(SWT.FILL, SWT.NONE, true, false);
		toolBarData.widthHint = 400;
		toolBar.setLayoutData(toolBarData);
		for (int i = 0; i < 20; i++) {
			ToolItem item = new ToolItem(toolBar, SWT.PUSH);
			item.setText(String.format("Test %s", i));
		}
		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
	}

}

It looks like none of the Eclipse / SWT versions are working with my current version of GTK (3.24.20)

Went back to 2018/19 version of Eclipse and had the same issue (had trouble downloading older versions)

Also tried this against the earliest versions in the maven central builds of SWT (going back to 3.105.2, dated 8 Jan 2018)

https://search.maven.org/artifact/org.eclipse.platform/org.eclipse.swt
https://search.maven.org/artifact/org.eclipse.platform/org.eclipse.swt.gtk.linux.x86_64

Same result, none of the above showed the overflow
Comment 7 Alexis Drogoul CLA 2022-05-30 07:59:49 EDT
Hi, same problem here. I have an RCP application that display a dynamic number of controls (buttons) in a toolbar declared with the SWT.WRAP flag. When the total width of the buttons exceeds the width of the toolbar, the latter behaves correctly on macOS and Windows (expanding vertically to welcome the new buttons). However, on Linux (GTK), nothing happens: the size of the toolbar does not change, and the additional buttons are just hidden.