aboutsummaryrefslogtreecommitdiff
path: root/terminal.c (follow)
Commit message (Collapse)AuthorAgeLines
* grid: move 'cursor' state from terminal to gridDaniel Eklöf2020-04-16-43/+44
| | | | | This way, the 'normal' and 'alt' grids have their own cursor state, and we don't need to switch between them.
* misc: replace all explicit zero-initializers with empty initializersDaniel Eklöf2020-04-13-8/+8
|
* term: reset: plug memory leakDaniel Eklöf2020-04-13-27/+31
| | | | | | | | | | | In reset, we allocated new rows for all the currently visible lines. We did **not** however, free the 'old' rows. Fix by not explicitly allocating new rows, but instead allocating uninitialized rows when needed, and then explicitly erasing the row. If there already was a row allocated, it is simply erased. If there wasn't, the a new line is malloc:ed, and then erased.
* conf: add 'title' conf option and --title command line optionDaniel Eklöf2020-04-01-1/+1
|
* Merge branch 'master' into scroll-damage-performanceDaniel Eklöf2020-03-27-3/+20
|\
| * client: add --maximized and --fullscreenDaniel Eklöf2020-03-27-3/+6
| | | | | | | | | | | | | | | | | | We now create a copy of the config for each client, and updates it with the values passed from the client. Since we're not actually cloning it (and e.g. strdup() all strings etc) we can't call conf_destroy() to free it, but need to free just the strings we've replaced.
| * config: add 'startup-mode' optionDaniel Eklöf2020-03-26-0/+14
| | | | | | | | | | This option controls the initial window mode: windowed, maximized or fullscreen. The default is windowed.
* | app synchronized updates: set is_armed=false when enablingDaniel Eklöf2020-03-25-0/+1
| |
* | render: pace title updatesDaniel Eklöf2020-03-25-1/+1
|/ | | | Synchronize window title updates with window rendering.
* term: delayed rendering: failure to read timers is always an errorDaniel Eklöf2020-03-24-8/+5
|
* delayed rendering: ignore frame callback if delayed rendering is activeDaniel Eklöf2020-03-23-7/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before, we applied delayed rendering (that is, we gave the client a chance to do more writes before we scheduled a render refresh) only when the renderer were idle. However, with e.g. a high keyboard repeat rate, it is very much possible to start the render loop and then never break out of it while receiving keyboard input. This causes screen flickering, as we're no longer even trying to detect the clients transaction boundaries. So, let's rewrite how this is done. First, we give the user the ability to disable delayed rendering altogether, by setting either the lower or upper timeout to 0. Second, when delayed rendering is enabled, we ignore the frame callback. That is, when receiving input, we *always* reschedule the lower timeout timer, regardless of whether the render is idle or not. The render's frame callback handler will *not* render the grid if the delayed render timers are armed. This means for longer client data bursts, we may now skip frames. That is, we're trading screen flicker for the occasional frame hickup. For short client data bursts we should behave roughly as before. This greatly improves the behavior of fullscreen, or near fullscreen, updates of large grids (example, scrolling in emacs in fullscreen, with a vertical buffer split).
* term: delayed rendering: read timers even though is_armed = falseDaniel Eklöf2020-03-23-5/+8
| | | | | | | | | There's a race/chance that we'll have disarmed the delayed rendering timers and still get the call. While it _shouldn't_ be anything to read from the timers, it doesn't hurt to try. And, if the timers *are* readable, not reading them means we'll end up in an infinite FDM loop.
* conf: make delayed rendering timeouts configurableDaniel Eklöf2020-03-17-7/+8
| | | | | | | | | | | This adds an undocumented 'tweak' section to footrc, with two new options: * delayed-render-lower * delayed-render-upper Both takes an integer value, representing the lower/upper timeout values (in nano seconds) for delayed rendering.
* term: ptmx: don't set 'pending' flag when app sync updates are in useDaniel Eklöf2020-03-17-38/+34
|
* term: ptmx: don't enqueue extra frame render when app sync updates have been changedDaniel Eklöf2020-03-16-2/+12
| | | | | | | | | | | | | | | | | | | | | | | | | Track whether app-sync updates were enabled or disabled while handling the current chunk of PTMX data. This fixes and issue where we called render_refresh() unnecessarily under (at least) the following conditions: * Application sent "BSU <data> ESU" in the *same* chunk. In this case we never saw that app sync was enabled and triggered delayed rendering as usual. * Application sent ESU. While we had noticed app sync updates being enabled in earlier PTMX reads, when it was disabled *in the current* PTMX read, we treated it as if it had not been enabled at all. This caused us to trigger delayed rendering. Now we call render_refresh() directly from ESU, and detect the "flip off" case in PTMX read and avoid triggering a delayed rendering. The end result of all this is that each key press (for e.g. scrolling in a pager application) went from two frames being rendered, to a single frame.
* alt-screen: use a custom 'saved' cursor when switching to alt screenDaniel Eklöf2020-03-16-5/+5
| | | | | | | | | | | | | This fixes an issue where we failed to restore the cursor correctly when exiting from the alternate screen, if the client had sent escapes to save the cursor position while inside the alternate screen. This was because we used the *same* storage for saving the cursor position through escapes, as for saving it when entering the alternate screen. Fix by using a custom variable dedicated to normal <--> alt screen switching.
* Merge branch 'scale-fonts-using-logical-dpi-plus-scale-factor'Daniel Eklöf2020-03-13-3/+24
|\
| * term: use logical DPI+scale factor when scaling fontsDaniel Eklöf2020-03-11-3/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes an issue where the fonts were rendered too small when the output had fractional scaling. For integral scaling, using the logical (scaled) DPI multiplied with the scaling factor results in the same final DPI value as if we had used the physical DPI. But for fractional scaling, this works around the fact that the compositor downscales the surface after we've rendered it. Closes #5
* | sixel: improve handling of images when reflowing the gridsDaniel Eklöf2020-03-13-7/+12
|/ | | | | | | | | | | Update the sixels' 'row' attribute when re-flowing a grid, to ensure it is rendered at the correct place. This should work in most cases, but will break when the cell size has changed (e.g. font size increase/decrease, or a DPI change). This patch also moves the sixel image list from the terminal struct into the grid struct. The sixels are per-grid after all.
* terminal: appky scale factor when force-resizing on font reloadDaniel Eklöf2020-03-10-1/+1
| | | | | | | If we don't, we'll end up e.g. increasing the window size when moving the window between outputs with different scaling. Closes #3
* term: init: no need to roundtripDaniel Eklöf2020-03-09-5/+5
|
* render: never render CSD and/or search box "immediately"Daniel Eklöf2020-03-06-10/+4
| | | | | | | | | | Handle the CSDs and the search box the same way we handle the main grid; when we need to redraw them, call render_refresh_{csd,search}(). This sets a flag that is checked after each FDM iteration. All actual rendering is done here. This also ties the commits of the Wayland sub-surfaces to the commit of the main surface.
* quirks: add shortcut for flipping all CSD surfaces sync/desync stateDaniel Eklöf2020-03-03-20/+0
|
* csd: initial implementation of minimize/maximize/close buttonsDaniel Eklöf2020-03-02-5/+11
|
* terminal: workaround founds with negative line gapsDaniel Eklöf2020-03-02-1/+2
| | | | | | | | | | | Some fonts, even monospaced ones, have a negative line gap (line height < ascent + descent). Using the font's line height as cell height will result in some glyphs overflowing into the cell above or below. Workaround by using which ever value is the largest: the line height or ascent + descent.
* term: visual_focus_{in,out}: use quirk_weston_subsurface_desync_{on,off}Daniel Eklöf2020-03-01-28/+29
|
* render: csd: split up positioning from renderingDaniel Eklöf2020-02-29-2/+4
|
* term: loop through all sub-surfaces when switching sync/desync modeDaniel Eklöf2020-02-29-4/+5
|
* terminal: error out when we fail to load the primary fontDaniel Eklöf2020-02-28-1/+2
|
* csd: position CSD sub-surfaces *outside* the main windowDaniel Eklöf2020-02-26-9/+17
| | | | | | | | | | | | | | | For now, this behavior is controlled with an ifdef. At least kwin seems very buggy when the decorations are positioned like this (but normally you'd use server-side decorations with kwin anyway). This commit also changes 'use_csd' to be a tri-state variable; when instantiating a window it is set to 'unknown'. If there's no decoration manager available (e.g. weston), we immediately set it to 'yes' (use CSDs). Otherwise, we wait for the decoration manager callback to indicate whether we should use CSDs or not.
* term: visual_focus_in/out: redraw CSDsDaniel Eklöf2020-02-25-0/+18
| | | | | | | We draw the CSDs in a darker color when we're inactive. Weston seems to be buggy with synchronized subsurfaces, so temporarily reconfigure them to desynchronized surfaces.
* render: resize with with/height == 0 resizes to user configured dimensionsDaniel Eklöf2020-02-25-17/+0
|
* main: geometry defaults to 800x600 pixelsDaniel Eklöf2020-02-25-7/+0
|
* term: add term_surface_kind(), and track currently active surfaceDaniel Eklöf2020-02-24-0/+21
| | | | | | This is needed to handle pointer motion and button events correctly, since mouse actions in e.g. CSD surfaces are very different from mouse actions in the main window.
* term: scroll: call sixel_delete_*() instead of manually erasing sixel imagesDaniel Eklöf2020-02-24-35/+4
|
* term: term_erase(): call sixel_delete_*()Daniel Eklöf2020-02-24-0/+2
| | | | | This ensures sixel images are removed, regardless of _how_ the screen was erased.
* term: scroll: don't delete sixel images on the 'other' gridDaniel Eklöf2020-02-22-0/+6
|
* sixel: rename: purge_at_cursor() -> delete_at_cursor()Daniel Eklöf2020-02-22-1/+1
|
* sixel: purge images at current cursor rowDaniel Eklöf2020-02-22-0/+2
| | | | | When printing a character, or starting a new sixel image, purge all images that cover the cursor's current row.
* sixel: application configurable palette size (color count)Daniel Eklöf2020-02-22-0/+3
| | | | | This implements the CSI escapes for retrieving and (re)setting the palette size.
* term: free sixel images on resetDaniel Eklöf2020-02-22-0/+4
|
* sixel: add sixel_destroy()Daniel Eklöf2020-02-21-10/+7
|
* sixel: calculate image height in (cell) rowsDaniel Eklöf2020-02-21-2/+1
|
* sixel: wip: maintain a list of finished, and "active" sixel imagesDaniel Eklöf2020-02-21-0/+39
| | | | | | | | | | | | | | | | | | | In unhook, add the generated image to a list of finished sixel images, along with positioning and size information. When rendering, loop this list of images, and render the images (or parts of) that are visible. When scrolling, check if any part of the images cover the re-cycled lines, and if so, remove the *entire* image from the list. This means we have the following limitations: * The renderer always renders the whole (visible area of) the image(s). There are times when this isn't necessary - for example, when the image is scrolled inside the visible area. * It would be nice if we could crop the image when parts of it is scrolled out.
* term: spawn_new: check return value of chdir() and write()Daniel Eklöf2020-02-20-3/+7
|
* slave: prefix argv[0] with a '-' when spawning a login-shellDaniel Eklöf2020-02-20-3/+3
|
* term: implement term_font_dpi_changed()Daniel Eklöf2020-02-15-53/+141
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This function reloads the font *if* the DPI has changed. To handle user run-time adjusted font sizes, we record the number of adjustments made. Then, when re-loading the font, we first load the font as specified in the configuration. Then, we re-apply the size adjustment using font_size_adjust(). Note that this means we end up loading the fonts twice; first using the default size (but with adjusted DPI), and then again with the adjusted size. This can probably be improved upon. The existing font code has been refactored to avoid code duplication. For example, term_init() now calls term_font_dpi_changed() to load the initial fonts, instead of directly instantiating them. Finally, the way we calculate the DPI to use has changed: instead of using the highest DPI of all available outputs, we use the highest DPI of the output's we're actually mapped on. If we're not mapped at all, we use the globally highest DPI. Doing it this way means we usually only have to load the fonts once. Otherwise, we'd end up using the default DPI of 96 when the terminal is first instantiated (since it's not mapped at that time). On a single monitor system, we'll use the globally highest DPI at first, before being mapped. Then when we get mapped, we re-load the fonts using the highest mapped DPI. But since they'll be the same, we can skip actually reloading the fonts.
* term: reset: use grid_row_alloc() with initialize=trueDaniel Eklöf2020-02-14-2/+2
| | | | | This will both zero out the cells, *and* re-initialize the row properties correctly.
* term: convert cell 'linefeed' attribute to a row 'linebreak' propertyDaniel Eklöf2020-02-14-5/+2
| | | | | | | | | | | | | | | | To do text reflow, we only need to know if a line has been explicitly linebreaked or not. If not, that means it wrapped, and that we should *not* insert a linebreak when reflowing text. When reflowing text, when reaching the end of a row in the old grid, only insert a linebreak in the new grid if the old row had been explicitly linebreaked. Furthermore, when reflowing text and wrapping a row in the new grid, mark the previous row as linebreaked if either the last cell was (the last column in the last row) empty, or the current cell (the first column in the new row) is empty. If both are non-empty, then we assume a linewrap.
* term: formfeed: set linefeed correctly when we're at last column with lcf=1Daniel Eklöf2020-02-12-2/+5
| | | | | | When cursor.lcf is set, that means the cursor column was *not* incremented when we printed the last character. Thus, we should *not* decrement the column before setting the linefeed bit.
* Merge branch 'text-reflow'Daniel Eklöf2020-02-11-2/+10
|\
| * term: font_size_{increase,descrease}: adjust size by 0.5ptDaniel Eklöf2020-02-10-2/+2
| |
| * vt: tag cells that were form-feed:ed, to allow correct text reflowDaniel Eklöf2020-02-10-0/+8
| | | | | | | | | | | | | | | | | | To handle text reflow correctly when a line has a printable character in the last column, but was still line breaked, we need to track the fact that the slave inserted a line break here. Otherwise, when the window width is increased, we'll end up pulling up the next line, when we really should have inserted a line break.
* | term: log error when failing to initialize the primary fontsDaniel Eklöf2020-02-09-0/+1
|/
* term: factor out common font changing codeDaniel Eklöf2020-02-08-22/+20
|
* term: add term_font_size_reset()Daniel Eklöf2020-02-08-7/+38
|
* term: add term_font_size_{increase,decrease}()Daniel Eklöf2020-02-08-0/+44
|
* term: reduce max number of iterations when trying to drain clientDaniel Eklöf2020-02-05-1/+1
|
* term: languageDaniel Eklöf2020-02-05-5/+5
|
* term: always read *all* we can from the client before updating stateDaniel Eklöf2020-02-05-8/+15
| | | | | | But place an upper limit on the number of iterations we read, to prevent starvation caused by a bad behaving client to constantly writes data.
* Implement --holdDaniel Eklöf2020-02-03-12/+20
| | | | When specified, we don't exit when the slave/client process exits.
* fcft: update to 1.1.0Daniel Eklöf2020-02-01-4/+4
|
* terminal: regression: char printed to wrong columnDaniel Eklöf2020-01-22-3/+4
| | | | | | | | | When term_print() was implemented, it introduced a regression where printing a character when the last cursor was in the last column on a line would print the character in the wrong column. This is because term_print() retrieved a pointer to the current cell *before* line wrapping (and possibly inserting empty cells).
* input: implement metaSendsEscape and eightBitMetaDaniel Eklöf2020-01-20-0/+7
|
* term: fix reset state of VT stateDaniel Eklöf2020-01-20-2/+2
|
* term: factor out character printing to new function term_print()Daniel Eklöf2020-01-20-0/+75
|
* fcft: update to 1.0.0Daniel Eklöf2020-01-19-13/+1
| | | | | Allow/disallow subpixel antialiasing in font_glyph_for_wc(), not using font_enable_subpixel_antialias().
* term: enable subpixel antialiasing if background is opaqueDaniel Eklöf2020-01-18-1/+13
|
* term: shorten application_synchronized_updates -> app_sync_updatesDaniel Eklöf2020-01-12-19/+19
|
* term: enable_application_synchronized_updates: not a noop if already enabledDaniel Eklöf2020-01-12-3/+0
| | | | | If synchronized updates are already enabled when we receive a request to enable them, extend the timeout.
* term: app sync updates: disable delayed rendering timers once onlyDaniel Eklöf2020-01-12-8/+9
| | | | | Disable the delayed rendering timers when enabling application synchronized updates, not every time we've received ptmx data.
* term/render: move {enable,disable}_application_synchronized_updates()Daniel Eklöf2020-01-12-1/+31
| | | | From render -> terminal
* render: add a timeout for application synchronized updatesDaniel Eklöf2020-01-12-2/+38
| | | | | This ensures we can recover from a crashing (or bad behaving) application that sends a BSU but then never sends an ESU.
* term: rename refresh_prohibited -> application_synchronized_updatesDaniel Eklöf2020-01-12-1/+1
|
* term: ptmx: cancel, and don't re-arm, delay timers when refresh has been disabledDaniel Eklöf2020-01-12-22/+34
|
* term/wayland: use MONOTONIC timersDaniel Eklöf2020-01-10-5/+5
|
* Revert "terminal: use edge-triggered FDM handler for the PTY"Daniel Eklöf2020-01-10-16/+16
| | | | This reverts commit f5e27b49eb53ec64a592236680deee0c68c32f0f.
* terminal: make the event FD used to delay shutdown non-blockingDaniel Eklöf2020-01-10-1/+1
|
* terminal: use edge-triggered FDM handler for the PTYDaniel Eklöf2020-01-10-16/+16
| | | | | | | | This means that the read handler now has to keep reading until we get EAGAIN. But it also means we don't have to flip the EPOLLOUT flag in the FDM handler back and forth when writing to the PTY.
* render: throttle xcursor updatesDaniel Eklöf2020-01-04-1/+1
| | | | | | | | | | | | | | | | | | | | | | | With a bad behaving client (e.g. 'less' with mouse support enabled), we can end up with a *lot* of xcursor updates (so much, that we flooded the wayland socket before we implemented a blocking wayl_flush()). Since there's little point in updating the cursor more than once per frame interval, use frame callbacks to throttle the updates. This works more or lesslike normal terminal refreshes: render_xcursor_set() stores the last terminal (window) that had (and updated) the cursor. The renderer's FDM hook checks if we have such a pending terminal set, and if so, tries to refresh the cursor. This is done by first checking if we're already waiting for a callback from a previous cursor update, and if so we do nothing; the callback will update the cursor for the next frame. If we're *not* already waiting for a callback, we update the cursor immediately.
* term: mouse_grabbed: ctrl may be pressed too (for block selection)Daniel Eklöf2020-01-04-1/+1
|
* wayland: don't use wl_display_dispatch()Daniel Eklöf2020-01-03-3/+1
| | | | | | | | | | | | | | | | | | | | | | wl_display_dispatch() calls poll(), which is unnecessary since we already know the FD is readable. Use the more lower level wl_display_read_events() + wl_display_dispatch_pending(). These require wl_display_prepare_read() to have been called. The idea is to call wl_display_prepare_read() **before** calling poll(). Thus, we do this more or less last in wayl_init(), and at the **end** of the FDM handler. However, having taking this lock also means we no longer can call wl_display_roundtrip() directly (it will hang). So, add a wrapper, wayl_roundtrip(), that cancels the read intent, does the roundtrip, and then re-acquires the read intent.
* term: init: don't resize if compositor has already resized usDaniel Eklöf2020-01-03-13/+16
|
* term: no need to call render_refresh() when starting/stopping blink timerDaniel Eklöf2020-01-03-2/+1
|
* render: remove 'refresh' from render_resize()Daniel Eklöf2020-01-03-1/+1
|
* wayland: window now keeps pointer to owning terminal, not waylandDaniel Eklöf2020-01-03-1/+1
|
* term: render_resize() now takes a 'refresh' argumentDaniel Eklöf2020-01-03-1/+1
|
* term: visual_focus_{in,out}: do nothing if already focused/defocusedDaniel Eklöf2020-01-03-0/+6
|
* term: term_init() calls wl_display_roundtrip()Daniel Eklöf2020-01-03-1/+6
| | | | | | | | | | | | | Instead of having `wayl_win_init()` call `wl_display_roundtrip()` (which it itself doesn't need), call it from `term_init()`. This allows us to add ourselves (the new terminal instance) to the terminal list in the wayland backend, before triggering the wayland events caused by `wayl_win_init()`. This is turn allows the wayland backend to find/lookup the new terminal when those events occur..
* term: spell 'initialize' correctlyDaniel Eklöf2020-01-03-1/+1
|
* term: add term_visual_focus_{in,out}Daniel Eklöf2020-01-02-8/+17
| | | | | | | These functions should be called when the terminal gets or loses visual focus. Note that this isn't necessarily the same as having keyboard focus.
* term: rename term_focus_{in,out} -> term_kbd_focus_{in,out}Daniel Eklöf2020-01-02-2/+2
|
* wayland: rename focused/moused to kbd_focus/mouse_focusDaniel Eklöf2020-01-02-12/+12
|
* term: bump lower delay limit to 500µsDaniel Eklöf2019-12-31-1/+1
| | | | | Emacs with a split screen often goes above 200µs. 500µs is still much better than 2000µs...
* term: ptmx timing: use a define instead of #if 0Daniel Eklöf2019-12-31-3/+5
|
* term: lower the lower delay timeout from 2ms to 200µsDaniel Eklöf2019-12-31-1/+1
|
* term: commented out code to measure time between slave outputDaniel Eklöf2019-12-31-0/+24
| | | | | | | | | | | | | | This allows us to measure the time between to refresh delays. That is, when we decide to delay a refresh, we store the current time. If we hit that code path _again_, without having refreshed, we calculate the time that has passed. This gives us an estimate for how we should set our lower delay timeout. This is of course application dependent, but is still much better than simply guessing a value...
* wayland: optionally use the presentation time protocol to measure input lagDaniel Eklöf2019-12-31-0/+6
| | | | | | | | | | | | | | | | | | | This adds a flag, -p,--presentation-timings, that enables input lag measuring using the presentation time Wayland protocol. When enabled, we store a timestamp when we *send* a key to the slave. Then, when we commit a frame for rendering to the compositor, we request presentation feedback. We also store a timestamp for when the frame was committed. The 'presented' callback then looks at the input and commit timestamps, and compares it with the presented timestamp. The delay is logged at INFO when the delay was less than one frame interval, at WARN when it was one frame interval, and at ERR when it was two or more frame intervals. We also update statistic counters that we log when foot is shut down.
* term: term_init: add 'cwd' argumentDaniel Eklöf2019-12-21-12/+4
| | | | | | | | | | This is used when spawning the slave, to set its current working directory just before we exec() the client. In a regular foot instance, we set the cwd from getcwd(). In a foot server instance, each connecting client sends its cwd to the server, and we use that.
* term: wip: track current working directoryDaniel Eklöf2019-12-21-0/+13
| | | | | | | This sets the initial current working directory, as it is when the terminal is instantiated. We chdir() to it just before spawning a new terminal.