Added a GTK3-safe null guard before unrefing cursors while keeping GTK2 behavior under !HAVE_GTK3.

Added a GTK3 pointer-device null fallback in gtk_xtext_get_pointer to safely handle missing devices before using gdk_device_get_position.
This commit is contained in:
2026-01-23 00:27:02 -07:00
parent 1bb0451d75
commit 7ac74220c4

View File

@@ -156,6 +156,8 @@ gtk_xtext_cursor_unref (GdkCursor *cursor)
#if !HAVE_GTK3 #if !HAVE_GTK3
gdk_cursor_unref (cursor); gdk_cursor_unref (cursor);
#else #else
if (!cursor)
return;
g_object_unref (cursor); g_object_unref (cursor);
#endif #endif
} }
@@ -746,6 +748,17 @@ gtk_xtext_get_pointer (GdkWindow *window, gint *x, gint *y, GdkModifierType *mas
gint win_x = 0; gint win_x = 0;
gint win_y = 0; gint win_y = 0;
if (!device)
{
if (x)
*x = 0;
if (y)
*y = 0;
if (mask)
*mask = 0;
return;
}
gdk_device_get_position (device, &screen, &root_x, &root_y); gdk_device_get_position (device, &screen, &root_x, &root_y);
gdk_window_get_origin (window, &win_x, &win_y); gdk_window_get_origin (window, &win_x, &win_y);