summaryrefslogtreecommitdiff
path: root/include/vcl/task.hxx
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2021-02-07 16:34:38 +0100
committerLuboš Luňák <l.lunak@collabora.com>2021-02-07 18:57:30 +0100
commitd3b498cc4732f964919fecb265085cefcc422469 (patch)
treeb5cc5bbc381e18a2cad621b75cbe7401db0c585c /include/vcl/task.hxx
parentf343ad6d8a78798814c9d38261043619b4e2b487 (diff)
invoke idle priority timers only when actually idle
The 'Idle' timers are misnamed. They are zero-timeout times, i.e. they are invoked immediately after returning to the main loop. But that does not necessarily mean they are invoked when idle, there may be e.g. user input pending in the system event queue. In fact, LO events are processed before system events, which means that 'Idle' timers are normally processed before user input. Besides being confused, this also leads to poor performance in some cases, such as when using mouse wheel to zoom in a large document. This results in several mouse wheel events, each of which will result in adjusting the zoom and that causing a repaint. Repaints are internally handled using a TaskPriority::REPAINT 'Idle', and so what happens is zoom->repaint->zoom->repaint->zoom->repaint instead of the more efficient zoom->zoom->zoom->repaint. This change (besides trying to clarify the confusion in the docs) delays invoking tasks with priorities TaskPriority::HIGH_IDLE and lower if there is user input or repaint events in the OS queue. That means that tasks using idle priorities actually will be invoked only when idle (barring background threads etc.). I'm reasonably certain this is a safe change, there's no guarantee when exactly tasks will be invoked (e.g. other tasks with a higher priority go first) and explicitly specifying such a priority means asking for it. I already implemented this once in 06d731428ef6cf93c7333e8228b, and it was also again done in 87199d3829257420429057336283, but apparently these have been removed. There was d348035a60361a1b9ba9e 'Drop special idle handling' with the reasoning that 'Idles are just instant timers'. Which strictly technically speaking is true due to 'Idle' being a misnomer, but the point is that some idles should be actual idles and that's why they need to be handled specially. Change-Id: I36c2b02a80ae7e1476b731f878d9b28aa87975f4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110538 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'include/vcl/task.hxx')
-rw-r--r--include/vcl/task.hxx1
1 files changed, 1 insertions, 0 deletions
diff --git a/include/vcl/task.hxx b/include/vcl/task.hxx
index d8adae7eff0b..e95aa5bc460a 100644
--- a/include/vcl/task.hxx
+++ b/include/vcl/task.hxx
@@ -28,6 +28,7 @@ enum class TaskPriority
{
HIGHEST, ///< These events should run very fast!
DEFAULT, ///< Default priority used, e.g. the default timer priority
+ // Input from the OS event queue is processed before HIGH_IDLE tasks.
HIGH_IDLE, ///< Important idle events to be run before processing drawing events
RESIZE, ///< Resize runs before repaint, so we won't paint twice
REPAINT, ///< All repaint events should go in here