| index.md - sites - public wiki contents of suckless.org | |
| git clone git://git.suckless.org/sites | |
| Log | |
| Files | |
| Refs | |
| --- | |
| index.md (3891B) | |
| --- | |
| 1 Synchronized rendering | |
| 2 ====================== | |
| 3 | |
| 4 Summary | |
| 5 ------- | |
| 6 Better draw timing to reduce flicker/tearing and improve animation smoot… | |
| 7 | |
| 8 Background | |
| 9 ---------- | |
| 10 | |
| 11 Terminals have to guess when to draw and refresh the screen. This is bec… | |
| 12 the terminal doesn't know whether the application has completed a "batch… | |
| 13 output, or whether it's about to have more output right after the refres… | |
| 14 | |
| 15 This means that sometimes the terminal draws before the application has | |
| 16 completed an output "batch", and usually this results in flicker or tear… | |
| 17 | |
| 18 In st, the parameters which control the timing are `xfps` and `actionfps… | |
| 19 `xfps` determines how long st waits before drawing after interactive X e… | |
| 20 (KB/mouse), and `actionfps` determines the draw frequency for output whi… | |
| 21 doesn't follow X events - i.e. unattended output - e.g. during animation. | |
| 22 | |
| 23 | |
| 24 Part 1: auto-sync | |
| 25 ----------------- | |
| 26 | |
| 27 *NOTE*: this patch (part 1) is not required if you use st-master. It was | |
| 28 merged upsream on 2020-05-10 and will be included in the next release. | |
| 29 | |
| 30 This patch replaces the timing algorithm and uses a range instead of fix… | |
| 31 timing values. The range gives it the flexibility to choose when to draw… | |
| 32 it tries to draw once an output "batch" is complete, i.e. when there's s… | |
| 33 idle period where no new output arrived. Typically this eliminates flick… | |
| 34 tearing almost completely. | |
| 35 | |
| 36 The range is defined with the new configuration values `minlatency` and | |
| 37 `maxlatency` (which replace xfps/actionfps), and you should ensure they'… | |
| 38 your `config.h` file. | |
| 39 | |
| 40 This range has equal effect for both X events and unattended output; it … | |
| 41 care what the trigger was, and only cares when idle arrives. Interactive… | |
| 42 usually arrives very quickly so latency is near `minlatency`, while for | |
| 43 animation it might take longer until the application completes its outpu… | |
| 44 `maxlatency` is almost never reached, except e.g. during `cat huge.txt` … | |
| 45 idle never happens until the whole file was printed. | |
| 46 | |
| 47 Note that the interactive timing (mouse/KB) was fine before this patch, … | |
| 48 main improvement is for animation e.g. `mpv --vo=tct`, `cava`, terminal … | |
| 49 etc, but interactive timing also benefits from this flexibility. | |
| 50 | |
| 51 Part 2: application-sync | |
| 52 ------------------------ | |
| 53 | |
| 54 The problem of draw timing is not unique to st. All terminals have to de… | |
| 55 with it, and a new suggested standard tries to solve it. It's called | |
| 56 "Synchronized Updates" and it allows the application to tell the termina… | |
| 57 the output "batch" is complete so that the terminal knows not to draw pa… | |
| 58 output - hence "application sync". | |
| 59 | |
| 60 The suggestion - by iTerm2 author - is available here: | |
| 61 https://gitlab.com/gnachman/iterm2/-/wikis/synchronized-updates-spec | |
| 62 | |
| 63 This patch adds synchronized-updates/application-sync support in st. It | |
| 64 requires the auto-sync patch above installed first. This patch has no ef… | |
| 65 except when an application uses the synchronized-update escape sequences. | |
| 66 | |
| 67 Note that currently there are very few terminals or applications which s… | |
| 68 it, but one application which does support it is `tmux` since 2020-04-18… | |
| 69 this patch nearly all cursor flicker is eliminated in tmux, and tmux det… | |
| 70 it automatically via terminfo and enables it when st is installed correc… | |
| 71 | |
| 72 | |
| 73 Download | |
| 74 -------- | |
| 75 Part 1 is independent, but part 2 needs part 1 first. Both files are git | |
| 76 patches and can be applied with either `git am` or with `patch`. Both fi… | |
| 77 add values at `config.def.h`, and part 2 also updates `st.info`. | |
| 78 | |
| 79 * Part 1 (merged upstream): [st-autosync-0.8.3.diff](st-autosync-0.8.3.d… | |
| 80 * Part 2 (st 0.8.3): [st-appsync-0.8.3.diff](st-appsync-0.8.3.diff) | |
| 81 * Part 2 (st master 2020-06-17 or later): | |
| 82 [st-appsync-20200618-b27a383.diff](st-appsync-20200618-b27a383.diff) | |
| 83 | |
| 84 | |
| 85 Author | |
| 86 ------ | |
| 87 * Avi Halachmi (:avih) - [https://github.com/avih](https://github.com/av… | |
| 88 Contact email is available inside the patch files. |