aboutsummaryrefslogtreecommitdiff
path: root/terminal.c (follow)
Commit message (Collapse)AuthorAgeLines
* 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
|
* term: define xcursor strings as global variablesDaniel Eklöf2019-11-30-3/+7
|
* term: xcursor: use selection_enabled()Daniel Eklöf2019-11-30-2/+1
| | | | | | | | Instead of duplicating the code from selection_enabled() that deals with forced selection, just call selection_enabled(). This was previously not possible since selection_enabled() didn't require keyboard_focus. Now it does.
* term: reset: set 'origin' to ORIGIN_ABSOLUTEDaniel Eklöf2019-11-29-0/+1
|
* term: reset: don't access rows directlyDaniel Eklöf2019-11-29-2/+2
| | | | | | | We've just re-set the grid offsets, meaning rows 0..term->rows may not all have been initialized. Call grid_row_and_alloc() to ensure they are.
* term: xcursor: use 'hand2' instead of 'left_ptr' when mouse trackingDaniel Eklöf2019-11-29-13/+5
| | | | | Mouse tracking always reports clicks, so using a cursor that suggests you can click makes sense I think.
* term: xcursor cleanupDaniel Eklöf2019-11-29-4/+11
| | | | | | | | | | Show 'text' cursor when: * we have no mouse tracking enabled * forced selection has been enabled (shift being held down) * We're *not* scrollback searching In all other cases, show the 'left_ptr' cursor.
* terminal: use the 'text' xcursor pointer whenever selection is possibleDaniel Eklöf2019-11-28-0/+14
|
* async: first synchronous write may succeed partiallyDaniel Eklöf2019-11-28-2/+3
| | | | | | | | | When trying to write (to e.g. the slave, or to a clipboard receiver), we first try to send the data synchronously, and only if that fails do we switch to asynchronous mode. However, the first synchronous may (in fact, is likely to) succeed partially.
* font: pass dpi=96 to fontconfigDaniel Eklöf2019-11-26-4/+4
| | | | TODO: use actual output PPI. Question is *which* output...
* font: move metrics from terminal struct to font structDaniel Eklöf2019-11-26-17/+2
|
* term: shutdown: handle *not* being unmappedDaniel Eklöf2019-11-21-0/+14
| | | | | | | | | | When we're shutting down a terminal, we destroy our Wayland window, and assume that will unmap us. There are cases when this isn't true (most likely when e.g. a screen locker is active, and the unmap is being deferred). Handle by explicitly setting focused to NULL.
* fonts: use 'weight' and 'slant', not 'style' when loading fontsDaniel Eklöf2019-11-19-3/+3
|
* term: report_mouse_click(): legacy mode only supports rows/cols up to 223.Daniel Eklöf2019-11-18-2/+8
| | | | | | In the legacy mouse reporting mode, line and column numbers are limited to 223 (255-32). In case the current coordinate falls outside this, simply ignore it (don't report it).
* term: assert(false) on MOUSE_X10Daniel Eklöf2019-11-18-3/+15
| | | | | This mouse mode is never enabled. I.e. we don't support it. Add asserts to catch usage of it, should we ever decide to implement it.
* term: try to improve on a performance regressionDaniel Eklöf2019-11-17-17/+7
| | | | | | | | When support was added for DECOM (absolute/relative row addressing), a small but noticeable (~3.5%) performance regression was introduced. Try to improve the situation by simplifying the relative-to-absolute conversion; only the row needs to be transformed.
* Revert "term: new function: term_autowrap()"Daniel Eklöf2019-11-17-15/+0
| | | | This reverts commit 686405b7031736445eeb35206e4a797a8dd78d91.
* term: new function: term_autowrap()Daniel Eklöf2019-11-17-0/+15
| | | | | | | Adds a linebreak (+ scroll if necessary) if we're in a deferred wrap and auto-margins are enabled. Return true when we wrapped, false otherwise.
* term: save/restore charsets on save/restore cursor+attributesDaniel Eklöf2019-11-17-0/+1
|
* term: move charset variables into an anonymous structDaniel Eklöf2019-11-17-5/+5
|
* term: restore_cursor: restore lcf flagDaniel Eklöf2019-11-17-0/+1
|
* term: move lcf flag into 'cursor' structDaniel Eklöf2019-11-17-4/+4
|
* term: add struct cursorDaniel Eklöf2019-11-17-23/+23
|
* term: rename: print_needs_wrap -> lcf (Last Column Flag)Daniel Eklöf2019-11-17-4/+4
|
* term: cursor_{up,down}: limit cursor movements based on origin modeDaniel Eklöf2019-11-16-2/+8
|
* term: add tab-stop list to terminal structDaniel Eklöf2019-11-16-0/+2
| | | | This list is intended to store tab stop columns
* csi: implement DECOM - switch cursor origin between absolute and relativeDaniel Eklöf2019-11-05-0/+32
| | | | | | | | | | | The default is absolute mode, where 0,0 is the upper left corner of the screen. In relative mode, the origin is relative the top scroll margin. Internally, we always track the current cursor position in absolute mode. Every time we the client *sets* or *queries* the cursor position in relative mode, we translate it to absolute.
* terminal: ptmx: ignore *both* EPOLLIN and EPOLLOUT on EPOLLHUPDaniel Eklöf2019-11-05-5/+11
|
* terminal: use async_write() when writing to ptmxDaniel Eklöf2019-11-04-50/+20
|
* selection: send primary/clipboard data asynchronouslyDaniel Eklöf2019-11-04-0/+1
| | | | TODO: try writing synchronously first
* terminal: add comments describing the sync/async writing modesDaniel Eklöf2019-11-04-1/+25
|
* terminal: malloc_trim() is a GNU extensionDaniel Eklöf2019-11-03-0/+4
|
* terminal: trim memory after free:ing a terminalDaniel Eklöf2019-11-03-0/+3
| | | | | | | | | | | | | A terminal with lots of scrollback history will have allocated a lot of memory. Normally, free() wont return this memory to the OS, and we don't seem to trigger the automatic trim calls. This means the server would accumulate quite a lot of memory over time, as terminals come and go. Now we explicitly trim the memory every time a terminal is destroyed.
* terminal: ptmx fdm handler: tag unlikely branchesDaniel Eklöf2019-11-03-3/+3
|
* terminal: comments and cleanupDaniel Eklöf2019-11-03-0/+9
|
* terminal: cleanup asynchronous ptmx output handlingDaniel Eklöf2019-11-03-37/+41
| | | | | Break out actual writing to a separate function, and call this function both from the synchronous and the asynchronous code paths.
* term: asynchronous writes to slaveDaniel Eklöf2019-11-03-21/+98
| | | | | | | | | | Make ptmx non-blocking. Then, when writing data to the slave would have blocked, use the FDM to asynchronously write the remaining data. This is done by enabling EPOLLOUT on ptmx, and enqueueing all outgoing data. The FDM handler will go through the enqueued data, and once all of it has been written, we turn off EPOLLOUT again (thus switching back to synchronous writes)
* Rename: vt_to_slave() -> term_to_slave()Daniel Eklöf2019-11-02-3/+23
|
* misc: fdm already logs failuresDaniel Eklöf2019-11-02-18/+4
|
* terminal: don't get stuck waiting for misbehaving slaves to terminateDaniel Eklöf2019-11-02-4/+64
| | | | | | | | | | | | | | While unusual, it *is* possible for a client *not* to terminate when we close ptmx. We need to handle this *somehow*. Since it is so unusual, we'll go with a fairly easy, but synchronous method: * Register a signal handler for SIGALRM, and setup a 2 second alarm * Wait for slave to die * If it didn't die, sent SIGTERM, then re-set the alarm for another 2 seconds. * If it still hasn't died, send SIGKILL (this time without an alarm).
* terminal: 'child_ret' variables isn't neededDaniel Eklöf2019-11-02-5/+3
|
* timerfd: read() returns -1 with errno == EAGAIN, not 0Daniel Eklöf2019-11-02-15/+9
| | | | | | When there hasn't been a timeout (or in our case, there was a timeout, but we reset the timer before we got to the read()), read() returns, not 0, but -1 with errno == EAGAIN.
* timerfd: use non-blocking mode, fixes dead lockDaniel Eklöf2019-11-02-4/+19
| | | | | | | | | | | Since we cancel the timers every now and then, there's a (small) chance that one handler cancels a timer that has triggered in the same epoll() iteration. When this happens, read() blocks. Fix by making the timer FDs non-blocking, and simply returning when we read 0 bytes.
* term_init(): initialize slave TERM from term_init() argumentDaniel Eklöf2019-11-01-2/+2
|
* slave: set TERM environment variable in slave processDaniel Eklöf2019-11-01-1/+1
|
* terminal: call user-defined callback when destroying terminalDaniel Eklöf2019-11-01-1/+8
| | | | main uses this to get the exit code of the terminal.
* term_shutdown(): cleanupDaniel Eklöf2019-11-01-49/+35
| | | | | * Close FDs, then delay destruction to next epoll() call * Destroy window before destroying terminal
* terminal: fdm_del() closes the FDDaniel Eklöf2019-11-01-20/+6
|
* terminal: delayed rendering: fdm_delayed_render() may be called with is_armged==falseDaniel Eklöf2019-11-01-1/+2
| | | | This would happen if *both* timers triggered in the same epoll() call.
* terminal: no need to check for EAGAIN - we don't use non-blockingDaniel Eklöf2019-11-01-18/+10
|