Login  Register

Re: JOGL incompatible with SWT 4.21

Posted by Martin on Dec 16, 2022; 9:09am
URL: https://forum.jogamp.org/JOGL-incompatible-with-SWT-4-21-tp4041643p4041973.html

Hi,

What I find surprising is that the root cause of your problem is located here according to the stack trace

Caused by: java.lang.NoSuchMethodException: org.eclipse.swt.internal.gtk.GDK.gdk_window_set_background_pattern(long,long)
        at java.base/java.lang.Class.getDeclaredMethod(Class.java:2675)
        at com.jogamp.nativewindow.swt.SWTAccessor.<clinit>(SWTAccessor.java:382)

But there actually nothing related to getDeclaredMethod(..) or gdk_window_set_background_pattern at line 382 of SWTAccessor

It should rather be line 281 if you work with Peter's patch, ... same if you are using the non patched SWTAccessor.

Anyway, this suggests gdk_window_set_background_pattern disappeared, which is confirmed by reading the diff you made between 4.21 and 4.22.

So a fix would be to change

if (_gtk_version.compareTo(GTK_VERSION_2_90_0) >= 0) {
        mb = cGDK.getDeclaredMethod(str_gdk_window_set_background_pattern, handleType, handleType);
} else {
        ma = cGTK.getDeclaredMethod(str_gdk_window_set_back_pixmap, handleType, handleType, boolean.class);
}

by something like this

if (_gtk_version.compareTo(GTK_VERSION_2_90_0) >= 0) {
    if (_gtk_version.compareTo(GTK_VERSION_2_21_0) <= 0)
        mb = cGDK.getDeclaredMethod(str_gdk_window_set_background_pattern, handleType, handleType);
} else {
        ma = cGTK.getDeclaredMethod(str_gdk_window_set_back_pixmap, handleType, handleType, boolean.class);
}

(but you should check wether str_gdk_window_set_back_pixmap is required or not as of 4.22).