From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Richard Stallman Newsgroups: gmane.emacs.devel Subject: [mega@hotpop.com: Re: x-backspace-delete-keys-p] Date: Thu, 03 Feb 2005 14:14:21 -0500 Message-ID: Reply-To: rms@gnu.org NNTP-Posting-Host: deer.gmane.org X-Trace: sea.gmane.org 1107458590 12235 80.91.229.6 (3 Feb 2005 19:23:10 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 3 Feb 2005 19:23:10 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Feb 03 20:23:01 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CwmZA-0003Fn-00 for ; Thu, 03 Feb 2005 20:23:00 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1CwmmX-0001ef-Sf for ged-emacs-devel@m.gmane.org; Thu, 03 Feb 2005 14:36:49 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1CwmgW-0005ou-KO for emacs-devel@gnu.org; Thu, 03 Feb 2005 14:30:36 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1CwmgR-0005lQ-UI for emacs-devel@gnu.org; Thu, 03 Feb 2005 14:30:32 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1CwmgP-0005f1-Gw for emacs-devel@gnu.org; Thu, 03 Feb 2005 14:30:29 -0500 Original-Received: from [199.232.76.164] (helo=fencepost.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CwmTe-0004RR-4R for emacs-devel@gnu.org; Thu, 03 Feb 2005 14:17:18 -0500 Original-Received: from rms by fencepost.gnu.org with local (Exim 4.34) id 1CwmQn-0003Ky-QP; Thu, 03 Feb 2005 14:14:21 -0500 Original-To: emacs-devel@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:32833 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:32833 Could people please study this, and try it, and see if it causes any problems? ------- Start of forwarded message ------- From: Gabor Melis To: rms@gnu.org Subject: Re: x-backspace-delete-keys-p Date: Wed, 2 Feb 2005 11:25:06 +0100 In-Reply-To: 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 #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 -------