Skip to content

No drawing on AWT canvas using SWT_AWT bridge on Linux/Wayland #635

Open
@ChristianR2

Description

@ChristianR2

I use AWT canvas for Java2D painting. I am embedding this into an otherwise SWT application. The canvas stays empty on Linux Wayland. Operation on Windows and Linux/GTK is OK. I saw it on RCP 4.27 but it also happens on RCP 4.9

I tried to make a minimum example to reproduce the problem:

package swtawttest;

import java.awt.Color;

import org.eclipse.swt.SWT;
import org.eclipse.swt.awt.SWT_AWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class Main {

	public static void main(String[] args) {
		Display display = new Display();
		Shell shell = new Shell(display);
				
		Composite composite = new Composite(shell, SWT.EMBEDDED);
		composite.setBounds(0, 0, 100, 100);
		
		java.awt.Frame frame = SWT_AWT.new_Frame(composite);
		java.awt.Canvas canvas = new java.awt.Canvas();
		canvas.setBackground(Color.BLACK);
		frame.add(canvas);
		
		shell.open();
				
		while (!shell.isDisposed()) { 
			if (!display.readAndDispatch()) {
				display.sleep();
			} 
		}
		
		display.dispose();
	}
}

The canvas in this example sets a black background which does not appear on Wayland but GTK. I did not retest this minimum example on Windows.

In the original RCP application I am writing I get these errors on the console when I am moving the SWT composite containing the AWT canvas:
Gdk-Message: 15:52:24.677: Window 0x7fa29cd98c80 is a temporary window without parent, application will not be able to position it on screen.
This does not happen on the minimum example as no canvas is moved there but maybe it hints to the problem.

I am using Java 17.0.6
I am running on Ubuntu 22.04.2 LTS
The SWT Bundle Version I am using is 3.123.0.v20230220-1431

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions