From f16bb8693f0122cea447edc243885428a4b8d370 Mon Sep 17 00:00:00 2001
From: Po Lu <luangruo@yahoo.com>
Date: Sun, 21 Nov 2021 09:32:46 +0800
Subject: [PATCH] Select device notification events correctly

* src/xfns.c (setup_xi_event_mask): Select PropertyEvent,
HierarchyChanged and DeviceChanged for all devices.
---
 src/xfns.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/xfns.c b/src/xfns.c
index a142f5518cc..5eff9f5b0f8 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -2938,6 +2938,13 @@ setup_xi_event_mask (struct frame *f)
   XISetMask (m, XI_Leave);
   XISetMask (m, XI_FocusIn);
   XISetMask (m, XI_FocusOut);
+  XISelectEvents (FRAME_X_DISPLAY (f),
+		  FRAME_X_WINDOW (f),
+		  &mask, 1);
+
+  memset (m, 0, l);
+  mask.deviceid = XIAllDevices;
+
   XISetMask (m, XI_PropertyEvent);
   XISetMask (m, XI_HierarchyChanged);
   XISetMask (m, XI_DeviceChanged);
-- 
2.39.5