Commit graph

257 commits

Author SHA1 Message Date
Daniel Eklöf
67614df9f9
term: print: reset combining characters for this cell
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.
2020-05-01 11:50:38 +02:00
Daniel Eklöf
69c3e74498
util.h: new header file defining commonly used macros 2020-05-01 11:46:24 +02:00
Daniel Eklöf
fc2e385d87
term: don't enable ptmx FDM callback until Wayland window has been configured
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.
2020-04-30 17:22:57 +02:00
Daniel Eklöf
ae5af7bb06
term: start slave before loading fonts and starting rendering threads
This allows the client to load in parallel with our font loading,
which should improve startup time.
2020-04-30 11:39:41 +02:00
Daniel Eklöf
589e984b91
term: font size adjust: re-load fonts in parallel 2020-04-29 20:09:21 +02:00
Daniel Eklöf
1d67f37045
term: destroy: handle rendering threads not being initialized
We sort of already did this. However, we did not handle the case where
the thread array itself hadn't yet been allocated.
2020-04-29 20:08:19 +02:00
Daniel Eklöf
84e945a851
term: initialize rendering worker threads after instantiating fonts
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.
2020-04-29 20:07:21 +02:00
Daniel Eklöf
3adcbf7d4d
term: load primary fonts in parallel
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.
2020-04-28 22:07:02 +02:00
Daniel Eklöf
e9ed3025a8
damage: remove 'scroll' sub struct
There is no other types of damage but scroll damage.
2020-04-26 12:47:19 +02:00
Daniel Eklöf
0b2006ecd5
term: fcft: max/space advance fields have been renamed 2020-04-23 11:54:03 +02:00
Daniel Eklöf
05bb0ae590
term: guess subpixel mode after initializing wayland window
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.
2020-04-22 19:38:38 +02:00
Daniel Eklöf
7194f65ae9
fcft: adjust to fcft-2.0 API changes
* font_*() -> fcft_*()
* struct font -> struct fcft_font
* struct glyph -> struct fcft_glyph
* enum subpixel_order -> enum fcft_subpixel
2020-04-21 19:29:36 +02:00
Daniel Eklöf
6f83ef81e5
render: use output's subpixel mode when rasterizing glyphs 2020-04-20 18:38:55 +02:00
Daniel Eklöf
5c4f5ab414
term: destroy: free scroll damage lists
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.
2020-04-19 15:26:52 +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
27a205e90f
term: reset: plug memory leak
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.
2020-04-13 11:42:10 +02:00
Daniel Eklöf
ec7a768487
conf: add 'title' conf option and --title command line option 2020-04-01 19:59:47 +02:00
Daniel Eklöf
598ac4bcd0
Merge branch 'master' into scroll-damage-performance 2020-03-27 21:16:42 +01:00
Daniel Eklöf
758fd9fd58
client: add --maximized and --fullscreen
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.
2020-03-27 21:14:49 +01:00
Daniel Eklöf
e197368c0f
config: add 'startup-mode' option
This option controls the initial window mode: windowed, maximized or
fullscreen. The default is windowed.
2020-03-26 19:39:12 +01:00
Daniel Eklöf
1891489cd6
app synchronized updates: set is_armed=false when enabling 2020-03-25 18:24: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
b79ed6f3e4
term: delayed rendering: failure to read timers is always an error 2020-03-24 17:41:33 +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
ba0d0e8bbb
term: delayed rendering: read timers even though is_armed = false
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.
2020-03-23 19:16:53 +01:00
Daniel Eklöf
6e63fdb053
conf: make delayed rendering timeouts configurable
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.
2020-03-17 16:46:54 +01:00
Daniel Eklöf
29c781b832
term: ptmx: don't set 'pending' flag when app sync updates are in use 2020-03-17 16:32:57 +01:00
Daniel Eklöf
233a909160
term: ptmx: don't enqueue extra frame render when app sync updates have been changed
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.
2020-03-16 17:47:27 +01:00
Daniel Eklöf
1006608093
alt-screen: use a custom 'saved' cursor when switching to alt screen
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.
2020-03-16 12:00:25 +01:00
Daniel Eklöf
59a1204c50
Merge branch 'scale-fonts-using-logical-dpi-plus-scale-factor' 2020-03-13 18:48:15 +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
acecab1c8b
term: use logical DPI+scale factor when scaling fonts
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
2020-03-11 16:10:55 +01:00
Daniel Eklöf
aa1aa0c09d
terminal: appky scale factor when force-resizing on font reload
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
2020-03-10 18:07:12 +01:00
Daniel Eklöf
6c6e3da7e2
term: init: no need to roundtrip 2020-03-09 18:46:50 +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
e077290c56
quirks: add shortcut for flipping all CSD surfaces sync/desync state 2020-03-03 18:20:09 +01:00
Daniel Eklöf
9699c9b8bf
csd: initial implementation of minimize/maximize/close buttons 2020-03-02 20:29:28 +01:00
Daniel Eklöf
f235bfdfdf
terminal: workaround founds with negative line gaps
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.
2020-03-02 18:43:23 +01:00
Daniel Eklöf
70cdb7af08
term: visual_focus_{in,out}: use quirk_weston_subsurface_desync_{on,off} 2020-03-01 13:09:25 +01:00
Daniel Eklöf
92d638eb1c
render: csd: split up positioning from rendering 2020-02-29 18:02:38 +01:00
Daniel Eklöf
8c98dfc51a
term: loop through all sub-surfaces when switching sync/desync mode 2020-02-29 09:26:49 +01:00
Daniel Eklöf
40f3d4c24c
terminal: error out when we fail to load the primary font 2020-02-28 18:35:05 +01:00
Daniel Eklöf
2f587f6f3d
csd: position CSD sub-surfaces *outside* the main window
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.
2020-02-26 12:17:58 +01:00
Daniel Eklöf
e9d3e7d87f
term: visual_focus_in/out: redraw CSDs
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.
2020-02-25 20:31:37 +01:00
Daniel Eklöf
ef53729242
render: resize with with/height == 0 resizes to user configured dimensions 2020-02-25 20:29:44 +01:00
Daniel Eklöf
ac32bcda07
main: geometry defaults to 800x600 pixels 2020-02-25 19:05:48 +01:00
Daniel Eklöf
7f270a9f01
term: add term_surface_kind(), and track currently active surface
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.
2020-02-24 22:38:35 +01:00
Daniel Eklöf
77fcb43ea5
term: scroll: call sixel_delete_*() instead of manually erasing sixel images 2020-02-24 18:42:52 +01:00
Daniel Eklöf
4c6f2ea340
term: term_erase(): call sixel_delete_*()
This ensures sixel images are removed, regardless of _how_ the screen
was erased.
2020-02-24 18:42:46 +01:00