0

This question might be related to those questions:

I would like to detect if a user input is older than a certain timeout and block such events if necessary. Imagine scenarios where the UI is not responsive and hangs in the main thread for a few seconds and the user keeps sending input events. Those events are queued and are then processed with a certain delay. I would like to catch this and be able to discard/ignore them. I know that this should never happen since a UI should always be responsive and long tasks should be moved to worker threads or similar concepts but I still want to be able to detect such rare scenarios. Note that the same could happen when the system itself freezes for a few seconds, maybe due to high burden on the system as a whole.

FrozenTarzan
  • 834
  • 10
  • 30
  • QEvent does not record the time when it's created (happened) so it is difficult to check if the currenct event is out of date or not. Otherwise you can override event handlers and check where is it from. Have a look at eventfilter(QObject*, QEvent*) – Ratah Oct 15 '18 at 13:32
  • @Ratah I tried hooking into the event loop using the event filters but that's already the time where the events "come off the queue" so it's too late and I don't know how to reconstruct their creation time. – FrozenTarzan Oct 15 '18 at 13:36
  • If you can identify where the signal is emitted (emit signalClick(); ) , you can run a timer at this moment and check that timer when a slot is called according to that signal. – Ratah Oct 15 '18 at 13:41
  • Unfortunately, that's not possible since the click is already a reaction to a user input. The timestamp of interest is way down there where the initial event is put onto the queue. Events and signals within widgets and event filters are already after the initial "action". – FrozenTarzan Oct 15 '18 at 14:04

1 Answers1

0

I took a look into the code of the default implementations of the available input drivers in Qt for embedded and decided to write my own input concept to be able to read the timestamps from the Linux input files. I then used those timestamps to compare them with the current time to drop them if they were queued too long ago.

The code needed is very platform specific but it worked for my scenario. I guess that I have to accept my own answer although I had hoped for a more general solution.

FrozenTarzan
  • 834
  • 10
  • 30