Commit graph

153 commits

Author SHA1 Message Date
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
26528f6a73
input: add key mapping for XKB_KEY_KP_Decimal 2020-06-27 20:03:41 +02:00
Daniel Eklöf
e4a2d41f51
selection: don't automatically no-op operations if selection isn't enabled
When the client is capturing the mouse, selection can only be done by
holding done shift.

This is why a lot of selection functions are no-ops if selection isn't
currently enabled.

However, there are many cases where we actually need to modify the
selection. In particular, selection_cancel().

Thus, only check for enabled selection when we're dealing with user
input.

Bonus: this also fixes a bug where an ongoing selection were finalized
as soon as the user released shift, even if he was still holding down
the mouse button.
2020-05-16 21:16:11 +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
c96a0b3b3c
misc: replace all explicit zero-initializers with empty initializers 2020-04-13 12:03:11 +02:00
Daniel Eklöf
d67f437458
mbstate: fix compile warning on systems where mbstate_t isn't an integral
An empty initializer still ensures the entire object is
zero-initialized.
2020-04-13 11:58:38 +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
fac4b73107
input: right mouse click extends the current selection 2020-04-04 12:02:07 +02:00
Daniel Eklöf
2344f153d9
input: hardcoded left mouse button handler requires click-count <= 3
This enables user mappings for the left mouse button with click count
> 3

I.e. it is now possible to create custom quad-click mappings (except
we don't yet support this in footrc).
2020-04-04 11:57:33 +02:00
Daniel Eklöf
210c0ee5cd
input: only cancel selection on left mouse button clicks 2020-04-04 11:57:08 +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
a69b818a62
input: bindings: don't match raw key code alone - mods must also match 2020-03-18 14:52:39 +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
fb5ab022de
input: key-binding: log error when we fail to translate to XKB symbol 2020-03-18 10:48:42 +01:00
Daniel Eklöf
c10399694e
input: remove Sway 1.2 keyboard/pointer workarounds
Sway 1.4 is better than 1.2, in that we always have keyboard focus
when we get a keyboard_key() event.

That however is because it doesn't send keyboard_leave() on e.g. a TTY
switch.

Still, this is good enough - foot handles this and doesn't crash. We
are also able to process input without having to refocus the window.

And, Sway master (what will become Sway 1.5) has fixed this for real -
we now get a keyboard_leave() and pointer_leave() event on a TTY
switch. And the corresponding enter events when switching back.
2020-03-14 11:54:23 +01:00
Daniel Eklöf
53b681c6f4
input: add debug logs to all keyboard/pointer enter/leave/action events 2020-03-14 11:51:47 +01:00
Daniel Eklöf
62a5805d4b
input: maximize: unset fullscreen before toggling maximized state 2020-03-12 17:47:53 +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
0c72128405
input: parse_key_binding_for_action: export function 2020-03-09 19:47:22 +01:00
Daniel Eklöf
f78a8a77ed
input: parse_key_binding_for_action: repair LOG_DBG statement 2020-03-09 19:47:01 +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
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
264acd6463
input: do a full CSD repaint on pointer motion over CSD buttons
This fixes repainting issues on mutter.
2020-03-03 18:22:32 +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
6eae5ebd94
input: don't change xcursor if active surface isn't the main grid 2020-03-02 18:47:17 +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
ae22366f3b
input: raise window 'move' timeout to 200ms
100ms was a bit low and prevented double-tap on touchpads from
working.
2020-03-01 13:20:07 +01:00
Daniel Eklöf
fff480e584
input: use xdg_toplevel_resize_edge enum type 2020-03-01 11:43:58 +01:00
Daniel Eklöf
ea2d7f8b8c
input: start window move right away if user starts dragging the window
When the user left-clicks the title-bar, we start a timer. When the
timer has elapsed, we initiate a 'move' operation.

However, if the user clicked, and then started dragging right away,
there was a very visible lag since we waited for the timeout before
starting the move.

Now, on a pointer motion event we detect a running 'move' timer, and
abort it and instead start the 'move' operation right away.
2020-02-29 15:38:04 +01:00
Daniel Eklöf
33744ebe63
input: fix 'unused variable' warning (release builds) 2020-02-29 15:29:58 +01:00
Daniel Eklöf
73133c10ee
input: cleanup 2020-02-29 15:29:00 +01:00
Daniel Eklöf
e496d81f4d
input: don't update xcursor on keyboard enter/leave
I'm not sure why I added this in the first place... our cursor doesn't
depend on keyboard focus.

Furthermore, with CSDs, we may get keyboard enter events for the CSD
surfaces, and these should definitely *not* update the xcursor
as if it was inside the main surface.
2020-02-29 13:04:18 +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
43c0551806
wayland: store pointer to window instance in all surfaces 2020-02-29 12:09:28 +01:00
Daniel Eklöf
1091d1c078
input: reset mouse state on pointer leave 2020-02-29 12:08:59 +01:00
Daniel Eklöf
4ee5a81d1a
input: toggle maximized state when double-clicking the title bar 2020-02-29 11:56:16 +01:00
Daniel Eklöf
7b51d6919d
input: handle double/triple click state regardless of surface 2020-02-29 11:55:43 +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
d863ea8a46
input: temporary code to trigger maximize/minimize 2020-02-26 13:23:11 +01:00
Daniel Eklöf
c0e3db1712
input: wip: trigger move/resize when left-clicking CSD 2020-02-25 20:31:13 +01:00
Daniel Eklöf
551170d940
input: pointer-motion/button: ignore actions in non-main surfaces 2020-02-24 22:42:04 +01:00
Daniel Eklöf
7b18f8394e
input: pointer-leave: reset 'active-surface' in terminal 2020-02-24 22:41:46 +01:00
Daniel Eklöf
d303084a81
input: pointer-enter: differentiate between the surfaces 2020-02-24 22:40:24 +01:00
Daniel Eklöf
d804bc8579
term: resize: pre-calculate right/bottom margins 2020-02-24 18:38:11 +01:00