aboutsummaryrefslogtreecommitdiff
path: root/render.c (unfollow)
Commit message (Collapse)AuthorLines
2026-09-02term: wrap url related fields into a structK4-7/+7
2026-08-29render: re-evaluate mouse col/row coordinates after a window resizeDaniel Eklöf-0/+8
Before this, the col/row coordinates for the mouse pointer was only updated when the mouse either entered our window, or was moved inside it. However, when a window is resized without using the mouse, and the user then clicks (again, without moving the mouse), we can get a button event outside the cell grid, that we still think is on top of the grid. Example: user moves mouse over the bottom row. The window is shrunk. Enough that the mouse is now outside the cell grid, but still inside our window. This means we get a button event outside the grid. But since we haven't updated the col/row coordinates, we think it's on a row, that no longer exists. Closes #2435
2026-07-30render: fix broken selection on delayed resizeCismonX-4/+8
Interactive resize of a terminal window breaks current selection, if scrollback is not empty, and option 'resize-delay-ms' is not 0. This behavior is introduced by commit 296e75f4f5, which: - Subtracts selection row by view offset every time render_resize() is called, resulting in bad coordinates. - Does not properly restore the original selection coordinates during the final text reflow stage.
2026-05-12render: cursor: improve handling of fg == bgDaniel Eklöf-5/+14
We already detect if the final cursor colors (foreground/background) are identical. If they were, we replaced them with the default fg/bg. Unfortunately, this can still result in an invisible cursor. For example, if the current cell's default bg matches the current cell's fg. Instead, update the colors in two steps: 1. First, use the provided (cell's) fg/bg 2. If they too match, invert the cursor color This should ensure the cursor is always visible Closes #2323
2026-04-06config: add url.style=none|single|double|curly|dotted|dashedDaniel Eklöf-2/+5
This option allows you to configure which underline style to use with URLs. The default is dotted. Since before this patch, URL underlines were always plain underlines, this means the default URL underline style has changed, from single to dotted. Closes #2302
2026-03-02Add support for background blurDaniel Eklöf-3/+1
This patch adds a new config option: colors{,2}.blur=no|yes. When enabled, transparent background are also blurred. Note that this requires the brand new ext-background-effect-v1 protocol, and specifically, that the compositor implements the blur effect.
2026-03-02support four-sided padding (left/top/right/bottom)pi66-14/+20
2026-02-02wayland: wait for pre-apply damage thread before destroying a terminal instanceDaniel Eklöf-5/+5
It's possible, but unlikely, that we've pushed a "pre-apply damage" job to the renderer thread queue (or that we've pushed it, and the a thread is now working on it) when we shutdown a terminal instance. This is sometimes caught in an assertion in term_destroy(), where we check the queue length is 0. Other times, or in release builds, we might crash in the thread, or in the shutdown logic when freeing the buffer chains associated with the terminal instance. Fix by ensuring there's no pre-apply damage operation queued, or running, before shutting down a terminal instance. Closes #2263
2026-01-04shm: don't bother with xrgb surfaces, always use argbDaniel Eklöf-10/+7
Before this patch, foot used xrgb surfaces for all fully opaque surfaces, and only used argb surfaces for the main window when the user enabled translucency. However, several compositors have damage-like issues when we switch between opaque and non-opaque surfaces (for example, when switching color theme, or when toggling fullscreen). Since the performance benefit of using non-alpha aware surfaces are likely minor (if there's any measurable performance difference at all!), lets workaround these compositor issues by always using argb surfaces.
2025-12-20config: add [colors-dark] and [colors-light], replacing [colors] and [colors2]Daniel Eklöf-30/+30
The main reason for having two color sections is to be able to switch between dark and light. Thus, it's better if the section names reflect this, rather than the more generic 'colors' and 'colors2' (which was the dark one and which was the light one, now again?) When the second color section was added, we kept the original name, colors, to make sure we didn't break existing configurations, and third-party themes. However, in the long run, it's probably better to be specific in the section naming, to avoid confusion. So, add 'colors-dark', and 'colors-light'. Keep 'colors' and 'colors2' as aliases for now, but mark them as deprecated. They WILL be removed in a future release. Also rename the option values for initial-color-theme, from 1/2, to dark/light. Keep the old ones for now, marked as deprecated. Update all bundled themes to use the new names. In the light-only themes (i.e. themes that define a single, light, theme), use colors-light, and set initial-color-theme=light. Possible improvements: disable color switching if only one color section has been explicitly configured (todo: figure out how to handle the default color theme values...)
2025-10-16render: don't warn about immediate buffer release if pre-apply-damage has been activatedDaniel Eklöf-1/+1
2025-10-10config: add colors.dim-blend-towards=black|whiteDaniel Eklöf-1/+8
Before this patch, we always blended towards black when dimming text. However, with light color themes, it usually looks better if we dim towards white instead. This option allows you to choose which color to blend towards. The default is 'black' in '[colors]', and 'white' in '[colors2]'. Closes #2187
2025-10-10render: when double-buffering, pre-apply previous frame's damage earlyDaniel Eklöf-11/+189
Foot likes it when compositor releases buffer immediately, as that means we only have to re-render the cells that have changed since the last frame. For various reasons, not all compositors do this. In this case, foot is typically forced to switch between two buffers, i.e. double-buffer. In this case, each frame starts with copying over the damage from the previous frame, to the new frame. Then we start rendering the updated cells. Bringing over the previous frame's damage can be slow, if the changed area was large (e.g. when scrolling one or a few lines, or on full screen updates). It's also done single-threaded. Thus it not only slows down frame rendering, but pauses everything else (i.e. input processing). All in all, it reduces performance and increases input latency. But we don't have to wait until it's time to render a frame to copy over the previous frame's damage. We can do that as soon as the compositor has released the buffer (for the frame _before_ the previous frame). And we can do this in a thread. This frees up foot to continue processing input, and reduces frame rendering time since we can now start rendering the modified cells immediately, without first doing a large memcpy(3). In worst case scenarios (or perhaps we should consider them best case scenarios...), I've seen up to a 10x performance increase in frame rendering times (this obviously does *not* include the time it takes to copy over the previous frame's damage, since that doesn't affect neither input processing nor frame rendering). Implemented by adding a callback mechanism to the shm abstraction layer. Use it for the grid buffers, and kick off a thread that copies the previous frame's damage, and resets the buffers age to 0 (so that foot understands it can start render to it immediately when it later needs to render a frame). Since we have certain way of knowing if a compositor releases buffers immediately or not, use a bit of heuristics; if we see 10 consecutive non-immediate releases (that is, we reset the counter as soon as we do see an immediate release), this new "pre-apply damage" logic is enabled. It can be force-disabled with tweak.pre-apply-damage=no. We also need to take care to wait for the thread before resetting the render's "last_buf" pointer (or we'll SEGFAULT in the thread...). We must also ensure we wait for the thread to finish before we start rendering a new frame. Under normal circumstances, the wait time is always 0, the thread has almost always finished long before we need to render the next frame. But it _can_ happen. Closes #2188
2025-06-09quirks: remove subsurface unmap quirk for SwayDaniel Eklöf-10/+1
Sway used to have an issue where unmapping a subsurface did not damage the surface below (https://github.com/swaywm/sway/issues/6960). This has been fixed for quite some time now, so let's remove the quirk.
2025-05-24conf: pad: add center-when-fullscreen and center-when-maximized-and-fullscreenDaniel Eklöf-3/+6
Before this patch, the grid content was *always* centered when the window was maximized or fullscreened, regardless of how the user had configured padding. Now, the behavior is controlled by the 'pad' option. Before this patch, the syntax was pad MxN [center] Now it is pad MxN [center|center-when-fullscreen|center-when-maximized-and-fullscreen] The default is "pad 0x0 center-when-maximized-and-fullscreen", to match current behavior. Closes #2111
2025-05-22cursor-shape: add 'dnd-ask' and 'all-resize'Daniel Eklöf-2/+3
These (non-css) cursor shapes were added to the cursor-shape-v1 protocol in wayland-protocols 1.42. We don't need (or use them at all) internally, but add them to the list we use to translate from shape names to shape enums. This allows users to set a custom shape (via OSC-22), while still using server side cursors (i.e. no need to fallback to client-side cursors). If we try to set a shape not implemented by the server, we get a protocol error and foot exits. This is bad. So, make sure we don't do that: 1. First, we need to explicitly bind v2 if implemented by the server 2. Track the bound version number in the wayland struct 3. When matching shape enum, skip shapes not supported in the currently bound version of the cursor-shape protocol
2025-05-21render: improve CSD button positioningKirill Primak-11/+16
This commit fixes titlebar button positioning when maximization isn't available but minimization is.
2025-05-05render: refactor to allow setting only selection bg or fgDaniel Eklöf-39/+57
Before this, we only applied custom selection colors, if *both* the selection bg and fg had been set. Since the options are already split up into two separate options, and since it makes sense to at least be able to keep the foreground colors unchanged (i.e. only setting the selection background), let's allow only having one of the selection colors set. Closes #1846
2025-05-01config: tweak.surface-bit-depth now defaults to 'auto'Daniel Eklöf-18/+13
When set to 'auto', use 10-bit surfaces if gamma-correct blending is enabled, and 8-bit surfaces otherwise. Note that we may still fallback to 8-bit surfaces (without disabling gamma-correct blending) if the compositor does not support 10-bit surfaces. Closes #2082
2025-05-01config: gamma-correct-blending: disable by defaultDaniel Eklöf-1/+1
2025-05-01config: tweak.surface-bit-depth now defaults to 'auto'Daniel Eklöf-18/+13
When set to 'auto', use 10-bit surfaces if gamma-correct blending is enabled, and 8-bit surfaces otherwise. Note that we may still fallback to 8-bit surfaces (without disabling gamma-correct blending) if the compositor does not support 10-bit surfaces. Closes #2082
2025-05-01config: gamma-correct-blending: disable by defaultDaniel Eklöf-1/+1
2025-04-25render: regression: alpha applied to inversed text/selectionsDaniel Eklöf-1/+1
Introduced by 5f83278afd0530c323d4192e1095b3d1dea644c9 Closes #2073
2025-04-19render: fix colors.alpha-mode=matchingDaniel Eklöf-1/+8
Before this patch, it only matched RGB color sources. It did not match the default bg color, or indexed colors. That is, e.g. CSI 43m didn't apply alpha, even if the color3 matched the default background color.
2025-04-14config+render: move alpha-mode to colors.alpha-mode, fix cursor handlingDaniel Eklöf-65/+57
Move main.alpha-mode to colors.alpha-mode. Fix (inverted) cursor handling, by always using the bg color without alpha. Do a minor optimization, where we don't even lock at colors.alpha-mode if there's no transparency configured.
2025-04-14config: add alpha_mode optionFazzi-0/+21
2025-03-23render: dim and brighten using linear rgb interpolationSam McCall-26/+30
Adds setting tweak.dim-amount, similar to bold-text-in-bright-amount. Closes #2006
2025-03-13meson: require wayland-protocols >= 1.41Daniel Eklöf-9/+0
2025-03-05render: gamma-correct blendingDaniel Eklöf-59/+112
This implements gamma-correct blending, which mainly affects font rendering. The implementation requires compile-time availability of the new color-management protocol (available in wayland-protocols >= 1.41), and run-time support for the same in the compositor (specifically, the EXT_LINEAR TF function and sRGB primaries). How it works: all colors are decoded from sRGB to linear (using a lookup table, generated in the exact same way pixman generates it's internal conversion tables) before being used by pixman. The resulting image buffer is thus in decoded/linear format. We use the color-management protocol to inform the compositor of this, by tagging the wayland surfaces with the 'ext_linear' image attribute. Sixes: all colors are sRGB internally, and decoded to linear before being used in any sixels. Thus, the image buffers will contain linear colors. This is important, since otherwise there would be a decode/encode penalty every time a sixel is blended to the grid. Emojis: we require fcft >= 3.2, which adds support for sRGB decoding color glyphs. Meaning, the emoji pixman surfaces can be blended directly to the grid, just like sixels. Gamma-correct blending is enabled by default *when the compositor supports it*. There's a new option to explicitly enable/disable it: gamma-correct-blending=no|yes. If set to 'yes', and the compositor does not implement the required color-management features, warning logs are emitted. There's a loss of precision when storing linear pixels in 8-bit channels. For this reason, this patch also adds supports for 10-bit surfaces. For now, this is disabled by default since such surfaces only have 2 bits for alpha. It can be enabled with tweak.surface-bit-depth=10-bit. Perhaps, in the future, we can enable it by default if: * gamma-correct blending is enabled * the user has not enabled a transparent background
2025-02-19config+render: allow cursor.style=hollowDaniel Eklöf-0/+5
Closes #1965
2025-02-10render: minimum window size: 2 cols -> 1 colDaniel Eklöf-1/+1
2025-02-10grid: refactor reflowDaniel Eklöf-3/+3
We've been trying to performance optimize reflow by "chunking" cells; try to gather as many as possible, and memcpy a chunk at once. The problem is that a) this quickly becomes very complex, and b) is very hard to get right for multi-column characters, especially when we need to truncate long ones due to the window being too small. Refactor, and once again walk and copy all cells one by one. This is slower, but at least it's correct.
2025-02-06render: resize: note why min_cols=7Daniel Eklöf-1/+1
2025-02-06osc: wip: kitty text size protocolDaniel Eklöf-13/+24
This brings initial support for the new kitty text-sizing protocol. Note hat only the width-parameter ('w') is supported. That is, no font scaling, and no multi-line cells. For now, only explicit widths are supported. That is, w=0 does not yet work. There are a couple of changes to the renderer, to handle e.g. OSC 66 ; w=6 ; foobar ST There are two ways this can get rendered, depending on whether grapheme shaping has been enabled. We either shape it, and get an array of glyphs back that we render. Or, we rasterize each codepoint ourselves, and render each resulting glyph. The two cases ends up in two different renderer loops, that worked somewhat different. In particular, the first case has probably never been tested/used at all... With this patch, both are changed, and now uses some heuristic to differentiate between multi-cell text strings (like in the example above), or single-cell combining characters. The difference is mainly in which offset to use for the secondary glyphs. In a multi-cell string, each glyph is mapped to its own cell, while in the combining case, we try to map all glyphs to the same cell.
2025-01-26render: resize: configure with only one dimension being zeroDaniel Eklöf-15/+42
The protocol states: If the width or height arguments are zero, it means the client should decide its own window dimension. This may happen when the compositor needs to configure the state of the surface but doesn't have any information about any previous or expected dimension. The wording is a bit ambiguous; does it mean we should set *both* width and height to values we choose, even if only one dimension is zero in the configure event? Or does it mean that we should choose the value for the dimension that is zero in the configure event? Regardless, it's pretty clear that it does *not* mean we should *only* choose width and height if *both* dimensions are zero in the configure event. This is foot's behavior before this patch, meaning if only one of them is zero, foot assumed the compositor wanted us to set the width (or height) to zero... Change this, so that we now choose value for the "missing" dimension, but do use the compositor provided value for the other dimension. Closes #1925 Relevant issues: * https://gitlab.freedesktop.org/wayland/wayland-protocols/-/issues/155 * https://github.com/YaLTeR/niri/issues/1050
2025-01-18Revert "config: don't allow colors.flash-alpha to be 1.0"Alexander Orzechowski-21/+0
This reverts commit 56d2c3e990509d18de31e6009e0d0c6254f99b67.
2025-01-18render: Expose render_overlayAlexander Orzechowski-1/+1
This function updates the overlay that foot uses. It will be used to update the overlay when the flash effect ends.
2025-01-09Revert "config: don't allow colors.flash-alpha to be 1.0"Alexander Orzechowski-21/+0
This reverts commit 56d2c3e990509d18de31e6009e0d0c6254f99b67.
2025-01-09render: Expose render_overlayAlexander Orzechowski-1/+1
This function updates the overlay that foot uses. It will be used to update the overlay when the flash effect ends.
2025-01-03render: fix order we're checking custom codepointsDaniel Eklöf-5/+5
Fixes a crash when trying to print a "Legacy Computing" symbol (U+1FB00-U+1FB9B). Closes #1901
2025-01-02config: don't allow colors.flash-alpha to be 1.0Daniel Eklöf-0/+21
A compositor will not send a frame callback for our main window if it is fully occluded (for example, by a fully opaque overlay...). This causes the overlay to stuck. For regular buffers, it _should_ be enough to *not* hint the compositor it's opaque. But at least some compositor special cases single-pixel buffers, and actually look at their pixel value. Thus, we have two options: implement frame callback handling for the overlay sub-surface, or ensure we don't use a fully opaque surface. Since no overlays are fully opaque by default, and the flash surface is the only one that can be configured to be opaque (colors.flash-alpha), and since adding frame callback handling adds a lot of boilerplate code... let's go with the simpler solution of
2024-12-08box-drawings: implement octantsDaniel Eklöf-2/+14
2024-10-06render: remove unnecessary call to wl_surface_damage_buffer()Daniel Eklöf-2/+0
The damage region(s) are translated to wl_surface_damage_buffer() calls after the entire frame has been rendered.
2024-10-05render: sixels: update damage region when rendering sixelsDaniel Eklöf-2/+6
This fixes flickering when foot is forced to double-buffer (e.g when running under KDE, or smithay based compositors). Since the damage region isn't updated, the sixel images aren't included in the memcpy that is done to transfer the last frame's updated regions to the next frame. As a result, every other frame will have the sixels, while the others don't. Closes #1851
2024-09-21render: do dirty/clean consistency check before rendering sixelsDaniel Eklöf-6/+6
Since the sixels may render some of the cells, we want the check to happen before the sixels.
2024-09-21render: double-buffer: optimization: skip clean rowsDaniel Eklöf-0/+5
When scanning the grid for all-dirty rows (that we can remove from the damage region we're about to memcpy from the old frame), check the row->dirty bit, and skip scanning the cells of that row altogether. We're only looking for rows where all cells are dirty - those rows can be removed from the region we copy from the old frame, since the entire row will be re-rendered anyway. If a row is clean, it *must* be copied from the old frame.
2024-09-21render: (debug): assert row->dirty vs. cell->attrs.clean consistencyDaniel Eklöf-0/+24
2024-09-21render: xcursor_is_valid(): don't crash when there's no theme loadedDaniel Eklöf-0/+2
When trying to set a custom cursor shape, we first validate it. This is done by checking against known server-side names, and then trying to load the cursor from the client side cursor theme. But, if we're using server side names, there is no theme loaded, and foot crashed. Fix by checking if we have a theme loaded, and if not, fail the cursor shape name validation.
2024-09-15render: add missing include, limits.hDaniel Eklöf-1/+2
2024-09-13toplevel-icon: implement OSC-1, CSI 20/21/22/23 tDaniel Eklöf-15/+42
* The toplevel icon is now set to the app-id, unless "overridden" by OSC-1 or OSC-0. * Implemented OSC-1 * OSC-0 extended to also set the icon * Implemented CSI 20 t - report window icon * Implemented CSI 21 t - report window title * Implemented CSI 22 ; 1 t - push window icon * Implemented CS 23 ; 1 t - pop window icon * Extended CSI 22/23 ; 0 t to also push/pop the icon * Verify app-id set by OSC-176 is valid UTF-8 * Verify icon set by OSC-0/1 is valid UTF-8
2024-09-13toplevel-icon: set to app-id, instead of hardcoding to "foot"Daniel Eklöf-3/+24
And, special case "footclient", and map it to "foot".
2024-09-09render: resize(): don't overflow the number of scrollback linesDaniel Eklöf-4/+29
The config system allows setting the scrollback lines to 2**32-1. However, the total number of grid lines is the scrollback lines plus the window size, and then rounded *up* to the nearest power of two. Furthermore, the number of rows is represented with a plain 'int' throughout the code base. The largest positive integer that fits in an int is 2**31-1. That however, is not a power of two. The largest positive integer, that also is a power of two, that fits in an int is 2**30, or 1073741824. Ideally, we'd just cast the line count to a 64-bit integer, and call __builtin_clzl{,l}() on it, and then take the smallest value of that, or 2**30. But, for some reason, __builtin_clzl(), and __builtin_clzll() appears to ignore bits above 32, despite they being typed to long and long long. Bug? Instead, ensure we never call __builtin_clz() on anything larger than 2**30. Closes #1828
2024-08-26add setting for strikeout thicknessOleh Hushchenkov-2/+12
2024-08-20render: follow cursor.unfocused-style regardless of cursor.styletokyo4j-12/+12
Before this commit, cursor.unfocused-style was effective only with cursor.style=block
2024-08-09csd: track pointer when rendering and handling CSD button clicksDaniel Eklöf-3/+32
* Render button as highlighted only when pointer is above them * Releasing the mouse button while *not* on the button does *not* activate the button When pressing, and holding, a mouse button, the compositor keeps sending motion events for the surface where the button was pressed, even if the mouse has moved outside it. We also don't get any surface leave/enter events. This meant that the button was rendered as highlighted, and a click registered, if the user pressed the mouse button while on the button, and then moved the cursor away from the button before releasing the button. This patch fixes it, by checking if the current cursor coordinates fall within the button surface.
2024-08-02Remove a number of unused includesDaniel Eklöf-1/+0
2024-07-19csi: in-band window resize notifications, private mode 2048Daniel Eklöf-0/+2
This implements https://gist.github.com/rockorager/e695fb2924d36b2bcf1fff4a3704bd83, in-band window resize notifications. When user enables private mode 2048 (in-band resize notifications), *always* send current size, even if the mode is already active. This ensures applications can rely on getting a reply from the terminal.
2024-07-13render: hollow-cursor: use correct cursor colorDaniel Eklöf-1/+1
2024-07-13render: cursor: use default fg/bg if cell fg/bg are the sameDaniel Eklöf-0/+8
When deciding which colors to use for the cursor, and the cursor text and background colors are the same, use the default fg/bg instead. Closes #1761
2024-07-03osc: merge OSC 10/11/12/17/19 handlingDaniel Eklöf-4/+4
10/11/17/19 were already merged, so this patch just stops special casing 12 (cursor color). In preparation for XTPUSHCOLORS/XTPOPCOLORS, the cursor colors are moved from their own struct, into the 'colors' struct. Also fix a bug where OSC 17/19 queries returned OSC-11 data.
2024-07-03render: fix "maybe-uninitialized" error in draw_styled_underline()Craig Barnes-2/+3
Reproducer: CFLAGS='-Og -g' meson setup --buildtype=debug bld ninja -C bld Error message: ../render.c: In function ‘draw_styled_underline’: ../render.c:490:19: error: ‘y_ofs’ may be used uninitialized [-Werror=maybe-uninitialized] 490 | const int top = y + y_ofs; | ^~~ ../render.c:405:9: note: ‘y_ofs’ was declared here 405 | int y_ofs; | ^~~~~
2024-07-01Rename various uses of "curly" in the source code with "underline"Craig Barnes-31/+31
Since "curly" could make it seem as if all underline styles are curled (to people unfamiliar with the codebase), whereas in reality only 1 is.
2024-07-01render: cursor color: remove assertion that both cursor fg/bg be setDaniel Eklöf-5/+6
Before this patch, we asserted both the cursor foreground, and background colors had been set. This is true in most cases; the config system enforces it. It is however possible to set only the cursor background color, while leaving the foreground (text) color unset: * Use a foot config that does *not* configure the cursor colors. This means foot will invert the default fg/bg colors when rendering the cursor. * Override the cursor color using an OSC-12 sequence. OSC-12 only sets the background color of the cursor, and there is no other OSC sequence to set the cursor's text color. To handle this, remove the assertion, and simply split the logic for the cursor backgound and foreground colors: * Use the configured background color if set (either through config or OSC-12), otherwise use the default foreground color. * Use the configured foreground color if set (through config), otherwise use the default background color.
2024-06-27render: draw_styled_underline(): respect main.underline-thicknessDaniel Eklöf-4/+19
Also refactor a bit, and break out early to draw_underline() for legacy underlines.
2024-06-27render: underlines: improve the appearance of the 'dotted' styleDaniel Eklöf-6/+32
Try to make the 'dotted' style appear more even, and less like each cell is rendered separately (even though they are). Algorithm: Each dot is a square; it's sides are that of the font's line thickness. The spacing (gaps) between the dots is initially the same width as the dots themselves. This means the number of dots per cell is the cell width divided by the dots' length/width, divided by two. At this point, there may be "left-over" pixels.I.e. the widths of the dots and the gaps between them may not add up to the width of the cell. These pixels are evenly (as possible) across the gaps. There are still visual inaccuracies at small font sizes. This is impossible to fix without changing the way underlines are rendered, to render an entire line in one go. This is not something we want to do, since it'll make styled underlines, for a specific cell/character, look differently, depending on the surrounding context.
2024-06-26render: underlines: minor perf-tweak: early break outDaniel Eklöf-0/+3
When looking up the extender underline range, break out early if we see that there can't possibly be any ranges matching the current column.
2024-06-26render: resize: copy styled underlines to temporary gridDaniel Eklöf-0/+23
When doing an interactive resize, we create a small grid copy of the current viewport, and then do a non-reflow resize. When the interactive resize is done, we do a proper reflow. This is for performance reasons. When creating the viewport copy, we also need to copy the styled underlines. Otherwise, styled underlines will be rendered as plain underlines *while resizing*.
2024-06-26render: styled underlinesDaniel Eklöf-1/+118
This was originally contributed by @kraftwerk28 in https://codeberg.org/dnkl/foot/pulls/1099 Here, we re-use the rendering logic only, as attribute tracking has been completely rewritten.
2024-06-26csi: wip: styled underlinesDaniel Eklöf-2/+37
This is work in progress, and fairly untested. This adds initial tracking of styled underlines. Setting attributes seems to work (both color and underline style). Grid reflow has *not* been tested. When rendering, style is currently ignored (all styles are rendered as a plain, legacy underline). Color however, *is* applied.
2024-05-22render: single-pixel: minor optimizationDaniel Eklöf-15/+32
Don't re-create the single-pixel buffer, unless necessary. The buffer itself doesn't have a size. That means we can re-use the buffer if the last frame's overlay style matches the current frame's style. What we *do not* know is whether the current frame's size is the same as the last frame's. This means we still have to set the viewport destination, and commit the surface.
2024-05-22render: use single-pixel buffers for overlays, when possibleDaniel Eklöf-8/+70
The unicode-mode, and flash overlays are single color buffers. This means we can use the single-pixel buffer protocol. It's undefined whether the compositor will release the buffer or not; to make things easier, simply destroy the buffer as soon as we've committed it. Note that since compositors don't necessarily release single-pixel buffers, we can't plug them into our own buffer interface. This means we can't use buffer pointers to check if we can re-use the previous buffer (i.e. we can skip comitting a new buffer), or if we have to create a new one. It's _almost_ enough to just check if the last overlay style is the same as the current one. Except that that doesn't take window resizes into account...
2024-05-21unicode-mode: move state from seat to termDaniel Eklöf-10/+1
This fixes an issue where entering unicode-mode in one foot client, also enabled unicode-mode on other foot clients. Both visually (although glitchy), and in effect. The reason the state was originally in the seat objects, was to fully support multi-seat. That is, one seat/keyboard entering unicode-mode should not affect other seats/keyboards. The issue with this is that seat objects are Wayland global. Thus, in server mode, all seat objects are shared between the foot clients. There is a similarity with IME, which also keeps state in the seat. There's one big difference, however, and that is IME has Wayland native enter/leave events, that the compositor emits when windows are focused/unfocused. These events allow us to reset IME state. For our own Unicode mode, there is nothing similar. This patch moves the Unicode state from seats, to the terminal struct. This does mean that if one seat/keyboard enters Unicode mode, then *all* seats/keyboards will affect the unicode state. This potential downside is outweighed by the fact that different foot clients no longer affect each other. Closes #1717
2024-04-10config: add cursor.unfocused-styleDaniel Eklöf-7/+20
This option controls how we render the cursor when the terminal window is unfocused. Possible values are: * hollow: the default, and how we rendered the cursor before this patch. * unchanged: render the cursor exactly the same way as when the window is focused. * none: do not render any cursor at all Closes #1582
2024-03-16wayland: skip loading cursor theme when using server side cursorsDaniel Eklöf-1/+1
We don't need the client side cursor theme when using server side cursors.
2024-03-01cursor-shape: improve xcursor fallback support, and prefer CSS namesDaniel Eklöf-20/+30
Before this patch, we used legacy X11 xcursor names, and didn't really have any fallback handling in place (we only tried to fallback to "xterm", regardless of which cursor shape we were trying to load). This patch changes two things: 1. Improved fallback support. cursor_shape_to_string() now returns a list of strings. This allows us to have per-shape fallbacks, and any number of fallbacks. 2. We prefer CSS xcursor names over legacy X11 names.
2024-02-29render: don't try to set a NULL xcursor imageDaniel Eklöf-2/+17
render_xcursor_update() is called when we've loaded a new xcursor image, and needs to display it. The reason it's not pushed to the compositor immediately is to ensure we don't flood the Wayland socket with xcursor updates. Normally, it's only called when we *succeed* to load a new xcursor image. I.e. if we try to load a non-existing xcursor image, we never schedule an update. However, we _can_ still end up in render_xcursor_update() without a valid xcursor image. For example, we have loaded a valid xcursor image, and scheduled an update. But before the update runs, the user moves the cursor, and we try to load a new xcursor image. If it fails, we crash when the previously scheduled update finally runs. Closes #1624
2024-02-21shm: use XRGB surfaces when we know we wont be using transparencyDaniel Eklöf-7/+10
2024-02-15render: always center grid when fullscreened or maximizedDaniel Eklöf-1/+5
2024-02-06osc: add support for osc 176 (app ID)delthas-0/+22
This adds support for a new OSC escape sequence: OSC 176, that lets terminal programs tell the terminal the name of the app that is running. foot then sets the app ID of the toplevel to that ID, which lets the compositor know which app is running, and typically sets the appropriate icon, window grouping, ... See: https://gist.github.com/delthas/d451e2cc1573bb2364839849c7117239
2024-02-06term: drop term->render.title.is_armedDaniel Eklöf-3/+0
This boolean isn't needed. The idea was probably to not re-program the timer unnecessarily, or even to prevent it from being moved forward in time indefinitely. However, the logic has (probably) gone through some changes, that now makes it irrelevant. The timer isn't moved forward indefinitely; it is always set to 8ms from the last title update. The closer we get to that point in time, the smaller the timeout we set. Now, is_armed _did_ prevent the timer from being re-programmed. But that tiny performance tweak isn't really necessary, as the title should, in normal cases, not be set that often anyway.
2024-02-06Don't use fancy Unicode quotes, stick to ASCIIDaniel Eklöf-53/+53
2024-02-05feature: add resize-by-cells option to constrain window sizes...Andrew J. Hesford-34/+53
...to multiples of the cell size, and preserve grid size when changing fonts or display scales in floating windows.
2024-02-05util: add streq() function and use in place of strcmp(...) == 0Craig Barnes-2/+2
2024-01-25Replace unchecked allocations with calls to xmalloc.h functionsCraig Barnes-1/+1
2023-10-13render: sixel: regression: wrong cell color behind opaque sixelsDaniel Eklöf-1/+1
An opaque sixel that isn't a multiple of the cell size will have some cells partially visible (either the entire last row, the entire last column, or both). These must be rendered before blitting the sixel. f5f2f5a954ee6cf3532a6aba023860ada183d486 introduced a regression, where all such cells were rendered as if the cursor was there, giving them the wrong appearance. Closes #1520
2023-10-12render: fix surface damage when rendering sixels.Daniel Eklöf-9/+10
Pass a damage region to render_row()/render_cell() when rendering partially visible cells underneath a sixel. This ensures the affected regions are later reported as 'damaged' to the Wayland compositor. Closes #1515
2023-10-10term: cache font baselineDaniel Eklöf-8/+8
No need to redo the calculation for every single cell we render, every frame...
2023-10-10render: better description of why we disable transparency in fullscreenDaniel Eklöf-13/+23
2023-10-10Enable the use of flash as visual bellRaimund Sacherer-2/+4
With this patch we can configure flash in the bell section. The colors section allow now to configure the color and translucency of the flash.
2023-10-10render: more fine-grained wayland surface damage trackingDaniel Eklöf-46/+49
Before this patch. Wayland surface damage tracking was done on a per-row basis. That is, even if just one cell was updated, the entire row was "damaged". Now, damage is per cell. This hopefully results in lower latencies in many use cases, and especially on high DPI monitors.
2023-10-07render: disable transparency in margins when in fullscreenDaniel Eklöf-2/+11
This amends 899b768b744c74e88e54e6d8eb32f53accea79d8, where we started disabling transparency in fullscreen Closes #1503
2023-10-03Codespell fixesDaniel Eklöf-2/+2
2023-08-07wayland: cursor-shape-v1 is now always availableDaniel Eklöf-2/+0
Since we're requiring wayland-protocols >= 1.32
2023-08-07render: OSD: center text verticallyDaniel Eklöf-9/+16
Rewrite render_osd(), and instead of passing in an y-offset, let render_osd() itself center the text inside the OSD buffer. This is done using the same baseline calculation term_font_baseline() does, except we use the buffer height instead of the line height. Note that most OSDs are sized based on the line height... Closes #1430
2023-07-31render: OSD: center text verticallyDaniel Eklöf-9/+16
Rewrite render_osd(), and instead of passing in an y-offset, let render_osd() itself center the text inside the OSD buffer. This is done using the same baseline calculation term_font_baseline() does, except we use the buffer height instead of the line height. Note that most OSDs are sized based on the line height... Closes #1430
2023-07-30--window-size-chars: ensure width/height are valid for current scaling factorDaniel Eklöf-16/+3
Before this patch, we didn’t ensure width and height were valid for the current scaling factor, when fractional scaling _is_ available. That is, we didn’t ensure the width/height values multiplied back to their original values after dividing with the scaling factor. Closes #1446
2023-07-28fractional scaling: another round(!) of rounding fixesDaniel Eklöf-63/+69
* Ensure buffer sizes are valid. That is, ensure that size / scale * scale == size. * Do size calculation of the window geometry in the same way we calculate the CSD offsets.
2023-07-28render: round scaled border/title/button widthsDaniel Eklöf-11/+27
And calculation of compounded offsets/widths/heights, to compensate for compositor rounding when positioning and scaling/sizing subsurfaces. Closes #1441
2023-07-28config: add tweak.bold-text-in-bright-amountDaniel Eklöf-1/+3
By how much to increase the luminance when brightening bold fonts. This was previously hard-coded to a factor of 1.3, which is now the default value of the new config option. Closes #1434
2023-07-28render: revert part of a36f67cbe311bebd9321fbf58773dace8128fcd7Daniel Eklöf-2/+2
render_osd() shouldn't use term_font_baseline(). This is because term_font_baseline() uses the line height to determine the position, while render_osd() renders to surfaces that aren't sized like the grid. This fixes a regression, where the CSD title were sometimes rendered too high up, and sometimes too low.