Commit graph

5014 commits

Author SHA1 Message Date
Daniel Eklöf
bfbb4b0830
term: xcursor_update_for_seat(): remove switch default case
Let the compiler catch missing enum values
2021-11-30 22:12:56 +01:00
Daniel Eklöf
fd82fb81fa
changelog: window-menu 2021-11-30 22:12:17 +01:00
Daniel Eklöf
90cfdcf1a5
Merge branch 'window-menu' 2021-11-30 22:10:27 +01:00
Daniel Eklöf
55f592b210
Merge branch 'csd-border-render-glitch'
Closes #823
2021-11-29 21:09:15 +01:00
Daniel Eklöf
3afe317e46
render: fix csd border rendering glitch when width > 5px
CSD borders are always *at least* 5px. If url.border-width=0, those
5px are all fully transparent (and act as interactive resize handles).

As csd.border-width increases, the number of transparent pixels
decrease. Once csd.border-width >= 5, the border is fully opaque.

When csd.border-width > 5, then width of the border is (obviously)
more than 5px. But, when rendering the opaque part of the border, we
still used 5px for the invisible part, which caused some pixman
rectangles to have negative x/y coordinates.

This resulted in rendering glitches due to overflows in pixman when
rendering the borders.

The fix is to ensure the total border size is always at least, but
not *always* 5px. That is, set it to max(5, csd.border-width).

This patch also fixes an issue where the CSD borders were not
dimmed (like the titlebar) when the window looses input focus.

Closes #823
2021-11-29 19:32:49 +01:00
Daniel Eklöf
73a048f9d3
input: regression: reset view (and cancel selection) on “handled” input
This fixes a regression, where the view (and selection) was only reset
if the keyboard input resulted in plain text. That is, key presses
like enter, arrows etc did not.
2021-11-29 19:31:48 +01:00
Jonas Ådahl
38741baf9a input: Add support for xdg_toplevl.show_window_menu()
This makes, if the compositor supports it, the window menu appear when
right clicking on the title bar.
2021-11-29 16:26:40 +01:00
Jonas Ådahl
c0ce131f1a input: Update mouse x/y coordinates on wl_pointer_enter
Otherwise if you don't receive motion event before e.g. button pressed,
the coordinates will be incorrect. This happens when e.g. you get
alt-tabbed so that the mouse cursor ends up on top of the terminal
window, but the mouse never actually moved.
2021-11-29 16:26:40 +01:00
Jonas Ådahl
5c2557b421 terminal: Make seat xcursor update focus aware
When term_xcursor_update_for_seat() was called on e.g. keyboard focus
loss, it'd update the curret xcursor to 'text' even if it was e.g. on
top of the window title, or resize areas. This makes the function a bit
more focus aware, and will not be so eager to set the text xcursor.
2021-11-29 16:26:40 +01:00
Daniel Eklöf
a55a3daae7
input: regression: special keys don’t reset view and cancel selection
This fixes an issue where e.g. holding down ctrl would cancel the
selection, thus making it impossible to copy text to the clipboard.
2021-11-28 16:48:30 +01:00
Daniel Eklöf
4334259c70
Merge branch 'kitty-kbd'
Part of #319
2021-11-28 15:15:24 +01:00
Daniel Eklöf
1f19dd6694
changelog: kitty keyboard protocol - disambiguate escape codes 2021-11-28 15:14:56 +01:00
Daniel Eklöf
8f41a8dc94
input: kitty: use XKB_CONSUMED_MODE_GTK when retrieving consumed mods 2021-11-28 15:14:56 +01:00
Daniel Eklöf
913dd8b4a6
input: get_current_modifiers(): use xkb_state_key_get_consumed_mods2()
Explicitly request consumed modifiers using the `XKB` mode.
2021-11-28 15:14:56 +01:00
Daniel Eklöf
8f38cd486f
term: rename: KITTY_KBD_MASK -> KITTY_KBD_SUPPORTED 2021-11-28 15:14:55 +01:00
Daniel Eklöf
546bcd66b7
input: legacy: use ALEN(mod_param_map) 2021-11-28 15:14:55 +01:00
Daniel Eklöf
42d1fcb484
input: grammar: “an UTF-8” -> “a UTF-8” 2021-11-28 15:14:55 +01:00
Daniel Eklöf
ce8ea2db66
input: legacy: reduce size of reply buffer
Its maximum size is known; the only two variables are two integers. We
know the maximum length of an integer converted to a string.
2021-11-28 15:14:55 +01:00
Daniel Eklöf
28ad0ca602
csi: kitty: remove unneeded xasserts
‘idx’ is calculated just above, and the logic is simple enough that we
don’t really need to assert it.
2021-11-28 15:14:55 +01:00
Daniel Eklöf
07068165ec
input: only report modifiers when “Report all keys as escape codes” is enabled 2021-11-28 15:14:55 +01:00
Daniel Eklöf
6930abe945
input: kitty: add shift/alt/ctrl/super/hyper/meta keys 2021-11-28 15:14:54 +01:00
Daniel Eklöf
9933284ab1
input: kitty: add ‘media’ keys 2021-11-28 15:14:54 +01:00
Daniel Eklöf
1ec218c3ac
input: kitty: map ISO_Left_Tab to Tab 2021-11-28 15:14:54 +01:00
Daniel Eklöf
66171f1045
input: rename ‘meta’ to ‘super’ 2021-11-28 15:14:54 +01:00
Daniel Eklöf
a08494a766
input: kitty: only emit CSIs for Caps- and Num-Lock when they aren’t modifiers 2021-11-28 15:14:54 +01:00
Daniel Eklöf
8fb641a7ed
input: handle “invalid” XKB modifiers
A modifier may not exist in a specific layout. This is indicated by
XKB returning XKB_MOD_INVALID from xkb_keymap_mod_get_index().
2021-11-28 15:14:54 +01:00
Daniel Eklöf
ebad4bba28
input: kitty: disable CSI for Caps- and Num-Lock
Not sure why these keys have CSIs in the kitty spec; they don’t emit
anything.

Could it be that they are used if the keys are *not* modifiers in the
current layout?
2021-11-28 15:14:53 +01:00
Daniel Eklöf
e744cee760
input: kitty: printables are emitted as text, even if Caps- or Num-Lock is in effect
Not sure if this is the best/correct way to do it. But kitty seems to
ignore at least Num-Lock for printables, while it _does_ affect other
keys. For example, Return, which usually emits ‘\r’, are affected by
Num-Lock and emit ‘CSI 13;129u’.

Note that as soon as some other modifier is in effect, the Num-Lock
modifier *is* encoded in the CSI, also for printables.
2021-11-28 15:14:53 +01:00
Daniel Eklöf
db746d72ed
input: get_current_modifiers() no longer strips insignificant mods
Our internal binding handling cares about a different set of
modifiers, compared to the kitty keyboard protocol.

To handle this, get_current_modifiers() has been modified, to no
longer strip the “unsignificant” modifiers. This is now up to the
caller to do.

To help, we keep two masks (for significant modifiers) in the seat
struct; one for our internal binding handling (and the legacy keyboard
protocol), and one for the kitty keyboard protocol. These two masks
are updated when the seat’s keymap is updated/changed.
2021-11-28 15:14:53 +01:00
Daniel Eklöf
b9d03c16a6
input: kitty: use base symbol instead of lowering the symbol
When emitting an escape sequence for a printable character, with
modifiers (e.g. ctrl+a), use the key’s base symbol instead of
“lowering” it.

This means we now handle e.g. ctrl+2 and ctrl+shift+2, with Swedish
layout.

There’s a twist however. We *only* use the base symbol if the
modifiers that is used to “generate” the symbol are “significant”.

Significant modifiers are, in this context, modifiers we can encode in
the kitty escape sequences.

In the Swedish layout, pressing AltGr+2 results in ‘@’. AltGr cannot
be encoded in the kitty protocol. If we were to use the base symbol,
AltGr+Alt+2 would result in exactly the same escape sequence as Alt+2.
2021-11-28 15:14:53 +01:00
Daniel Eklöf
ab5dfa3f3b
input: wip: add support for kitty kbd protocol “Disambiguate escape codes”
Most things appear to work as in kitty. There’s one known difference:
tri-state keys don’t generate the same unshifted symbol while holding
Shift (but e.g. Ctrl+a and Ctrl+Shift+a *does* generate the same base
symbol).

For example, the Swedish keyboard layout has double quote, ‘2’ and ‘@’
on the same key. ‘2’ is the base (unshifted) symbol. Double quote is
Shift+2. ‘@’ is AltGr+2.

Kitty generates the same base symbol for ‘2’ and double quote (the
base symbol is, as expected, ‘2’).

But, for ‘@’ kitty generates the base symbol ‘@’.

Currently, foot generates the base symbol by calling
xkb_keysym_to_lower().

I _think_ what we need to do is “consume” the shift modifier, and then
re-retrieve the symbol (given the current xkb state and key pressed).
2021-11-28 15:14:53 +01:00
Daniel Eklöf
2d85dbec6b
input: enable repeat while COMPOSING 2021-11-28 15:14:52 +01:00
Daniel Eklöf
9f3dba683e
input: refactor: new function: legacy_kbd_protocol()
This breaks out all handling of key escapes to-be-sent to the client,
to a separate function, legacy_kbd_protocol().

That is, the key press/release handler first handles key generic
handling, such as starting and stopping the repeat timer.

Then it checks for foot keyboard bindings. If not bindings match, we
need to pass the keyboard event to the client. This code has now been
separated out into a new function.
2021-11-28 15:14:52 +01:00
Daniel Eklöf
3c01eb48dc
term: kitty kbd: fix typo: ‘BKD’ -> ‘KBD’ 2021-11-28 15:14:52 +01:00
Daniel Eklöf
c3fda01554
csi: kitty: log flags after ‘update’ operation 2021-11-28 15:14:52 +01:00
Daniel Eklöf
ad2539af44
csi: kitty: s/mode/flags in debug logs 2021-11-28 15:14:52 +01:00
Daniel Eklöf
fec42e5941
kitty kbd: add flag state, implement push/pop/update/query 2021-11-28 15:14:40 +01:00
Daniel Eklöf
2fe2dfa847
grid: uri_range_erase(): unittest: try erasing a row without any URIs 2021-11-28 11:05:00 +01:00
Daniel Eklöf
66b8c92c30
grid: uri_range_erase: walk the ranges backwards
This way, ranges are deleted last-to-first, thus avoiding memmoving
multiple ranges over and over again when erasing e.g. a full line.
2021-11-28 11:03:07 +01:00
Daniel Eklöf
747da83c76
grid: remove useless assertion
grid.c:1041:24: warning: comparison of unsigned expression in ‘>= 0’ is always true [-Wtype-limits]
2021-11-27 18:15:59 +01:00
Daniel Eklöf
512a07fd14
Merge branch 'osc8-dont-use-tllist' 2021-11-27 16:41:24 +01:00
Daniel Eklöf
5ce6c89df6
grid: resize without reflowing: use URI range utility functions 2021-11-27 16:31:33 +01:00
Daniel Eklöf
dfeca4e134
grid: uri_range_{append,insert}: pass range attributes as separate parameters 2021-11-27 16:25:29 +01:00
Daniel Eklöf
5c6c2de051
grid: snapshot: use uri range utility functions 2021-11-27 16:11:26 +01:00
Daniel Eklöf
5c7e881cd4
grid: uri_range_ensure_size(): add the requested amount of entries 2021-11-27 16:03:07 +01:00
Daniel Eklöf
7699271316
grid: reflow: no need to keep a uri-range-idx variable
The URI ranges are now an array, which means we can get the next URI
range by incrementing the pointer.

Instead of checking if range is not NULL, check that it isn’t the
range terminator (which is NULL when we don’t have any ranges, and
the first address *after* the last range otherwise).
2021-11-26 20:57:08 +01:00
Daniel Eklöf
41565a0d0e
grid: resize without reflow: only verify URI ranges in debug builds 2021-11-26 20:36:59 +01:00
Daniel Eklöf
be203aeae1
grid: bug: OSC-8 URIs were incorrectly skipped while resizing the alt screen 2021-11-26 20:29:23 +01:00
Daniel Eklöf
4eb0aa0f18
osc8: replace grid_row_uri_range_add() with internal uri_range_append()
grid_row_uri_range_add() was only used while reflowing. In this case,
we know the new URIs being added are always going at the end of the
URI list (since we’re going top-to-bottom, left-to-right).

Thus, we don’t need the insertion logic, and can simply append instead.
2021-11-26 20:25:07 +01:00
Daniel Eklöf
ccee08a393
osc8: uri ranges: use a dynamically re-sizable array instead of a tllist 2021-11-26 20:09:15 +01:00