Skip to content

Commit 3ca1397

Browse files
committed
[GTK4] Update callback.c debugging for GDK4
This was useful for diagnosing #2703 To test this change you need to uncomment `#define DEBUG_CALL_PRINTS`
1 parent 286e614 commit 3ca1397

File tree

1 file changed

+29
-8
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/common/library

1 file changed

+29
-8
lines changed

bundles/org.eclipse.swt/Eclipse SWT/common/library/callback.c

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1641,6 +1641,10 @@ JNIEXPORT void JNICALL CALLBACK_NATIVE(unbind)
16411641
int i;
16421642
for (i=0; i<MAX_CALLBACKS; i++) {
16431643
if (callbackData[i].callback != NULL && (*env)->IsSameObject(env, callback, callbackData[i].callback)) {
1644+
#ifdef DEBUG_CALL_PRINTS
1645+
fprintf(stderr, "SWT-JNI: Unbinding callback[%02d]\n", i);
1646+
fflush(stderr);
1647+
#endif
16441648
if (callbackData[i].callback != NULL) (*env)->DeleteGlobalRef(env, callbackData[i].callback);
16451649
if (callbackData[i].object != NULL) (*env)->DeleteGlobalRef(env, callbackData[i].object);
16461650
memset(&callbackData[i], 0, sizeof(CALLBACK_DATA));
@@ -1863,14 +1867,31 @@ jlong callback(int index, ...)
18631867
}
18641868

18651869
if (!isPrinted && (i == callbackData[index].arg_GdkEvent)) {
1866-
const GdkEventAny* event = (const GdkEventAny*)arg;
1867-
fprintf(stderr,
1868-
"%p [GdkEvent type=%d window=%p [%s]] ",
1869-
event,
1870-
event->type,
1871-
event->window,
1872-
glibTypeNameFromInstance(event->window)
1873-
);
1870+
#if GDK_MAJOR_VERSION == 4
1871+
GdkEvent* event = (GdkEvent*)arg;
1872+
fprintf(stderr,
1873+
"%p [GdkEvent type=%d device=%p [%s] display=%p [%s] surface=%p [%s]] ",
1874+
event,
1875+
gdk_event_get_event_type(event),
1876+
gdk_event_get_device(event),
1877+
glibTypeNameFromInstance(gdk_event_get_device(event)),
1878+
gdk_event_get_display(event),
1879+
glibTypeNameFromInstance(gdk_event_get_display(event)),
1880+
gdk_event_get_surface(event),
1881+
glibTypeNameFromInstance(gdk_event_get_surface(event))
1882+
);
1883+
#elif GDK_MAJOR_VERSION == 3
1884+
const GdkEventAny* event = (const GdkEventAny*)arg;
1885+
fprintf(stderr,
1886+
"%p [GdkEvent type=%d window=%p [%s]] ",
1887+
event,
1888+
event->type,
1889+
event->window,
1890+
glibTypeNameFromInstance(event->window)
1891+
);
1892+
#else
1893+
#error Unsupported GDK version
1894+
#endif
18741895

18751896
isPrinted = 1;
18761897
}

0 commit comments

Comments
 (0)