Commit graph

769 commits

Author SHA1 Message Date
Daniel Eklöf
2e78dcc5e5
Don't use non-blocking FDs
We use epoll() to determine when we can read/write FDs so there's
absolutely no need for non-blocking.
2019-11-01 20:24:13 +01:00
Daniel Eklöf
95b7c405d4
wayland: wayl_win_destroy(): unmap windows before destroying
This will trigger e.d. keyboard_leave() and wl_pointer_leave() events,
which ensures there aren't any references to the destroyed window from
the global wayland struct.

Call wl_display_roundtrip() to trigger those events *before* we
destroy the window.
2019-11-01 20:19:53 +01:00
Daniel Eklöf
66b2097275
wayland: wayl_init(): call wl_display_roundtrip() when done 2019-11-01 20:04:40 +01:00
Daniel Eklöf
291a928a49
render: call wl_display_flush() after rendering
This allows us to remove that call from the main event loop.
2019-11-01 20:01:36 +01:00
Daniel Eklöf
b793919aba
wayland: fdm_del() now closes the FD 2019-11-01 19:59:39 +01:00
Daniel Eklöf
80c4721e57
fdm: don't free FD data that may be referenced by epoll return data
It is perfectly possible, and legal, for a FDM handler to delete
another handler. The problem however is when the epoll returned array
of FD events contain the removed FD handler *after* the handler that
removed it.

That is, if the epoll returned array is:

  [FD=13, FD=37]

and the handler for FD=13 removes FD=37, then given the current
implementation, the FD user data (our handler callback etc) will point
to a free:d address.

Add support for this situation by deferring FD handler removal *when
called from another handler*.

This is done by "locking" the FDM struct before looping the handlers
for FDs with events (and unlocking afterwards).

In fdm_del(), we check if the FDM has been locked, in which case the
FD is marked as deleted, and put on a deferred list. But
not *actually* deleted.

Meanwhile, in the FDM poll function, we skip calling handlers for
marked-for-deletion FDs.

Then, when all FDs have been processed, we loop the deferred list and
finally deletes the FDs for real.
2019-11-01 19:51:33 +01:00
Daniel Eklöf
4ae22b72a1
term: fdm_shutdown(): remove debug output 2019-10-30 20:28:21 +01:00
Daniel Eklöf
b7546abca9
main: get exit value from wayland struct 2019-10-30 20:26:08 +01:00
Daniel Eklöf
644585a3e5
term: term_shutdown(): set exit value in wayland 2019-10-30 20:25:45 +01:00
Daniel Eklöf
1ed78ab443
wayland: temporary: track last terminal's exit value 2019-10-30 20:25:31 +01:00
Daniel Eklöf
883354ffb1
wayland: wayl_win_destroy(): return early if win == NULL 2019-10-30 20:25:16 +01:00
Daniel Eklöf
c7238ef7f3
term: assign client PID to term->slave 2019-10-30 20:24:54 +01:00
Daniel Eklöf
58e31728a0
term: term_init(): create wayland window *last*
* Configure all FDs *completely* before moving on
* Start client before creating the wayland window
2019-10-30 20:22:01 +01:00
Daniel Eklöf
54039c1fb4
slave: log child's errno, not parents 2019-10-30 20:21:19 +01:00
Daniel Eklöf
98ccd01c1b
slave: fix debug logging (no 'term' variable) 2019-10-30 20:20:56 +01:00
Daniel Eklöf
2e0888bf3d
wayland: xdg_toplevel_close(): call term_shutdown() 2019-10-30 20:05:34 +01:00
Daniel Eklöf
9d5926ce12
term: add term_shutdown()
This function unmaps the terminal window, removes itself from the
wayland list of terminals and then finally destroys itself.

We ensure we don't get any callbacks/events referring to a free:d
terminal struct, we close all terminal related FDs and unmap the
wayland window.

Then, to be really really sure there aren't any (by the FDM) queued up
events, we delay the self-destruction to the next FDM poll iteration,
by opening an event FD and adding it to the FDM.

The callback for the event FD removes the FD from the FDM again, and
closes it. And then proceeds to destroy the terminal.
2019-10-30 20:03:11 +01:00
Daniel Eklöf
445bbe3469
wayland: track multiple terminals
The wayland 'term' member is gone and replaced by a list,
'terms'. This list contains all currently running terminal (windows).
2019-10-30 20:02:06 +01:00
Daniel Eklöf
e084bf2b0f
Merge branch 'term-init-cleanup' 2019-10-30 18:07:22 +01:00
Daniel Eklöf
a853896715
main: free 'config' on command line parse error 2019-10-30 18:06:47 +01:00
Daniel Eklöf
18921f7f45
term: move client startup to a new function, slave_spawn() 2019-10-30 18:05:03 +01:00
Daniel Eklöf
348f3738da
term: break out font initialization to a separate function 2019-10-30 17:50:12 +01:00
Daniel Eklöf
7dcd6b7d55
term: break out render worker threads initialization to a separate function 2019-10-30 17:45:59 +01:00
Daniel Eklöf
54accd8060
term: break out color cube initialization to a separate function 2019-10-30 17:40:09 +01:00
Daniel Eklöf
8d6817a999
term: require all font variants to load 2019-10-30 17:37:30 +01:00
Daniel Eklöf
ad0f8a02d5
Merge branch 'fdm' 2019-10-30 17:31:44 +01:00
Daniel Eklöf
ce5f5e4d51
slave: rename slave_spawn() -> slave_exec() 2019-10-30 17:30:58 +01:00
Daniel Eklöf
a42df2434b
scrollback: regression: fix rendering of scrollback diffs less than a screen
When doing "small" scrolls (typically done via mouse wheel or
similar), we render the scrolling by emitting a "scroll damage".

A recent commit changed how scroll damage is rendered; only when the
view is at the bottom ("following" the screen output) do we render the
damage.

To fix this, add a new type of scroll damage,
SCROLL_DAMAGE_IN_VIEW and SCROLL_DAMAGE_REVERSE_IN_VIEW.

These signal to the renderer that it should always render the damage.
2019-10-29 21:09:37 +01:00
Daniel Eklöf
4ec9db8e18
term: no need to stack-allocate an array of worker contexts 2019-10-28 19:23:41 +01:00
Daniel Eklöf
8e6f87eb17
render worker context: allocate, and let worker threads free
Since we now initialize the worker threads from term_init(), which
returns before the threads terminate, we can no longer use
stack-allocated worker contexts.

We _could_ put them in the terminal struct. But a simpler solution is
to allocate them in term_init(), and let the threads free them when
they don't need them anymore.
2019-10-28 18:51:04 +01:00
Daniel Eklöf
720d0df067
term: open FDs before allocating terminal struct 2019-10-28 18:46:03 +01:00
Daniel Eklöf
fe974956b0
term: integrate directly with FDM 2019-10-28 18:35:16 +01:00
Daniel Eklöf
0979a0e2e5
terminal: implement term_init() and term_destroy() 2019-10-28 18:25:19 +01:00
Daniel Eklöf
89cec15920
render: regression: don't apply scroll damage when view is in scrollback
When user has scrolled back in the output history, new output should
not trigger scrolling.

This was true for normal cell rendering, which renders the cells *in
view*, not caring where the "front" of the output is.

However, we still applied scroll damage. I.e. we memmoved part of the
screen.

The fix is simple; only apply scroll damage when the view is at the
front of the output.
2019-10-28 17:58:44 +01:00
Daniel Eklöf
957fb25559
wayland: move reload_cursor_theme() and update_cursor_surface() to wayland 2019-10-27 19:36:45 +01:00
Daniel Eklöf
664641104c
main: remove a couple of includes 2019-10-27 19:28:23 +01:00
Daniel Eklöf
3684547fd7
main: kbd repeat FD is handled by the wayland backend 2019-10-27 19:23:22 +01:00
Daniel Eklöf
4a63defeb1
wayland: backend now configures FD as non-blocking, not main 2019-10-27 19:21:36 +01:00
Daniel Eklöf
2eaa258e11
main: cleanup 2019-10-27 19:21:27 +01:00
Daniel Eklöf
9a31c1ed96
wayland: free wayland/wl_window instances 2019-10-27 19:16:42 +01:00
Daniel Eklöf
6314de554d
wayl_destroy: early return on NULL 2019-10-27 19:16:25 +01:00
Daniel Eklöf
251cf98388
wayland: move keyboard repeat handling into wayland 2019-10-27 19:16:12 +01:00
Daniel Eklöf
1e75b89552
wayland: integrate directly with the FDM 2019-10-27 19:11:35 +01:00
Daniel Eklöf
61cc8c3c55
wayland: implement wayl_init()
Wayland instantiation is now done by the wayland backend, not in main.
2019-10-27 19:08:48 +01:00
Daniel Eklöf
1adab32906
term: wayland struct is now not a part of the terminal struct
We do however need access to it, so provide a pointer. The difference
is that now we can have a *single* wayland instance, but multiple
terminal instances.
2019-10-27 18:51:14 +01:00
Daniel Eklöf
33e4b8a5b8
wayland: pull in sys/time.h, for 'struct timeval' 2019-10-27 18:46:36 +01:00
Daniel Eklöf
8c534d0520
input: input_repeat() takes a 'struct wayland' pointer 2019-10-27 18:44:58 +01:00
Daniel Eklöf
9f0b1f94c2
wayland: change all wayland callbacks to take a wayland pointer
Instead of passing the terminal to the wayland callbacks, pass a
'struct wayland' pointer.
2019-10-27 18:43:07 +01:00
Daniel Eklöf
eda04d0560
wayland: add back-pointer to terminal
This can, in the future, be extended to e.g. a list, to support
multiple windows.
2019-10-27 17:13:29 +01:00
Daniel Eklöf
c9455d5f21
kbd: move into wayland 2019-10-27 17:10:32 +01:00