Commit graph

242 commits

Author SHA1 Message Date
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
Daniel Eklöf
6d69311630
term: scroll: don't delete sixel images on the 'other' grid 2020-02-23 00:41:10 +01:00
Daniel Eklöf
86d640ef71
sixel: rename: purge_at_cursor() -> delete_at_cursor() 2020-02-22 23:06:11 +01:00
Daniel Eklöf
80361ca04e
sixel: purge images at current cursor row
When printing a character, or starting a new sixel image, purge all
images that cover the cursor's current row.
2020-02-22 21:35:45 +01:00
Daniel Eklöf
8e37a18083
sixel: application configurable palette size (color count)
This implements the CSI escapes for retrieving and (re)setting the
palette size.
2020-02-22 14:02:00 +01:00
Daniel Eklöf
ad5b2030f0
term: free sixel images on reset 2020-02-22 10:47:16 +01:00
Daniel Eklöf
bb82b9fabc
sixel: add sixel_destroy() 2020-02-22 00:23:19 +01:00
Daniel Eklöf
63140a68f5
sixel: calculate image height in (cell) rows 2020-02-22 00:05:25 +01:00
Daniel Eklöf
f0fc82f098
sixel: wip: maintain a list of finished, and "active" sixel images
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.
2020-02-21 23:40:35 +01:00
Daniel Eklöf
01f8719c77
term: spawn_new: check return value of chdir() and write() 2020-02-20 18:46:16 +01:00
Daniel Eklöf
b5efe984bb
slave: prefix argv[0] with a '-' when spawning a login-shell 2020-02-20 18:36:09 +01:00
Daniel Eklöf
4d3ab6176d
term: implement term_font_dpi_changed()
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.
2020-02-15 19:08:14 +01:00
Daniel Eklöf
d11a71e0b2
term: reset: use grid_row_alloc() with initialize=true
This will both zero out the cells, *and* re-initialize the row
properties correctly.
2020-02-14 22:43:23 +01:00
Daniel Eklöf
ce8005545d
term: convert cell 'linefeed' attribute to a row 'linebreak' property
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.
2020-02-14 22:39:26 +01:00
Daniel Eklöf
69a633221f
term: formfeed: set linefeed correctly when we're at last column with lcf=1
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.
2020-02-12 18:06:27 +01:00
Daniel Eklöf
335bf2e5b4
Merge branch 'text-reflow' 2020-02-11 19:39:23 +01:00