aboutsummaryrefslogtreecommitdiff
path: root/terminal.c (follow)
Commit message (Collapse)AuthorAgeLines
* Revert "term: print: line-wrap multi-column characters instead of cutting them in half"Daniel Eklöf2020-05-09-5/+3
| | | | | | | This reverts commit 8448296bb3c0fa96f5af5cb7ec563bb0c7e99093. Applications need to be multi-column character aware anyway, and they should deal with this.
* term: print: line-wrap multi-column characters instead of cutting them in halfDaniel Eklöf2020-05-09-3/+5
|
* term: don't register ptmx with FDM if we're shutting downDaniel Eklöf2020-05-04-2/+4
| | | | | This can happen when there's an error instantiating the terminal *after* we've spawned the slave process.
* term: set 'is_shutting_down' before calling term_destroy() on errorDaniel Eklöf2020-05-04-0/+1
|
* term: check return value when instantiating thread synchronization primitivesDaniel Eklöf2020-05-04-4/+25
|
* term: thrd_success isn't necessarily 0Daniel Eklöf2020-05-03-3/+3
|
* thrd_create(): handle errors correctlyDaniel Eklöf2020-05-03-13/+31
| | | | | | * Detect thrd_create() failures in all places where we instantiate threads * Log error correctl; thrd_create() does not return an errno value
* unicode-combining: store seen combining chains "globally" in the term structDaniel Eklöf2020-05-03-4/+4
| | | | | | | | | | | | | | | | | | | | Instead of storing combining data per cell, realize that most combinations are re-occurring and that there's lots of available space left in the unicode range, and store seen base+combining combinations chains in a per-terminal array. When we encounter a combining character, we first try to pre-compose, like before. If that fails, we then search for the current base+combining combo in the list of previously seen combinations. If not found there either, we allocate a new combo and add it to the list. Regardless, the result is an index into this array. We store this index, offsetted by COMB_CHARS_LO=0x40000000ul in the cell. When rendering, we need to check if the cell character is a plain character, or if it's a composed character (identified by checking if the cell character is >= COMB_CHARS_LO). Then we render the grapheme pretty much like before.
* unicode-combine: remove utf8proc dependencyDaniel Eklöf2020-05-02-1/+1
| | | | | | | | | | | | We only used utf8proc to try to pre-compose a glyph from a base and combining character. We can do this ourselves by using a pre-compiled table of valid pre-compositions. This table isn't _that_ big, and binary searching it is fast. That is, for a very small amount of code, and not too much extra RO data, we can get rid of the utf8proc dependency.
* unicode-combining: completely remove unicode combining characters when feature is disabledDaniel Eklöf2020-05-01-0/+3
|
* render: render combining charactersDaniel Eklöf2020-05-01-1/+1
| | | | | | | | | | | | | | | | | This is basically just a loop that renders additional glyphs on top off the base glyph. Since we now need access to the row struct, for the combining characters, the function prototype for 'render_cell()' has changed. When rendering the combining characters we also need to deal with broken fonts; some fonts use positive offsets (as if the combining character was a regular character), while others use a negative offset (to be used as if you had already advanced the pen position). We handle both - a positive offset is rendered just like a regular glyph. When we see a negative offset we simply add the width of a cell first.
* term: print: reset combining characters for this cellDaniel Eklöf2020-05-01-0/+1
| | | | | | | | | | | This is the *only* place combining characters are reset. In particular, we do *not* reset them in a normal cell erase. This is a performance design decision - clearing the combining characters in erase is way too slow. This way, we clear it only when we *have* to. Anything looking at the combining characters must first ensure the base character is not 0.
* util.h: new header file defining commonly used macrosDaniel Eklöf2020-05-01-4/+1
|
* term: don't enable ptmx FDM callback until Wayland window has been configuredDaniel Eklöf2020-04-30-4/+21
| | | | | | | | | | | | | The way things works right now, we cannot enable the ptmx FDM callback right away. We need to wait for the Wayland window to have been configured. Before the window is configured, we don't have a size, and no grid. Thus, if we try to process ptmx data we'll crash since we have no where to write it to. So, registering the ptmx fd with the FDM is now delayed until we've received the first 'configure' event from Wayland.
* term: start slave before loading fonts and starting rendering threadsDaniel Eklöf2020-04-30-8/+9
| | | | | This allows the client to load in parallel with our font loading, which should improve startup time.
* term: font size adjust: re-load fonts in parallelDaniel Eklöf2020-04-29-9/+30
|
* term: destroy: handle rendering threads not being initializedDaniel Eklöf2020-04-29-11/+15
| | | | | We sort of already did this. However, we did not handle the case where the thread array itself hadn't yet been allocated.
* term: initialize rendering worker threads after instantiating fontsDaniel Eklöf2020-04-29-3/+2
| | | | | | This ensures the resources (e.g. stack) used by the transient threads used to load the primary fonts can be re-used by the rendering worker threads.
* term: load primary fonts in parallelDaniel Eklöf2020-04-28-8/+35
| | | | | | | | Use four threads to load the four primary font variants - normal, bold, italic and bold italic. This speeds up initial startup, and reloading of fonts on a DPI change.
* damage: remove 'scroll' sub structDaniel Eklöf2020-04-26-4/+5
| | | | There is no other types of damage but scroll damage.
* term: fcft: max/space advance fields have been renamedDaniel Eklöf2020-04-23-2/+2
|
* term: guess subpixel mode after initializing wayland windowDaniel Eklöf2020-04-22-0/+2
| | | | | | | | | At this point, we're not mapped, but we should have all the outputs initialized. Which means we can at least guess which subpixel mode to use. If that turns out to be wrong, something we'll detect when we're mapped, we'll just have to re-render.
* fcft: adjust to fcft-2.0 API changesDaniel Eklöf2020-04-21-36/+36
| | | | | | | * font_*() -> fcft_*() * struct font -> struct fcft_font * struct glyph -> struct fcft_glyph * enum subpixel_order -> enum fcft_subpixel
* render: use output's subpixel mode when rasterizing glyphsDaniel Eklöf2020-04-20-0/+72
|
* term: destroy: free scroll damage listsDaniel Eklöf2020-04-19-0/+3
| | | | | | | | | These lists are typically empty when we destroy the terminal. However, if we had queued up damage, and then manage to destroy the terminal instance before the last changes were rendered, then they will *not* be empty. Found by the address sanitizer.
* 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
|