From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <9front-bounces@9front.inri.net> X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI autolearn=ham autolearn_force=no version=3.4.4 Received: from 9front.inri.net (9front.inri.net [168.235.81.73]) by inbox.vuxu.org (Postfix) with ESMTP id E60AB20CC9 for ; Sat, 29 Jun 2024 01:54:33 +0200 (CEST) Received: from out-189.mta0.migadu.com ([91.218.175.189]) by 9front; Fri Jun 28 19:53:15 -0400 2024 X-Envelope-To: 9front@9front.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=trbsw.dev; s=key1; t=1719618786; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=DJlASzVNxwcUhFqoTZqwf2u6NuSPFEVbpt4KD17I9Jg=; b=GE2+zzDJVDGA/R6N+4Wslbk929PxvX4DV35zWvMbN2Zpzh8do6wYt4xRhDPhH3B1QJIIP1 6snjyx+NmxlY5Qc8NjORJq2Hyrc8LKK0/J3pPgTvXX7d48lQeybcHJq/oiKuKRGbxboGyt LNJ0CTaN18OaPNgdqtz76WdQf54AN/g= Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Fri, 28 Jun 2024 19:53:03 -0400 Message-Id: X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: "Timothy Robert Bednarzyk" To: <9front@9front.org> X-Migadu-Flow: FLOW_OUT List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: overflow-preventing ACPI scripting service plugin Subject: [9front] [PATCH] Fix shift release events in X11 drawterm with shift:both_capslock xmodmap option Reply-To: 9front@9front.org Precedence: bulk I have recently started using 9front on a couple of different machines (including a native installation on my Thinkpad T470) and use drawterm on my main laptop (which uses the X11 window manager dwm on Artix Linux) to connect to one of them. However, on that laptop, I have the caps lock key remapped to be another control key (ctrl:no_caps) and I have it set to toggle caps lock when I press both shift keys at the same time (shift:both_capslock). As it turns out, when the latter xmodmap option is set, XLookupString interprets shift key release events as caps lock key release events. This was causing my middle and right mouse buttons to effectively be swapped permanently after pressing a shift key even once in a drawterm session (although I didn't know why it was happening until I did some research and found someone else mentioning them having shift-related problems in a different program whenever they were using shift:both_capslock). I ended up solving this by utilizing the rather strange and unintuitive fact that the xkey event's state still has the ShiftMask bit set during the release event (even for actual shift key release events, according to what I found during my research) and using that to determine whether the release event should be interpreted as being for a shift key or for the caps lock key. This likely will cause the middle and right mouse buttons to unswap if the user is holding down the shift key while releasing the caps lock key, but considering how unlikely of a scenario that is and the fact that it is only a temporary and mild problem (all they would have to do is release and re-press the shift key), I think this fix is acceptable enough (unless someone else can think of a better solution, which I would greatly appreciate). diff --git a/gui-x11/x11.c b/gui-x11/x11.c index b4f1ad3..8f2b694 100644 --- a/gui-x11/x11.c +++ b/gui-x11/x11.c @@ -882,7 +882,16 @@ xkeyboard(XEvent *e) break; case XK_Shift_Lock: case XK_Caps_Lock: - k =3D Kcaps; + /* + * Using the xmodmap option shift:both_capslock causes shift + * release events to appear as capslock release events instead. + * Not having this causes the middle and right mouse buttons to + * be swapped permanently after the shift key is pressed once. + */ + if(e->xany.type =3D=3D KeyRelease && (e->xkey.state & ShiftMask)) + k =3D Kshift; + else + k =3D Kcaps; break; case XK_Scroll_Lock: k =3D Kscroll; -- trb