From 9944711d9102c70e838d0344e3c92e48c438f3a2 Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Fri, 7 Nov 2025 11:17:39 -0500 Subject: [PATCH] [GTK4] Update callback.c debugging for GDK4 This was useful for diagnosing https://github.com/eclipse-platform/eclipse.platform.swt/pull/2703 To test this change you need to uncomment `#define DEBUG_CALL_PRINTS` --- .../Eclipse SWT/common/library/callback.c | 37 +++++++++++++++---- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/library/callback.c b/bundles/org.eclipse.swt/Eclipse SWT/common/library/callback.c index 6e59e1d40be..9a022c16514 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/common/library/callback.c +++ b/bundles/org.eclipse.swt/Eclipse SWT/common/library/callback.c @@ -1641,6 +1641,10 @@ JNIEXPORT void JNICALL CALLBACK_NATIVE(unbind) int i; for (i=0; iIsSameObject(env, callback, callbackData[i].callback)) { + #ifdef DEBUG_CALL_PRINTS + fprintf(stderr, "SWT-JNI: Unbinding callback[%02d]\n", i); + fflush(stderr); + #endif if (callbackData[i].callback != NULL) (*env)->DeleteGlobalRef(env, callbackData[i].callback); if (callbackData[i].object != NULL) (*env)->DeleteGlobalRef(env, callbackData[i].object); memset(&callbackData[i], 0, sizeof(CALLBACK_DATA)); @@ -1863,14 +1867,31 @@ jlong callback(int index, ...) } if (!isPrinted && (i == callbackData[index].arg_GdkEvent)) { - const GdkEventAny* event = (const GdkEventAny*)arg; - fprintf(stderr, - "%p [GdkEvent type=%d window=%p [%s]] ", - event, - event->type, - event->window, - glibTypeNameFromInstance(event->window) - ); + #if GDK_MAJOR_VERSION == 4 + GdkEvent* event = (GdkEvent*)arg; + fprintf(stderr, + "%p [GdkEvent type=%d device=%p [%s] display=%p [%s] surface=%p [%s]] ", + event, + gdk_event_get_event_type(event), + gdk_event_get_device(event), + glibTypeNameFromInstance(gdk_event_get_device(event)), + gdk_event_get_display(event), + glibTypeNameFromInstance(gdk_event_get_display(event)), + gdk_event_get_surface(event), + glibTypeNameFromInstance(gdk_event_get_surface(event)) + ); + #elif GDK_MAJOR_VERSION == 3 + const GdkEventAny* event = (const GdkEventAny*)arg; + fprintf(stderr, + "%p [GdkEvent type=%d window=%p [%s]] ", + event, + event->type, + event->window, + glibTypeNameFromInstance(event->window) + ); + #else + #error Unsupported GDK version + #endif isPrinted = 1; }