Article View: gnu.emacs.bug
Article #98397Mouse buttons act strange when caps-lock is depressed
From: John Bradstreet
Date: Tue, 30 Jul 1991 01:24
Date: Tue, 30 Jul 1991 01:24
66 lines
2895 bytes
2895 bytes
Bug description:
Mouse buttons act strange when the caps-lock is depressed.
This was detected in emacs 18.57 running X under OS 4.1.1, on
a Sun Sparc II, but probably occurs on most X systems.
Bug cause:
X events and emacs use different bit fields to represent the same
keyboard state. The emacs routine x-proc-mouse-event is responsible
for doing this conversion. Some of these bit fields are:
X event: Emacs Key Mask:
0x01 shift key 0x10 shift key
0x02 caps lock 0x20 meta key
0x04 control key 0x40 control key
0x08 meta key 0x80 zero
In emacs, there appears as if there was never any need to detect
wether caps lock was depressed in the event handler, so the X meta key
was copied down to where the X shift lock bit goes.
Unfortunately, this bit doesn't get cleared before the meta bit is
copied. Hence, when the caps lock key is depressed, many events
(in particular mouse events which don't set the shift bit)
act as if the meta key is depressed.
Bug Fixes:
One way around this is to declare meta-mouse buttons in
your .emacs file like so.
(define-key mouse-map x-button-m-left 'x-mouse-set-point)
(define-key mouse-map x-button-m-middle 'x-mouse-paste-and-mark-at-point)
(define-key mouse-map x-button-m-right 'x-mouse-set-mark)
A better way is to fix the offending code. This is in the file
emacs/src/x11fns.c, in the function x-proc-mouse-event.
Add the indicated line.
...
if (XXm_queue_num) {
event = *XXm_queue[XXm_queue_out];
free (XXm_queue[XXm_queue_out]);
XXm_queue_out = (XXm_queue_out + 1) % XMOUSEBUFSIZE;
XXm_queue_num--;
com_letter = 3-(event.xbutton.button & 3);
key_mask = (event.xbutton.state & 15) << 4;
/**** Add next line to fix bug ****/
key_mask &= ~0x20; /* clear X shift-lock status */
/* Report meta in 2 bit, not in 8 bit. */
if (key_mask & 0x80)
{
key_mask |= 0x20;
key_mask &= ~0x80;
}
...
A more elegant, but extremely obscure fix would be to change the
(... & 15) to (... & 0xB). A much clearer fix would be to use
the X11 key mask #defines from X.h.
--
Technical Details
Message-ID:
<BRADST.91Jul29182459@monterey.ai.sri.com>Path:
arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!cis.ohio-state.edu!monterey.ai.sri.com!bradstShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fb2f1,c227b8775552b10,start X-Google-Attributes: gidfb2f1,public X-Google-ArrivalTime: 1991-07-30 05:03:19 PST Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!cis.ohio-state.edu!monterey.ai.sri.com!bradst From: bradst@monterey.ai.sri.com (John Bradstreet) Newsgroups: gnu.emacs.bug Subject: Mouse buttons act strange when caps-lock is depressed Message-ID: <BRADST.91Jul29182459@monterey.ai.sri.com> Date: 30 Jul 91 01:24:59 GMT Sender: gnulists@ai.mit.edu Distribution: gnu Organization: SRI International, Menlo Park, CA Lines: 66 Approved: bug-gnu-emacs@prep.ai.mit.edu