FLTK logo

STR #1616

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 Home  |  Articles & FAQs  |  Bugs & Features  |  Documentation  |  Download  |  Screenshots  ]
 

Return to Bugs & Features | Roadmap 1.1 | SVN ⇄ GIT ]

STR #1616

Application:FLTK Library
Status:2 - Closed w/o Resolution
Priority:2 - Low, e.g. a documentation error or undocumented side-effect
Scope:3 - Applies to all machines and operating systems
Subsystem:X11
Summary:Unexpected FL_KEYUP events appear when a key is pressed for a long time
Version:1.1.7
Created By:142857
Assigned To:matt
Fix Version:None
Update Notification:

Receive EMails Don't Receive EMails

Trouble Report Files:


Name/Time/Date Filename/Size  
 
#1 142857
09:26 Feb 25, 2007
keyup.cc
1k
 
     

Trouble Report Comments:


Name/Time/Date Text  
 
#1 142857
09:26 Feb 25, 2007
When I hold down a key for some seconds, a series of FL_KEYDOWN events are produced. The bug is that among all those FL_KEYDOWN, at some time appears an isolated FL_KEYUP event or more. The time and rate of FL_KEYUPs is not constant, but after ~ 300 events, there has been normally one.

Try the example. You can see the problem if it appears something like this:
...
191: FL_KEYDOWN
192: FL_KEYDOWN
193: FL_KEYDOWN
194: FL_KEYDOWN
195: FL_KEYDOWN
196: FL_KEYDOWN
197: FL_KEYUP
198: FL_KEYDOWN
199: FL_KEYDOWN
200: FL_KEYDOWN
201: FL_KEYDOWN
202: FL_KEYDOWN
203: FL_KEYDOWN
204: FL_KEYDOWN
205: FL_KEYDOWN
...

To have a bit more of fun while you test the bug, try the synthesizer "zynaddsubfx": select an instrument which sounds interesting, and hold a key (with the keyboard on your computer) for some seconds. It restarts randomly. However, with a mouse click on the key, the sound is stable.

fltk 1.1.7 on Debian; g++ 4.1.2
 
 
#2 matt
13:30 Feb 27, 2007
To quote the source code of the keyboard event handling system:

// Stupid X sends fake key-up events when a repeating key is held
// down, probably due to some back compatability problem. Fortunately
// we can detect this because the repeating KeyPress event is in
// the queue, get it and execute it instead:

Well, in some cases, the KeyPress event is not in the queue yet, so a few KeyUp's slip through the net. This is a problem of the implementation of X Servers.

I have to suggestions for fixes on your side. They are to specific to fix in FLTK:

1: try calling Fl::key_state() whenever you get a FL_KEY_UP event. The state may still show the key as pressed

or 2: whenever you receive a FL_KEY_UP, set a very short timeout, then wait if you get another FL_KEY_DOWN on the same key. It should come pretty much immediatly, so calling Fl::check() may already be enough.

Matthias
 
     

Return to Bugs & Features ]

 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.