Re: [Plib-users] Lost and buffered key events
Brought to you by:
sjbaker
|
From: Joerg H. <jo...@lu...> - 2006-04-26 22:06:48
|
Hi all,
I solved at least one problem, and thought it might be useful for others
to have the solution:
[...]
> 2) I noticed as well that some of my menus are very slow to react.
> After some searching I again printed the events inside the event
> loop of pwX11.
> While my application updates the frames roughly every 0.03 seconds,
> sometimes events get not delivered at once, but are delayed, and
> after some time suddenly all events get delivered in the same call to
> the event handler, e.g. I press and release 'down', 'down',
> 'up'. I get the event:
> press 'down'
> The nothing for 'some time', while I release
> the key, press 'down' again, release 'down', press 'up'.
> Then suddenly there are three events reported in the event loop.
It turns out that the main reason was a big background texture
(512x512). When the texture was disabled, everything was fine. But even
a small texture (16x16) scaled up on the 800x600 screen would show the
slow down.
So I guess that the X server appeared to be overloaded, since the
texture was drawn too quickly/often - and as a result of this (again: I
guess) keyboard events were buffered.
As a first solution, I then used some kind of 'lazy update' - only
drawing the background picture if anything was changed on the screen.
This worked fine, but is quite a bit of implementation work. The much
easier solution: I added a small delay (usleep(2000)) before drawing the
background texture, and everything is fine now - this delay is not
noticeable for the user.
On a side note: this solution improved another user's problem of having
a delay when going from one screen to the next as well.
Best regards,
Joerg
--
----------------------------------------------------------------
Joerg Henrichs
Luding Administration
e-mail: jo...@lu...
URL: http://luding.org
|