From: Cecilio Pardo <cpardo@imayhem.com>
To: Po Lu <luangruo@yahoo.com>
Cc: 74423@debbugs.gnu.org
Subject: bug#74423: Low level key events
Date: Sat, 23 Nov 2024 13:08:24 +0100 [thread overview]
Message-ID: <dce2177f-bf03-4da3-94cd-ac1bd9f26dfc@imayhem.com> (raw)
In-Reply-To: <87ttc4hzmb.fsf@yahoo.com>
On 19/11/2024 0:49, Po Lu wrote:
> You are computing the modifier event to be generated incorrectly. You
> should search the modifier map (dpyinfo->modmap) for columns containing
> received keysyms, and compare modifier bits derived from the rows where
> they appear against meta_mod_mask, shift_lock_mask, alt_mod_mask,
> super_mod_mask, and hyper_mod_mask in the display structure, or CtrlMask
> and ShiftMask.
Thanks for the guidance. Does this look ok?
Lisp_Object
x_get_modifier_for_keycode (struct x_display_info *dpyinfo,
int keycode)
{
#ifdef HAVE_XKB
if (dpyinfo->xkb_desc)
for (int mod = 0; mod < XkbNumModifiers; mod++)
{
int mask = (1 << mod);
if (dpyinfo->xkb_desc->map->modmap[keycode] & mask)
{
if (mask == ShiftMask)
return Qshift;
if (mask == ControlMask)
return Qctrl;
if (mask == dpyinfo->meta_mod_mask)
return Qmeta;
if (mask == dpyinfo->alt_mod_mask)
return Qalt;
if (mask == dpyinfo->super_mod_mask)
return Qsuper;
if (mask == dpyinfo->hyper_mod_mask)
return Qhyper;
}
}
#endif
XModifierKeymap *map = dpyinfo->modmap;
if (map)
for (int mod = 0; mod < 8; mod++)
{
int mask = (1 << mod);
for (int key = 0; key < map->max_keypermod; key++)
if (map->modifiermap[mod * map->max_keypermod + key] == keycode)
{
if (mask == ShiftMask)
return Qshift;
if (mask == ControlMask)
return Qctrl;
if (mask == dpyinfo->meta_mod_mask)
return Qmeta;
if (mask == dpyinfo->alt_mod_mask)
return Qalt;
if (mask == dpyinfo->super_mod_mask)
return Qsuper;
if (mask == dpyinfo->hyper_mod_mask)
return Qhyper;
}
}
return Qnil;
}
next prev parent reply other threads:[~2024-11-23 12:08 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <fb50ec11-7aec-481e-8a3a-ecdcf22eb7c0@imayhem.com>
[not found] ` <31bdc55d-8c13-4de0-9cef-bd6cc4fb033f@imayhem.com>
[not found] ` <s1r8qtzsvbe.fsf@yahoo.com>
2024-11-18 20:35 ` bug#74423: Low level key events Cecilio Pardo
2024-11-18 23:49 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-23 12:08 ` Cecilio Pardo [this message]
2024-11-19 15:29 ` Eli Zaretskii
2024-11-19 16:43 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-19 20:05 ` Cecilio Pardo
2024-11-20 4:21 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-02 16:54 ` Cecilio Pardo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=dce2177f-bf03-4da3-94cd-ac1bd9f26dfc@imayhem.com \
--to=cpardo@imayhem.com \
--cc=74423@debbugs.gnu.org \
--cc=luangruo@yahoo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).