Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » No drawing on AWT canvas using SWT_AWT bridge on Linux/wayland
No drawing on AWT canvas using SWT_AWT bridge on Linux/wayland [message #1858649] Thu, 13 April 2023 14:01 Go to next message
ChristianR Mising name is currently offline ChristianR Mising nameFriend
Messages: 25
Registered: December 2009
Location: Germany
Junior Member
I just upgraded to Eclipse RCP 4.27 and I am facing troubles on Linux/Wayland. It was not working before and I was hoping upgrading from 4.9 to 4.27 would help with Wayland integration.

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 get some scaling issues on GTK recently and need to investigate this but it is a separate problem).

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.


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

I appreciate any hints.

[Updated on: Tue, 18 April 2023 05:57]

Report message to a moderator

Re: No drawing on AWT canvas using SWT_AWT bridge on Linux/wayland [message #1858711 is a reply to message #1858649] Mon, 17 April 2023 15:02 Go to previous messageGo to next message
ChristianR Mising name is currently offline ChristianR Mising nameFriend
Messages: 25
Registered: December 2009
Location: Germany
Junior Member
As the basic code came from an SWT tutorial I expect that it is a bug. I created a bug report here:
https://github.com/eclipse-platform/eclipse.platform.swt/issues/635
Re: No drawing on AWT canvas using SWT_AWT bridge on Linux/wayland [message #1858759 is a reply to message #1858711] Wed, 19 April 2023 19:56 Go to previous message
ChristianR Mising name is currently offline ChristianR Mising nameFriend
Messages: 25
Registered: December 2009
Location: Germany
Junior Member
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.
Previous Topic:Unable to execute js code injected in html through SWT Browser
Next Topic:fillPolygon causing crash within SWT Native Code
Goto Forum:
  


Current Time: Fri Nov 08 13:08:27 GMT 2024

Powered by FUDForum. Page generated in 0.02961 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top