aboutsummaryrefslogtreecommitdiff
path: root/render.c (follow)
Commit message (Collapse)AuthorAgeLines
* 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.
* wayland: read XCURSOR_{THEME,SIZE} in reload_xcursor themeDaniel Eklöf2020-07-10-2/+1
|
* multi-seat: improve handling of multiple (mouse) pointersDaniel Eklöf2020-07-09-17/+17
| | | | | | | | * xcursor always set for all pointers * xcursor sometimes not updated when it should be * mouse grabbed state wasn't per seat, but global (i.e. "does at least one seat enable mouse grabbing") * selection enabled state wasn't per seat
* multi-seat: enable xcursor theme support againDaniel Eklöf2020-07-08-50/+40
|
* wip: multi-seat supportDaniel Eklöf2020-07-08-3/+12
| | | | | Compiles and runs, but mouse, clipboard and other things have been disabled.
* render: sixel: regression: need to take current offset into account when early-quitting sixel ↵Daniel Eklöf2020-06-28-8/+18
| | | | | | | | | rendering The sixel images are sorted, that's true. But in order for our row numer comparisons to actually work, we need to rebase all numbers against the current scrollback offset (or, the scrollback *end*, to be precise).
* render: sixels: break out of loop when we're sure there aren't any more visible imagesDaniel Eklöf2020-06-28-1/+25
| | | | | | | | | | | | | The sixel list is sorted, with the most recent images *first* in the list (and thus the "oldest" images are at the back). This means we can break out of the loop when we see a sixel that *ends before* the current view starts. As a minor optimization, we also recognize sixels that *start after* the current view ends. We can't break out of the loop, but we can skip trying to render them (they wouldn't have been rendered, but more work would have been done in render_sixel() to reach this conclusion).
* render: sixel: use pixman_image_composite32()Daniel Eklöf2020-06-06-1/+1
|
* render: cell: reset clip region also when we're NOT rendering a glyphDaniel Eklöf2020-06-06-1/+1
|
* render: regression: don't let cell background overflow into the marginsDaniel Eklöf2020-06-05-6/+8
| | | | | | | | | | | | This used to work before because we had a "global" clip region on the text area, excluding the margins. When we introduced per-cell clipping, this global clip region was removed, and the background drawing code could now overflow into the margins. This fixes it by setting the cell clip region not just when rendering a glyph, but before we render the cell background.
* render: re-write cell clipping to use pixman destination clippingDaniel Eklöf2020-06-04-47/+36
| | | | | | | | | | | | Our home rolled clip-to-cell code was, obviously, not correct. The original problem was that we couldn't use pixman clipping since we have multiple threads writing to the same pixman image, and thus there would be races between the threads setting clipping. The fix is actually simple - just instantiate one pixman image (referencing the same backing image data) for each rendering thread.