[Kde-games-devel] keyboard delay on keyPressEvent

Albert Astals Cid tsdgeos at terra.es
Wed Feb 25 20:31:47 CET 2004


A Dimecres 25 Febrer 2004 20:19, Jan Bernatik va escriure:
> Jan Bernatik wrote:
> > Hi
> > I experience a delay when I hold a key. I get first keypress
> > immediately, then like 1/2 sec delay, and then AutoRepeat events.
> > I didn't find in keyPressEvent docs any information what cause this
> > delay. Can anybody push me in the good direction ? I searched archives
> > on trolltech, but there are just AutoRepeat ignoring threads and nothing
> > about this delay.
> >
> > Thanks a lot.
> > Jan
>
> hmm I'm sorry bothering all of you second time with this, but maybe I
> wasn't clear before, and after whole day trying to beat this, I'm still
> stuck with it. What I need to know is, how do you override
> "X -ar1 milisecons" setting of xserver (which cause the behavior I was
> writing about). When I start xserver with -ar1 1 argument, delay is not
> noticable. I was studying kasteroids game source (where it works well)
> but I couldn't figure out what exactly changes the behaviour of keyboard
> in processKeyPress(QKeyEvent *event) function. I also tried glut
> library, with same effect. I'm newbie to QT & kde. Any pointer in good
> direction will be great.

If you say kasteroids is the behaviour you want you might have a look at this

void KAstTopLevel::focusInEvent( QFocusEvent *e )
{
// bla bla 
    XAutoRepeatOff( qt_xdisplay() );
    KMainWindow::focusInEvent(e);
}

void KAstTopLevel::focusOutEvent( QFocusEvent *e )
{
// bla bla 
    XAutoRepeatOn( qt_xdisplay() );
    KMainWindow::focusOutEvent(e);
}

KAstTopLevel::~KAstTopLevel()
{
    XAutoRepeatOn( qt_xdisplay() );
// bla bla 
}

This sets autorepeat off the the windows has the focus and sets in on when it 
loses it and when the window is destroyed. I could not find qt_xdisplay() in 
assistant documentation but looking for it in the qt src it says

Display *qt_xdisplay()                          // get current X display

Albert

>
> thanks, have a nice day
>
> Jan



More information about the kde-games-devel mailing list