From efbc8b4390dc38317520a7acd66cf29bbf097afd Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 7 Nov 2024 06:13:12 +0100 Subject: [PATCH] Turn touchscreen debug prints into gdk-debug messages --- libs/tk/ydk/gdk.c | 3 ++- libs/tk/ydk/win32/gdkevents-win32.c | 30 +++++++++++++++++++++++------ libs/tk/ydk/x11/gdkevents-x11.c | 15 ++++++++++++--- libs/tk/ydk/ydk/gdk/gdkinternals.h | 3 ++- 4 files changed, 40 insertions(+), 11 deletions(-) diff --git a/libs/tk/ydk/gdk.c b/libs/tk/ydk/gdk.c index f722dbf96a..18ae13dc8d 100644 --- a/libs/tk/ydk/gdk.c +++ b/libs/tk/ydk/gdk.c @@ -81,7 +81,8 @@ static const GDebugKey gdk_debug_keys[] = { {"multihead", GDK_DEBUG_MULTIHEAD}, {"xinerama", GDK_DEBUG_XINERAMA}, {"draw", GDK_DEBUG_DRAW}, - {"eventloop", GDK_DEBUG_EVENTLOOP} + {"eventloop", GDK_DEBUG_EVENTLOOP}, + {"touch", GDK_DEBUG_TOUCH} }; static const int gdk_ndebug_keys = G_N_ELEMENTS (gdk_debug_keys); diff --git a/libs/tk/ydk/win32/gdkevents-win32.c b/libs/tk/ydk/win32/gdkevents-win32.c index b2724c19d7..440695c468 100644 --- a/libs/tk/ydk/win32/gdkevents-win32.c +++ b/libs/tk/ydk/win32/gdkevents-win32.c @@ -373,10 +373,16 @@ _gdk_win32_window_procedure (HWND hwnd, void _gdk_events_init (void) { - printf ("CHECK FOR Touch/Pointer API..\n"); +#ifdef G_ENABLE_DEBUG + if (_gdk_debug_flags & GDK_DEBUG_TOUCH) + g_message ("CHECK FOR Touch/Pointer API..\n"); +#endif getPointerType = (PFN_GetPointerType) GetProcAddress (GetModuleHandle ("user32.dll"), "GetPointerType"); getPointerTouchInfo = (PFN_GetPointerTouchInfo) GetProcAddress (GetModuleHandle ("user32.dll"), "GetPointerTouchInfo"); - printf ("Found GetPointerType = %p GetPointerTouchInfo = %p\n", getPointerType, getPointerTouchInfo); +#ifdef G_ENABLE_DEBUG + if (_gdk_debug_flags & GDK_DEBUG_TOUCH) + g_message ("Found GetPointerType = %p GetPointerTouchInfo = %p\n", getPointerType, getPointerTouchInfo); +#endif GSource *source; @@ -2045,19 +2051,28 @@ handle_wm_pointer (GdkEventType type, GdkWindow* window, MSG* msg) } if (!getPointerType (GET_POINTERID_WPARAM (msg->wParam), &pointer_type)) { - printf ("getPointerType failed to translate event\n"); +#ifdef G_ENABLE_DEBUG + if (_gdk_debug_flags & GDK_DEBUG_TOUCH) + g_message ("getPointerType failed to translate event\n"); +#endif return FALSE; } if (pointer_type != 2 /* touch */) { - printf ("Not A Touch event\n"); +#ifdef G_ENABLE_DEBUG + if (_gdk_debug_flags & GDK_DEBUG_TOUCH) + g_message ("Not A Touch event\n"); +#endif return FALSE; } POINTER_TOUCH_INFO touch_info; if (!getPointerTouchInfo (GET_POINTERID_WPARAM (msg->wParam), &touch_info)) { - printf ("getPointerTouchInfo failed to translate event\n"); +#ifdef G_ENABLE_DEBUG + if (_gdk_debug_flags & GDK_DEBUG_TOUCH) + g_message ("getPointerTouchInfo failed to translate event\n"); +#endif return FALSE; } @@ -2125,7 +2140,10 @@ handle_wm_pointer (GdkEventType type, GdkWindow* window, MSG* msg) event->touch.flags = 0; // touch_sequence == 0 ? 0x20000 : 0; event->touch.deviceid = 0; - printf ("getPointerTouchInfo type = %d at: %.1fx%.1f root: %1.fx%1.f seq=%d\n", type, event->touch.x, event->touch.y, event->touch.x_root, event->touch.y_root, touch_sequence); +#ifdef G_ENABLE_DEBUG + if (_gdk_debug_flags & GDK_DEBUG_TOUCH) + g_message ("getPointerTouchInfo type = %d at: %.1fx%.1f root: %1.fx%1.f seq=%d\n", type, event->touch.x, event->touch.y, event->touch.x_root, event->touch.y_root, touch_sequence); +#endif _gdk_win32_append_event (event); } diff --git a/libs/tk/ydk/x11/gdkevents-x11.c b/libs/tk/ydk/x11/gdkevents-x11.c index 6b21642539..6b2c1d1523 100644 --- a/libs/tk/ydk/x11/gdkevents-x11.c +++ b/libs/tk/ydk/x11/gdkevents-x11.c @@ -263,7 +263,10 @@ _gdk_events_init (GdkDisplay *display) int firstevent, firsterror; if (display_x11->xi.libxi && XQueryExtension (display_x11->xdisplay, "XInputExtension", &display_x11->xid_opcode, &firstevent, &firsterror)) { - printf ("CHECK FOR TOUCHSCREENs\n"); +#ifdef G_ENABLE_DEBUG + if (_gdk_debug_flags & GDK_DEBUG_TOUCH) + g_message ("CHECK FOR TOUCHSCREENs\n"); +#endif int n_devices; XIDeviceInfo* info; @@ -290,7 +293,10 @@ _gdk_events_init (GdkDisplay *display) } } if (direct_touch) { - printf ("XI: touch-device id=%d name='%s' ntouch: %d\n", dev->deviceid, dev->name, classInfo->num_touches); +#ifdef G_ENABLE_DEBUG + if (_gdk_debug_flags & GDK_DEBUG_TOUCH) + g_message ("XI: touch-device id=%d name='%s' ntouch: %d\n", dev->deviceid, dev->name, classInfo->num_touches); +#endif if (!display_x11->touch_devices) { display_x11->touch_devices = g_hash_table_new (g_direct_hash, NULL); } @@ -2246,7 +2252,10 @@ gdk_event_translate (GdkDisplay *display, && display_x11->touch_devices && g_hash_table_lookup (display_x11->touch_devices, GUINT_TO_POINTER (((XIDeviceEvent *)xevent->xcookie.data)->deviceid))) { XIDeviceEvent *xev = (XIDeviceEvent *) xevent->xcookie.data; - printf ("TOUCH dev=%d src=%d | dt: %u flags: %x\n", xev->deviceid, xev->sourceid, xev->detail, xev->flags); +#ifdef G_ENABLE_DEBUG + if (_gdk_debug_flags & GDK_DEBUG_TOUCH) + g_message ("TOUCH dev=%d src=%d | dt: %u flags: %x\n", xev->deviceid, xev->sourceid, xev->detail, xev->flags); +#endif window = gdk_window_lookup_for_display (display, xev->event); g_object_ref (window); diff --git a/libs/tk/ydk/ydk/gdk/gdkinternals.h b/libs/tk/ydk/ydk/gdk/gdkinternals.h index 895b2587ce..14548a6bf0 100644 --- a/libs/tk/ydk/ydk/gdk/gdkinternals.h +++ b/libs/tk/ydk/ydk/gdk/gdkinternals.h @@ -92,7 +92,8 @@ typedef enum { GDK_DEBUG_MULTIHEAD = 1 <<12, GDK_DEBUG_XINERAMA = 1 <<13, GDK_DEBUG_DRAW = 1 <<14, - GDK_DEBUG_EVENTLOOP = 1 <<15 + GDK_DEBUG_EVENTLOOP = 1 <<15, + GDK_DEBUG_TOUCH = 1 <<16 } GdkDebugFlag; #ifndef GDK_DISABLE_DEPRECATED