On Thursday, 23 September 2021 at 17:02:17 UTC+1 rs wrote:
It's a nice idea, but I tested it and, whilst it sometime "survives" longer (sometimes it doesn't - indeed sometimes only managing one full "loop" see below) whilst flicking the window on/off, it does eventually lead to the same problem. Basically, its not *just* FL_KEYBOARD events but also FL_KEYUP events that are continuously being generated, so this doesn't sidestep the issue. In an attempt a debugging with std::couts in a few places I get the following:
Ah... hmm, OK, that's a bit more of a nuisance...
FWIW, under Windows (Win10, I only have my laptop today...) "my" version does not flicker at all, the win2 toggles on/off once per keyboard press, regardless how long I keep the "Alt+s" combo held for, suggesting (to me, at least) that the Win32 system is only delivering the KEY_UP when I actually let go the keys.
It's been a long time since I looked at raw X11 keyboard handling, so I can't remember what I'd even expect it to do, but it does look very much as if it is generating down/up pairs all the time when the key-combo is held down (where I think Win32 is generating streams of key_down events, but apparently fewer, or only one, key_up.)
(Actually, reading that back, that rang a very faint bell... there is something about handling repeat keys under X11, might be that fltk is generating synthetic events for repeated keys... but I can't remember any of the details...)
If it is a "feature" of the X11 client/server mechanism, it may be hard to dodge. Might be able to start a fl_timeout on key_up events and then only toggle the show/hide state if the key_up is not followed by a key_down within the timeout period... or something. (I'm just making this up as I go along now, can you tell?)