GNU bug report logs - #74423
Low level key events

Previous Next

Package: emacs;

Reported by: Cecilio Pardo <cpardo <at> imayhem.com>

Date: Mon, 18 Nov 2024 20:36:02 UTC

Severity: wishlist

Full log


View this message in rfc822 format

From: Cecilio Pardo <cpardo <at> imayhem.com>
To: Po Lu <luangruo <at> yahoo.com>
Cc: 74423 <at> debbugs.gnu.org
Subject: bug#74423: Low level key events
Date: Sat, 23 Nov 2024 13:08:24 +0100
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;
}





This bug report was last modified 46 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.