Commit graph

64 commits

Author SHA1 Message Date
Daniel Eklöf
4e48d550ef
multi-seat: improve handling of multiple (mouse) pointers
* xcursor always set for all pointers
* xcursor sometimes not updated when it should be
* mouse grabbed state wasn't per seat, but global (i.e. "does at least
  one seat enable mouse grabbing")
* selection enabled state wasn't per seat
2020-07-09 09:52:11 +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
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
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
6f83ef81e5
render: use output's subpixel mode when rasterizing glyphs 2020-04-20 18:38:55 +02:00
Daniel Eklöf
00dbe12e41
input: slow trackpad scrolling now eventually scroll a line
Before, we converted each axis event's scroll amount to an integer and
scrolled that many lines.

However, axis events are speed sensitive - very slow scrolling will
result in events with a scroll amount that is < 1.0.

For us, this meant we never scrolled a single line. You could slow
scroll all day if you wanted, and still we would never scroll a single
line.

Fix this by aggregating the scroll amount from axis events until the
scroll amount is > 1.0, and then scroll.
2020-04-10 18:43:29 +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
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
Daniel Eklöf
c58f9a9ef9
config: mouse-bindings: verify button isn't already mapped
A button may only be mapped to a single action. Detect when the user
tried to map the same button to multiple actions and error out.

To clear a binding (for example, to free up a button from the default
bindings), one can set the action it is bound to to
`NONE` (e.g. `primary-paste=NONE`).
2020-03-12 10:46:27 +01:00
Daniel Eklöf
45384839f0
config/input: implement mouse bindings
* New config section, "mouse-bindings", where bindings are defined on
  the form "action=BTN_<name>
* pointer_button() handler now scans the bindings list instead of
  hardcoding primary-paste to BTN_MIDDLE.
* The implementation handles single- double- and triple clicks in the
  bindings, but there is currently no way to define anything but a
  single-click binding in the configuration.
2020-03-12 10:20:05 +01:00
Daniel Eklöf
65ff582358
bindings: add minimize/maximize/fullscreen actions
These actions are by default not bound to anything.
2020-03-12 09:34:09 +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
0d188895c3
search: add support for user configurable key bindings
No default bindings defined yet, though.
2020-03-08 15:28:47 +01:00
Daniel Eklöf
fcf4832775
input: convert the rest of the normal key bindings to configurable bindings
New actions defined and implemented:

* scrollback up/down
* font size up/down/reset
* spawn terminal

Break out key combo parsing to a new function,
parse_key_binding_for_action(). This function parses a string
containing one or more space separated key combo definitions on the
form (mod1+mod2+...+key), where key is a XKB key name (e.g. KP_Add).

Convert all hardcoded key bindings to configuration based
bindings. These still cannot actually be configured by the user, but
at least lives in the conf struct.
2020-03-08 15:17:57 +01:00
Daniel Eklöf
b22bb30976
wip: initial framework for dealing with key/mouse bindings in different modes
This adds initial support for defining key and mouse bindings that are
applied in different terminal modes/states.

For example, there are two arrays dealing with key and mouse bindings
in the "normal" mode. Most bindings will go here.

There's also an array for "search" mode. These bindings will be used
when the user has started a scrollback search.

In the future, there may be a model selection mode as well. Or maybe
"search" and "modal selection" will be combined into a single
"keyboard" mode. We'll see.

Since the keyboard bindings depend on the current XKB keymap,
translation from the user specified key combination string cannot be
done when loading the configuration, but must be done when we've
received a keymap from the wayland server.

We should explore if it's possible to load some kind of default keymap
just to be able to verify the validity of the key combination strings
at configuration load time, to be able to reject the configuration at
startup.

A couple of key bindings have been added as proof of concept.

Mouse bindings aren't handled at all yet, and is likely to be
re-written. For example, we can probably translate the configuration
strings at configuration load time.
2020-03-08 12:08:46 +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
22ce09eb44
config: make CSD user configurable
The user can now configure the following:

* Whether to prefer CSDs or SSDs. But note that this is only a hint to
  the compositor - it may deny our request. Furthermore, not all
  compositors implement the decoration manager protocol, meaning CSDs
  will be used regardless of the user configuration (GNOME/mutter
  being the most prominent one).
* Title bar size and color, including transparency
* Border size and color, including transparency

Also drop support for rendering the CSDs inside the main surface.
2020-03-02 18:42:49 +01:00
Daniel Eklöf
92d638eb1c
render: csd: split up positioning from rendering 2020-02-29 18:02:38 +01:00
Daniel Eklöf
73133c10ee
input: cleanup 2020-02-29 15:29:00 +01:00
Daniel Eklöf
43b07b122a
input: csd: add a small delay before initiating a move
This ensures the user has time to double-click to toggle the maximized
state.
2020-02-29 12:56:04 +01:00
Daniel Eklöf
c917a74f48
wayland: remove all usages of wayl_terminal_from_surface()
Use the 'user data' pointer from the wayland surface instead.
2020-02-29 12:13:58 +01:00
Daniel Eklöf
d48a789412
input: handle CSD border corners correctly
That is, change to correct cursor, and do resize correctly.
2020-02-29 09:32:22 +01:00
Daniel Eklöf
77b37fb288
wayland: once again switch to positioning CSDs outside the main surface 2020-02-26 20:45:44 +01:00
Daniel Eklöf
66decac16b
wayland: document what FOOT_CSD_OUTSIDE does 2020-02-26 13:49:54 +01:00
Daniel Eklöf
1ccfceca05
wayland: switch back to positioning CSDs inside the main surface 2020-02-26 13:47:29 +01:00
Daniel Eklöf
5fbbd2f80e
wayland: track window maximized state 2020-02-26 13:23:00 +01:00
Daniel Eklöf
1e1b204377
csd: don't draw CSDs in fullscreen mode 2020-02-26 12:39:17 +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
d15eb936ef
render: make CSD border and title size globally accessible 2020-02-25 19:08:14 +01:00
Daniel Eklöf
8368e8184f
csd: wip: something to get started... 2020-02-23 14:17:48 +01:00
Daniel Eklöf
5ec447697c
render: throttle xcursor updates
With a bad behaving client (e.g. 'less' with mouse support enabled),
we can end up with a *lot* of xcursor updates (so much, that we
flooded the wayland socket before we implemented a blocking
wayl_flush()).

Since there's little point in updating the cursor more than once per
frame interval, use frame callbacks to throttle the updates.

This works more or lesslike normal terminal refreshes:

render_xcursor_set() stores the last terminal (window) that had (and
updated) the cursor.

The renderer's FDM hook checks if we have such a pending terminal set,
and if so, tries to refresh the cursor.

This is done by first checking if we're already waiting for a callback
from a previous cursor update, and if so we do nothing; the callback
will update the cursor for the next frame. If we're *not* already
waiting for a callback, we update the cursor immediately.
2020-01-04 22:58:32 +01:00
Daniel Eklöf
abc36d8f09
wayland: wl_display_flush() never blocks
Since it doesn't block, we need to detect EAGAIN failures and ensure
we actually flush everything.

If we don't, we sooner or later end up in a wayland client library
call that aborts due to the socket buffer being full.

Ideally, we'd simply enable POLLOUT in the FDM. However, we cannot
write *anything* to the wayland socket until we've actually managed to
send everything. This means enabling POLLOUT in the FDM wont work
since we may (*will*) end up trying to write more data to it before
we've flushed it.

So, add a wrapper function, wayl_flush(), that acts as a blocking
variant of wl_display_flush(), by detecting EAGAIN failiures and
calling poll() itself, on the wayland socket only, until all data has
been sent.
2020-01-04 21:10:08 +01:00
Daniel Eklöf
0ea0323d0f
wayland: don't use wl_display_dispatch()
wl_display_dispatch() calls poll(), which is unnecessary since we
already know the FD is readable.

Use the more lower level wl_display_read_events() +
wl_display_dispatch_pending().

These require wl_display_prepare_read() to have been called.

The idea is to call wl_display_prepare_read() **before** calling
poll().

Thus, we do this more or less last in wayl_init(), and at the **end**
of the FDM handler.

However, having taking this lock also means we no longer can call
wl_display_roundtrip() directly (it will hang).

So, add a wrapper, wayl_roundtrip(), that cancels the read intent,
does the roundtrip, and then re-acquires the read intent.
2020-01-03 21:02:12 +01:00
Daniel Eklöf
f7362d381b
render: refresh: ensure window has been configured 2020-01-03 18:55:13 +01:00
Daniel Eklöf
46c434d3f1
wayland: window: apply all configure changes after acking the event 2020-01-03 13:54:44 +01:00
Daniel Eklöf
765fe13aff
wayland: remove wayl_terminal_from_xdg_{surface,toplevel} 2020-01-03 13:46:37 +01:00
Daniel Eklöf
9a0238bb52
wayland: window now keeps pointer to owning terminal, not wayland 2020-01-03 13:37:03 +01:00
Daniel Eklöf
4ecb0ecf4d
wayland: rename focused/moused to kbd_focus/mouse_focus 2020-01-02 15:58:52 +01:00
Daniel Eklöf
b100a82c2a
wayland: only bind to 'presentation' interface if -p,--presentation-timings 2019-12-31 16:12:48 +01:00
Daniel Eklöf
5a07419096
wayland: optionally use the presentation time protocol to measure input lag
This adds a flag, -p,--presentation-timings, that enables input lag
measuring using the presentation time Wayland protocol.

When enabled, we store a timestamp when we *send* a key to the
slave. Then, when we commit a frame for rendering to the compositor,
we request presentation feedback. We also store a timestamp for when
the frame was committed.

The 'presented' callback then looks at the input and commit
timestamps, and compares it with the presented timestamp.

The delay is logged at INFO when the delay was less than one frame
interval, at WARN when it was one frame interval, and at ERR when it
was two or more frame intervals.

We also update statistic counters that we log when foot is shut down.
2019-12-31 15:39:40 +01:00
Daniel Eklöf
db1d913ba8
wayland: include more output (monitor) details in the log output 2019-12-05 19:35:34 +01:00
Daniel Eklöf
fd9c28464d
fcft: use fcft instead of local copy of font.c/font.h 2019-12-01 13:43:51 +01:00
Daniel Eklöf
a87b39f6eb
wayland: track current xcursor, and don't update if same
We may have many windows open, which tries to update/change the
xcursor at various points.

Track which cursor is currently loaded, regardless of which window it
was set by. If someone tries to load that very same xcursor again,
simply skip it.

One example is when we've moused over a window that does *not* have
keyboard focus, and then the user clicks, or by some other mean gives
that window keyboard focus. In many cases it will then try to set the
same cursor again (most of the times, the cursor is the same
regardless of keyboard focus, but not always).
2019-11-30 12:09:57 +01:00
Daniel Eklöf
0dd37f0a36
terminal: use the 'text' xcursor pointer whenever selection is possible 2019-11-28 19:35:47 +01:00
Daniel Eklöf
204bfa02f4
wayland: calculate output PPI (pixels-per-inch) 2019-11-26 19:02:35 +01:00
Daniel Eklöf
1e41a25f00
terminal: call user-defined callback when destroying terminal
main uses this to get the exit code of the terminal.
2019-11-01 20:34:32 +01:00