Until this point we was using one single buffer. This cause tearing when
they are scanned while we are drawing.
This refactorize our buffer and damage tracking to use two buffers. One
buffer, the back_buffer, is our dirty area. The other one, the
display_buffer, is left untouched.
Now we only flip buffers on adequate moments, indicated by the
compositor sending the frame callback event. We can draw multiple
time between those events, and we store all damaged areas. We only
schedule frame callbacks when needed, after storing a new damaged area.
Once flipped, we backport the damaged area from the new display_buffer
to the new back_buffer. Which generally means, for wvkbd, one rectangle
for each one of the surf and popup_surf.
Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
There's probably a better way of doing this, But this will do for now.
Added basic rounding to buttons.
Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
Add the members font and font_descriptor to struct clr_scheme, so that
it is possible to specify a font for each scheme.
During initialization create the font descriptors for each scheme.
Instead of initially setting the font descriptor when setting up the
buffer, set the font descriptor when drawing the text.
Signed-off-by: Frank Oltmanns <frank@oltmanns.dev>
Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
This is a bit hacky. The main problem is that there is no way to tell
cairo to limit the width. It will wrap text accordingly to width and
height, it will add ellipsizes if it overlow the box, but if a word
width is larger than the box width, it will write it.
To avoid that, I make sure we don't go too much to the left, and I
redraw the background at the right of the keys. This is not visible
cause we damage track correctly the updated buffer coordinates.
I also moved the damage tracking from do_rectangle and draw_text to
higher draw_key and draw_layout.
Previously wvkbd would commit an (usually) unchanged surface at the
framerate of the compositor, this only commits the buffer when we render
something new.
Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>