]> git.eshelyaron.com Git - emacs.git/commitdiff
* src/pgtkterm.c (pgtk_enumerate_devices): Circumvent bug#76239.
authorPo Lu <luangruo@yahoo.com>
Mon, 17 Feb 2025 02:56:37 +0000 (10:56 +0800)
committerEshel Yaron <me@eshelyaron.com>
Tue, 18 Feb 2025 08:47:05 +0000 (09:47 +0100)
(cherry picked from commit e34ea5db5f1c09582e3779828ba248eec5769eb2)

src/pgtkterm.c

index d47b1da72623c34d4b7ff1035b3c5d139262d806..6840340dec638f1811a4fb28f2bcf5cb67973051 100644 (file)
@@ -184,11 +184,27 @@ pgtk_enumerate_devices (struct pgtk_display_info *dpyinfo,
        {
          rec = xmalloc (sizeof *rec);
          rec->seat = g_object_ref (seat);
-         rec->device = GDK_DEVICE (t1->data);
-         rec->name = (make_formatted_string
-                      ("%u:%s",
+
+         if (t1->data)
+           {
+             rec->device = GDK_DEVICE (t1->data);
+             snprintf (printbuf, 1026, "%u:%s",
                        gdk_device_get_source (rec->device),
-                       gdk_device_get_name (rec->device)));
+                       gdk_device_get_name (rec->device));
+
+             rec->name = build_string (printbuf);
+           }
+         else
+           {
+             /* GTK bug 7737 results in GDK seats being initialized
+                with NULL devices in some cirumstances.  As events will
+                presumably also be delivered with their device fields
+                set to NULL, insert a ersatz device record associated
+                with NULL.  (bug#76239) */
+             rec->device = NULL;
+             rec->name = build_string ("0:unknown device");
+           }
+
          rec->next = dpyinfo->devices;
          dpyinfo->devices = rec;
        }