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

Support SWT 4.21 #15

Open
jzy3d opened this issue Feb 18, 2022 · 1 comment
Open

Support SWT 4.21 #15

jzy3d opened this issue Feb 18, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@jzy3d
Copy link
Owner

jzy3d commented Feb 18, 2022

Initial report in JOGL forum :

We updated the target platform to 2021-09 for our Eclipse RCP application that uses JOGL (via Jzy3d) and found an issue.

When JOGL's SWTAccessor class is loaded (for a NewtCanvasSWT or GLCanvas), it initializes some field to point to methods in SWT's internal classes. The recent release of SWT 4.21 separated some gtk methods off to gtk3 and gtk4 specific bindings. This breaks the initialization code when looking for gtk_widget_get_window.

---8<---
--- SWTAccessor.java.orig 2022-02-16 10:22:07.702204475 +0000
+++ SWTAccessor.java 2022-02-16 10:25:38.589674850 +0000
@@ -95,6 +95,7 @@
 
     private static final String str_OS_gtk_class = "org.eclipse.swt.internal.gtk.OS";    // used by earlier versions of SWT
     private static final String str_GTK_gtk_class = "org.eclipse.swt.internal.gtk.GTK";  // used by later versions of SWT
+    private static final String str_GTK3_gtk_class = "org.eclipse.swt.internal.gtk3.GTK3";  // used by later versions of SWT (4.21+)
     private static final String str_GDK_gtk_class = "org.eclipse.swt.internal.gtk.GDK";  // used by later versions of SWT
     public static final Class<?> OS_gtk_class;
     private static final String str_OS_gtk_version = "GTK_VERSION";
@@ -124,6 +125,8 @@
     private static final String str_gdk_window_set_back_pixmap = "gdk_window_set_back_pixmap";
     private static final String str_gdk_window_set_background_pattern = "gdk_window_set_background_pattern";
 
+    private static final int SWT_VERSION_4_21 = 4946;
+
     private static final VersionNumber GTK_VERSION_2_14_0 = new VersionNumber(2, 14, 0);
     private static final VersionNumber GTK_VERSION_2_24_0 = new VersionNumber(2, 24, 0);
     private static final VersionNumber GTK_VERSION_2_90_0 = new VersionNumber(2, 90, 0);
@@ -261,7 +264,12 @@
                 _gtk_version = GTK_VERSION(field_OS_gtk_version.getInt(null));
                 m1 = cGTK.getDeclaredMethod(str_gtk_widget_realize, handleType);
                 if (_gtk_version.compareTo(GTK_VERSION_2_14_0) >= 0) {
-                    m4 = cGTK.getDeclaredMethod(str_gtk_widget_get_window, handleType);
+                    if (SWT.getVersion() < SWT_VERSION_4_21) {
+                        m4 = cGTK.getDeclaredMethod(str_gtk_widget_get_window, handleType);
+                    } else {
+                        Class<?> cGTK3 = ReflectionUtil.getClass(str_GTK3_gtk_class, false, cl);
+                        m4 = cGTK3.getDeclaredMethod(str_gtk_widget_get_window, handleType);
+                    }
                 } else {
                     m3 = cGTK.getDeclaredMethod(str_GTK_WIDGET_WINDOW, handleType);
                 }
---8<---

@jzy3d jzy3d added the enhancement New feature or request label Feb 18, 2022
@PeterC-DLS
Copy link

PeterC-DLS commented Apr 14, 2022

See my PR sgothel/jogl#108. I can offer it here too, just let me know.

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

No branches or pull requests

2 participants