aboutsummaryrefslogtreecommitdiff
path: root/render.c (follow)
Commit message (Collapse)AuthorAgeLines
* render: block all signals in the rendering threadsDaniel Eklöf2021-02-12-0/+5
|
* Send text_input_rectangle requests for text-inputTadeo Kondrak2021-01-29-1/+30
|
* ime: fix rendering of pre-edit cursor when positioned after the pre-edit stringDaniel Eklöf2021-01-26-1/+12
| | | | | | | | | | | | We failed to convert the byte-indices to cell indices, resulting in a box cursor covering the entire pre-edit string. Note that in addition to fixing the translation from byte index to cell index, the rendered had to be updated to dirty one extra cell from the original grid. Without this, we left trailing cursors behind us when the user deleted text from the pre-edit string.
* search: ad-hoc workaround for combining characters with positive x-offsetsDaniel Eklöf2021-01-26-2/+8
| | | | | | | | | | | | When rendering the search input box, do the same ad-hoc workaround for combining characters with a positive x-offset as we do when rendering normal grid cells. In this case, we don’t *know* when we’re dealing with combining characters. But we can detect zero-width characters. For these, check their glyph’s x-offset. If positive, adjust it like we do when rendering combining glyphs in the main grid, to ensure the glyph is positioned over the _previous_ character, not the next.
* render: set thread name in a portable wayJan Beich2021-01-23-2/+8
| | | | | | | | | | | | | | | | | | prctl is Linux-only but pthread_setname_np is same as PR_SET_NAME. Solaris and FreeBSD >= 13 have pthread_setname_np similar to Linux. DragonFly, OpenBSD, FreeBSD < 13 lack pthread_setname_np but provide pthread_set_name_np which doesn't return a value. NetBSD requires 3 arguments for pthread_setname_np where the last one is void *. render.c:8:10: fatal error: 'sys/prctl.h' file not found #include <sys/prctl.h> ^~~~~~~~~~~~~ render.c:1234:9: error: implicit declaration of function 'prctl' is invalid in C99 [-Werror,-Wimplicit-function-declaration] if (prctl(PR_SET_NAME, proc_title, 0, 0, 0) < 0) ^ render.c:1234:15: error: use of undeclared identifier 'PR_SET_NAME' if (prctl(PR_SET_NAME, proc_title, 0, 0, 0) < 0) ^
* render: sixel: fix assertion: x/y coords may be outside visible areaDaniel Eklöf2021-01-21-2/+2
| | | | But when they are, width/height must be 0.
* render: codespell: accomodate -> accommodateDaniel Eklöf2021-01-21-1/+1
|
* render: draw combining characters on top of colored bitmap glyphs (emoji)Daniel Eklöf2021-01-21-16/+34
|
* render: mark cell overflowed into as dirtyDaniel Eklöf2021-01-21-1/+10
| | | | | | | | | | | | | | | | When tweak.allow-overflowing-double-width-glyphs=yes, then certain glyphs are allowed to overflow into the neighbouring cell. However, if the cell “owning” the double-width glyph is erased (_only_ that cell), then the cell overflowed into is not redrawn, causing part of the double-width glyph to remain on screen. To avoid checking for these glyphs when printing to the terminal (i.e at parse time), simply mark both cells as dirty when we render the overflowing glyph. Yes, this means that the cells will always be re-rendered. We count on them only making up a small portion of the screen.
* render: fix rounding error when calculating background color with alphaDaniel Eklöf2020-12-20-7/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | We use pre-multiplied alpha color channels, but were having bad rounding errors due to the alpha divider being truncated to an integer. The algorithm for pre-multiplying a color channel is: alpha_divider = 0xffff / alpha pre_mult_color = color / alpha_divider In order to fix the rounding errors, we could turn ‘alpha_divider’ into a double. That however would introduce a performance penalty since now we’d need to do floating point math for each cell. The algorithm can be trivially converted to: pre_mult_color = color * alpha / 0xffff Since both color and alpa values are < 65536, the multiplication is “safe”; it will not overflow an uint32_t. Closes #249
* render: ime: ensure cursor is visibleDaniel Eklöf2020-12-08-13/+41
|
* render: search: render IME pre-edit text correctly, hopefullyDaniel Eklöf2020-12-07-61/+116
|
* render: ime: adjust cursor cell index when adjusting glyph offsetDaniel Eklöf2020-12-07-1/+4
|
* render: ime: wip: pre-editDaniel Eklöf2020-12-07-22/+75
|
* render: search: don’t access term->search.buf[] directlyDaniel Eklöf2020-12-07-8/+11
|
* render: codespell: cound -> countDaniel Eklöf2020-12-07-1/+1
|
* render: search: glyph_offset is in *cells*, cursor position in *characters*Daniel Eklöf2020-12-07-18/+64
| | | | | | When calculating the offset into the search string, from where to start rendering, take into account that the cursor position is in *characters*, and the glyph-offset is in *cells*.
* render: search: wcsnlen() -> wcswidth()Daniel Eklöf2020-12-07-1/+1
|
* render: search: handle multi-column charactersDaniel Eklöf2020-12-07-2/+3
|
* render: search: render colorized glyphs (emojis) correctlyDaniel Eklöf2020-12-07-5/+13
|
* render: ime: don’t render pre-edit string in grid while searchingDaniel Eklöf2020-12-07-0/+3
| | | | | | | | | While doing a scrollback search, the pre-edit string should be rendered in the search box, not in the grid. Note that we don’t yet support IME in scrollback search mode. This patch simply prevents the pre-edit text being rendered in the grid, in the “background”, while searching.
* render: ime: draw a ‘bar’ cursor when the pre-edit cursor’s begin == endDaniel Eklöf2020-12-07-6/+14
|
* render: ime: don’t render cursor if cursor begin == endDaniel Eklöf2020-12-07-3/+4
|
* render: ime: calculate on-screen cursor position ourselvesDaniel Eklöf2020-12-07-3/+12
| | | | | | | | The position calculated by render_grid() may be -1,-1 if the cursor is currently hidden. This fixes a crash when trying to input IME while the cursor is hidden.
* render: ignore IME preedit state when deciding which cursor style to renderDaniel Eklöf2020-12-07-1/+1
|
* ime: make IME compile-time optionalDaniel Eklöf2020-12-07-0/+3
|
* ime: render pre-edit textDaniel Eklöf2020-12-07-19/+127
| | | | | | | | | | | | | | This is done by allocating cells for the pre-edit text when receiving the text-input::done() call, and populating them by converting the utf-8 formatted pre-edit text to wchars. We also convert the pre-edit cursor position to cell positions (it can cover multiple cells). When rendering, we simply render the pre-edit cells on-top off the regular grid. While doing so, we also mark the underlying, “real”, cells as dirty, to ensure they are re-rendered when the pre-edit text is modified or removed.
* config: replace union in config struct with simple width/height membersCraig Barnes2020-11-30-4/+4
|
* resize: don’t reflow text on alt screenDaniel Eklöf2020-11-25-9/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Alt screen applications normally reflow/readjust themselves on a window resize. When we do it too, the result is graphical glitches/flashes since our re-flowed text is rendered in one frame, and the application re-flowed text soon thereafter. We can’t avoid rendering some kind of re-flowed frame, since we don’t know when, or even if, the application will update itself. To avoid glitches, we need to render, as closely as possible, what the application itself will render shortly. This is actually pretty simple; we just need to copy the visible content over from the old grid to the new grid. We don’t bother with text re-flow, but simply truncate long lines. To simplify things, we simply cancel any active selection (since often times, it will be corrupted anyway when the application redraws itself). Since we’re not reflowing text, there’s no need to translate e.g. the cursor position - we just keep the current position (but bounded to the new dimensions). Fun thing: ‘less’ gets corrupted if we don’t leave the cursor at the (new) bottom row. To handle this, we check if the cursor (before resize) is at the bottom row, and if so, we move it to the new bottom row. Closes #221
* render: don’t call term_arm_blink_timer() from multiple threadsDaniel Eklöf2020-11-23-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | We call term_arm_blink_timer() from render_cell(), which runs in multiple threads. This caused multiple blink timer FDs to be created and registered with the FDM, later causing read failures after one of those FDs had been closed again. This rarely happened under normal circumstances, but was easy to trigger when the whole screen was full of blinking text. As a small optimization, we don’t bother taking the lock if the timer FD already is valid. This is safe, because: 1) If the timer FD isn’t valid, we take the lock and then call term_arm_blink_timer(), which again checks if the FD is already valid. 2) The blink timer FD cannot be closed while we’re rendering cells. It is only disabled in the FDM callback, which cannot execute while we’re rendering.
* render: no need to call attrs_to_font(), we already have a font referenceDaniel Eklöf2020-11-22-8/+4
|
* render: allow-overflow: require a space in the next cellDaniel Eklöf2020-11-19-1/+5
| | | | | | | | When checking if we should allow a single-width character double-width glyph to overflow into the next cell, require the next cell to either be empty, or contain a space. Closes #203
* render: dim/brighten: multiply/divide instead of add/subtractDaniel Eklöf2020-11-15-2/+2
|
* render: dim and brighten colors by adjusting luminanceDaniel Eklöf2020-11-15-27/+30
| | | | | To do this, we need to convert our RGB to HSL, adjust luminance, and then convert back to RGB.
* render: remove debug outputDaniel Eklöf2020-11-15-1/+0
|
* render: brighten color of bold text if default.bold-text-in-bright=yesDaniel Eklöf2020-11-14-0/+10
| | | | Closes #199
* render: improve sixel rendering performanceDaniel Eklöf2020-11-13-43/+132
| | | | | | | | | | | | | | | | | | Up until now, we’ve always re-rendered the entire image (the part of it that is visible at least), *every* time we render a frame. This is not really needed. In many cases, the cells covered by the image hasn’t been touched. Rewrite the sixel rendering code to only render the part of the sixel image that covers dirty cells. This is done on a per-row basis. I.e. Each *row* of the image that covers at least one dirty cell is re-rendered. For this to work, we now also dirty all cells covered by the image when we emit the image. Finally, for this to work, the sixels need to be rendered *before* we do the normal grid render pass (since that will clear all dirty bits).
* tiocswinsz: fix compilation error on e.g. ppc64Daniel Eklöf2020-10-29-1/+1
| | | | | | | | | | | | | | | | | | | | | | | On some platforms, TIOCSWINSZ has a very large value, > 0x80000000. On some platforms, the `request` argument to `ioctl(3)` is an `int`. For platforms where both of the above is true, gcc will warn (and error out if compiled with `-Werror`) on: ioctl(fd, TIOCSWINSZ, ...) To silence this warning, we need to cast `TIOCSWINSZ` to an integer. However, doing this on platforms where `request` is an `unsigned long` will result in `TIOCSWINSZ` being sign-extended (and thus we end up with an invalid value). It seems that casting to `unsigned int` works in both cases; it silences the long -> int conversion warning, while also preserving the correct value in all cases.
* render: blink switches between foreground and dimmed foregroundDaniel Eklöf2020-10-22-3/+3
|
* wayland: properly restore window size when being un-tiledDaniel Eklöf2020-10-20-6/+11
| | | | | | | | Bind to xdg-shell version 2 if available, as this enables us to track our window’s ‘tiled’ state in the ‘configure’ events. This in turn allows us to stash the ‘old’ window size when being tiled, to be used again when restoring the window size when un-tiled.
* render: resize: call sixel_reflow() after reflowing gridsDaniel Eklöf2020-10-09-0/+3
|
* bell: optionally render margins in red when receiving BELDaniel Eklöf2020-10-08-0/+32
| | | | | | | | | | | Add anew config option, ‘bell=none|set-urgency’. When set to ‘set-urgency’, the margins will be painted in red (if the window did not have keyboard focus). This is intended as a cheap replacement for the ‘urgency’ hint, that doesn’t (yet) exist on Wayland. Closes #157
* render: apply opacity correctly when in reverse video modeDaniel Eklöf2020-10-08-2/+8
|
* render: remove render_refresh_margins()Daniel Eklöf2020-09-29-6/+0
|
* render: term->render.margins is used to explicitly tell us to re-render marginsDaniel Eklöf2020-09-29-15/+7
|
* render: fix rounding errors when setting initial window size and scale != 1Daniel Eklöf2020-09-17-4/+16
| | | | | | | | | An odd cell width/height sometimes resulted in an odd grid size. Combined with a scaling factor of e.g. 2, that led to a rounding error when converting pixel sizes to logical window sizes. As a result, the _next_ configure event would cause us to loose a pixel, which led to us dropping a row from the grid.
* render: best-effort attempt to set initial window size in chars when scale != 1Daniel Eklöf2020-09-14-6/+7
| | | | | | | | | | | The initial window size is set *before* we’re initially mapped. This means we don’t (yet) know on which output we’ll be mapped. _That_ means we don’t know which scaling factor to use. This implements a best effort attempt, where we use the “guessed” scaling factor. This will always be correct in single-monitor configurations, but may be wrong in multi-monitor setups with different scaling factors.
* render: csd: hide buttons when title bar gets too small to fit themDaniel Eklöf2020-09-10-8/+16
|
* Add -W,--window-size-chars, and foot.ini:initial-window-size-charsDaniel Eklöf2020-09-08-6/+17
| | | | | | | | | | | * Add -W,--window-size-chars command line option * Add initial-window-size-chars foot.ini option * Add -w,--window-size-pixels command line option * Add initial-window-size-pixels foot.ini option * Deprecate -g,--geometry command line option in favor of -w,--window-size-pixels * Deprecate geometry option in foot.ini in favor of initial-window-size-pixels
* Merge branch 'tweak-damage-everything' into masterDaniel Eklöf2020-09-07-0/+5
|\
| * config: add tweak.damage-whole-windowDaniel Eklöf2020-09-06-0/+5
| | | | | | | | | | | | | | | | | | | | When enabled, foot will ‘damage’ the entire window, instead of just the modified/updated rows. This will force the compositor to redraw/blend the whole window. This can be used to workaround an issue with fractional scaling in Gnome, where random thin lines may appear.
* | Merge branch 'reflow-multi-column-composed-characters' into masterDaniel Eklöf2020-09-07-2/+4
|\ \
| * | grid: reflow: calculate width of composed characters correctlyDaniel Eklöf2020-09-06-2/+4
| |/ | | | | | | | | Before this patch, reflow called `wcwidth()` on our magic values for composed characters.
* / render: change minimum window size from 4x20 -> 1x2 (rows/cols)Daniel Eklöf2020-09-07-2/+2
|/
* render: optionally enable heuristics that deal with private usage area charsDaniel Eklöf2020-09-03-0/+25
| | | | | | | | | | | | | | Try to detect double-width *glyphs* for single-width *characters*, and allow them to overflow into the next cell. This is only done for single-width chars with a glyph width that is at least 1.5 cells wide, but at most 3 cells. The feature is gated by the new ‘tweak.allow-overflowing-double-width-glyphs’, and is disabled by default. Closes #116
* render: ’redraw_margins’ is now a parameter to grid_render()Daniel Eklöf2020-09-01-11/+7
| | | | | render_refresh_margins() now passes ’true’ here, instead of re-setting term->render.last_buf to NULL.
* render: implement render_refresh_margins()Daniel Eklöf2020-09-01-2/+22
| | | | | For now, it will reset term->render.last_buf to NULL, and then calls grid_render() to do a full screen refresh.
* Merge branch 'scrollback-indicator-positioning' into masterDaniel Eklöf2020-08-27-4/+16
|\ | | | | | | Closes #108
| * render: scrollback indicator: only leave room for search box when necessaryDaniel Eklöf2020-08-26-1/+5
| |
| * render: scrollback indicator: subtract visible rows from populated rowsDaniel Eklöf2020-08-26-1/+1
| | | | | | | | | | This prevents the indicator from starting too high up when the number of used scrollback rows is low.
| * render: scrollback position: only count _used_ scrollback linesDaniel Eklöf2020-08-25-3/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When calculating where in the scrollback history we are, we previously did this against the total number of scrollback lines. I.e. the `scrollback.lines` setting in `footrc`. Now, we count only the used/allocated scrollback lines. Note that the initial indicator position might still seem to start a bit high up, if the number of used scrollback lines is low. This is because we use the *top* of the screen for the current position. Thus, we'll never be at the bottom (except for the special case when we're *really* at the bottom).
* | don't use empty struct initializersDaniel Eklöf2020-08-23-3/+3
|/
* Fix some spelling mistakesCraig Barnes2020-08-15-1/+1
|
* render: render the render timer *before* committing the main surfaceDaniel Eklöf2020-08-14-17/+17
|
* render: render-timer: position sub-surface similar to the scrollback indicatorDaniel Eklöf2020-08-14-0/+5
|
* render: oops... swprintf() needs to number of *chars*, not *bytes*Daniel Eklöf2020-08-13-1/+1
|
* render: fix printf-errors in 32-bit buildsDaniel Eklöf2020-08-13-2/+3
|
* config: add tweak.render-timer optionDaniel Eklöf2020-08-13-53/+96
| | | | | | | | | This can be set to 'none' (the default), 'osd', 'log' or 'both'. When 'osd' is enabled, we'll render the frame rendering time to a sub-surface after each frame. When 'log' is enabled, the frame rendering time is logged on stderr.
* config: make selection foreground/background colors configurableDaniel Eklöf2020-08-12-8/+12
| | | | | | | | | The default is still to inverse the regular foreground/background colors. If the user sets *both* of the new options, selection-foreground and selection-background, those colors will *always* be used for selected cells, instead of inverting the regular foreground/background colors.
* render: fix compilation errors in 32-bit buildsDaniel Eklöf2020-08-11-6/+9
| | | | timeval.tv_usec is an 'unsigned long long' on 32-bit
* Convert most dynamic allocations to use functions from xmalloc.hCraig Barnes2020-08-08-3/+9
|
* config: add 'hide-when-typing'Daniel Eklöf2020-07-31-0/+9
| | | | | | When enabled, the mouse cursor is hidden when the user types in the terminal. It is un-hidden when the user moves the mouse, or when the window loses keyboard focus.
* render: make compiler happy; make sure 'cell_count' has been initializedDaniel Eklöf2020-07-29-1/+1
| | | | | | | | | Compiler, in release builds, complains about 'cell_count' "may be used uninitialized". This isn't true, as it is initialized in every possible switch case below. But, make the compiler happy and zero-initialize it before the switch statement.
* config: add free-form text variant to 'scrollback-indicator-format'Daniel Eklöf2020-07-28-3/+9
| | | | And make the empty string the new default.
* config: rename scrollback-indicator-style to scrollback-indicator-positionDaniel Eklöf2020-07-27-5/+5
|
* render: scrollback indicator: apply weston sub-surface quirkDaniel Eklöf2020-07-27-0/+2
|
* render: scrollback indicator: render relative indicator "smoothly"Daniel Eklöf2020-07-27-7/+7
| | | | That is, don't require it to be placed on a grid row.
* render: scrollback indicator: add top marginDaniel Eklöf2020-07-26-4/+4
|
* config: scrollback-indicator-format: percent -> percentageDaniel Eklöf2020-07-26-1/+1
|
* render: scrollback indicator: use black on bright blueDaniel Eklöf2020-07-26-2/+2
|
* render: scrollback indicator: implement 'relative' and 'line' variantsDaniel Eklöf2020-07-26-9/+41
| | | | | We now implement all combinations of 'scrollback-indicator-style' and 'scrollback-indicator-format'.
* render: scrollback indicator: wip: implement 'fixed:percent' indicatorDaniel Eklöf2020-07-26-10/+100
| | | | | | | | | | | | | When scrollback indicator has been enabled, and the viewport isn't at the bottom, we now render a *static* indicator with the position in percent. We use the color scheme's blue color as background, and it's white color as foreground. This is subject to change... Should maybe be configurable as well. The Wayland surface + sub-surface are instantiated on-demand, and automatically destroyed when no longer used.
* render: search: fix subpixel argument to fcft_glyph_rasterize()Daniel Eklöf2020-07-26-1/+1
|
* config: rename scrollback-indicator to scrollback-indicator-styleDaniel Eklöf2020-07-25-1/+1
| | | | | | | | And turn it from a boolean to an enum. It can be set to: * `none` - disables the indicator * `static` - always rendered near the top of the window * `moving` - position reflects the scrollback position
* config: rename show-scrollback-position to scrollback-indicatorDaniel Eklöf2020-07-24-1/+1
|
* config: add 'show-scrollback-position' option to footrcDaniel Eklöf2020-07-24-2/+0
|
* render: add code that calculates current position in scrollbackDaniel Eklöf2020-07-24-0/+46
|
* render: bump maximum window title length from 100 to 2048 (bytes)Daniel Eklöf2020-07-22-2/+1
| | | | Apparently, the max is ~8K, but lets stay on the safe side.
* term: don't re-render last cursor cell if cursor was hiddenDaniel Eklöf2020-07-15-1/+2
|
* term: print: write special value CELL_MULT_COL_SPACER to extra cellsDaniel Eklöf2020-07-14-1/+1
| | | | | | When printing a multi-column character, write CELL_MULT_COL_SPACER instead of '0' to both padding cells (when character doesn't fit at the end of the line), and to the cells following the actual character.
* term: rename COMB_CHARS_LO,HI -> CELL_COMB_CHARS_LO,HIDaniel Eklöf2020-07-14-3/+3
|
* render: render_margin: don't damage margins when rendering scroll damageDaniel Eklöf2020-07-13-12/+10
| | | | | | | | | | | | | | | | | | | When applying scroll damage, we may have to re-render the margins. This is because when we SHM-scroll, we actually move the entire surface, and thus we end up overwriting the top margin area with old window content, and scroll in uninitialized memory in the bottom margin. But, we don't have to tell the compositor about this - the last frame always contains correct margins; i.e. there's no change between the last frame and current frame being rendered. TODO: we _could_ micro-optimize and only damage the margins after a surface resize. We do it slightly more often now, when dealing with state changes in screen flash or scrollback searching. But I don't think it's worth the effort.
* render: doh! flush the last surface damage *outside* of the rendering loopDaniel Eklöf2020-07-13-8/+8
|
* render: render_margin: add 'damage_{top,bottom,left,right}' argumentsDaniel Eklöf2020-07-13-20/+24
|
* render: render_margin(): remove top/bottom argumentsDaniel Eklöf2020-07-13-24/+20
| | | | All calls to render_margin() set top=true and bottom=true anyway.
* render: merge wl surface damage for consecutive dirty rowsDaniel Eklöf2020-07-13-38/+55
|
* render: keep lock while pushing dirty rows to worker queueDaniel Eklöf2020-07-13-9/+3
| | | | | | | | | | | | | | | | Instead of locking the queue for each dirty row we append, and signaling a condition variable, just keep the lock while going through the visible rows. Release the lock once done. Since we take the lock *before* posting the 'start' semaphore, all workers will be waiting for the lock to be released. Then, one at a time they'll get the lock and pick a row to render. The queue will never get empty - when all rows have been rendered, each worker will pick a 'frame done' "job" from the queue, and break the rendering loop.
* render: don't render cursor when it has been explicitly hiddenDaniel Eklöf2020-07-12-2/+2
|
* render: remove most of the special handling of cursor renderingDaniel Eklöf2020-07-12-80/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, we had to explicitly render the old cursor cell *before* applying scrolling damage. We then rendered all the dirty rows, *without* rendering the cursor - even if the cursor cell was among the dirty rows. Finally, when everything else was done, we explicitly rendered the cursor cell. This meant a lot of code, and unnecessary render_cell() calls, along with unnecessary wl_surface_damage_buffer() calls. This was a necessary in the early design of foot, but not anymore. We can simply mark both the old cursor cell, and the current one, as dirty and let the normal rendering framework render it. All we need to do is pass the cursor column to render_row(), so that it can pass has_cursor=true in the appropriate call to render_cell(). We pass -1 here for all rows, except the cursor's row, where we pass the actual cursor column. With this, there's no need to calculate whether the cursor is visible or not; just mark it's cell as dirty, and if that row is visible, the normal rendering will take care of it. This also simplifies the state needed to be saved between two frames; we only need a row pointer, and the cursor column index. Part of https://codeberg.org/dnkl/foot/issues/35
* render: use kbd-focus instead of visual focus for hollow block cursorDaniel Eklöf2020-07-11-5/+5
| | | | | | When determining whether we should render a hollow block cursor, i.e. to signal that we're unfocused, base the decision on the terminals current keyboard focus, not visual focus.