aboutsummaryrefslogtreecommitdiff
path: root/render.c (follow)
Commit message (Collapse)AuthorAgeLines
* render: apply a dimmed overlay while in Unicode input modeDaniel Eklöf2022-08-12-5/+28
|
* Add support for xdg_toplevel.wm_capabilitiesSimon Ser2022-08-04-2/+4
| | | | See https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/122
* config: add colors.search-box-{no-,}matchDaniel Eklöf2022-07-28-5/+20
| | | | Closes #1112
* render: it’s unlikely() the current cell is where the cursor isDaniel Eklöf2022-07-28-1/+1
|
* ime: track IME focus independently from keyboard focusDaniel Eklöf2022-06-15-2/+2
| | | | | | | | | | | | | | | | | Replace the seat->ime.focused boolean with a terminal instace pointer, seat->ime_focus. Set and reset this on ime::enter() and ime::leave() events, and use this instead of seat->kbd_focus on all other IME events. This fixes two issues: a) buggy compositors that sometimes sends an IME enter event without first having sent a keyboard enter event. b) seats may be IME capable while still lacking the keyboard capability. Such seats will *always* see IME enter events without a corresponding keyboard enter event.
* render: fix refresh logic of pending csd|search|urlDaniel Eklöf2022-04-24-1/+1
| | | | | | | | | | | | | | | | | Our CSDs, the search-box and URL labels are all implemented using sub-surfaces, synchronized with the main grid. This means we *must* commit the main surface as well, when updating one of these sub-surfaces. The logic for doing so in the frame callback was flawed, and only triggered when the main grid was actually dirty. That is, e.g. search box updates that did not also resulted in grid updates (for example - pasting a search criteria that doesn’t match), did not result in a UI refresh. Closes #1040
* render: overlay: reset ‘start_col’ after handling the first rowDaniel Eklöf2022-04-17-0/+2
|
* wayland: refactor: remove ‘struct config’ pointer from wayland structDaniel Eklöf2022-04-17-1/+1
| | | | | | | | | | | | | | The global config doesn’t necessarily reflect the correct configuration to use - we should *always* use the current terminal instance’s conf pointer. * Move selection override modifier mask to the key_binding_set struct * Always warn if XDG activation is unavailable, not just if bell.urgent is set (we no longer have access to this information) * Pass ‘bool presentation_timings’ as a parameter to wayl_init() * Remove ‘presentation_timings’ member from the ‘terminal’ struct Closes #932
* render: overlay: apply weston quirkDaniel Eklöf2022-04-17-0/+2
|
* search/render: initial support for highlighting all visible matchesDaniel Eklöf2022-04-16-11/+25
| | | | | | | | | | | | | | | | | Before this patch, only the currently “selected” match was highlighted (by having the “selected” attribute, and by *not* dimming it, like the rest of the grid during a scrollback search). With this patch, we now highlight matches within the viewport. While searching, only the “primary” match is searched-for, and tracked. Then, when rendering a frame, we find all “secondary” matches as well. “holes” are added to the search-mode overlay by the means of an search-match iterator. The iterator’s text matching logic is *very* similar to what we do when the search criteria has been updated, and we re-search the scrollback. It should be possible to refactor this, and share code.
* render: implement ‘flash’ and search mode’s ‘dimming’ with a sub-surfaceDaniel Eklöf2022-04-16-44/+158
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Search mode and ‘flash’ (OSC-555) both achieves similar visual effects: flash tints the entire window yellow, and search mode dims it (except the search match). But, they do so in completely different ways. Search mode is detected in render_cell(), and the colors are then dimmed there. Flash is implemented by blending a yellow, semi-transparent color on top of the rendered grid. This patch replaces those two implementations with a single one. We add a new sub-surface, called the ‘overlay’. In normal mode, it’s unmapped. When either search mode, or flash, is enabled, we enable it, and fill it with a semi-transparent color. Yellow for ‘flash’, and “black” (i.e. no color) for search mode. The compositor then blends it with the grid. Hopefully on the GPU, meaning it’ll be faster than if we blend in software. There are more performance benefits however. By using a separate surface, we can do much better damage tracking. The normal grid rendering code no longer have to care about neither search mode, nor flash. Thus, we get rid of a couple of ‘if’ statements in render_cell(), which is nice. But more importantly, we can drop full grid repaints in a couple of circumstances: * Entering/exiting search mode * Every frame while flash is active Now, when rendering the search mode overlay, we do want to do some damage tracking, also of the overlay. This, since search mode doesn’t dim the *entire* window. The search match is *not* dimmed. This is implemented by punching a hole in the overlay sub-surface. That is, we make part of it *fully* transparent. The basic idea is to set a clip region that excludes the search match, and then dim the rest of the overlay. It’s slightly more complicated than that however, if we want to reuse the last frame’s overlay buffer (i.e we don’t want to re-render the *entire* overlay every frame). In short, we need to: * Clear (punch hole) in areas that are part of this frame’s search match, but not the last frame’s (since those parts are _already_ cleared). * Dim the areas that were part of the last frame’s search match, but aren’t anymore (the rest of the overlay should already be dimmed). To do this, we save the last frame’s “holes” (as a pixman region). Then, when rendering the next frame, we first calculate the new frame’s “holes” region. The region to clear is “this frame’s holes minus last frame’s holes” The region to dim is “last frame’s holes minus this frames holes”. Finally, we compute the bounding box of all modified cells by taking the union of the two diff regions mentioned above. This allows us to limit the buffer damage sent to the compositor.
* wayland: optionally disable pointer input on subsurfacesDaniel Eklöf2022-04-16-1/+3
| | | | | | | | | | | | | | | | We have a number of sub-surfaces for which we are *not* interrested in pointer (or touch) input. Up until now, we’ve manually dealt with these, by recognizing these surfaces in all pointer events, and ignoring them. But, lo and behold, there are better ways of doing this. By clearing the subsurface’s input region, the compositor will do this for us - when a pointer is outside a surface’s input region, the event is passed to the next surface underneath it. This is exactly what we want! Do this for all subsurfaces, *except* the CSDs.
* render: take (visible) CSD border size into account when setting initial sizeDaniel Eklöf2022-04-16-0/+5
|
* wayland: add helper functions wayl_win_csd_{titlebar,borders}_visible()Daniel Eklöf2022-04-16-18/+15
|
* render: take visible border width into account when setting window geometryDaniel Eklöf2022-04-16-5/+12
| | | | This fixes e.g. window snapping in GNOME.
* refactor: add a ‘range’ struct, grouping a start and end coord togetherDaniel Eklöf2022-04-09-4/+4
|
* render: ensure an underline cursor is not positioned too lowDaniel Eklöf2022-04-06-19/+21
| | | | | | | | The underline cursor is positioned just below regular underlines. A bug in the positioning logic related to this, sometimes resulted in the cursor being thinner than what it should be, or even invisible. Fixes #1005
* config: rename csd.color.close -> quitDaniel Eklöf2022-02-09-1/+1
| | | | | | | | | | | This fixes a compilation error on FreeBSD: ../../foot/render.c:2055:45: error: no member named 'epoll_shim_close' in 'struct config::(anonymous at ../../foot/config.h:254:9)' conf_color = &term->conf->csd.color.close; ~~~~~~~~~~~~~~~~~~~~~ ^ /usr/local/include/libepoll-shim/epoll-shim/detail/common.h:8:15: note: expanded from macro 'close': #define close epoll_shim_close
* Specify a fallback mouse cursorAshish SHUKLA2022-02-07-2/+6
| | | | | `text' cursor is not available in lots of cursor themes, but `xterm' is, so specify `xterm' as a fallback cursor name.
* render: add render_xcursor_is_valid()Daniel Eklöf2022-02-07-0/+8
| | | | | Returns true if the provided cursor name is non-NULL, and exist in the currently loaded xcursor theme.
* render: call wl_cursor_theme_get_cursor() earlierDaniel Eklöf2022-02-07-8/+13
| | | | | | | | | | | | | | | | | | | | | Before this patch, wl_cursor_theme_get_cursor() was called in the FDM hook, just before we’re about to update the mouse cursor “for real”. This relies on seat->pointer.xcursor still being valid. This is true as long as we’re only using our compiled-in static xcursor names, but not otherwise. Now, we call wl_cursor_theme_get_cursor() in render_xcursor_set(). At this point, we *know* seat->pointer.xcursor is valid. There is a slight chance of added overhead here, if the client application is switching mouse grabbing on/off rapidly. Before, the calls to wl_cursor_theme_get_cursor() would automatically be throttled. However, the main point of delaying the actual pointer update to the FDM hook is to throttle the *Wayland* calls. And this is still happening: wl_cursor_theme_get_cursor() is client-side only.
* render: resize: add TODO: translate pivot coordsDaniel Eklöf2022-02-07-0/+6
|
* render: resize: finalize selection before reflowing the gridDaniel Eklöf2022-02-07-0/+10
| | | | | | | | | | | | | | This fixes a crash caused by the selection’s pivot point not being translated during reflow. While we could simply reflow the pivot point as well, testing shows irregular behavior with ongoing selections across window resizes, with different compositors behaving differently. For now, we simply finalize the selection, instead of trying to handle ongoing selections. Closes #922
* fcft: adapt to API changes in fcft-3.xDaniel Eklöf2022-02-05-71/+78
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fcft no longer uses wchar_t, but plain uint32_t to represent codepoints. Since we do a fair amount of string operations in foot, it still makes sense to use something that actually _is_ a string (or character), rather than an array of uint32_t. For this reason, we switch out all wchar_t usage in foot to char32_t. We also verify, at compile-time, that char32_t used UTF-32 (which is what fcft expects). Unfortunately, there are no string functions for char32_t. To avoid having to re-implement all wcs*() functions, we add a small wrapper layer of c32*() functions. These wrapper functions take char32_t arguments, but then simply call the corresponding wcs*() function. For this to work, wcs*() must _also_ be UTF-32 compatible. We can check for the presence of the __STDC_ISO_10646__ macro. If set, wchar_t is at least 4 bytes and its internal representation is UTF-32. FreeBSD does *not* define this macro, because its internal wchar_t representation depends on the current locale. It _does_ use UTF-32 _if_ the current locale is UTF-8. Since foot enforces UTF-8, we simply need to check if __FreeBSD__ is defined. Other fcft API changes: * fcft_glyph_rasterize() -> fcft_codepoint_rasterize() * font.space_advance has been removed * ‘tags’ have been removed from fcft_grapheme_rasterize() * ‘fcft_log_init()’ removed * ‘fcft_init()’ and ‘fcft_fini()’ must be explicitly called
* replace gettimeofday with clock_gettimePranjal Kole2022-01-15-40/+40
| | | | | | | | | | | | | POSIX.1-2008 has marked gettimeofday(2) as obsolete, recommending the use of clock_gettime(2) instead. CLOCK_MONOTONIC has been used instead of CLOCK_REALTIME because it is unaffected by manual changes in the system clock. This makes it better for our purposes, namely, measuring the difference between two points in time. tv_sec has been casted to long in most places since POSIX does not define the actual type of time_t.
* config: convert tweak.render_timer to an enumDaniel Eklöf2022-01-13-4/+20
|
* render: csd: scale border width when rendering the CSD border’s visible partDaniel Eklöf2021-12-29-2/+3
|
* render: limit the unfocused block cursor’s outline widthDaniel Eklöf2021-12-29-4/+5
| | | | Ensure the outline width doesn’t exceed the cell width/height.
* render: scale the width out the outline of the unfocused block cursorDaniel Eklöf2021-12-28-4/+6
|
* csi: store color index, not actual color, in cell’s fg/bg attributesDaniel Eklöf2021-12-26-2/+31
| | | | | | | | | | | | | | | | | | When using indexed colors (i.e. SGR 30/40/90/100), store the index into the cell’s fg/bg attributes, not the actual color value. This has a couple of consequences: Color table lookup is now done when rendering. This means a rendered cell will always reflect the *current* color table, not the color table that was in use when the cell was printed to. This simplifies the OSC-4/104 logic, since we no longer need to update the grid - we just have to damage it to trigger rendering. Furthermore, this change simplifies the VT parsing, since we no longer need to do any memory loads (except loading the SGR parameter values), only writes.
* render: make sure ‘maximized’ button doesn’t use negative coordinatesDaniel Eklöf2021-12-22-1/+5
|
* config: csd.border_width now always reflects the full/total widthDaniel Eklöf2021-12-22-4/+4
|
* Merge branch 'window-menu'Daniel Eklöf2021-11-30-8/+1
|\
| * input: Add support for xdg_toplevl.show_window_menu()Jonas Ådahl2021-11-29-8/+1
| | | | | | | | | | This makes, if the compositor supports it, the window menu appear when right clicking on the title bar.
* | render: fix csd border rendering glitch when width > 5pxDaniel Eklöf2021-11-29-4/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | CSD borders are always *at least* 5px. If url.border-width=0, those 5px are all fully transparent (and act as interactive resize handles). As csd.border-width increases, the number of transparent pixels decrease. Once csd.border-width >= 5, the border is fully opaque. When csd.border-width > 5, then width of the border is (obviously) more than 5px. But, when rendering the opaque part of the border, we still used 5px for the invisible part, which caused some pixman rectangles to have negative x/y coordinates. This resulted in rendering glitches due to overflows in pixman when rendering the borders. The fix is to ensure the total border size is always at least, but not *always* 5px. That is, set it to max(5, csd.border-width). This patch also fixes an issue where the CSD borders were not dimmed (like the titlebar) when the window looses input focus. Closes #823
* | term: track cell color sourceDaniel Eklöf2021-11-20-3/+3
|/ | | | | | | | | | | | | Each cell now tracks it’s current color source: * default fg/bg * base16 fg/bg (maps to *both* the regular and bright colors) * base256 fg/bg * RGB Note that we don’t have enough bits to separate the regular from the bright colors. These _shouldn’t_ be the same, so we ought to be fine...
* config: add [colors].dim0-7Daniel Eklöf2021-11-13-7/+34
| | | | | | | | | | | | | | | | | | | | | | | | | This allows you to configure custom colors to be used when colors are being dimmed (`\E[2m`). It is implemented by color matching (just like bold-text-in-bright=palette-based); the color-to-be-dimmed is matched against the current color palette. If it matches one of the regular colors (colors 0-7), the corresponding “dim” color will be used. If it matches one of the bright colors (colors 8-15), the corresponding “regular” color will be used (but *only* if the “dim” color has been set). Otherwise, the color is dimmed by reducing its luminance. The default behavior, i.e. when dim0-7 hasn’t been configured, is to dim by reducing luminance for *all* colors. I.e. we don’t do any color matching at all. In particular, this means that dimming a bright color will *not* result in the corresponding “regular” color. Closes #776
* config: add {str,value}_to_uint{16,32}()Daniel Eklöf2021-11-13-1/+1
| | | | | This allows us to pass the final pointer directly to the conversion functions, as well as allowing us to print outside-range errors.
* render: csd_part: we don’t use the ‘src’ pixman imageDaniel Eklöf2021-10-29-3/+0
|
* csd: add support for a visible borderDaniel Eklöf2021-10-27-5/+54
| | | | | | | | | | | | | | | | | | | | | | | | When we’re using CSDs, we’ve up until now rendered a 5px invisible border. This border handles interactive resizing. I.e. hovering it changes the mouse cursor, and mouse button events are used to start an interactive resize. This patch makes it possible to color part of (or the entire) border, with a configurable color. To facilitate this, two new options have been added: * csd.border-width * csd.border-color border-width defaults to 0, resulting in the look we’re used to. border-color defaults to the title bar color. If the title bar color hasn’t been set, it defaults to the default foreground color (just like the title bar color does). This means that, setting border-width but not border-color, results in a border that blends with the title bar.
* render: tab -> spacesDaniel Eklöf2021-10-20-6/+6
|
* config, render: scrollback indicator: allow configuring scrollback indicator colorsfeeptr@codeberg.org2021-10-09-1/+8
|
* fix crashes when resizing after CSD enabled at runtime with csd.size = 0feeptr2021-10-04-1/+2
|
* term: turn ‘box-drawings’ array into three dynamically allocated arraysDaniel Eklöf2021-09-14-25/+35
| | | | | | | | | | | | | | | | | | | The box_drawings array is now quite large, and uses up ~4K when *empty*. This patch splits it up into three separate, dynamically allocated arrays; one for the traditional box+line drawing and block elements glyphs, one for braille, and one for the legacy computing symbols. When we need to render a glyph, the *entire* array (that it belongs to) is allocated. I.e this is one step closer to a dynamic glyph cache (like the one fcft uses), but doesn’t go all the way. This is especially nice for people with ‘box-drawings-uses-font-glyphs=yes’; for them, the custom glyphs now uses 3*8 bytes (for the three array pointers), instead of 4K.
* render: codespell: aquire -> acquireDaniel Eklöf2021-09-12-1/+1
|
* box-drawing: add braille charactersDaniel Eklöf2021-09-12-4/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Render braille ourselves, instead of using font glyphs. Decoding a braille character is easy enough; there are 256 codepoints, represented by an 8-bit integer (i.e. subtract the Unicode codepoint offset, 0x2800, and you’re left with an integer in the range 0-255). Each bit corresponds to a dot. The first 6 bits represent the upper 6 dots, while the two last bits represent the fourth (and last) row of dots. The hard part is sizing the dots and the spacing between them. The aim is to have the spacing between the dots be the same size as the dots themselves, and to have the margins on each side be half the size of the dots. In a perfectly sized cell, this means two braille characters next to each other will be evenly spaced. This is however almost never the case. The layout logic currently: * Set dot size to either the width / 4, or height / 8, depending on which one is smallest. * Horizontal spacing is initialized to the width / 4 * Vertical spacing is initialized to the height / 8 * Horizontal margins are initialized to the horizontal spacing / 2 * Vertical margins are initialized to the vertical spacing / 2. Next, we calculate the number of “remaining” pixels. That is, if we add the left margin, two dots and the spacing between, how many pixels are left on the horizontal axis? These pixels are distributed in the following order (we “stop” as soon as we run out of pixels): * If the dot size is 0 (happens for very small font sizes), increase it to 1. * If the margins are 0, increase them to 1. * If we have enough pixels (need at 2 horizontal and 4 vertical), increase the dot size. * Increase spacing. * Increase margins. Closes #702
* render: unref clip regionDaniel Eklöf2021-09-04-0/+1
|
* selection: don’t require two cell attr bits for selection updatingDaniel Eklöf2021-08-16-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When updating the selection (i.e when changing it - adding or removing cells to the selection), we need to do two things: * Unset the ‘selected’ bit on all cells that are no longer selected. * Set the ‘selected’ bit on all cells that *are* selected. Since it’s quite tricky to calculate the difference between the “old” and “new” selection, this is done by first un-selecting the old selection, and then selecting the new, updated selection. I.e. first we clear the ‘selected’ bit from *all* cells, and then we re-set it on those cells that are still selected. This process also dirties the cells, to make sure they are re-rendered (needed to reflect their new selected/un-selected status). To avoid dirtying *all* previously selected, and newly selected cells, we have used an algorithm that first runs a “pre-pass”, marking all cells that *will* be selected as such. The un-select pass would then skip (no dirty) cells that have been marked by the pre-pass. Finally, the select pass would only dirty cells that have *not* been marked by the pre-pass. In short, we only dirty cells whose selection state have *changed*. To do this, we used a second ‘selected’ bit in the cell attribute struct. Those bits are *scarce*. This patch implements an alternative algorithm, that frees up one of the two ‘selected’ bits. This is done by lazy allocating a bitmask for the entire grid. The pre-pass sets bits in the bitmask. Thus, after the pre-pass, the bitmask has set bits for all cells that *will* be selected. The un-select pass simply skips cells with a one-bit in the bitmask. Cells without a one-bit in the bitmask are dirtied, and their ‘selected’ bit is cleared. The select-pass doesn’t even have to look at the bitmask - if the cell already has its ‘selected’ bit set, it does nothing. Otherwise it sets it and dirties the cell. The bitmask is implemented as an array of arrays of 64-bit integers. Each outer element represents one row. These pointers are calloc():ed before starting the pre-pass. The pre-pass allocates the inner arrays on demand. The unselect pass is designed to handle both the complete absence of a bitmask, as well as row entries being NULL (both means the cell is *not* pre-marked, and will thus be dirtied).
* render: run the “overflowing glyphs” prepass *before* rendering sixelsDaniel Eklöf2021-08-11-18/+68
| | | | | | | | | | | | | | | | | | | | | | | This fixes an issue where the left-most column of a sixel was “overwritten” by the cell content. This patch also rewrites the prepass logic, to try to reduce the number of loads performed. The new logic loops each row from left to right, looking for dirty cells. When a dirty cell is found, we first scan backwards, until we find a non-overflowing cell. That cell is unaffected by the overflowing cell we’re currently dealing with. We can also stop as soon as we see a dirty cell, since that cell will already have been dealt with. Then, we scan forward, dirtying cells until we see a non-overflowing cell. That first non-overflowing cell is also dirtied, but after that we break. The last loop, that scans forward, advances the same cell pointer used in the outer loop.
* box-drawing: add U+1FB3C-U+1FB6F, U+1FB9A and U+1FB9BDaniel Eklöf2021-08-05-7/+4
| | | | | | These are the “wedges” from the Unicode 13 “Legacy Computing” symbols. Closes #474
* term: consolidate shutdown related state into an anonymous structDaniel Eklöf2021-07-31-3/+3
|
* term: asynchronous client application terminationDaniel Eklöf2021-07-31-1/+1
| | | | | | | | | | | | | | | | | | When the foot window is closed, and we need to terminate the client application, do this in an asynchronous fashion: * Don’t do a blocking call to waitpid(), instead, rely on the reaper callback * Use a timer FD to implement the timeout before sending SIGKILL (instead of using SIGALRM). * Send SIGTERM immediately (we used to *just* close the PTY, and then wait 2 seconds before sending SIGTERM). * Raise the timeout from 2 seconds to 60 Full shutdown now depends on *two* asynchronous tasks - unmapping the window, and waiting for the client application to terminate. Only when *both* of these have completed do we proceed and call term_destroy(), and the user provided shutdown callback.
* Only brighten palette colors with bold-text-in-bright=palette-basedDavid Rosca2021-07-26-0/+1
|
* render: render_osd(): use fcft_text_run_rasterize(), if availableDaniel Eklöf2021-07-24-6/+32
|
* render: render_osd(): fix rendering of color bitmap glyphsDaniel Eklöf2021-07-24-6/+11
|
* render: render_osd(): don’t re-instantiate foreground color for each glyphDaniel Eklöf2021-07-24-0/+2
|
* render: render_osd(): don’t assume a monospace fontDaniel Eklöf2021-07-24-6/+1
|
* render: csd_title(): use a custom font, sized based on the title bar’s heightDaniel Eklöf2021-07-24-3/+8
| | | | | | | | We still use the primary font, but use a custom size, based on the title bar’s height. This fixes an issue where the window title could be way too small, or way too big. And changed size when the terminal font size was changed.
* render: render_osd() now needs a ‘font’ argumentDaniel Eklöf2021-07-24-3/+3
|
* render: render_osd(): pass font as argumentDaniel Eklöf2021-07-24-5/+9
|
* render: refresh CSD in render_refresh_title(), not render_update_title()Daniel Eklöf2021-07-24-1/+2
| | | | | This fixes an issue where the CSD title sometimes got stuck on an “old” title.
* render: refresh CSDs when updating the titleDaniel Eklöf2021-07-24-0/+1
|
* render: csd_title(): use render_osd() to render the current window titleDaniel Eklöf2021-07-24-11/+25
|
* render: must now set alpha in bg color when calling render_osd()Daniel Eklöf2021-07-24-4/+4
|
* render: render_osd(): set clip region, use background alphaDaniel Eklöf2021-07-24-53/+61
| | | | | | | | | Set clip region in render_osd(). This ensures we don’t step outside the pixman buffer when rendering the glyphs. Furthermore, don’t ignore the alpha channel in the background color. Move render_osd() to make it visible to the render_csd_*() functions.
* render: color_dim(): retain alpha channelDaniel Eklöf2021-07-24-1/+2
|
* render: prevent cells from overflowing into marginTimur Celik2021-07-20-1/+2
|
* render: use a single backing SHM pool for CSD surface buffersDaniel Eklöf2021-07-18-36/+37
|
* shm: refactor: move away from a single, global, buffer listDaniel Eklöf2021-07-17-27/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Up until now, *all* buffers have been tracked in a single, global buffer list. We've used 'cookies' to separate buffers from different contexts (so that shm_get_buffer() doesn't try to re-use e.g. a search-box buffer for the main grid). This patch refactors this, and completely removes the global list. Instead of cookies, we now use 'chains'. A chain tracks both the properties to apply to newly created buffers (scrollable, number of pixman instances to instantiate etc), as well as the instantiated buffers themselves. This means there's strictly speaking not much use for shm_fini() anymore, since its up to the chain owner to call shm_chain_free(), which will also purge all buffers. However, since purging a buffer may be deferred, if the buffer is owned by the compositor at the time of the call to shm_purge() or shm_chain_free(), we still keep a global 'deferred' list, on to which deferred buffers are pushed. shm_fini() iterates this list and destroys the buffers _even_ if they are still owned by the compositor. This only happens at program termination, and not when destroying a terminal instance. I.e. closing a window in a “foot --server” does *not* trigger this. Each terminal instatiates a number of chains, and these chains are destroyed when the terminal instance is destroyed. Note that some buffers may be put on the deferred list, as mentioned above.
* shm: replace 'locked' attribute with a ref-counterDaniel Eklöf2021-07-17-7/+5
| | | | | | | | | | | | | | | | | The initial ref-count is either 1 or 0, depending on whether the buffer is supposed to be released "immeidately" (meaning, as soon as the compositor releases it). Two new user facing functions have been added: shm_addref() and shm_unref(). Our renderer now uses these two functions instead of manually setting and clearing the 'locked' attribute. shm_unref() will decrement the ref-counter, and destroy the buffer when the counter reaches zero. Except if the buffer is currently "busy" (compositor owned), in which case destruction is deferred to the release event. The buffer is still removed from the list though.
* shm: we may exit with busy buffers remaining (seen on KDE)Daniel Eklöf2021-07-17-1/+1
|
* shm: move ‘size’ to the private buffer structDaniel Eklöf2021-07-17-1/+1
|
* shm: rename buffer.mmapped to buffer.dataDaniel Eklöf2021-07-17-3/+3
|
* render: Allow cells to bleed into their neighborTimur Celik2021-07-17-38/+40
| | | | | | | | | | | | | | | | This patch adds a `confined` flag to each cell to track if the last rendered glyph bled into it's right neighbor. To keep things simple, bleeding into any other neighbor cell than the immediate right one is not allowed. This should cover most use cases. Before rendering a row we now do a prepass and mark all cells unclean that are affected by a bleeding neighbor. If there are consecutive bleeding cells, the whole group must be re-rendered even if only a single cell has changed. The patch also deprecates both old overflowing glyph options *allow-overflowing-double-width-glyphs* and *pua-double-width* in favor of a single new one named *overflowing-glyphs*.
* url-mode: use shm_get_many()Daniel Eklöf2021-07-15-14/+78
| | | | | | | | | | | | | | | | If we have lots of URLs, we use up a *lot* of SHM buffers (and thus pools). Each and every one is a single mmap(), of at least 4K. Since all URL labels are created and destroyed at the same time, it makes sense to use a single pool for all buffers. To do this, we must now do two passes; first one to generate the actual string (label content), and to calculate the label sizes. Then we use this information to allocate all SHM buffers at once, from the same pool. Finally, we iterate the URLs again, this time to actually render them.
* shm: add shm_get_many() - allows buffers to share a single poolDaniel Eklöf2021-07-15-0/+4
| | | | | | | | | | | | | | shm_get_many() always returns new buffers (i.e. never old, cached ones). The newly allocated buffers are also marked for immediate purging, meaning they’ll be destroyed on the next call to either shm_get_buffer(), or shm_get_many(). Furthermore, we add a new attribute, ‘locked’, to the buffer struct. When auto purging buffers, look at this instead of comparing cookies. Buffer consumers are expected to set ‘locked’ while they hold a reference to it, and don’t want it destroyed behind their back.
* render: search: set clip regionDaniel Eklöf2021-07-15-0/+6
| | | | | Fixes crash when the search box has been reduced in height, due to limited window space.
* render: scrollback indicator: improve handling of very small window sizesDaniel Eklöf2021-07-15-10/+17
|
* render: margins: use correct background colorDaniel Eklöf2021-07-15-6/+3
| | | | | | * Sync actual color used, with how render_cell() selects the background color * Use color_dim_for_search(), not color_dim()
* render: track alpha directly, rather whether to use it or notDaniel Eklöf2021-07-15-6/+5
|
* render: tiocswinsz: don’t remove/close the fd passed as argumentDaniel Eklöf2021-07-14-2/+4
| | | | | | | | There’s a chance the resize timeout FD was closed, and *reused*, after epoll() told us the FD is readable, but before our callback runs. Thus, closing the FD provided as an argument is dangerous, as it may refer to something completely different.
* Revert "render: don’t assume PIXMAN_a8r8g8b8 for color glyphs"Daniel Eklöf2021-07-14-2/+2
| | | | | | | This reverts commit 9b4796e996a6b524718591df8d8ea1ebe3b9bbbd. Sub-pixel anti-aliasing also uses 32-bit glyphs (but x8r8g8b8, instead of a8r8g8b8)...
* render: don’t assume PIXMAN_a8r8g8b8 for color glyphsDaniel Eklöf2021-07-14-2/+2
| | | | We may want to use PIXMAN_b8g8r8a8 on big-endian in the future.
* render: require glyph count > 0 and cell-cols also for forced double-width PUAsDaniel Eklöf2021-07-02-4/+4
|
* allow-overflowing-double-width-glyphs: take glyph offset into accountDaniel Eklöf2021-07-02-3/+3
| | | | | | | | A narrow, but offset:ed glyph should still be considered double width. This patch also fixes a crash, when the maybe-double width glyph is in the last column. This is a regression.
* render: don’t look at glyphs[0]->cols when determining if overflow should be allowedDaniel Eklöf2021-06-30-1/+1
| | | | | Use ‘cell_cols’ instead, which is the number of cells we’ll actually be using.
* composed: store compose chains in a binary search treeDaniel Eklöf2021-06-24-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The previous implementation stored compose chains in a dynamically allocated array. Adding a chain was easy: resize the array and append the new chain at the end. Looking up a compose chain given a compose chain key/index was also easy: just index into the array. However, searching for a pre-existing chain given a codepoint sequence was very slow. Since the array wasn’t sorted, we typically had to scan through the entire array, just to realize that there is no pre-existing chain, and that we need to add a new one. Since this happens for *each* codepoint in a grapheme cluster, things quickly became really slow. Things were ok:ish as long as the compose chain struct was small, as that made it possible to hold all the chains in the cache. Once the number of chains reached a certain point, or when we were forced to bump maximum number of allowed codepoints in a chain, we started thrashing the cache and things got much much worse. So what can we do? We can’t sort the array, because a) that would invalidate all existing chain keys in the grid (and iterating the entire scrollback and updating compose keys is *not* an option). b) inserting a chain becomes slow as we need to first find _where_ to insert it, and then memmove() the rest of the array. This patch uses a binary search tree to store the chains instead of a simple array. The tree is sorted on a “key”, which is the XOR of all codepoints, truncated to the CELL_COMB_CHARS_HI-CELL_COMB_CHARS_LO range. The grid now stores CELL_COMB_CHARS_LO+key, instead of CELL_COMB_CHARS_LO+index. Since the key is truncated, collisions may occur. This is handled by incrementing the key by 1. Lookup is of course slower than before, O(log n) instead of O(1). Insertion is slightly slower as well: technically it’s O(log n) instead of O(1). However, we also need to take into account the re-allocating the array will occasionally force a full copy of the array when it cannot simply be growed. But finding a pre-existing chain is now *much* faster: O(log n) instead of O(n). In most cases, the first lookup will either succeed (return a true match), or fail (return NULL). However, since key collisions are possible, it may also return false matches. This means we need to verify the contents of the chain before deciding to use it instead of inserting a new chain. But remember that this comparison was being done for each and every chain in the previous implementation. With lookups being much faster, and in particular, no longer requiring us to check the chain contents for every singlec chain, we can now use a dynamically allocated ‘chars’ array in the chain. This was previously a hardcoded array of 10 chars. Using a dynamic allocated array means looking in the array is slower, since we now need two loads: one to load the pointer, and a second to load _from_ the pointer. As a result, the base size of a compose chain (i.e. an “empty” chain) has now been reduced from 48 bytes to 32. A chain with two codepoints is 40 bytes. This means we have up to 4 codepoints while still using less, or the same amount, of memory as before. Furthermore, the Unicode random test (i.e. write random “unicode” chars) is now **faster** than current master (i.e. before text-shaping support was added), **with** test-shaping enabled. With text-shaping disabled, we’re _even_ faster.
* render: use cell cols from compose chain, not graphemeDaniel Eklöf2021-06-24-1/+2
| | | | | | fcft’s view of how many columns a grapheme cluster is may differ from our own. Make sure the rendered glyph matches the number of columns that were allocated when the cluster was printed.
* render: don’t modify the cell’s x position. Fixes broken underlinesDaniel Eklöf2021-06-24-6/+7
|
* render: we’ve already assigned ‘base’ a couple of lines higher upDaniel Eklöf2021-06-24-2/+1
|
* render: repair parenthesis after rebaseDaniel Eklöf2021-06-24-5/+5
|
* render: ensure ‘cell_cols’ have been initializedDaniel Eklöf2021-06-24-1/+1
|
* render: handle fcft_glyph_rasterize() failure correctlyDaniel Eklöf2021-06-24-3/+8
|
* render: use column count from grapheme instead of first glyph, when we have oneDaniel Eklöf2021-06-24-2/+8
|
* wip: grapheme shapingDaniel Eklöf2021-06-24-43/+85
|
* wayland: apply CSD/SSD changes in the surface configure eventDaniel Eklöf2021-06-23-11/+11
| | | | | | | | | | | | | | | | | | The configure event asks the client to change its decoration mode. The configured state should not be applied immediately. Clients must send an ack_configure in response to this event. See xdg_surface.configure and xdg_surface.ack_configure for details. In particular, ”the configured state should *not* be applied immediately”. Instead, treat CSD/SSD changes like all other window dimension related changes: store the to-be mode in win->configure, and apply it in the surface configure event. This fixes an issue where foot incorrectly resized the window when the server switched between CSD/SSD at run-time.
* config: add csd.button-color optionDaniel Eklöf2021-06-20-4/+18
| | | | | | | | This option controls the foreground color of the minimize/maximize/close buttons. I.e. the color used to draw the minimize/maximize/close glyphs. It defaults to default background color.
* render: don’t create/destroy the title update timer each timeDaniel Eklöf2021-06-18-30/+2
| | | | | Create it once when instantiating the terminal. Add a boolean to track whether the timer is running or not.
* render: use a timer instead of relying on the frame callback for title update throttlingDaniel Eklöf2021-06-18-13/+50
| | | | | | | | | | | | | | | | | | | | | Using the frame callback works most of the time, but e.g. Sway doesn’t call it while the window is hidden, and thus prevents us from updating the title in e.g. stacked views. This patch uses a timer FD instead. We store a timestamp from when the title was last updated. When the application wants to update the title, we first check if we already have a timer running, and if so, does nothing. If no timer is running, check the timestamp. If enough time has passed, update the title immediately. If not, instantiate a timer and wait for it to trigger. Set the minimum time between two updates to ~8ms (twice per frame, for a 60Hz output, and ~once per frame on a 120Hz output). Closes #591
* config: add underline-offset optionDaniel Eklöf2021-06-17-1/+5
| | | | | | | | This option allows the user to configure a custom underline offset. That is, use the user provided offset instead of the font provided one. Closes #490