render: don’t let URL jump label sub-surfaces extend outside window geometry

We have no guarantee that sub-surfaces extending outside the window
geometry are rendered correctly (if at all).

For example, both Sway and River will render the window border on top
of the sub-surface.

Future versions of Sway may clip the sub-surface.

Since jump-labels are positioned slightly above, and to the left of
the URLs first character, having a label on either the top row, or on
the first column, will likely position it outside the window. This is
handled by simply setting x/y to 0 (or, to -margin, since the label
coordinate is later offsetted with the window margins).

Second, if the label is very long, it may extend outside the
window. This is very unusual for labels only showing the key, and not
the URL itself, but could happen in this case too, if e.g. the user
has configured double-width key characters.

This is handled by calculating its maximum width, and then truncating
the label.

Although very unlikely, it is possible for a label to also extend
outside the window’s vertical size. This could happen for very small
font sizes, where the label’s own margins are large, relative to the
font size. This case is currently not handled.

Closes #443
This commit is contained in:
Daniel Eklöf 2021-04-10 13:16:39 +02:00
parent 4325d5a4ab
commit 8561fdb004
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
2 changed files with 60 additions and 27 deletions

View file

@ -40,6 +40,8 @@
* Underline cursor is now rendered below text underline
(https://codeberg.org/dnkl/foot/issues/415).
* Foot now tries much harder to keep URL jump labels inside the window
geometry (https://codeberg.org/dnkl/foot/issues/443).
### Deprecated