aboutsummaryrefslogtreecommitdiff
path: root/render.c (unfollow)
Commit message (Collapse)AuthorLines
2020-10-29tiocswinsz: fix compilation error on e.g. ppc64Daniel Eklöf-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.
2020-10-22render: blink switches between foreground and dimmed foregroundDaniel Eklöf-3/+3
2020-10-20wayland: properly restore window size when being un-tiledDaniel Eklöf-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.
2020-10-11render: resize: call sixel_reflow() after reflowing gridsDaniel Eklöf-0/+3
2020-10-11render: apply opacity correctly when in reverse video modeDaniel Eklöf-2/+8
2020-10-11render: remove render_refresh_margins()Daniel Eklöf-6/+0
2020-10-11render: term->render.margins is used to explicitly tell us to re-render marginsDaniel Eklöf-15/+7
2020-10-09render: resize: call sixel_reflow() after reflowing gridsDaniel Eklöf-0/+3
2020-10-08bell: optionally render margins in red when receiving BELDaniel Eklöf-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
2020-10-08render: apply opacity correctly when in reverse video modeDaniel Eklöf-2/+8
2020-09-29render: remove render_refresh_margins()Daniel Eklöf-6/+0
2020-09-29render: term->render.margins is used to explicitly tell us to re-render marginsDaniel Eklöf-15/+7
2020-09-17render: fix rounding errors when setting initial window size and scale != 1Daniel Eklöf-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.
2020-09-14render: best-effort attempt to set initial window size in chars when scale != 1Daniel Eklöf-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.
2020-09-10render: csd: hide buttons when title bar gets too small to fit themDaniel Eklöf-8/+16
2020-09-08Add -W,--window-size-chars, and foot.ini:initial-window-size-charsDaniel Eklöf-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
2020-09-07render: change minimum window size from 4x20 -> 1x2 (rows/cols)Daniel Eklöf-2/+2
2020-09-06grid: reflow: calculate width of composed characters correctlyDaniel Eklöf-2/+4
Before this patch, reflow called `wcwidth()` on our magic values for composed characters.
2020-09-06config: add tweak.damage-whole-windowDaniel Eklöf-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.
2020-09-03render: optionally enable heuristics that deal with private usage area charsDaniel Eklöf-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
2020-09-01render: ’redraw_margins’ is now a parameter to grid_render()Daniel Eklöf-11/+7
render_refresh_margins() now passes ’true’ here, instead of re-setting term->render.last_buf to NULL.
2020-09-01render: implement render_refresh_margins()Daniel Eklöf-2/+22
For now, it will reset term->render.last_buf to NULL, and then calls grid_render() to do a full screen refresh.
2020-08-26render: scrollback indicator: only leave room for search box when necessaryDaniel Eklöf-1/+5
2020-08-26render: scrollback indicator: subtract visible rows from populated rowsDaniel Eklöf-1/+1
This prevents the indicator from starting too high up when the number of used scrollback rows is low.
2020-08-25render: scrollback position: only count _used_ scrollback linesDaniel Eklöf-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).
2020-08-23don't use empty struct initializersDaniel Eklöf-3/+3
2020-08-15Fix some spelling mistakesCraig Barnes-1/+1
2020-08-14render: render the render timer *before* committing the main surfaceDaniel Eklöf-17/+17
2020-08-14render: render-timer: position sub-surface similar to the scrollback indicatorDaniel Eklöf-0/+5
2020-08-13render: oops... swprintf() needs to number of *chars*, not *bytes*Daniel Eklöf-1/+1
2020-08-13render: fix printf-errors in 32-bit buildsDaniel Eklöf-2/+3
2020-08-13config: add tweak.render-timer optionDaniel Eklöf-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.
2020-08-12config: make selection foreground/background colors configurableDaniel Eklöf-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.
2020-08-11render: fix compilation errors in 32-bit buildsDaniel Eklöf-6/+9
timeval.tv_usec is an 'unsigned long long' on 32-bit
2020-08-08Convert most dynamic allocations to use functions from xmalloc.hCraig Barnes-3/+9
2020-07-31config: add 'hide-when-typing'Daniel Eklöf-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.
2020-07-29render: make compiler happy; make sure 'cell_count' has been initializedDaniel Eklöf-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.
2020-07-28config: add free-form text variant to 'scrollback-indicator-format'Daniel Eklöf-3/+9
And make the empty string the new default.
2020-07-27config: rename scrollback-indicator-style to scrollback-indicator-positionDaniel Eklöf-5/+5
2020-07-27render: scrollback indicator: apply weston sub-surface quirkDaniel Eklöf-0/+2
2020-07-27render: scrollback indicator: render relative indicator "smoothly"Daniel Eklöf-7/+7
That is, don't require it to be placed on a grid row.
2020-07-26render: scrollback indicator: add top marginDaniel Eklöf-4/+4
2020-07-26config: scrollback-indicator-format: percent -> percentageDaniel Eklöf-1/+1
2020-07-26render: scrollback indicator: use black on bright blueDaniel Eklöf-2/+2
2020-07-26render: scrollback indicator: implement 'relative' and 'line' variantsDaniel Eklöf-9/+41
We now implement all combinations of 'scrollback-indicator-style' and 'scrollback-indicator-format'.
2020-07-26render: scrollback indicator: wip: implement 'fixed:percent' indicatorDaniel Eklöf-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.
2020-07-26render: search: fix subpixel argument to fcft_glyph_rasterize()Daniel Eklöf-1/+1
2020-07-25config: rename scrollback-indicator to scrollback-indicator-styleDaniel Eklöf-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
2020-07-24config: rename show-scrollback-position to scrollback-indicatorDaniel Eklöf-1/+1
2020-07-24config: add 'show-scrollback-position' option to footrcDaniel Eklöf-2/+0
2020-07-24render: add code that calculates current position in scrollbackDaniel Eklöf-0/+46
2020-07-22render: bump maximum window title length from 100 to 2048 (bytes)Daniel Eklöf-2/+1
Apparently, the max is ~8K, but lets stay on the safe side.
2020-07-15term: don't re-render last cursor cell if cursor was hiddenDaniel Eklöf-1/+2
2020-07-14term: print: write special value CELL_MULT_COL_SPACER to extra cellsDaniel Eklöf-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.
2020-07-14term: rename COMB_CHARS_LO,HI -> CELL_COMB_CHARS_LO,HIDaniel Eklöf-3/+3
2020-07-13render: render_margin: don't damage margins when rendering scroll damageDaniel Eklöf-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.
2020-07-13render: doh! flush the last surface damage *outside* of the rendering loopDaniel Eklöf-8/+8
2020-07-13render: render_margin: add 'damage_{top,bottom,left,right}' argumentsDaniel Eklöf-20/+24
2020-07-13render: render_margin(): remove top/bottom argumentsDaniel Eklöf-24/+20
All calls to render_margin() set top=true and bottom=true anyway.
2020-07-13render: merge wl surface damage for consecutive dirty rowsDaniel Eklöf-38/+55
2020-07-13render: keep lock while pushing dirty rows to worker queueDaniel Eklöf-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.
2020-07-12render: don't render cursor when it has been explicitly hiddenDaniel Eklöf-2/+2
2020-07-12render: remove most of the special handling of cursor renderingDaniel Eklöf-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
2020-07-11render: use kbd-focus instead of visual focus for hollow block cursorDaniel Eklöf-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.
2020-07-10wayland: read XCURSOR_{THEME,SIZE} in reload_xcursor themeDaniel Eklöf-2/+1
2020-07-09multi-seat: improve handling of multiple (mouse) pointersDaniel Eklöf-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
2020-07-08multi-seat: enable xcursor theme support againDaniel Eklöf-50/+40
2020-07-08wip: multi-seat supportDaniel Eklöf-3/+12
Compiles and runs, but mouse, clipboard and other things have been disabled.
2020-06-28render: sixel: regression: need to take current offset into account when early-quitting sixel ↵Daniel Eklöf-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).
2020-06-28render: sixels: break out of loop when we're sure there aren't any more visible imagesDaniel Eklöf-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).
2020-06-06render: sixel: use pixman_image_composite32()Daniel Eklöf-1/+1
2020-06-06render: cell: reset clip region also when we're NOT rendering a glyphDaniel Eklöf-1/+1
2020-06-05render: regression: don't let cell background overflow into the marginsDaniel Eklöf-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.
2020-06-04render: re-write cell clipping to use pixman destination clippingDaniel Eklöf-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.
2020-06-03render: do not allow glyphs to overflow into surrounding cellsDaniel Eklöf-37/+40
This would be done cleaner by using destination clipping in pixman, but since we have multiple threads rendering cells simultaneously, that is not possible. We also cannot use source clipping since we need to offset the destination x,y coordinates with the glyph offsets. So, roll our own clipping by not allowing the x,y offsets to go outside the cell boundaries, and adjusting the glyph offset accordingly. Closes #21
2020-06-02render: draw hollow block cursor on top of the character, not the oppositeDaniel Eklöf-2/+2
2020-05-27render: resize: don't try to signal TIOCSWINSZ on a closed ptmx FDDaniel Eklöf-1/+1
2020-05-16selection/render: sync cells' 'selected' bit before renderingDaniel Eklöf-0/+19
For performance reasons, we track whether a cell is selected or not using a bit in a cell's attributes. This makes it easy for the renderer to determine if the cells should be rendered as selected or not - it just have to look at the 'selected' bit instead of doing a complex range check against the current selection. This works nicely in most cases. But, if the cell is updated, the 'selected' bit is cleared. This results in the renderer rendering the cell normally, i.e. _not_ selected. Checking for this, and re-setting the 'selected' bit when the cell is updated (printed to) is way too expensive as it is in the hot path. Instead, sync the 'selected' bits just before rendering. This isn't so bad as it may sound; if there is no selection this is a no-op. Even if there is a selection, only those cells whose 'selected' bit have been cleared are dirtied (and thus re-rendered) - these cells would have been re-rendered anyway.
2020-05-16render: only apply transparency to the default background colorDaniel Eklöf-2/+4
2020-05-03unicode-combining: store seen combining chains "globally" in the term structDaniel Eklöf-17/+28
Instead of storing combining data per cell, realize that most combinations are re-occurring and that there's lots of available space left in the unicode range, and store seen base+combining combinations chains in a per-terminal array. When we encounter a combining character, we first try to pre-compose, like before. If that fails, we then search for the current base+combining combo in the list of previously seen combinations. If not found there either, we allocate a new combo and add it to the list. Regardless, the result is an index into this array. We store this index, offsetted by COMB_CHARS_LO=0x40000000ul in the cell. When rendering, we need to check if the cell character is a plain character, or if it's a composed character (identified by checking if the cell character is >= COMB_CHARS_LO). Then we render the grapheme pretty much like before.
2020-05-02render: don't re-instantiate the foreground pixman sourceDaniel Eklöf-6/+5
2020-05-02unicode-combine: remove utf8proc dependencyDaniel Eklöf-1/+1
We only used utf8proc to try to pre-compose a glyph from a base and combining character. We can do this ourselves by using a pre-compiled table of valid pre-compositions. This table isn't _that_ big, and binary searching it is fast. That is, for a very small amount of code, and not too much extra RO data, we can get rid of the utf8proc dependency.
2020-05-01render: de-indent #if statementDaniel Eklöf-1/+1
2020-05-01unicode-combining: completely remove unicode combining characters when feature is disabledDaniel Eklöf-0/+2
2020-05-01render: render combining charactersDaniel Eklöf-10/+33
This is basically just a loop that renders additional glyphs on top off the base glyph. Since we now need access to the row struct, for the combining characters, the function prototype for 'render_cell()' has changed. When rendering the combining characters we also need to deal with broken fonts; some fonts use positive offsets (as if the combining character was a regular character), while others use a negative offset (to be used as if you had already advanced the pen position). We handle both - a positive offset is rendered just like a regular glyph. When we see a negative offset we simply add the width of a cell first.
2020-05-01util.h: new header file defining commonly used macrosDaniel Eklöf-4/+1
2020-04-29csd: buttons: use default color table as default colorsDaniel Eklöf-3/+3
If the user hasn't configured any CSD button colors, use the color scheme's default colors for blue/green/red.
2020-04-26damage: remove 'scroll' sub structDaniel Eklöf-25/+25
There is no other types of damage but scroll damage.
2020-04-26render: make 'glyph' assignment more readableDaniel Eklöf-3/+4
2020-04-24fcft: fcft_glyph_for_wc() has been renamed to fcft_glyph_rasterize()Daniel Eklöf-2/+4
2020-04-21fcft: adjust to fcft-2.0 API changesDaniel Eklöf-10/+10
* font_*() -> fcft_*() * struct font -> struct fcft_font * struct glyph -> struct fcft_glyph * enum subpixel_order -> enum fcft_subpixel
2020-04-20render: use output's subpixel mode when rasterizing glyphsDaniel Eklöf-1/+1
2020-04-19render: search: improve handling of very long search stringsDaniel Eklöf-4/+10
2020-04-18csi: implement CSI Ps ; Ps ; Ps t reporting escape sequencesDaniel Eklöf-1/+1
A lot of the escape sequences on the "CSI Ps ; Ps ; Ps t" form are expected to return a reply. Thus, not having these implemented means we will hang if the client sends these escapes. Not all of these escapes can be meaningfully implemented on Wayland, and thus this implementation is best effort. We now support the following escapes: * 11t - report if window is iconified (always replies "no") * 13t - report window position (always replies 0,0) * 13;2t - report text area position (replies with margins, since we cannot get the window's position) * 14t - report text area size, in pixels * 14;2t - report window size, in pixels * 15t - report screen size, in pixels * 16t - report cell size, in pixels * 18t - report text area size, in cells * 19t - report screen size, in cells
2020-04-17render: resize: no need to truncate selection anymore - it's being translatedDaniel Eklöf-7/+1
2020-04-17render: resize: need to translate selection coordinatesDaniel Eklöf-2/+15
While it *looked* like the selection was working before, it really wasn't. When rendering, we're looking at the cells' attributes to determine whether they have been selected or not. When copying text however, we use the terminal's 'selection' state, which consists of 'start' and 'end' coordinates. These need to be translated when reflowing text.
2020-04-17render: resize: no need to clear the selection - just truncate if necessaryDaniel Eklöf-2/+6
2020-04-17grid: reflow: caller may now pass a list of coordinates that should be translatedDaniel Eklöf-2/+2
2020-04-16grid: grid_reflow() now translates cursor coordinatesDaniel Eklöf-34/+2
2020-04-16grid: move 'cursor' state from terminal to gridDaniel Eklöf-11/+11
This way, the 'normal' and 'alt' grids have their own cursor state, and we don't need to switch between them.