Avoid repainting the whole screen
At the moment, the whole screen is repainted each time a window is modified, which is a huge performance bottleneck. It would be better to repaint only the damaged area.
Repaint only the damaged area, not the whole screen (closes #8).
This obviously improves dramatically the performances. For example, results
for displaying a single window before:
Painting time in ms (#1): 785, min=785, max=785, average=785 (/- 576.7)
Painting time in ms (#3): 1734, min=785, max=1938, average=1485 (/- 503.6)
Painting time in ms (#1): 103, min=103, max=103, average=103 (/- 12.0)
Painting time in ms (#3): 654, min=103, max=654, average=294 (/- 227.2)
Painting time in ms (#5): 76, min=76, max=654, average=276 (+/- 226.3)
There may be still a few remaining glitches to fix though due to the fact that
we clip the region to be painted according to the damaged area, thus some code
may have been working wrongly in the past.