aboutsummaryrefslogtreecommitdiff
path: root/render.c (unfollow)
Commit message (Collapse)AuthorLines
2023-07-25scaling: always round the scaling factor when converting to intDaniel Eklöf-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()
2023-07-25render: apply new baseline calculation everywhereDaniel Eklöf-21/+10
* URL jump labels * Scrollback position indicator * Line/box drawings characters Closes #1430
2023-07-21render: change baseline calculation, to center it within the lineDaniel Eklöf-1/+6
Before this patch, fonts were anchored to the top of the line. With this patch, it is instead centered. Closes #1302
2023-07-19render: OSD: don’t mark surface as being opaque, when it’s notDaniel Eklöf-6/+9
2023-07-19render: disable transparency when we’re fullscreenedDaniel Eklöf-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
2023-07-18terminal: break out scaling factor updating, and reduce number of calls to render_resize()Daniel Eklöf-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.
2023-07-18render: fix xcursor scaling with fractional-scale-v1Daniel Eklöf-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.
2023-07-16render: use rounding for fractional scaleRonan Pigott-2/+2
If we truncate the buffer dimensions we may accidentally submit a buffer with inappropriate size.
2023-07-14render: don’t invert cursor colors when custom colors are being usedDaniel Eklöf-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
2023-07-03render: move variables inside #ifdef, as they’re not used outside of itDaniel Eklöf-1/+1
2023-07-03cursor-shape: use server-side cursors for custom (OSC-22), if possibleDaniel Eklöf-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().
2023-07-03render: don’t (can’t) use cursor-shape-v1 when user has set a custom cursorDaniel Eklöf-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.
2023-07-03render: debug log which method we use to set the xcursorDaniel Eklöf-0/+3
2023-07-03cursor-shape: add support for server side cursor shapesDaniel Eklöf-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
2023-07-03refactor: track current xcursor using an enum, instead of a char pointerDaniel Eklöf-9/+15
2023-06-30sixel: re-scale images when the cell dimensions changeDaniel Eklöf-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
2023-06-29wayland: refactor: surface_scale(): pass wl_window pointer, instead of wayland globalDaniel Eklöf-5/+6
2023-06-29wayland: refactor: add a buffer argument to wayl_*_scale() functionsDaniel Eklöf-11/+17
This will be needed later, when using fractional scaling + viewporter to scale.
2023-06-29wayland: refactor: wayl_surface_scale(): pass wayl_surface pointerDaniel Eklöf-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).
2023-06-29wayland: refactor: wrap wl_surface pointers in a wayl_surface structDaniel Eklöf-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).
2023-06-29wayland: add wayl_surface_scale(), and wayl_win_scale()Daniel Eklöf-34/+13
These functions scale a surface+buffer. For now, only using the legacy scaling method (wl_surface_set_buffer_scale()).
2023-06-29render: maybe_resize(): convert local variable ‘scale’ to floatDaniel Eklöf-8/+13
2023-06-29render: xcursor_update(): convert local ‘scale’ variable to floatDaniel Eklöf-1/+1
2023-06-29render: urls(): round scaling factorDaniel Eklöf-1/+1
2023-06-29render: search_box(): round scaling factorDaniel Eklöf-1/+1
2023-06-29render: render_timer(): round scaling factorDaniel Eklöf-1/+1
2023-06-29render: csd_border: round scaled border width, instead of truncatingDaniel Eklöf-4/+3
2023-06-29render: draw_unfocused_block(): round scale, instead of truncatingDaniel Eklöf-1/+1
2023-06-29term: convert ‘scale’ to a floatDaniel Eklöf-12/+12
2023-06-20render: resize: fix crash when reflowing the alt screenDaniel Eklöf-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
2023-05-18customized gnome-like csd buttonslocture-72/+107
2023-05-12quirks: sway does not damage surface beneath sub-surface, when unmappedDaniel Eklöf-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
2023-04-12render: regression: keep empty bottom scroll margin empty after resizeDaniel Eklöf-1/+4
2023-04-12render: ensure scroll region’s endpoint is valid after a window resizeDaniel Eklöf-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.
2023-03-30render: protect against integer underflow when calculating scroll areaDaniel Eklöf-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
2023-03-27render: fix glitchy selection while resizing the ‘normal’ screenDaniel Eklöf-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.
2023-03-02render: resize: call xdg_toplevel_set_min_size()Daniel Eklöf-9/+8
This is a hint to the compositor, not to set a smaller size than this.
2023-02-28render: fix inversed cursor fg color when alpha != 1.0, take #2Daniel Eklöf-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
2023-02-27render: fix selected cursor cell being ‘invisble’ when background alpha is usedDaniel Eklöf-1/+1
... by taking the cell ‘selected’ state into account when determining whether to use the default fg or bg as the ‘text’ color.
2023-01-17render: fix incorrect indent introduced by previous commitCraig Barnes-1/+1
2023-01-17render: fix double-width glyphs glitching when surrounding cells overflow into itDaniel Eklöf-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
2022-11-01render: maybe_resize(): remove debug assertDaniel Eklöf-1/+0
This, depending on which compiler being used, caused issues not only in debug builds, but release builds as well (with NDEBUG defined).
2022-10-30render: never apply alpha to text colorDaniel Eklöf-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
2022-10-23render: resize: do full text reflow immediately if resize-delay-ms == 0Daniel Eklöf-2/+3
That is, skip all custom grid handling when doing an interactive resize, if resize-delay-ms == 0.
2022-10-17interactive resize: improve user experienceDaniel Eklöf-60/+81
Re-initialize the temporary ‘normal’ grid instance each time we receive a configure event while doing an interactive resize. This way, window content will not be "erased" when the window is first made smaller, then larger again. And, if the viewport is up in the scrollback history, increasing the window size will reveal more of the scrollback, instead of just being black. The last issue is the cursor; it’s currently not "stuck" where it should be. Instead, it follows the window around. This is due to two things: 1) the temporary grid we create is large enough to contain the current viewport, but not more than that. That means we can’t "scroll up", to hide the cursor. 2) grid_resize_without_reflow() doesn’t know anything about "interactive resizing". As such, it will ensure the cursor is bound to the new grid dimensions. I don’t yet have a solution for this. This patch implements a workaround to at least reduce the impact, by simply hiding the cursor while we’re doing an interactive resize.
2022-10-10render: rename term->render.resizing -> term->interactive_resizingDaniel Eklöf-29/+39
But also, more importantly, logical fixes: * Stash the number of new scrollback lines the stashed ‘normal’ grid should be resized *to*. There’s also a couple of performance changes here: * When doing a delayed reflow (tiocswinsz timer), call sixel_reflow_grid(term, &term->normal) - there’s no need to reflow sixels in the ‘alt’ screen. * When doing a delayed reflow, free all scroll damage. It’s not needed, since we’re damaging the entire window anyway. * Use minimum size for the temporary ‘normal’ grid (that contains the current viewport). We just need it to be large enough to fit the current viewport, and be a valid grid row count (power of 2). This just so happens to be the current ‘alt’ grid’s row count...
2022-10-10render: resize: do delayed reflow immediately when failing to arm tiocswinsz timerDaniel Eklöf-1/+3
2022-10-10render: delayed reflow: not enough to damage current view; need to refresh tooDaniel Eklöf-1/+3
2022-10-10render: resize: ignore ptmx read events during interactive resizeDaniel Eklöf-0/+4
2022-10-10render: performance improvements during interactive resizeDaniel Eklöf-5/+37
Instead of copying the entire grid when an interactive resize is started, stash the complete grid (to be used in the final reflow). Copy the current viewport only, to be used during the interactive resize. This gets rid of the initial "pause" when snapshotting the grid when an interactive resize is started.
2022-10-10render: delay reflow for ‘resize-delay-ms’ millisecondsDaniel Eklöf-13/+105
Reflowing a large scrollback is *slow*. During an interactive resize, it can easily take long enough that the compositor fills the Wayland socket with configure events. Eventually, the socket becomes full and the compositor terminates the connection, causing foot to exit. This patch is work-in-progress, and the first step towards alleviating this. It delays the reflow by: * Snapshotting (copying) the original grid when an interactive resize is started. * While resizing, we apply a simple truncation resize of the grid (like we handle the alt screen). * When the resize is done, or paused for ‘resize-delay-ms’, the grid is reflowed. TODO: we *must* not allow any changes to the temporary (truncated) grid during the resize. Any changes to the grid would be lost when the final reflow is applied. That is, we must completely pause the ptmx pipe while a resize is in progress. Future improvements: The initial copy can be slow. We should be able to avoid it by rewriting the reflow algorithm to not free anything. This is complicated by the fact that some resources (e.g. sixel images) are currently *moved* to the new grid. They’d instead have to be copied.
2022-10-05render: fix nanosec "overflow" when calculating timeout valueAlexey Sakovets-1/+4
2022-09-23render: overlay: fix visual glitches when double bufferingDaniel Eklöf-10/+19
When rendering the overlay for scrollback search, the logic assumed buffer re-use. On some compositors this isn’t happening (on e.g. KDE/plasma we’re forced to double buffer). This resulted in matches not being highlighted correctly. The problem is in how we calculated the region for which areas to clear ("un-dim"). It uses the "previous frame’s see-through area" minus the current frame’s see-through area. However, when we’ve detected that the current buffer isn’t the same as the last one, we set the last frame’s see-through region to "the entire buffer". Thus, when calculating the diff, we end up with an empty region, and nothing is highlighted. Fix by simply using the current frame’s see-through region as-is when we’ve detected we’re not re-using the last frame’s buffer.
2022-09-23render: fix application of old scroll damage when double bufferingDaniel Eklöf-62/+68
On compositors that forces us to double buffer, we need to re-apply the last frame’s damage to the current frame (which uses the buffer from the next-to-last frame). General cell updates are handled by simply copying from the last frame’s pixman buffer to the current frame’s. In an attempt to improve performance, scroll damage were up until now handled by re-playing the last frame’s scroll damage (on the current frame’s buffer). This does not work, and resulted in glitches when scrolling in the scrollback. This patch does the following: * grid_render_scroll{,_reverse}() now update the buffer’s "dirty" region. This means the generic copy-old-frames-buffer handles the scroll damage (albeit in, potentially, a less efficient way). * Tracking of, and re-applying old scroll damage is completely removed. Closes #1173
2022-09-23render: timer: print/log *total* rendering timeDaniel Eklöf-7/+13
2022-08-20config: add setting for underline thicknessYorick Peterse-1/+4
This adds an "underline-thickness" setting to the "main" section, similar to the existing "underline-offset" setting. This setting is used to specify a custom height for regular (= non-cursor) underlines. Fixes #1136
2022-08-12render: apply a dimmed overlay while in Unicode input modeDaniel Eklöf-5/+28
2022-08-08render: apply a dimmed overlay while in Unicode input modeDaniel Eklöf-5/+28
2022-08-04Add support for xdg_toplevel.wm_capabilitiesSimon Ser-2/+4
See https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/122
2022-07-28config: add colors.search-box-{no-,}matchDaniel Eklöf-5/+20
Closes #1112
2022-07-28render: it’s unlikely() the current cell is where the cursor isDaniel Eklöf-1/+1
2022-06-15ime: track IME focus independently from keyboard focusDaniel Eklöf-2/+2
Replace the seat->ime.focused boolean with a terminal instace pointer, seat->ime_focus. Set and reset this on ime::enter() and ime::leave() events, and use this instead of seat->kbd_focus on all other IME events. This fixes two issues: a) buggy compositors that sometimes sends an IME enter event without first having sent a keyboard enter event. b) seats may be IME capable while still lacking the keyboard capability. Such seats will *always* see IME enter events without a corresponding keyboard enter event.
2022-04-24render: fix refresh logic of pending csd|search|urlDaniel Eklöf-1/+1
Our CSDs, the search-box and URL labels are all implemented using sub-surfaces, synchronized with the main grid. This means we *must* commit the main surface as well, when updating one of these sub-surfaces. The logic for doing so in the frame callback was flawed, and only triggered when the main grid was actually dirty. That is, e.g. search box updates that did not also resulted in grid updates (for example - pasting a search criteria that doesn’t match), did not result in a UI refresh. Closes #1040
2022-04-17render: overlay: reset ‘start_col’ after handling the first rowDaniel Eklöf-0/+2
2022-04-17wayland: refactor: remove ‘struct config’ pointer from wayland structDaniel Eklöf-1/+1
The global config doesn’t necessarily reflect the correct configuration to use - we should *always* use the current terminal instance’s conf pointer. * Move selection override modifier mask to the key_binding_set struct * Always warn if XDG activation is unavailable, not just if bell.urgent is set (we no longer have access to this information) * Pass ‘bool presentation_timings’ as a parameter to wayl_init() * Remove ‘presentation_timings’ member from the ‘terminal’ struct Closes #932
2022-04-17render: overlay: apply weston quirkDaniel Eklöf-0/+2
2022-04-16search/render: initial support for highlighting all visible matchesDaniel Eklöf-11/+25
Before this patch, only the currently “selected” match was highlighted (by having the “selected” attribute, and by *not* dimming it, like the rest of the grid during a scrollback search). With this patch, we now highlight matches within the viewport. While searching, only the “primary” match is searched-for, and tracked. Then, when rendering a frame, we find all “secondary” matches as well. “holes” are added to the search-mode overlay by the means of an search-match iterator. The iterator’s text matching logic is *very* similar to what we do when the search criteria has been updated, and we re-search the scrollback. It should be possible to refactor this, and share code.
2022-04-16render: implement ‘flash’ and search mode’s ‘dimming’ with a sub-surfaceDaniel Eklöf-44/+158
Search mode and ‘flash’ (OSC-555) both achieves similar visual effects: flash tints the entire window yellow, and search mode dims it (except the search match). But, they do so in completely different ways. Search mode is detected in render_cell(), and the colors are then dimmed there. Flash is implemented by blending a yellow, semi-transparent color on top of the rendered grid. This patch replaces those two implementations with a single one. We add a new sub-surface, called the ‘overlay’. In normal mode, it’s unmapped. When either search mode, or flash, is enabled, we enable it, and fill it with a semi-transparent color. Yellow for ‘flash’, and “black” (i.e. no color) for search mode. The compositor then blends it with the grid. Hopefully on the GPU, meaning it’ll be faster than if we blend in software. There are more performance benefits however. By using a separate surface, we can do much better damage tracking. The normal grid rendering code no longer have to care about neither search mode, nor flash. Thus, we get rid of a couple of ‘if’ statements in render_cell(), which is nice. But more importantly, we can drop full grid repaints in a couple of circumstances: * Entering/exiting search mode * Every frame while flash is active Now, when rendering the search mode overlay, we do want to do some damage tracking, also of the overlay. This, since search mode doesn’t dim the *entire* window. The search match is *not* dimmed. This is implemented by punching a hole in the overlay sub-surface. That is, we make part of it *fully* transparent. The basic idea is to set a clip region that excludes the search match, and then dim the rest of the overlay. It’s slightly more complicated than that however, if we want to reuse the last frame’s overlay buffer (i.e we don’t want to re-render the *entire* overlay every frame). In short, we need to: * Clear (punch hole) in areas that are part of this frame’s search match, but not the last frame’s (since those parts are _already_ cleared). * Dim the areas that were part of the last frame’s search match, but aren’t anymore (the rest of the overlay should already be dimmed). To do this, we save the last frame’s “holes” (as a pixman region). Then, when rendering the next frame, we first calculate the new frame’s “holes” region. The region to clear is “this frame’s holes minus last frame’s holes” The region to dim is “last frame’s holes minus this frames holes”. Finally, we compute the bounding box of all modified cells by taking the union of the two diff regions mentioned above. This allows us to limit the buffer damage sent to the compositor.
2022-04-16wayland: optionally disable pointer input on subsurfacesDaniel Eklöf-1/+3
We have a number of sub-surfaces for which we are *not* interrested in pointer (or touch) input. Up until now, we’ve manually dealt with these, by recognizing these surfaces in all pointer events, and ignoring them. But, lo and behold, there are better ways of doing this. By clearing the subsurface’s input region, the compositor will do this for us - when a pointer is outside a surface’s input region, the event is passed to the next surface underneath it. This is exactly what we want! Do this for all subsurfaces, *except* the CSDs.
2022-04-16render: take (visible) CSD border size into account when setting initial sizeDaniel Eklöf-0/+5
2022-04-16wayland: add helper functions wayl_win_csd_{titlebar,borders}_visible()Daniel Eklöf-18/+15
2022-04-16render: take visible border width into account when setting window geometryDaniel Eklöf-5/+12
This fixes e.g. window snapping in GNOME.
2022-04-09refactor: add a ‘range’ struct, grouping a start and end coord togetherDaniel Eklöf-4/+4
2022-04-06render: ensure an underline cursor is not positioned too lowDaniel Eklöf-19/+21
The underline cursor is positioned just below regular underlines. A bug in the positioning logic related to this, sometimes resulted in the cursor being thinner than what it should be, or even invisible. Fixes #1005
2022-02-09config: rename csd.color.close -> quitDaniel Eklöf-1/+1
This fixes a compilation error on FreeBSD: ../../foot/render.c:2055:45: error: no member named 'epoll_shim_close' in 'struct config::(anonymous at ../../foot/config.h:254:9)' conf_color = &term->conf->csd.color.close; ~~~~~~~~~~~~~~~~~~~~~ ^ /usr/local/include/libepoll-shim/epoll-shim/detail/common.h:8:15: note: expanded from macro 'close': #define close epoll_shim_close
2022-02-07Specify a fallback mouse cursorAshish SHUKLA-2/+6
`text' cursor is not available in lots of cursor themes, but `xterm' is, so specify `xterm' as a fallback cursor name.
2022-02-07render: add render_xcursor_is_valid()Daniel Eklöf-0/+8
Returns true if the provided cursor name is non-NULL, and exist in the currently loaded xcursor theme.
2022-02-07render: call wl_cursor_theme_get_cursor() earlierDaniel Eklöf-8/+13
Before this patch, wl_cursor_theme_get_cursor() was called in the FDM hook, just before we’re about to update the mouse cursor “for real”. This relies on seat->pointer.xcursor still being valid. This is true as long as we’re only using our compiled-in static xcursor names, but not otherwise. Now, we call wl_cursor_theme_get_cursor() in render_xcursor_set(). At this point, we *know* seat->pointer.xcursor is valid. There is a slight chance of added overhead here, if the client application is switching mouse grabbing on/off rapidly. Before, the calls to wl_cursor_theme_get_cursor() would automatically be throttled. However, the main point of delaying the actual pointer update to the FDM hook is to throttle the *Wayland* calls. And this is still happening: wl_cursor_theme_get_cursor() is client-side only.
2022-02-07render: resize: add TODO: translate pivot coordsDaniel Eklöf-0/+6
2022-02-07render: resize: finalize selection before reflowing the gridDaniel Eklöf-0/+10
This fixes a crash caused by the selection’s pivot point not being translated during reflow. While we could simply reflow the pivot point as well, testing shows irregular behavior with ongoing selections across window resizes, with different compositors behaving differently. For now, we simply finalize the selection, instead of trying to handle ongoing selections. Closes #922
2022-02-05fcft: adapt to API changes in fcft-3.xDaniel Eklöf-71/+78
Fcft no longer uses wchar_t, but plain uint32_t to represent codepoints. Since we do a fair amount of string operations in foot, it still makes sense to use something that actually _is_ a string (or character), rather than an array of uint32_t. For this reason, we switch out all wchar_t usage in foot to char32_t. We also verify, at compile-time, that char32_t used UTF-32 (which is what fcft expects). Unfortunately, there are no string functions for char32_t. To avoid having to re-implement all wcs*() functions, we add a small wrapper layer of c32*() functions. These wrapper functions take char32_t arguments, but then simply call the corresponding wcs*() function. For this to work, wcs*() must _also_ be UTF-32 compatible. We can check for the presence of the __STDC_ISO_10646__ macro. If set, wchar_t is at least 4 bytes and its internal representation is UTF-32. FreeBSD does *not* define this macro, because its internal wchar_t representation depends on the current locale. It _does_ use UTF-32 _if_ the current locale is UTF-8. Since foot enforces UTF-8, we simply need to check if __FreeBSD__ is defined. Other fcft API changes: * fcft_glyph_rasterize() -> fcft_codepoint_rasterize() * font.space_advance has been removed * ‘tags’ have been removed from fcft_grapheme_rasterize() * ‘fcft_log_init()’ removed * ‘fcft_init()’ and ‘fcft_fini()’ must be explicitly called
2022-01-15replace gettimeofday with clock_gettimePranjal Kole-40/+40
POSIX.1-2008 has marked gettimeofday(2) as obsolete, recommending the use of clock_gettime(2) instead. CLOCK_MONOTONIC has been used instead of CLOCK_REALTIME because it is unaffected by manual changes in the system clock. This makes it better for our purposes, namely, measuring the difference between two points in time. tv_sec has been casted to long in most places since POSIX does not define the actual type of time_t.
2022-01-13config: convert tweak.render_timer to an enumDaniel Eklöf-4/+20
2021-12-29render: csd: scale border width when rendering the CSD border’s visible partDaniel Eklöf-2/+3
2021-12-29render: limit the unfocused block cursor’s outline widthDaniel Eklöf-4/+5
Ensure the outline width doesn’t exceed the cell width/height.
2021-12-28render: scale the width out the outline of the unfocused block cursorDaniel Eklöf-4/+6
2021-12-26csi: store color index, not actual color, in cell’s fg/bg attributesDaniel Eklöf-2/+31
When using indexed colors (i.e. SGR 30/40/90/100), store the index into the cell’s fg/bg attributes, not the actual color value. This has a couple of consequences: Color table lookup is now done when rendering. This means a rendered cell will always reflect the *current* color table, not the color table that was in use when the cell was printed to. This simplifies the OSC-4/104 logic, since we no longer need to update the grid - we just have to damage it to trigger rendering. Furthermore, this change simplifies the VT parsing, since we no longer need to do any memory loads (except loading the SGR parameter values), only writes.
2021-12-22render: make sure ‘maximized’ button doesn’t use negative coordinatesDaniel Eklöf-1/+5
2021-12-22config: csd.border_width now always reflects the full/total widthDaniel Eklöf-4/+4
2021-11-29render: fix csd border rendering glitch when width > 5pxDaniel Eklöf-4/+22
CSD borders are always *at least* 5px. If url.border-width=0, those 5px are all fully transparent (and act as interactive resize handles). As csd.border-width increases, the number of transparent pixels decrease. Once csd.border-width >= 5, the border is fully opaque. When csd.border-width > 5, then width of the border is (obviously) more than 5px. But, when rendering the opaque part of the border, we still used 5px for the invisible part, which caused some pixman rectangles to have negative x/y coordinates. This resulted in rendering glitches due to overflows in pixman when rendering the borders. The fix is to ensure the total border size is always at least, but not *always* 5px. That is, set it to max(5, csd.border-width). This patch also fixes an issue where the CSD borders were not dimmed (like the titlebar) when the window looses input focus. Closes #823
2021-11-29input: Add support for xdg_toplevl.show_window_menu()Jonas Ådahl-8/+1
This makes, if the compositor supports it, the window menu appear when right clicking on the title bar.
2021-11-20term: track cell color sourceDaniel Eklöf-3/+3
Each cell now tracks it’s current color source: * default fg/bg * base16 fg/bg (maps to *both* the regular and bright colors) * base256 fg/bg * RGB Note that we don’t have enough bits to separate the regular from the bright colors. These _shouldn’t_ be the same, so we ought to be fine...
2021-11-13config: add [colors].dim0-7Daniel Eklöf-7/+34
This allows you to configure custom colors to be used when colors are being dimmed (`\E[2m`). It is implemented by color matching (just like bold-text-in-bright=palette-based); the color-to-be-dimmed is matched against the current color palette. If it matches one of the regular colors (colors 0-7), the corresponding “dim” color will be used. If it matches one of the bright colors (colors 8-15), the corresponding “regular” color will be used (but *only* if the “dim” color has been set). Otherwise, the color is dimmed by reducing its luminance. The default behavior, i.e. when dim0-7 hasn’t been configured, is to dim by reducing luminance for *all* colors. I.e. we don’t do any color matching at all. In particular, this means that dimming a bright color will *not* result in the corresponding “regular” color. Closes #776
2021-11-13config: add {str,value}_to_uint{16,32}()Daniel Eklöf-1/+1
This allows us to pass the final pointer directly to the conversion functions, as well as allowing us to print outside-range errors.
2021-10-29render: csd_part: we don’t use the ‘src’ pixman imageDaniel Eklöf-3/+0
2021-10-27csd: add support for a visible borderDaniel Eklöf-5/+54
When we’re using CSDs, we’ve up until now rendered a 5px invisible border. This border handles interactive resizing. I.e. hovering it changes the mouse cursor, and mouse button events are used to start an interactive resize. This patch makes it possible to color part of (or the entire) border, with a configurable color. To facilitate this, two new options have been added: * csd.border-width * csd.border-color border-width defaults to 0, resulting in the look we’re used to. border-color defaults to the title bar color. If the title bar color hasn’t been set, it defaults to the default foreground color (just like the title bar color does). This means that, setting border-width but not border-color, results in a border that blends with the title bar.
2021-10-20render: tab -> spacesDaniel Eklöf-6/+6
2021-10-09config, render: scrollback indicator: allow configuring scrollback indicator colorsfeeptr@codeberg.org-1/+8
2021-10-04fix crashes when resizing after CSD enabled at runtime with csd.size = 0feeptr-1/+2
2021-09-14term: turn ‘box-drawings’ array into three dynamically allocated arraysDaniel Eklöf-25/+35
The box_drawings array is now quite large, and uses up ~4K when *empty*. This patch splits it up into three separate, dynamically allocated arrays; one for the traditional box+line drawing and block elements glyphs, one for braille, and one for the legacy computing symbols. When we need to render a glyph, the *entire* array (that it belongs to) is allocated. I.e this is one step closer to a dynamic glyph cache (like the one fcft uses), but doesn’t go all the way. This is especially nice for people with ‘box-drawings-uses-font-glyphs=yes’; for them, the custom glyphs now uses 3*8 bytes (for the three array pointers), instead of 4K.