all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [mega@hotpop.com: Re: x-backspace-delete-keys-p]
@ 2005-02-03 19:14 Richard Stallman
  2005-02-03 20:28 ` Jan D.
  0 siblings, 1 reply; 9+ messages in thread
From: Richard Stallman @ 2005-02-03 19:14 UTC (permalink / raw)


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

------- Start of forwarded message -------
From: Gabor Melis <mega@hotpop.com>
To: rms@gnu.org
Subject: Re: x-backspace-delete-keys-p
Date: Wed, 2 Feb 2005 11:25:06 +0100
In-Reply-To: <E1CwEwe-0004Qs-QS@fencepost.gnu.org>
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 -------

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2005-02-07 12:50 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-02-03 19:14 [mega@hotpop.com: Re: x-backspace-delete-keys-p] Richard Stallman
2005-02-03 20:28 ` Jan D.
2005-02-03 20:35   ` Jan D.
2005-02-05 17:38   ` Richard Stallman
2005-02-05 18:08     ` Jan D.
2005-02-06 12:42       ` Richard Stallman
2005-02-06 14:27         ` Jan D.
2005-02-07  9:18           ` Richard Stallman
2005-02-07 12:50             ` Jan D.

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.