Commit graph

310 commits

Author SHA1 Message Date
Daniel Eklöf
6f83ef81e5
render: use output's subpixel mode when rasterizing glyphs 2020-04-20 18:38:55 +02:00
Daniel Eklöf
b7593897b7
render: search: improve handling of very long search strings 2020-04-19 14:50:48 +02:00
Daniel Eklöf
fa8b0cbd80
csi: implement CSI Ps ; Ps ; Ps t reporting escape sequences
A lot of the escape sequences on the "CSI Ps ; Ps ; Ps t" form are
expected to return a reply. Thus, not having these implemented means
we will hang if the client sends these escapes.

Not all of these escapes can be meaningfully implemented on Wayland,
and thus this implementation is best effort.

We now support the following escapes:

* 11t   - report if window is iconified (always replies "no")
* 13t   - report window position (always replies 0,0)
* 13;2t - report text area position (replies with margins, since we
          cannot get the window's position)
* 14t   - report text area size, in pixels
* 14;2t - report window size, in pixels
* 15t   - report screen size, in pixels
* 16t   - report cell size, in pixels
* 18t   - report text area size, in cells
* 19t   - report screen size, in cells
2020-04-18 11:51:53 +02:00
Daniel Eklöf
761bf426dc
render: resize: no need to truncate selection anymore - it's being translated 2020-04-17 22:30:56 +02:00
Daniel Eklöf
7eb990c8b1
render: resize: need to translate selection coordinates
While it *looked* like the selection was working before, it really
wasn't.

When rendering, we're looking at the cells' attributes to determine
whether they have been selected or not.

When copying text however, we use the terminal's 'selection' state,
which consists of 'start' and 'end' coordinates.

These need to be translated when reflowing text.
2020-04-17 22:20:27 +02:00
Daniel Eklöf
5509fe514a
render: resize: no need to clear the selection - just truncate if necessary 2020-04-17 21:11:30 +02:00
Daniel Eklöf
ef52ed8a10
grid: reflow: caller may now pass a list of coordinates that should be translated 2020-04-17 21:04:32 +02:00
Daniel Eklöf
5546b40369
grid: grid_reflow() now translates cursor coordinates 2020-04-16 19:38:30 +02:00
Daniel Eklöf
89559d5466
grid: move 'cursor' state from terminal to grid
This way, the 'normal' and 'alt' grids have their own cursor state,
and we don't need to switch between them.
2020-04-16 18:51:14 +02:00
Daniel Eklöf
c96a0b3b3c
misc: replace all explicit zero-initializers with empty initializers 2020-04-13 12:03:11 +02:00
Daniel Eklöf
03bdb40bd9
render: don't dim so much when in search mode 2020-04-10 17:51:33 +02:00
Daniel Eklöf
23b2eed409
render: strip 'pixman' from color function names 2020-04-09 13:41:16 +02:00
Daniel Eklöf
29d4722de5
render: remove unused functions 2020-04-09 13:35:35 +02:00
Daniel Eklöf
03319560f5
shm: scroll: keep shm pool around, and fix its size at max allowed
This lessens the burden on (primarily) the compositor, since we no
longer tear down and re-create the SHM pool when scrolling.

The SHM pool is setup once, and its size is fixed at the maximum
allowed (512MB for now, 2GB would be possible).

This also allows us to mmap() the memfd once. The exposed raw pointer
is simply an offset from the memfd mmapping.

Note that this means e.g. rouge rendering code will be able to write
outside the buffer.

Finally, only do this if the caller explicitly wants to enable
scrolling. The memfd of other buffers are sized to the requested size.
2020-03-25 18:26:58 +01:00
Daniel Eklöf
9bbbd26c7a
render: pace title updates
Synchronize window title updates with window rendering.
2020-03-25 18:23:55 +01:00
Daniel Eklöf
b46ad6a50a
render: explain _why_ we set a clip region 2020-03-24 21:04:30 +01:00
Daniel Eklöf
dc393bd5d7
render: bug: clear clip region before tinting the window 2020-03-24 17:45:45 +01:00
Daniel Eklöf
b08238a1a1
render: attach buffer just before commit 2020-03-24 17:45:38 +01:00
Daniel Eklöf
9a3e97afa7
render: clear scroll damage list when we force-refresh the entire window 2020-03-24 17:45:16 +01:00
Daniel Eklöf
3a04061847
Merge branch 'master' into scroll-damage-performance 2020-03-24 17:44:05 +01:00
Daniel Eklöf
be8b6e8c75
render: fdm refresh handler: don't clear pending flags
The pending flags may already be set (from a previous call to the FDM
hook). In this case, they should not be cleared.
2020-03-24 17:42:29 +01:00
Daniel Eklöf
759fd572e9
shm: shm_scroll(): initial implementation of reverse scrolling
Implemented by truncating the file size and moving the offset
backwards. This means we can only reverse scroll when we've previously
scrolled forward.

TODO: figure out if we can somehow do fast reverse scrolling even
though offset is 0 (or well, less than required for scrolling).
2020-03-23 21:14:51 +01:00
Daniel Eklöf
0de3701984
shm: scroll: move top/bottom region handling from renderer into shm
This allows us to restore the regions without copying the contents to
temporary memory.
2020-03-23 20:45:27 +01:00
Daniel Eklöf
00129b1935
render: scroll: use shm scrolling even though we have a top region 2020-03-23 20:16:19 +01:00
Daniel Eklöf
75180cea37
render: scroll: take margins into account when restoring bottom scroll region 2020-03-23 20:15:53 +01:00
Daniel Eklöf
7958f8b5ef
render: scroll: move comment to where it belongs 2020-03-23 20:15:04 +01:00
Daniel Eklöf
9166be8aed
render: margins: caller explicitly asks for top/bottom margins 2020-03-23 20:14:30 +01:00
Daniel Eklöf
7fd6916446
render: margins: regression: fix incorrect margins 2020-03-23 20:12:19 +01:00
Daniel Eklöf
6bc9fd4ba1
Merge branch 'master' into scroll-damage-performance 2020-03-23 19:30:20 +01:00
Daniel Eklöf
5a972cb98e
delayed rendering: ignore frame callback if delayed rendering is active
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).
2020-03-23 19:21:41 +01:00
Daniel Eklöf
ed987b2de7
render: use shm_scroll() when we believe it will be faster
shm_scroll() is fast when memmove() is slow. That is, when scrolling
a *small* amount of lines, shm_scroll() is fast.

Conversely, when scrolling a *large* number of lines, memmove() is
fast.

For now, assume the two methods perform _roughly_ the same given a
certain number of bytes they have to touch.

This means we should use shm_scroll() when number of scroll lines is
less than half the screen. Otherwise we use memmove.

Since we need to repair the bottom scroll region after a shm_scroll,
those lines are added to the count when determining which method to
use.

TODO:

* Check if it's worth to do shm scrolling when we have a top scroll
  region.
* Do more performance testing with a) various amount of scrolling
  lines, and b) larger bottom scroll regions.
2020-03-22 20:22:17 +01:00
Daniel Eklöf
48091966cb
render: resize: update saved 'normal' cursor if we're in alt screen
When resizing in alt mode, we never updated the saved 'normal'
cursor. This meant that when we exited alt mode, the cursor would be
positioned where it was in the old pre-resize/reflow grid.

Now, we update the saved cursor in the same way we update visible
cursor. The result is that when we exit the alt screen, the cursor
is restored to the same coordinates it would have been updated to had
the resize been done in the 'normal' screen.
2020-03-22 11:14:56 +01:00
Daniel Eklöf
6a35abb6ca
shm: new functions: shm_cookie_*()
These functions return a SHM cookie given a terminal instance.
2020-03-18 16:52:33 +01:00
Daniel Eklöf
a2774878ef
render: don't try to resize if we're shutting down
This fixes an issue where we sometimes (depends on compositor?) tried
to signal a TIOCSWINSZ and failed. This caused us to log a misleading
error message.
2020-03-17 13:27:26 +01:00
Daniel Eklöf
93207bc482
render: render non-block cursors after rendering the glyph + decorations
This fixes an issue where an 'underline' cursor wasn't visible on
underlined text - the cursor was rendered first, and then shadowed by
the text underline.
2020-03-17 11:47:47 +01:00
Daniel Eklöf
d482bf0a30
sixel: improve handling of images when reflowing the grids
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.
2020-03-13 18:47:16 +01:00
Daniel Eklöf
c5a1af4e53
render: never render CSD and/or search box "immediately"
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.
2020-03-06 19:16:54 +01:00
Daniel Eklöf
e5540a0d2e
render: csd: improved look of minimize/maximize/close buttons
* minimize: a downward triangle
* maximize (window): an upward triangle
* maximize (already maximized): a hollow square
* close: a filled square

The glyphs are now rendered using the default background color instead
of hardcoded to black.
2020-03-06 19:15:09 +01:00
Daniel Eklöf
f434933824
render: CSD: use *default* foreground, not current foreground
Applications may temporarily change the foreground color. Don't use
this when rendering the CSD title bar - use the default
foreground (i.e the default default one, or the one configured by the
user in footrc).
2020-03-06 19:13:10 +01:00
Daniel Eklöf
a78cca74a0
render: oops, add missing '}' 2020-03-03 18:29:46 +01:00
Daniel Eklöf
b81b1b6ff7
render: configure a clip region to exclude the grid margins
This ensures content in the last column doesn't flow over into the
margins (where they are typically never erased, unless the window is
resized).
2020-03-03 18:27:59 +01:00
Daniel Eklöf
d76484ae50
wayland: set window geometry to exclude the invisible CSD borders
But it *does* include the title bar. This simplifies the 'adjustment'
needed to be done to the configured window size.

It also fixes a number of issues:

* the compositor will now properly snap the window to screen
  edges (before, there was an empty space between the edge and the
  window - the CSD border).
* This also removes the need for the mutter 'commit' workaround. We
  must be doing something right now.
2020-03-03 18:26:15 +01:00
Daniel Eklöf
044556ef3e
render: csd: render surfaces in reverse order
This ensures the inner most child surfaces are rendered and comitted
before the parent surfaces.
2020-03-03 18:24:51 +01:00
Daniel Eklöf
da91a9de4b
render: csd: assert surfaces exist before trying to use them 2020-03-03 18:24:31 +01:00
Daniel Eklöf
09bb9bef33
render: csd: center 'close' button's cross 2020-03-03 18:24:09 +01:00
Daniel Eklöf
c9659ecd14
render: csd: don't even try to render CSDs when we're in fullscreen mode 2020-03-03 18:23:52 +01:00
Daniel Eklöf
c10f1d5459
render: don't try to render CSDs when the terminal is shutting down 2020-03-03 18:23:37 +01:00
Daniel Eklöf
c90d70b2bf
config: CSD borders are always invisible
That is, remove all configuration options and always draw them fully
transparent.
2020-03-03 18:18:59 +01:00
Daniel Eklöf
cb6616ef8a
render: csd: maximize: change default color to a lighter green 2020-03-02 21:11:17 +01:00
Daniel Eklöf
63a3d6ce03
render: csd: close: change default color to a lighter blue 2020-03-02 21:10:25 +01:00