Commit graph

173 commits

Author SHA1 Message Date
Daniel Eklöf
8c3d48c5cd
ime: render pre-edit text
This is done by allocating cells for the pre-edit text when receiving
the text-input::done() call, and populating them by converting the
utf-8 formatted pre-edit text to wchars.

We also convert the pre-edit cursor position to cell positions (it can
cover multiple cells).

When rendering, we simply render the pre-edit cells on-top off the
regular grid. While doing so, we also mark the underlying, “real”,
cells as dirty, to ensure they are re-rendered when the pre-edit text
is modified or removed.
2020-12-07 20:44:10 +01:00
Daniel Eklöf
5745c610ac
ime: wip: commit all changes in ‘done()’ 2020-12-07 20:44:10 +01:00
Daniel Eklöf
148bb1ff13
ime: wip: add text-input object to seat 2020-12-07 20:44:09 +01:00
Kenny Levinsen
ab6327da26 wayland: Use wl_output_release with wl_output v3
wl_output_release, the use of which was recently introduced, is not
available until wl_output interface version 3.

However, only wl_output version 2 was bound. This lead to protocol
errors when a display was disconnected, causing foot to terminate.

Instead, only use wl_output_release if wl_output version 3 is provided
and bound. Otherwise, just use wl_output_destroy.

Closes: https://codeberg.org/dnkl/foot/issues/219
2020-11-25 00:19:23 +01:00
Daniel Eklöf
02ee570c27
wayland: preempt render scheduling in ‘configure’ events
A configure event must be “committed”. In case of resizing, that means
rendering a new frame and committing that surface.

render_resize() will resize the grid and *schedule* a render
refresh. However, if one is already pending, the refresh will take a
very (relatively) long time - until the next frame callback is
received.

This poses a problem when the window is hidden, since in this case,
the frame callback *never* comes. This in turn means we fail to commit
a new surface in response to the ‘configure’ event. And that means the
compositor needs to wait for a transaction timeout before continuing.

The end effect is very slow and jerky window resizing when a hidden
foot window is being resized.

This can happen in tiled compositors, like Sway, where a window can be
tabbed (and thus invisible), but still resized when its container is
resized.

Closes #190
2020-11-10 19:20:35 +01:00
Daniel Eklöf
85220a5543
wayland: use wl_*_release() instead of wl_*_destroy()
This lets the compositor free up internal state.
2020-11-09 19:59:45 +01:00
Daniel Eklöf
b541ce9d5c
wayland: output removed: only call surface_leave() if term is actually mapped on that output 2020-11-06 19:25:54 +01:00
Daniel Eklöf
af3b604d8e
wayland: bind to data-device-manager version 3, for drag-and-drop support 2020-10-26 21:02:24 +01:00
Daniel Eklöf
f928c1fa68
wayland: properly restore window size when being un-tiled
Bind to xdg-shell version 2 if available, as this enables us to
track our window’s ‘tiled’ state in the ‘configure’ events.

This in turn allows us to stash the ‘old’ window size when being
tiled, to be used again when restoring the window size when un-tiled.
2020-10-20 20:58:03 +02:00
Daniel Eklöf
6afe64b7f4
wayland: don’t instantiate a decoration object when user disabled decorations
An application opts *in* for being compositor-decorated by
instantiating a decoration object.

This means, even if we request e.g. CSDs, the compositor can choose to
use SSDs.

By *not* instantiating a decorator object, the compositor *must* not
decorate the window for us.

So, when the user has set csd.preferred=none, we absolute do not want
the compositor to decorate us. Thus, we refrain from instantiating a
decoration object.
2020-10-11 18:47:26 +02:00
Daniel Eklöf
6ff97128fc
conf: csd.preferred can now be set to ‘none’
When csd.preferred == none, we will request CSDs from the compositor,
but internally render as if we are using SSDs. That is, we don’t
render any window decorations at all.

Note that some compositors may ignore our request to use CSDs, and
still render SSDs for us.

Closes #163
2020-10-10 13:07:29 +02:00
Daniel Eklöf
f2c59f8608
wayland: register xdg-output interface on pre-existing output objects
The XDG output manager object may arrive *after* output objects. In
this case, we need to register the pre-existing output objects with
the XDG output manager.

This fixes an issue with some monitors having a DPI value of 0 on
Gnome/mutter, which resulted in incorrect font sizes.
2020-09-04 17:56:40 +02:00
Daniel Eklöf
640445acb4
render: render-timer: position sub-surface similar to the scrollback indicator 2020-08-14 07:48:40 +02:00
Daniel Eklöf
49eea3893e
wayland: global-remove: return after finding a matching seat 2020-08-13 18:47:19 +02:00
Daniel Eklöf
6b18bd998a
wayland: global-remove: fix call to pointer_listener.leave()
Don't call it when we have keyboard focus, call it when we have mouse
focus.
2020-08-13 18:47:19 +02:00
Daniel Eklöf
544c1b1976
config: wip: add support for modifiers in mouse bindings
Mouse bindings can now include modifiers. They are specified in pretty
much the same way as in keyboard bindings:

  Control+BTN_LEFT
2020-08-13 18:47:19 +02:00
Daniel Eklöf
17070a0d54
config: add tweak.render-timer option
This can be set to 'none' (the default), 'osd', 'log' or 'both'.

When 'osd' is enabled, we'll render the frame rendering time to a
sub-surface after each frame.

When 'log' is enabled, the frame rendering time is logged on stderr.
2020-08-13 18:35:17 +02:00
Craig Barnes
4e6100494c Handle allocation failures explicitly in *_init() functions 2020-08-09 08:55:20 +01:00
Craig Barnes
7a77958ba2 Convert most dynamic allocations to use functions from xmalloc.h 2020-08-08 20:37:57 +01:00
Daniel Eklöf
295083059c
Merge branch 'master' into diagonal-dpi 2020-07-28 20:01:56 +02:00
Daniel Eklöf
2815c1c076
wayland: add scrollback indicator surface + sub-surface to wl_window 2020-07-26 10:00:50 +02:00
Daniel Eklöf
e955a14dd0
wayland: calculate a single, scaled DPI value
Previously, we calculated the monitors horizontal and vertical PPI
values.

For font sizing, we used the vertical PPI value. It seems however,
that using the diagonal PPI value, i.e. diagonal_px / diagonal_inch,
gives more consistent results.

This is still a PPI value, but since it is intended to be used as a
FontConfig DPI value, name it 'dpi'.
2020-07-26 07:41:57 +02:00
Daniel Eklöf
067cf6ccb1
wayland: don't assume data-device globals are added before seats
When we're handling the initial set of globals, the data-device and
primary-selection-device objects may, or may not be registered before
the seat(s).

We need to handle both cases.

When adding a seat, instantiate the data-device and
primary-selection-device **if available**.

When adding the device objects, instantiate them on **all** currently
available seats.
2020-07-16 17:47:47 +02:00
Daniel Eklöf
d169e96346
wayland: configure: do a regular resize instead of a force resize
The commit log says that was needed to get tiling in GNOME
working. However, I don't know *which* extension that was.

Force resizing in a configure event means we'll trash a perfectly
valid buffer on e.g. 'activated' state changes.

So, let's revert this for now, and if this breaks GNOME, let's try to
find another solution. If worse comes to worse, we can detect if we're
running under GNOME and do a force-resize then, but not on sane
compositors.
2020-07-13 15:01:27 +02:00
Daniel Eklöf
1c13061f35
wayland: destroy cursor theme when removing pointer capability 2020-07-10 19:32:48 +02:00
Daniel Eklöf
5677df629e
wayland: seat: instantiate pointer surface in capabilities event
This way we only instantiate the surface for seats that actually have
a pointer.
2020-07-10 19:24:33 +02:00
Daniel Eklöf
bf62519d83
wayland: read XCURSOR_{THEME,SIZE} in reload_xcursor theme 2020-07-10 12:06:55 +02:00
Daniel Eklöf
a6da07b3dd
wayland: globals: destroy: seat: use keyboard/pointer listener interfaces 2020-07-09 08:52:39 +02:00
Daniel Eklöf
b6342bb36d
wayland: globals: destroy: handle seats being destroyed 2020-07-09 08:47:56 +02:00
Daniel Eklöf
98f3ccfe79
wayland: log: be clear that these are the XCRUSOR_* environment variables 2020-07-08 20:04:02 +02:00
Daniel Eklöf
d377221e24
xcursor: trigger theme reload in pointer-enter event
Previously, we triggered a theme reload on output changes. This is
completely wrong. We may get a new output with a scale different from
the output the pointer is actually on.

Now, we store the current scale along with the theme. We then trigger
a call to reload the xcursor theme *every* time the pointer enters a
surface. When it does, we use the current scale factor of the terminal
that owns that surface.

If the terminal covers multiple outputs, with different scale factors,
we'll use the largest scale factor. This may not be 100% correct. But
to fix that, we'd need to track which regions of a surface are mapped
on which outputs. Too complicated I say.
2020-07-08 19:52:17 +02:00
Daniel Eklöf
5539af2597
wayland: seat: log keyboard/pointer capability 2020-07-08 19:30:34 +02:00
Daniel Eklöf
4c7d29f7eb
multi-seat: re-enable selection support (excluding OSC 52) 2020-07-08 18:41:09 +02:00
Daniel Eklöf
04e566492c
multi-seat: re-enable scrollback search support 2020-07-08 18:20:34 +02:00
Daniel Eklöf
be2490022d
multi-seat: enable xcursor theme support again 2020-07-08 18:08:39 +02:00
Daniel Eklöf
c470825067
wip: multi-seat support
Compiles and runs, but mouse, clipboard and other things have been
disabled.
2020-07-08 16:45:26 +02:00
Daniel Eklöf
32e70263f9
wayland: use xdg_output's description if there's no 'model' 2020-06-25 17:30:51 +02:00
Daniel Eklöf
6d0f8e52cb
wayland: force-trigger a resize on 'configured' event
This ensures we _always_ commit a **new** buffer in response to a
configured event.

This fixes an issue in Gnome where e.g. tiling the window (on the
left/right side) only worked if that caused the windows size to
change.
2020-05-12 18:35:28 +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
2fd5a9ee8d
wayland: monitor unplug: call surface_leave() to handle terminal unmapping 2020-04-28 19:05:10 +02:00
Daniel Eklöf
9cfe720000
wayland: handle outputs disappearing
That is, deal with monitors being unplugged.

At least on Sway 1.4, surfaces are not unmapped before the output is
removed. Thus, in addition to free:ing the monitor resources, we also
need to update all terminals that are mapped on this output - remove
the output from their "mapped on" list.
2020-04-27 20:46:40 +02:00
Daniel Eklöf
37871aad84
wayland: group handle_global() together with handle_global_removed() 2020-04-27 20:18:03 +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
4d52a870b4
conf: add app-id config option and --app-id command line option 2020-04-01 18:40:51 +02:00
Daniel Eklöf
0419156494
search: replace hard-coded key bindings with "user configurable" ones
They aren't really user configurable. At least not yet.

However, with this, we now handle raw key codes just like the normal
key bindings. Meaning, e.g. ctrl+g, ctrl+a, ctrl+e etc now works while
searching with e.g. a russian layout.
2020-03-18 15:30:14 +01:00
Daniel Eklöf
6d30e7d15d
input: bind key bindings to raw key codes too
Before, when looking for a matching user key binding, we only
matched *symbols*.

This means that the physical keys that generate a specific key binding
is layout dependent. What's worse, it may not even be possible to
generate the key binding at all.

Russian is one such layout, where all the "normal" (us) symbols are
replaced.

By using raw key codes, we can get around this - the key code has a
direct mapping to the physical key.

However, matching raw key codes **only** doesn't always make sense
either. For now, match **both** symbols _and_ key codes. Symbols take
precedence.

TODO: we might have to make this configurable _per binding_.

Note: 'search' mode still uses mostly hardcoded shortcuts that still
have this problem (i.e. ctrl+g doesn't work with a russian layout).
2020-03-18 14:29:34 +01:00
Daniel Eklöf
6eeea06cc0
wayland: add FDs to FDM as soon as the FDs are ready 2020-03-15 13:37:56 +01:00
Daniel Eklöf
71fde3bfac
wayland: store display FD in wayland struct
This way we:

* Don't have to call wl_display_get_fd() all the time
* No longer call fdm_del_no_close() even though the FD hasn't been
  added to the FDM.
2020-03-15 13:36:35 +01:00
Daniel Eklöf
59a1204c50
Merge branch 'scale-fonts-using-logical-dpi-plus-scale-factor' 2020-03-13 18:48:15 +01:00