We have those fields on the drwbuf struct, but we always use the
same ones. Let's deduplicate those fields by moving them on the drwsurf.
Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
At the moment we flip the two buffers, and we backport the damaged
area on every frame callback. We completely ignore the compositor
sent event buffer->release. This event means that the compositor
finished reading the buffer pixels, and will never read them again. So
we can keep using the same buffer instead of fliping, if we receive the
event before asking for a new frame callback.
The change is not complicated, but we have to distinguish
drwsurf_attach, and drwsurf_flip. We try to flip before trying to
draw anything. And if the buffer has already been released, we don't
flip.
We also have to track the backport_damage separately than the buffer
current damage.
Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
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>
Cairo is properly restored when not rounding, but in the codepath for
rounding it is not. Call cairo_restore() in both cases, otherwise
artefacts appear when using transparent fonts.
Signed-off-by: Frank Oltmanns <frank@oltmanns.dev>
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>
Before 1920*1080 scaled 1.40 was giving a buffer width of 1919 pixels.
The buffer dimensions have to be ceiled here, instead of rounded.
The rest of the dimensions have to stay the same, here 1371x120.
Signed-off-by: Willow Barraco <contact@willowbarraco.fr>
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 unoticeable without fractional scaling, but becore a real
problem with it. It add transparency arround rectangles, and so cause
drawing problems.
Signed-off-by: Willow Barraco <contact@willowbarraco.fr>
Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
This isn't a good way to solve this, and cause restrictions and
breakages.
We should find a better way to enforce text inside of keys, probably
using a second buffer to write into.
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>