emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: address@hidden: Re: x-backspace-delete-keys-p]


From: Jan D.
Subject: Re: address@hidden: Re: x-backspace-delete-keys-p]
Date: Thu, 03 Feb 2005 21:28:21 +0100
User-agent: Mozilla Thunderbird 1.0 (X11/20041206)

Richard Stallman wrote:

Could people please study this, and try it, and see if it causes
any problems?

If you have (like I usually have) Backspace and Delete on the same key (Shift-Backspace generates a Delete) and no other delete key, XKeysymToKeycode will return the same key for XK_Backspace and XK_Delete. The code suggested will then incorrectly assume there are two keys.

The code could be modified to check for different keysyms for delete and backspace, but I'm not sure what problem it is trying to solve. Doesn't the current code work?

   Jan D.

------- Start of forwarded message -------
From: Gabor Melis <address@hidden>
To: address@hidden
Subject: Re: x-backspace-delete-keys-p
Date: Wed, 2 Feb 2005 11:25:06 +0100
In-Reply-To: <address@hidden>
X-Spam-Status: No, hits=-2.5 required=5.0
        tests=EMAIL_ATTRIBUTION,IN_REP_TO,PATCH_UNIFIED_DIFF,
              QUOTED_EMAIL_TEXT,RCVD_IN_ORBS,REFERENCES,
              REPLY_WITH_QUOTES,USER_AGENT_KMAIL
        version=2.55
X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.55 (1.174.2.19-2003-05-19-exp)

- --Boundary-00=_CqKACLDpv2J5AY6
Content-Type: text/plain;
 charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

On Wednesday 02 February 2005 08:29, Richard Stallman wrote:
   I don't know much about other keyboards but checking only
   whether XK_Delete/XK_Backspace is mapped to a keycode that belongs
to _any_
   key in the current keyboard sounds enough.

Maybe you are right, but I don't know how to do this, or if there
is a way to do this.  Do you want to find out?

This patch (against 21.3) does what I described. It could probably be improved by checking for the the geometry in case the keycode belongs to a key, but that key is not present on the physical keyboard. I tested it with my lisp machine, us and us-without-a-backspace-key layouts and it seems to work returning t, t an nil respectively.

- --Boundary-00=_CqKACLDpv2J5AY6
Content-Type: text/x-diff;
 charset="iso-8859-1";
 name="x-backspace-delete-keys-p.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
        filename="x-backspace-delete-keys-p.patch"

- --- xfns.c.orig       2005-02-02 11:15:23.000000000 +0100
+++ xfns.c      2005-02-02 11:07:46.000000000 +0100
@@ -11350,6 +11350,16 @@
#include <X11/keysym.h>
#endif

+#ifdef HAVE_XKBGETKEYBOARD
+static int
+is_keycode_mapped (XkbDescPtr kb, int keycode)
+{
+  /* We could also check if the key is physically present in the
+     geometry component, but that is more trouble than it is worth. */
+  return (kb->min_key_code <= keycode) && (keycode <= kb->max_key_code);
+}
+#endif
+
DEFUN ("x-backspace-delete-keys-p", Fx_backspace_delete_keys_p,
       Sx_backspace_delete_keys_p, 0, 1, 0,
  "Check if both Backspace and Delete keys are on the keyboard of FRAME.\n\
@@ -11390,34 +11400,19 @@
  kb = XkbGetMap (dpy, XkbAllMapComponentsMask, XkbUseCoreKbd);
  if (kb)
    {
- -      int delete_keycode = 0, backspace_keycode = 0, i;
+      int delete_keycode = XKeysymToKeycode (dpy, XK_Delete);
+      int backspace_keycode = XKeysymToKeycode (dpy, XK_BackSpace);

      if (XkbGetNames (dpy, XkbAllNamesMask, kb) == Success)
        {
- -       for (i = kb->min_key_code;
- -            (i < kb->max_key_code
- -             && (delete_keycode == 0 || backspace_keycode == 0));
- -            ++i)
- -         {
- -           /* The XKB symbolic key names can be seen most easily in
- -              the PS file generated by `xkbprint -label name
- -              $DISPLAY'.  */
- -           if (bcmp ("DELE", kb->names->keys[i].name, 4) == 0)
- -             delete_keycode = i;
- -           else if (bcmp ("BKSP", kb->names->keys[i].name, 4) == 0)
- -             backspace_keycode = i;
- -         }
+          if (is_keycode_mapped (kb, delete_keycode) &&
+              is_keycode_mapped (kb, backspace_keycode))
+            have_keys = Qt;

          XkbFreeNames (kb, 0, True);
        }

      XkbFreeClientMap (kb, 0, True);
- -
- -      if (delete_keycode
- -       && backspace_keycode
- -       && XKeysymToKeycode (dpy, XK_Delete) == delete_keycode
- -       && XKeysymToKeycode (dpy, XK_BackSpace) == backspace_keycode)
- -     have_keys = Qt;
    }
  UNBLOCK_INPUT;
  return have_keys;

- --Boundary-00=_CqKACLDpv2J5AY6--
------- End of forwarded message -------


_______________________________________________
Emacs-devel mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/emacs-devel





reply via email to

[Prev in Thread] Current Thread [Next in Thread]