From 102406edb1d387bcb3c82ac320c30da5bd705194 Mon Sep 17 00:00:00 2001
From: Po Lu <luangruo@yahoo.com>
Date: Sat, 13 Nov 2021 20:03:05 +0800
Subject: [PATCH] Don't emit SELECT_WINDOW_EVENT when an xwidget is scrolled

* src/xterm.c (handle_one_event): Don't select xwidget window
on button event if the button pressed actually represents the
scroll wheel.
---
 src/xterm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/xterm.c b/src/xterm.c
index 172abe919dd..4492db85029 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -9304,7 +9304,9 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 			    event->xbutton.button, event->xbutton.state,
 			    event->xbutton.time);
 
-	    if (!EQ (selected_window, xvw->w))
+	    if (!EQ (selected_window, xvw->w)
+		&& ((event->xbutton.button < 3)
+		    || (event->xbutton.button > 7)))
 	      {
 		inev.ie.kind = SELECT_WINDOW_EVENT;
 		inev.ie.frame_or_window = xvw->w;
-- 
2.39.5