aboutsummaryrefslogtreecommitdiff
path: root/render.c (follow)
Commit message (Collapse)AuthorAgeLines
* render: remove unnecessary call to wl_surface_damage_buffer()Daniel Eklöf2024-10-06-2/+0
| | | | | The damage region(s) are translated to wl_surface_damage_buffer() calls after the entire frame has been rendered.
* render: sixels: update damage region when rendering sixelsDaniel Eklöf2024-10-05-2/+6
| | | | | | | | | | | | | | This fixes flickering when foot is forced to double-buffer (e.g when running under KDE, or smithay based compositors). Since the damage region isn't updated, the sixel images aren't included in the memcpy that is done to transfer the last frame's updated regions to the next frame. As a result, every other frame will have the sixels, while the others don't. Closes #1851
* render: do dirty/clean consistency check before rendering sixelsDaniel Eklöf2024-09-21-6/+6
| | | | | Since the sixels may render some of the cells, we want the check to happen before the sixels.
* render: double-buffer: optimization: skip clean rowsDaniel Eklöf2024-09-21-0/+5
| | | | | | | | | | | | When scanning the grid for all-dirty rows (that we can remove from the damage region we're about to memcpy from the old frame), check the row->dirty bit, and skip scanning the cells of that row altogether. We're only looking for rows where all cells are dirty - those rows can be removed from the region we copy from the old frame, since the entire row will be re-rendered anyway. If a row is clean, it *must* be copied from the old frame.
* render: (debug): assert row->dirty vs. cell->attrs.clean consistencyDaniel Eklöf2024-09-21-0/+24
|
* render: xcursor_is_valid(): don't crash when there's no theme loadedDaniel Eklöf2024-09-21-0/+2
| | | | | | | | | | | | When trying to set a custom cursor shape, we first validate it. This is done by checking against known server-side names, and then trying to load the cursor from the client side cursor theme. But, if we're using server side names, there is no theme loaded, and foot crashed. Fix by checking if we have a theme loaded, and if not, fail the cursor shape name validation.
* render: add missing include, limits.hDaniel Eklöf2024-09-15-1/+2
|
* toplevel-icon: implement OSC-1, CSI 20/21/22/23 tDaniel Eklöf2024-09-13-15/+42
| | | | | | | | | | | | | | * The toplevel icon is now set to the app-id, unless "overridden" by OSC-1 or OSC-0. * Implemented OSC-1 * OSC-0 extended to also set the icon * Implemented CSI 20 t - report window icon * Implemented CSI 21 t - report window title * Implemented CSI 22 ; 1 t - push window icon * Implemented CS 23 ; 1 t - pop window icon * Extended CSI 22/23 ; 0 t to also push/pop the icon * Verify app-id set by OSC-176 is valid UTF-8 * Verify icon set by OSC-0/1 is valid UTF-8
* toplevel-icon: set to app-id, instead of hardcoding to "foot"Daniel Eklöf2024-09-13-3/+24
| | | | And, special case "footclient", and map it to "foot".
* render: resize(): don't overflow the number of scrollback linesDaniel Eklöf2024-09-09-4/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The config system allows setting the scrollback lines to 2**32-1. However, the total number of grid lines is the scrollback lines plus the window size, and then rounded *up* to the nearest power of two. Furthermore, the number of rows is represented with a plain 'int' throughout the code base. The largest positive integer that fits in an int is 2**31-1. That however, is not a power of two. The largest positive integer, that also is a power of two, that fits in an int is 2**30, or 1073741824. Ideally, we'd just cast the line count to a 64-bit integer, and call __builtin_clzl{,l}() on it, and then take the smallest value of that, or 2**30. But, for some reason, __builtin_clzl(), and __builtin_clzll() appears to ignore bits above 32, despite they being typed to long and long long. Bug? Instead, ensure we never call __builtin_clz() on anything larger than 2**30. Closes #1828
* add setting for strikeout thicknessOleh Hushchenkov2024-08-26-2/+12
|
* render: follow cursor.unfocused-style regardless of cursor.styletokyo4j2024-08-20-12/+12
| | | | | Before this commit, cursor.unfocused-style was effective only with cursor.style=block
* csd: track pointer when rendering and handling CSD button clicksDaniel Eklöf2024-08-09-3/+32
| | | | | | | | | | | | | | | | | | | | * Render button as highlighted only when pointer is above them * Releasing the mouse button while *not* on the button does *not* activate the button When pressing, and holding, a mouse button, the compositor keeps sending motion events for the surface where the button was pressed, even if the mouse has moved outside it. We also don't get any surface leave/enter events. This meant that the button was rendered as highlighted, and a click registered, if the user pressed the mouse button while on the button, and then moved the cursor away from the button before releasing the button. This patch fixes it, by checking if the current cursor coordinates fall within the button surface.
* Remove a number of unused includesDaniel Eklöf2024-08-02-1/+0
|
* csi: in-band window resize notifications, private mode 2048Daniel Eklöf2024-07-19-0/+2
| | | | | | | | | | | | | This implements https://gist.github.com/rockorager/e695fb2924d36b2bcf1fff4a3704bd83, in-band window resize notifications. When user enables private mode 2048 (in-band resize notifications), *always* send current size, even if the mode is already active. This ensures applications can rely on getting a reply from the terminal.
* render: hollow-cursor: use correct cursor colorDaniel Eklöf2024-07-13-1/+1
|
* render: cursor: use default fg/bg if cell fg/bg are the sameDaniel Eklöf2024-07-13-0/+8
| | | | | | | When deciding which colors to use for the cursor, and the cursor text and background colors are the same, use the default fg/bg instead. Closes #1761
* osc: merge OSC 10/11/12/17/19 handlingDaniel Eklöf2024-07-03-4/+4
| | | | | | | | | | 10/11/17/19 were already merged, so this patch just stops special casing 12 (cursor color). In preparation for XTPUSHCOLORS/XTPOPCOLORS, the cursor colors are moved from their own struct, into the 'colors' struct. Also fix a bug where OSC 17/19 queries returned OSC-11 data.
* render: fix "maybe-uninitialized" error in draw_styled_underline()Craig Barnes2024-07-03-2/+3
| | | | | | | | | | | | | | | | | | Reproducer: CFLAGS='-Og -g' meson setup --buildtype=debug bld ninja -C bld Error message: ../render.c: In function ‘draw_styled_underline’: ../render.c:490:19: error: ‘y_ofs’ may be used uninitialized [-Werror=maybe-uninitialized] 490 | const int top = y + y_ofs; | ^~~ ../render.c:405:9: note: ‘y_ofs’ was declared here 405 | int y_ofs; | ^~~~~
* Rename various uses of "curly" in the source code with "underline"Craig Barnes2024-07-01-31/+31
| | | | | Since "curly" could make it seem as if all underline styles are curled (to people unfamiliar with the codebase), whereas in reality only 1 is.
* render: cursor color: remove assertion that both cursor fg/bg be setDaniel Eklöf2024-07-01-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | Before this patch, we asserted both the cursor foreground, and background colors had been set. This is true in most cases; the config system enforces it. It is however possible to set only the cursor background color, while leaving the foreground (text) color unset: * Use a foot config that does *not* configure the cursor colors. This means foot will invert the default fg/bg colors when rendering the cursor. * Override the cursor color using an OSC-12 sequence. OSC-12 only sets the background color of the cursor, and there is no other OSC sequence to set the cursor's text color. To handle this, remove the assertion, and simply split the logic for the cursor backgound and foreground colors: * Use the configured background color if set (either through config or OSC-12), otherwise use the default foreground color. * Use the configured foreground color if set (through config), otherwise use the default background color.
* render: draw_styled_underline(): respect main.underline-thicknessDaniel Eklöf2024-06-27-4/+19
| | | | | Also refactor a bit, and break out early to draw_underline() for legacy underlines.
* render: underlines: improve the appearance of the 'dotted' styleDaniel Eklöf2024-06-27-6/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Try to make the 'dotted' style appear more even, and less like each cell is rendered separately (even though they are). Algorithm: Each dot is a square; it's sides are that of the font's line thickness. The spacing (gaps) between the dots is initially the same width as the dots themselves. This means the number of dots per cell is the cell width divided by the dots' length/width, divided by two. At this point, there may be "left-over" pixels.I.e. the widths of the dots and the gaps between them may not add up to the width of the cell. These pixels are evenly (as possible) across the gaps. There are still visual inaccuracies at small font sizes. This is impossible to fix without changing the way underlines are rendered, to render an entire line in one go. This is not something we want to do, since it'll make styled underlines, for a specific cell/character, look differently, depending on the surrounding context.
* render: underlines: minor perf-tweak: early break outDaniel Eklöf2024-06-26-0/+3
| | | | | When looking up the extender underline range, break out early if we see that there can't possibly be any ranges matching the current column.
* render: resize: copy styled underlines to temporary gridDaniel Eklöf2024-06-26-0/+23
| | | | | | | | | | | | When doing an interactive resize, we create a small grid copy of the current viewport, and then do a non-reflow resize. When the interactive resize is done, we do a proper reflow. This is for performance reasons. When creating the viewport copy, we also need to copy the styled underlines. Otherwise, styled underlines will be rendered as plain underlines *while resizing*.
* render: styled underlinesDaniel Eklöf2024-06-26-1/+118
| | | | | | | | This was originally contributed by @kraftwerk28 in https://codeberg.org/dnkl/foot/pulls/1099 Here, we re-use the rendering logic only, as attribute tracking has been completely rewritten.
* csi: wip: styled underlinesDaniel Eklöf2024-06-26-2/+37
| | | | | | | | | | | | | This is work in progress, and fairly untested. This adds initial tracking of styled underlines. Setting attributes seems to work (both color and underline style). Grid reflow has *not* been tested. When rendering, style is currently ignored (all styles are rendered as a plain, legacy underline). Color however, *is* applied.
* render: single-pixel: minor optimizationDaniel Eklöf2024-05-22-15/+32
| | | | | | | | | | | | | | Don't re-create the single-pixel buffer, unless necessary. The buffer itself doesn't have a size. That means we can re-use the buffer if the last frame's overlay style matches the current frame's style. What we *do not* know is whether the current frame's size is the same as the last frame's. This means we still have to set the viewport destination, and commit the surface.
* render: use single-pixel buffers for overlays, when possibleDaniel Eklöf2024-05-22-8/+70
| | | | | | | | | | | | | | | | | | | The unicode-mode, and flash overlays are single color buffers. This means we can use the single-pixel buffer protocol. It's undefined whether the compositor will release the buffer or not; to make things easier, simply destroy the buffer as soon as we've committed it. Note that since compositors don't necessarily release single-pixel buffers, we can't plug them into our own buffer interface. This means we can't use buffer pointers to check if we can re-use the previous buffer (i.e. we can skip comitting a new buffer), or if we have to create a new one. It's _almost_ enough to just check if the last overlay style is the same as the current one. Except that that doesn't take window resizes into account...
* unicode-mode: move state from seat to termDaniel Eklöf2024-05-21-10/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes an issue where entering unicode-mode in one foot client, also enabled unicode-mode on other foot clients. Both visually (although glitchy), and in effect. The reason the state was originally in the seat objects, was to fully support multi-seat. That is, one seat/keyboard entering unicode-mode should not affect other seats/keyboards. The issue with this is that seat objects are Wayland global. Thus, in server mode, all seat objects are shared between the foot clients. There is a similarity with IME, which also keeps state in the seat. There's one big difference, however, and that is IME has Wayland native enter/leave events, that the compositor emits when windows are focused/unfocused. These events allow us to reset IME state. For our own Unicode mode, there is nothing similar. This patch moves the Unicode state from seats, to the terminal struct. This does mean that if one seat/keyboard enters Unicode mode, then *all* seats/keyboards will affect the unicode state. This potential downside is outweighed by the fact that different foot clients no longer affect each other. Closes #1717
* config: add cursor.unfocused-styleDaniel Eklöf2024-04-10-7/+20
| | | | | | | | | | | | | | | This option controls how we render the cursor when the terminal window is unfocused. Possible values are: * hollow: the default, and how we rendered the cursor before this patch. * unchanged: render the cursor exactly the same way as when the window is focused. * none: do not render any cursor at all Closes #1582
* wayland: skip loading cursor theme when using server side cursorsDaniel Eklöf2024-03-16-1/+1
| | | | | We don't need the client side cursor theme when using server side cursors.
* cursor-shape: improve xcursor fallback support, and prefer CSS namesDaniel Eklöf2024-03-01-20/+30
| | | | | | | | | | | | | | Before this patch, we used legacy X11 xcursor names, and didn't really have any fallback handling in place (we only tried to fallback to "xterm", regardless of which cursor shape we were trying to load). This patch changes two things: 1. Improved fallback support. cursor_shape_to_string() now returns a list of strings. This allows us to have per-shape fallbacks, and any number of fallbacks. 2. We prefer CSS xcursor names over legacy X11 names.
* render: don't try to set a NULL xcursor imageDaniel Eklöf2024-02-29-2/+17
| | | | | | | | | | | | | | | | | | | render_xcursor_update() is called when we've loaded a new xcursor image, and needs to display it. The reason it's not pushed to the compositor immediately is to ensure we don't flood the Wayland socket with xcursor updates. Normally, it's only called when we *succeed* to load a new xcursor image. I.e. if we try to load a non-existing xcursor image, we never schedule an update. However, we _can_ still end up in render_xcursor_update() without a valid xcursor image. For example, we have loaded a valid xcursor image, and scheduled an update. But before the update runs, the user moves the cursor, and we try to load a new xcursor image. If it fails, we crash when the previously scheduled update finally runs. Closes #1624
* shm: use XRGB surfaces when we know we wont be using transparencyDaniel Eklöf2024-02-21-7/+10
|
* render: always center grid when fullscreened or maximizedDaniel Eklöf2024-02-15-1/+5
|
* osc: add support for osc 176 (app ID)delthas2024-02-06-0/+22
| | | | | | | | | | This adds support for a new OSC escape sequence: OSC 176, that lets terminal programs tell the terminal the name of the app that is running. foot then sets the app ID of the toplevel to that ID, which lets the compositor know which app is running, and typically sets the appropriate icon, window grouping, ... See: https://gist.github.com/delthas/d451e2cc1573bb2364839849c7117239
* term: drop term->render.title.is_armedDaniel Eklöf2024-02-06-3/+0
| | | | | | | | | | | | | | | | | This boolean isn't needed. The idea was probably to not re-program the timer unnecessarily, or even to prevent it from being moved forward in time indefinitely. However, the logic has (probably) gone through some changes, that now makes it irrelevant. The timer isn't moved forward indefinitely; it is always set to 8ms from the last title update. The closer we get to that point in time, the smaller the timeout we set. Now, is_armed _did_ prevent the timer from being re-programmed. But that tiny performance tweak isn't really necessary, as the title should, in normal cases, not be set that often anyway.
* Don't use fancy Unicode quotes, stick to ASCIIDaniel Eklöf2024-02-06-53/+53
|
* feature: add resize-by-cells option to constrain window sizes...Andrew J. Hesford2024-02-05-34/+53
| | | | | ...to multiples of the cell size, and preserve grid size when changing fonts or display scales in floating windows.
* util: add streq() function and use in place of strcmp(...) == 0Craig Barnes2024-02-05-2/+2
|
* Replace unchecked allocations with calls to xmalloc.h functionsCraig Barnes2024-01-25-1/+1
|
* render: sixel: regression: wrong cell color behind opaque sixelsDaniel Eklöf2023-10-13-1/+1
| | | | | | | | | | | | | | An opaque sixel that isn't a multiple of the cell size will have some cells partially visible (either the entire last row, the entire last column, or both). These must be rendered before blitting the sixel. f5f2f5a954ee6cf3532a6aba023860ada183d486 introduced a regression, where all such cells were rendered as if the cursor was there, giving them the wrong appearance. Closes #1520
* render: fix surface damage when rendering sixels.Daniel Eklöf2023-10-12-9/+10
| | | | | | | | | | Pass a damage region to render_row()/render_cell() when rendering partially visible cells underneath a sixel. This ensures the affected regions are later reported as 'damaged' to the Wayland compositor. Closes #1515
* term: cache font baselineDaniel Eklöf2023-10-10-8/+8
| | | | | No need to redo the calculation for every single cell we render, every frame...
* render: better description of why we disable transparency in fullscreenDaniel Eklöf2023-10-10-13/+23
|
* Enable the use of flash as visual bellRaimund Sacherer2023-10-10-2/+4
| | | | | | With this patch we can configure flash in the bell section. The colors section allow now to configure the color and translucency of the flash.
* render: more fine-grained wayland surface damage trackingDaniel Eklöf2023-10-10-46/+49
| | | | | | | | | Before this patch. Wayland surface damage tracking was done on a per-row basis. That is, even if just one cell was updated, the entire row was "damaged". Now, damage is per cell. This hopefully results in lower latencies in many use cases, and especially on high DPI monitors.
* render: disable transparency in margins when in fullscreenDaniel Eklöf2023-10-07-2/+11
| | | | | | | This amends 899b768b744c74e88e54e6d8eb32f53accea79d8, where we started disabling transparency in fullscreen Closes #1503
* Codespell fixesDaniel Eklöf2023-10-03-2/+2
|
* wayland: cursor-shape-v1 is now always availableDaniel Eklöf2023-08-07-2/+0
| | | | Since we're requiring wayland-protocols >= 1.32
* render: OSD: center text verticallyDaniel Eklöf2023-07-31-9/+16
| | | | | | | | | | | | Rewrite render_osd(), and instead of passing in an y-offset, let render_osd() itself center the text inside the OSD buffer. This is done using the same baseline calculation term_font_baseline() does, except we use the buffer height instead of the line height. Note that most OSDs are sized based on the line height... Closes #1430
* --window-size-chars: ensure width/height are valid for current scaling factorDaniel Eklöf2023-07-30-16/+3
| | | | | | | | | | Before this patch, we didn’t ensure width and height were valid for the current scaling factor, when fractional scaling _is_ available. That is, we didn’t ensure the width/height values multiplied back to their original values after dividing with the scaling factor. Closes #1446
* fractional scaling: another round(!) of rounding fixesDaniel Eklöf2023-07-28-63/+69
| | | | | | | * Ensure buffer sizes are valid. That is, ensure that size / scale * scale == size. * Do size calculation of the window geometry in the same way we calculate the CSD offsets.
* render: round scaled border/title/button widthsDaniel Eklöf2023-07-28-11/+27
| | | | | | | | And calculation of compounded offsets/widths/heights, to compensate for compositor rounding when positioning and scaling/sizing subsurfaces. Closes #1441
* config: add tweak.bold-text-in-bright-amountDaniel Eklöf2023-07-28-1/+3
| | | | | | | | By how much to increase the luminance when brightening bold fonts. This was previously hard-coded to a factor of 1.3, which is now the default value of the new config option. Closes #1434
* render: revert part of a36f67cbe311bebd9321fbf58773dace8128fcd7Daniel Eklöf2023-07-28-2/+2
| | | | | | | | | | | render_osd() shouldn't use term_font_baseline(). This is because term_font_baseline() uses the line height to determine the position, while render_osd() renders to surfaces that aren't sized like the grid. This fixes a regression, where the CSD title were sometimes rendered too high up, and sometimes too low.
* scaling: always round the scaling factor when converting to intDaniel Eklöf2023-07-25-43/+68
| | | | | | | | | * In all calls to wl_subsurface_set_position() * (wp_viewport_set_destination() already does this) * Whenever we use the scale to calculate margins (search box, scrollback indicator etc) * Since the scaling factor is stored as a float (and not a double), use roundf() instead of round()
* render: apply new baseline calculation everywhereDaniel Eklöf2023-07-25-21/+10
| | | | | | | | * URL jump labels * Scrollback position indicator * Line/box drawings characters Closes #1430
* render: change baseline calculation, to center it within the lineDaniel Eklöf2023-07-21-1/+6
| | | | | | | Before this patch, fonts were anchored to the top of the line. With this patch, it is instead centered. Closes #1302
* render: OSD: don’t mark surface as being opaque, when it’s notDaniel Eklöf2023-07-19-6/+9
|
* render: disable transparency when we’re fullscreenedDaniel Eklöf2023-07-19-2/+29
| | | | | | | | | | | | | | | The wayland protocol recommends (or mandates?) that compositors render a black background behind fullscreened transparent windows. I.e. you never see what’s _actually_ behind the window. So, if you have a white, but semi-transparent background in foot, it’ll be rendered in a shade of gray. Given this, it’s better to simply disable transparency while we’re fullscreened. That way, we at least get the "correct" background color. Closes #1416
* terminal: break out scaling factor updating, and reduce number of calls to render_resize()Daniel Eklöf2023-07-18-22/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Break out the logic that updates the terminal’s scaling factor value, from render_resize(), to a new function, term_update_scale(). This allows us to update the scaling factor without a full grid resize. We also change how we pick the scaling factor (when fractional scaling is not in use). Before, we’d use the highest scaling factor from all monitors we were mapped on. Now, we use the scaling factor from the monitor we were *last* mapped on. Then, add a boolean parameter to term_set_fonts(), and when false, *don’t* call render_resize_force(). Also change term_font_dpi_changed() to only return true if the font was changed in any way. Finally, rewrite update_term_for_output_change() to: * Call term_update_scale() before doing anything else * Call render_resize{,_force} *last*, and *only* if either the scale or the fonts were updated. This fixes several things: * A bug where we failed to update the fonts when fractional scaling was in use, and we guessed the initial scale/DPI wrong. The bug happened because updated the internal "preferred" scale value, and a later call to render_resize() updated the terminal’s scale value, but since that code path didn’t call term_font_dpi_changed() (and it shouldn’t), the fonts weren’t resized properly. * It ensures we only resize the grid *once* when the scaling factor, or DPI is changed. Before this, we’d resize it twice. And this happened when e.g. dragging the window between monitors.
* render: fix xcursor scaling with fractional-scale-v1Daniel Eklöf2023-07-18-5/+7
| | | | | | This worked just after the fractional-scaling branch was merged, but was then broken by the cursor-shape branch, due to a bad rebase of that branch.
* render: use rounding for fractional scaleRonan Pigott2023-07-16-2/+2
| | | | | If we truncate the buffer dimensions we may accidentally submit a buffer with inappropriate size.
* render: don’t invert cursor colors when custom colors are being usedDaniel Eklöf2023-07-14-11/+3
| | | | | | | | | | | | When the user has configured custom cursor colors (cursor.color is set in foot.ini), don’t invert those colors when the cell is either selected, or has the ‘reverse’ attribute set. This aligns foot’s behavior with Alacritty, Kitty and Wezterm. Contour also behaves similarly, except mouse selections override the cursor colors (turning the cursor invisible). Closes #1347
* render: move variables inside #ifdef, as they’re not used outside of itDaniel Eklöf2023-07-03-1/+1
|
* cursor-shape: use server-side cursors for custom (OSC-22), if possibleDaniel Eklöf2023-07-03-29/+63
| | | | | | | | | | | | Using a lookup table, try to map the user-provided xcursor string to a cursor-shape-v1 known shape. If we succeed, set the user’s custom cursor using server side cursors (i.e. using cursor-shape-v1). If not, fallback to trying to load the image ourselves (using wl_cursor_theme_get_cursor()), and set it using the legacy wl_pointer_set_cursor().
* render: don’t (can’t) use cursor-shape-v1 when user has set a custom cursorDaniel Eklöf2023-07-03-3/+8
| | | | | Well, we _could_, but we’d have to reverse map the string to a cursor-shape-v1 enum value. Let’s not do that, for now at least.
* render: debug log which method we use to set the xcursorDaniel Eklöf2023-07-03-0/+3
|
* cursor-shape: add support for server side cursor shapesDaniel Eklöf2023-07-03-17/+30
| | | | | | | | | | | | | This implements support for the new cursor-shape-v1 protocol. When available, we use it, instead of client-side cursor surfaces, to select the xcursor shape. Note that we still need to keep client side pointers, for: * backward compatibility * to be able to "hide" the cursor Closes #1379
* refactor: track current xcursor using an enum, instead of a char pointerDaniel Eklöf2023-07-03-9/+15
|
* sixel: re-scale images when the cell dimensions changeDaniel Eklöf2023-06-30-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Before this patch, when the cell dimensions changed (i.e. when the font size changes), sixel images were either removed (the new cell dimensions are smaller than the old), or simply kept at their original size (new cell dimensions are larger). With this patch, sixels are instead resized. This means a sixel *always* occupies the same number of rows and columns, regardless of how much the font size is changed. This is done by maintaining two sets of image data and pixman images, as well as their dimensions. These two sets are the new ‘original’ and ‘scaled’ members of the sixel struct. The "top-level" pixman image pointer, and the ‘width’ and ‘height’ members either point to the "original", or the "scaled" version. They are invalidated as soon as the cell dimensions change. They, and the ‘scaled’ image is updated on-demand (when we need to render a sixel). Note that the ‘scaled’ image is always NULL when the current cell dimensions matches the ones used when emitting the sixel (to save run-time memory). Closes #1383
* wayland: refactor: surface_scale(): pass wl_window pointer, instead of wayland globalDaniel Eklöf2023-06-29-5/+6
|
* wayland: refactor: add a buffer argument to wayl_*_scale() functionsDaniel Eklöf2023-06-29-11/+17
| | | | | This will be needed later, when using fractional scaling + viewporter to scale.
* wayland: refactor: wayl_surface_scale(): pass wayl_surface pointerDaniel Eklöf2023-06-29-33/+28
| | | | | | | | Instead of passing a raw wl_surface pointer, pass a wayl_surface pointer. This is needed later, when using fractional scaling to scale the surface (since then we need the surface’s viewport object).
* wayland: refactor: wrap wl_surface pointers in a wayl_surface structDaniel Eklöf2023-06-29-50/+50
| | | | | | | | | And add a viewport object to accompany the surface (to be used when scaling the surface). Also rename the wl_surf_subsurf struct to wayl_sub_surface, and add a wayl_surface object to it, rather than a plain wl_surface pointer (to also get the viewport pointer).
* wayland: add wayl_surface_scale(), and wayl_win_scale()Daniel Eklöf2023-06-29-34/+13
| | | | | | | These functions scale a surface+buffer. For now, only using the legacy scaling method (wl_surface_set_buffer_scale()).
* render: maybe_resize(): convert local variable ‘scale’ to floatDaniel Eklöf2023-06-29-8/+13
|
* render: xcursor_update(): convert local ‘scale’ variable to floatDaniel Eklöf2023-06-29-1/+1
|
* render: urls(): round scaling factorDaniel Eklöf2023-06-29-1/+1
|
* render: search_box(): round scaling factorDaniel Eklöf2023-06-29-1/+1
|
* render: render_timer(): round scaling factorDaniel Eklöf2023-06-29-1/+1
|
* render: csd_border: round scaled border width, instead of truncatingDaniel Eklöf2023-06-29-4/+3
|
* render: draw_unfocused_block(): round scale, instead of truncatingDaniel Eklöf2023-06-29-1/+1
|
* term: convert ‘scale’ to a floatDaniel Eklöf2023-06-29-12/+12
|
* render: resize: fix crash when reflowing the alt screenDaniel Eklöf2023-06-20-3/+7
| | | | | | | | | | | | | | | | When doing an interactive resize, and `resize-delay-ms` > 0 (the default), we would crash if the original screen size (i.e. the size before the interactive resize started) was larger than the last window size. For example, if we interactively go from 85 rows to 75, and then non-interactively went from 75 to 80, we’d crash. The resizes had to be made in a single go. One way to trigger this was to start an interactive resize on a floating window, and then *while resizing* toggle the window’s floating mode. Closes #1377
* customized gnome-like csd buttonslocture2023-05-18-72/+107
|
* quirks: sway does not damage surface beneath sub-surface, when unmappedDaniel Eklöf2023-05-12-1/+10
| | | | | | | | | | | | | | | | | | | | | When unmapping a sub-surface, Sway <= 1.8 does not damage the surface beneath the sub-surface. https://github.com/swaywm/sway/issues/6960 The workaround is to manually damage the main surface. Previously, this was done when exiting scrollback search, and after the ‘flash’ OSC. But other sub-surfaces, that may also be unmapped, did not. This patch adds a quirk handler that does this, and calls it when: * Exiting scrollback search * Ending the ‘flash’ OSC * Exiting unicode input mode * Clearing URL labels * Removing the scrollback position indicator Closes #1335
* render: regression: keep empty bottom scroll margin empty after resizeDaniel Eklöf2023-04-12-1/+4
|
* render: ensure scroll region’s endpoint is valid after a window resizeDaniel Eklöf2023-04-12-2/+1
| | | | | | | | | If we had a non-empty bottom scroll region, and the window was resized to a smaller size, the scroll region was not reset correctly. This led to a crash when scrolling the screen content. Fix by making sure the scroll region’s endpoint is within range.
* render: protect against integer underflow when calculating scroll areaDaniel Eklöf2023-03-30-6/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | When applying scroll damage, we calculate the affected region’s height (in pixels), by subtracting the number of rows to scroll, from the scrolling region, and finally multiply by the cell height. If the number of rows to scroll is very large, the subtraction may underflow, resulting in a very large height value instead of a negative one. This caused the check for "scrolling too many lines" to fail. That in turn resulted in an integer overflow when calculating the source offset into the rendered surface buffer, which typically triggered a segfault. This bug happened when there was continuous output in the terminal without any new frames being rendered. This caused a buildup of scroll damage, that triggered the underflow+overflow when we finally did render a new frame. For example, a compositor that doesn’t send any frame callbacks (for example because the terminal window is minimized, or on a different workspace/tag) would cause this. Closes #1305
* render: fix glitchy selection while resizing the ‘normal’ screenDaniel Eklöf2023-03-27-0/+6
| | | | | | | | | | | The selection coordinates are in absolute row numbers. As such, selection breaks when interactively resizing the normal grid, since we then instantiate a temporary grid mapping directly to the current viewport (for performance reason, to avoid reflowing the entire grid over and over again). Fix by stashing the actual selection coordinates, and ajusting the "active" ones to the temporary grid.
* render: resize: call xdg_toplevel_set_min_size()Daniel Eklöf2023-03-02-9/+8
| | | | This is a hint to the compositor, not to set a smaller size than this.
* render: fix inversed cursor fg color when alpha != 1.0, take #2Daniel Eklöf2023-02-28-6/+5
| | | | | | | | No need to check if terminal colors have been reversed - this is done by the cell rendering logic. This hopefully fixes all remaining issues with invisible text when background alpha < 1.0
* render: fix selected cursor cell being ‘invisble’ when background alpha is usedDaniel Eklöf2023-02-27-1/+1
| | | | | ... by taking the cell ‘selected’ state into account when determining whether to use the default fg or bg as the ‘text’ color.
* render: fix incorrect indent introduced by previous commitCraig Barnes2023-01-17-1/+1
|
* render: fix double-width glyphs glitching when surrounding cells overflow into itDaniel Eklöf2023-01-17-6/+10
| | | | | | | | | | | | | | | | | | | | | | | If cells overflowed (for example, by using an italic font that isn’t truly monospaced) into a double-width glyph (that itself is *not* overflowing), then the double-width glyph would glitch when being rendered; typically the second half of it would occasionally disappear. This happened because we tried to rasterize the second cell of the double-width glyph. This cell contains a special “spacer” value. Rasterizing that typically results the font’s “not available” glyph. If _that_ glyph overflows, things broke; we’d later end up forcing a re-render of it (thus erasing half the double-width glyph). But since the double-width glyph _itself_ doesn’t overflow, _it_ wouldn’t be re-rendered, leaving it half erased. Fix by recognizing spacer cells, and not trying to rasterize them (set glyph count to 0, and cell count to 1). Closes #1256
* render: maybe_resize(): remove debug assertDaniel Eklöf2022-11-01-1/+0
| | | | | This, depending on which compiler being used, caused issues not only in debug builds, but release builds as well (with NDEBUG defined).
* render: never apply alpha to text colorDaniel Eklöf2022-10-30-1/+8
| | | | | | | | | | | | | | | | | | | | | | When drawing a block cursor using inversed fg/bg colors, we didn’t strip the alpha from the background color. This meant that the text "behind" the cursor was rendered with transparency. If alpha was set to 0, the text was completely invisible. We should never apply alpha to the text color. So, detect this, and force alpha to 1.0. Normally, when selecting the cursor’s color, we don’t really know _where_ the background color is coming from (or more accurately, _what_ it is). However, the *only* background color that can have a non-1.0 alpha is the *default* background color. This is why we can ignore the bg parameter, and use term->colors.fg/bg instead. Closes #1205