Bug 572968

Summary: setBackgroundMode + background-image + Text-Widget results in broken UI
Product: [Eclipse Project] Platform Reporter: Thomas Schindl <tom.schindl>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3 CC: lshanmug
Version: 4.19   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS X   
Whiteboard:
Attachments:
Description Flags
Broken UI
none
Splash none

Description Thomas Schindl CLA 2021-04-19 07:30:35 EDT
Created attachment 286163 [details]
Broken UI

Running the following SWT sample results in a a broken UI (as seen in the attachment).

---
package t;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

public class Reproducer {
	
	public static void main(String[] args) {
		Display d = new Display();
		
		Shell splash = new Shell(d);
		splash.setBackgroundImage(new Image(d, Reproducer.class.getResourceAsStream("splash.bmp")));
		splash.setSize(455, 295);
		
		splash.setLayout(new FillLayout());
		splash.setBackgroundMode(SWT.INHERIT_DEFAULT);
		
		Composite fCompositeLogin = new Composite(splash, SWT.BORDER);
		fCompositeLogin.setLayout(new GridLayout(1, false));
		
		Composite spanner = new Composite(fCompositeLogin, SWT.NONE);
		GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
		spanner.setLayoutData(data);

		Label label = new Label(fCompositeLogin, SWT.NONE);
		label.setText("Hello World:");
		data = new GridData();
		label.setLayoutData(data);		
		
		Text text = new Text(fCompositeLogin, SWT.BORDER); // Comment to see it working 
		Button b = new Button(fCompositeLogin, SWT.PUSH); 

		splash.layout(true);
		splash.open();
		
		while( ! splash.isDisposed() ) {
			if( ! d.readAndDispatch() ) {
				d.sleep();
			}
		}
		
	}
}
---

It looks like this is somehow caused by the Text-Widget if you comment that code you'll see all looks good. This is on BigSur I didn't yet test it on pre BigSur-Releases.

BTW: This is trimmed down version from "Interactive Splash"-Template.
Comment 1 Thomas Schindl CLA 2021-04-19 07:31:20 EDT
Created attachment 286164 [details]
Splash
Comment 2 Thomas Schindl CLA 2021-04-19 07:54:08 EDT
Looks like this is NOT a BigSur issue because I could reproduce it on Catalina as well with 4.19.
Comment 3 Lakshmi P Shanmugam CLA 2021-04-20 16:46:48 EDT
The problem is not seen when running the snippet with Java8, but happens with Java11 and later.
So, looks like it's caused by some change in Cocoa API behavior. Needs further investigation.