31 Commits

Author SHA1 Message Date
Willow Barraco
ace77b2aaa
Tie the damage tracking to the drawing methods
So that keyboard.c just need to draw things, and stop worring about
damaging.
2025-04-18 07:51:19 +02:00
Willow Barraco
73caeee513 Deduplicate some drwbuf fields
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>
2025-04-17 19:48:53 +02:00
Willow Barraco
55b88bc14f Optimize the backporting condition
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>
2025-04-17 19:48:50 +02:00
Willow Barraco
686b27a72d Implement double buffering
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>
2025-04-17 19:48:43 +02:00
Frank Oltmanns
d5db545dcc Restore cairo also when using rounding
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>
2024-10-26 20:49:11 +02:00
Amir Dahan
d423720553 Add basic rounding
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>
2024-04-14 18:18:34 +02:00
Willow Barraco
538b48d08d fix fractional scalled buffer missing one pixel
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>
2024-01-30 18:44:05 +01:00
Frank Oltmanns
d6439afcb9 Make font selection scheme specific
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>
2023-10-29 13:07:57 +01:00
Willow Barraco
a152fd036f
Break on function definitions 2023-09-08 23:14:40 +02:00
Willow Barraco
fbbf563d70
Simplest clang-format 2023-09-08 22:57:14 +02:00
Willow Barraco
2747980a4e
clang-format 2023-09-08 22:42:49 +02:00
Willow Barraco
7af5410235 Disable cairo antialiasing
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>
2023-09-08 21:17:34 +02:00
Willow Barraco
730e97038c Support fractional-scale-v1
This make text less blurry. It continues to works without.

before:
https://dav.missbanal.net/00bd0fd5-e22f-4a60-87f8-ce6f400d33c9.png

after:
https://dav.missbanal.net/a3f02f1e-d6ce-4378-a141-e2093ba87eed.png
Signed-off-by: Willow Barraco <contact@willowbarraco.fr>
Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
2023-09-08 21:17:31 +02:00
Willow Barraco
24e354ce9e
Add popup to display pressed keys 2023-09-06 15:29:07 +02:00
Willow Barraco
fa659b4584
Remove black boxes
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.
2023-09-01 08:11:31 +02:00
Willow Barraco
3752d0e392
Fix remaining too long text cases 2023-08-31 22:25:11 +02:00
Willow Barraco
4444c6e664
Prevent writing outside of key without ellipsize 2023-08-31 22:03:51 +02:00
Willow Barraco
8f7142b171
Remove ellipsize now that we crop text outside of keys 2023-08-31 21:27:02 +02:00
Willow Barraco
c45446a794
Do not write texts outside of keys
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.
2023-08-31 18:04:26 +02:00
ArenM
1843e60a74 only commit surface when it changed
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>
2022-07-05 22:13:21 +02:00
John Sullivan
849f4600e9 project: rerun clang-format
TODO make a commit or PR hook for this
2022-06-13 21:55:47 +02:00
Zach DeCook
564eb4536a overlapped key output: highlight letters swiped through 2022-01-10 03:08:06 +00:00
Maarten van Gompel
bb1eff09be applied clang-format (no functional changes), but exempted custom include order in keyboard.c and main.c 2021-10-19 23:12:01 -07:00
Stacy Harper
450d43ff44 Handle hide and show signals 2021-10-19 23:12:01 -07:00
Stacy Harper
5fb98bd005 Do not set scale everyframe 2021-10-19 23:12:01 -07:00
Stacy Harper
4ce0cf1b53 Better damage tracking 2021-10-19 23:12:01 -07:00
Stacy Harper
b65ea995f1 Simplify ctx initializer 2021-10-19 23:12:01 -07:00
Stacy Harper
32cf611c9c Remove useless cb 2021-10-19 23:12:01 -07:00
Stacy Harper
fb82daea9c Handle output scaling 2021-10-19 23:12:01 -07:00
Stacy Harper
c806023fd5 Drop wld and implement our own pangocairo renderer 2021-10-19 23:12:01 -07:00
John Sullivan
590b75b23a Init 2020-09-13 04:44:15 -07:00