aboutsummaryrefslogtreecommitdiff
path: root/terminal.c (follow)
Commit message (Collapse)AuthorAgeLines
* term: use logical DPI+scale factor when scaling fontsDaniel Eklöf2020-03-14-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
* terminal: appky scale factor when force-resizing on font reloadDaniel Eklöf2020-03-14-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
* 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.
* term: term_spawn_new: always spawn foot/footclient from PATHDaniel Eklöf2019-12-21-1/+1
|
* term: term_spawn_new(): new function, spawns a new foot/footclient processDaniel Eklöf2019-12-21-1/+66
| | | | Bind ctrl+shift+return to it
* term: experimental: tweak delay timeoutsDaniel Eklöf2019-12-20-2/+2
| | | | | | | | | | | | Increase the low timeout, to try to give clients/slaves more time to emit data. Decrease the upper timeout. On average, we should have ~½ frame left until the next frame. So a maximum delay of a whole frame *will* delay the update one extra frame in many cases. Hopefully, the low timeout is still low enough that we don't miss the next frame, on average.
* term: cursor blink reset doesn't force-refresh the cursorDaniel Eklöf2019-12-19-2/+5
|
* term/render: check for is_shutting_down in grid_render()Daniel Eklöf2019-12-19-3/+0
|
* term: remove TODODaniel Eklöf2019-12-19-4/+0
|
* cursor blink: move reset to pty inputDaniel Eklöf2019-12-19-0/+3
|
* render: get rid of 'all-clean' detectionDaniel Eklöf2019-12-17-1/+2
| | | | | | | | | | | | | | | | | Instead of trying to figure out if we had to render something (i.e. something in the grid was dirty), and using that to determine whether to post a callback or not, we now let render_refresh() set a flag indication we need to render another frame. This simplifies render_grid(), which now _always_ renders, and pushes it to the compositor. The callback handler checks the pending flag and simply doesn't call render_grid() when there's no more pending state to render. This ends up reducing the number of wakeups when e.g. having a blinking cursor.
* render: move blink timer handling to term.cDaniel Eklöf2019-12-17-1/+31
|
* term: disable cursor blink on unfocus, and re-enable on focusDaniel Eklöf2019-12-16-6/+14
|
* term: disable cursor blink before shutting down terminal, and remove from FDMDaniel Eklöf2019-12-16-0/+4
|
* term: cursor blink: cursor refresh now dirties the cursor cellDaniel Eklöf2019-12-16-5/+43
| | | | | | | | Normally we don't dirty the cell on cursor movement. But, since a blinking cursor isn't a cursor that has moved, our normal cursor rendering wont work. Dirty the cursor cell to force a redraw of it.
* term: implement cursor blinkingDaniel Eklöf2019-12-15-1/+64
| | | | | | | | | | | | | | Blinking can be enabled either by setting the cursor style with CSI Ps SP q and selecting a blinking style. Or, with 'CSI ? 12 h' Note that both affect the same internal state. I.e. you can disable blinking with CSI ? 12l after having selected a blinking cursor style. This is consistent with XTerm behavior.
* term: determine cell width from the width of the space characterDaniel Eklöf2019-12-05-1/+2
|
* term: test: set font DPI to the highest DPI we findDaniel Eklöf2019-12-04-4/+17
| | | | | | | | | | | In most cases (i.e. when there's only a single output/monitor), this will be *the* DPI value. In other cases, well... The _right_ thing to do is track the outputs our window is actually mapped on, and re-instantiate fonts depending on the current output's DPI. But that's for the future...
* fcft: font_from_name() no longer accepts a tllistDaniel Eklöf2019-12-01-13/+10
|
* term: mouse reporting functions no longer take modifier stateDaniel Eklöf2019-11-30-6/+19
| | | | | | | | | | | | | | | | The mouse reporting functions are called from input when we receive Wayland mouse events. We used to pass the current keyboard modifier (shift, alt, ctrl, etc) to the terminal functions. This however is wrong, since we may receive Wayland mouse events without having keyboard focus. When we don't have keyboard focus, the modifier state doesn't apply to us. Remove the modifier arguments from the terminal mouse reporting functions. These functions now read this state directly instead, but only when the terminal instance in question has keyboard focus.
* term: add term_mouse_grabbed()Daniel Eklöf2019-11-30-18/+15
| | | | | | When this returns true, it means we have keyboard focus and are grabbing the mouse (for e.g. selections), regardless of whether the client has enabled mouse tracking or not.
* term: "raw" mouse mode requires shift only to be pressedDaniel Eklöf2019-11-30-3/+12
|