From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alexander Klimov Newsgroups: gmane.emacs.devel Subject: Re: Monitoring KeyRelease Date: Fri, 6 Jul 2012 21:38:47 +0300 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: dough.gmane.org 1341599939 7158 80.91.229.3 (6 Jul 2012 18:38:59 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 6 Jul 2012 18:38:59 +0000 (UTC) Cc: Stefan Monnier To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jul 06 20:38:59 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SnDQf-0002JM-Jt for ged-emacs-devel@m.gmane.org; Fri, 06 Jul 2012 20:38:57 +0200 Original-Received: from localhost ([::1]:51491 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SnDQe-0003dd-MQ for ged-emacs-devel@m.gmane.org; Fri, 06 Jul 2012 14:38:56 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:41284) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SnDQb-0003dM-Do for emacs-devel@gnu.org; Fri, 06 Jul 2012 14:38:54 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SnDQZ-00049R-Lq for emacs-devel@gnu.org; Fri, 06 Jul 2012 14:38:52 -0400 Original-Received: from 62.128.58.36.static.012.net.il ([62.128.58.36]:48016 helo=mx.eitan.edu) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SnDQZ-00047I-7f for emacs-devel@gnu.org; Fri, 06 Jul 2012 14:38:51 -0400 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by mx.eitan.edu (8.13.8/8.13.8) with ESMTP id q66Iclbw030732; Fri, 6 Jul 2012 21:38:48 +0300 In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 62.128.58.36 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:151463 Archived-At: On Thu, 5 Jul 2012, Stefan Monnier wrote: > > The proper way seems to require handling KeyPress/KeyRelase, but it > > seems Emacs currently ignores KeyRelease (xterm.c:6680). > > That could be changed, of course. Looks like it is more complicated than it seems. I added logging of KeyPress/KeyRelease: event.xkey.keycode, `[' or ']' (means press or release), event.xkey.time-last_user_time, and keysym if ASCII. Turns out I commonly press the next key before releasing the previous one, for example, `test' looks like 28 [ 1719 't' 26 [ 88 'e' 28 ] 64 39 [ 24 's' 26 ] 80 28 [ 40 't' 39 ] 40 28 ] 88 `just a test' looks like 44 [ 652 'j' 44 ] 128 30 [ 128 'u' 39 [ 80 's' 30 ] 24 28 [ 88 't' 39 ] 72 65 [ 40 ' ' 28 ] 96 65 ] 24 38 [ 48 'a' 65 [ 136 ' ' 38 ] 48 65 ] 128 28 [ 56 't' 26 [ 88 'e' 28 ] 24 39 [ 40 's' 26 ] 56 28 [ 48 't' 39 ] 64 28 ] 96 while using `f' as a modifier and moving cursor with `j', `l', or `k' looks like 41 [ 1136 'f' 44 [ 328 'j' 44 ] 96 44 [ 64 'j' 44 ] 80 44 [ 72 'j' 44 ] 72 44 [ 72 'j' 44 ] 120 46 [ 1257 'l' 46 ] 55 46 [ 80 'l' 46 ] 88 41 ] 624 That is if I use a key as a modifier it actually takes longer to press the next key than when I am typing a word and hold the previous key unintentionally. I guess, we should collect all the event information during KeyPress, but do not store the event into the kbd_buffer until we get the corresponding KeyRelease. While processing the KeyRelease we should add to the corresponding KeyPress event the information about all "extended modifiers" which are currently pressed. If we used an extended modifier, than we should remember this fact and skip adding it to the kbd_buffer while processing its KeyRelease event. A key X can be considered as a modifier for key Y, only if X was pressed before Y and X is still pressed while Y is released. overlap: ----- time -----> t [ ] e [ ] modifier: ----- time -----> f [ ] j [ ] For example, 28 [ 1719 't' remember `t' 26 [ 88 'e' remember `e' 28 ] 64 store `t' to kbd_buffer, not `e-t' since `e' was pressed after `t' 39 [ 24 's' remember `s' 26 ] 80 store `e' 28 [ 40 't' remember `t' 39 ] 40 store `s' 28 ] 88 store `t' and 41 [ 1136 'f' remember `f' 44 [ 328 'j' remember `j' 44 ] 96 store `f-j' (`f' was pressed before `j') and mark `f' as been used as a modifier 44 [ 64 'j' remember `j' 44 ] 80 store `f-j' [...] 41 ] 624 skip `f' since it was used as modifier Am I missing something and what you think is the best way to actually implement this scheme? -- Regards, ASK