Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ChristianR2 opened this issue Apr 17, 2023 · 1 comment
Open

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

ChristianR2 opened this issue Apr 17, 2023 · 1 comment

Comments

@ChristianR2
Copy link

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

@ChristianR2
Copy link
Author

ChristianR2 commented Apr 19, 2023

I found a workaround:
If I set environment variable GDK_BACKEND=x11
I get the graphical output. This tells GTK to not use wayland as backend for default but instead run Xwayland for compatibility.
I get other problems then that I do not have running directly on X11 (like Wizard dialogs appearing behind my main window) but that is a different issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant