discuss-gnustep
[Top][All Lists]
Advanced

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

Re: [NSEvent isARepeat]


From: Chris Vetter
Subject: Re: [NSEvent isARepeat]
Date: Fri, 28 Apr 2006 16:41:13 +0200

On 2006-04-28 09:49:36 +0200 Richard Frith-Macdonald <address@hidden> wrote:
On 28 Apr 2006, at 10:23, Stephane Goujet wrote:
A quick look at the backend source code reveals (back/Source/x11/ XGServerEvent.m) the line ...
isARepeat: NO /* isARepeat can't be supported with X */
So the X11 backends always set it to 'NO'
I have no idea whether the comment is really accurate ... but I guess the issue to look at is if/how you can determine whether a keypress is a repeat in X, and if it can be determined you need to provide a patch to do it.

X11 doesn't give you an easy way deciding whether a key is repeated or not, however, it gives you everything you need for doing it yourself / the hard way.

You know when a key gets pressed, and when it's released. Therefor you know the timestamp when the key is pressed. So what you do is, when a key is pressed, you memorize
a) that a key is pressed for the first time (eg. in a BOOL)
b) the timestamp when it was pressed
c) which key it was (event key keysym)

Next key-down event, you check which key it is, compare it to the previous key and if it's equal and the timestamp from then and the timestamp 'now' is below a 'threshold' you got a double-press. Now you toggle 'first press' to false.

Next key-down event, you do the same, plus, if it's below the 'threshold' AND 'first press' is false, we got a repeat.

I know, this is over-simplified, but you probably get the idea, what I'm talking about.

--
Chris





reply via email to

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