From b5ac604b15532db0418f3c2393907daa317f2ca5 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Sat, 12 Mar 2022 13:02:28 +0800 Subject: [PATCH] Fix some issues with input methods that depend on button state * src/xterm.c (handle_one_xevent): Translate button state before filtering events. --- src/xterm.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/xterm.c b/src/xterm.c index cf79135497c..d8311828116 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -12771,6 +12771,19 @@ handle_one_xevent (struct x_display_info *dpyinfo, xkey.time = xev->time; xkey.state = ((xev->mods.effective & ~(1 << 13 | 1 << 14)) | (xev->group.effective << 13)); + + /* Some input methods react differently depending on the + buttons that are pressed. */ + if (xev->buttons.mask_len) + { + if (XIMaskIsSet (xev->buttons.mask, 1)) + xkey.state |= Button1Mask; + if (XIMaskIsSet (xev->buttons.mask, 2)) + xkey.state |= Button2Mask; + if (XIMaskIsSet (xev->buttons.mask, 3)) + xkey.state |= Button3Mask; + } + xkey.keycode = xev->detail; xkey.same_screen = True; @@ -13126,6 +13139,19 @@ handle_one_xevent (struct x_display_info *dpyinfo, xkey.time = xev->time; xkey.state = ((xev->mods.effective & ~(1 << 13 | 1 << 14)) | (xev->group.effective << 13)); + + /* Some input methods react differently depending on the + buttons that are pressed. */ + if (xev->buttons.mask_len) + { + if (XIMaskIsSet (xev->buttons.mask, 1)) + xkey.state |= Button1Mask; + if (XIMaskIsSet (xev->buttons.mask, 2)) + xkey.state |= Button2Mask; + if (XIMaskIsSet (xev->buttons.mask, 3)) + xkey.state |= Button3Mask; + } + xkey.keycode = xev->detail; xkey.same_screen = True; -- 2.39.2