aboutsummaryrefslogtreecommitdiff
path: root/input.c (follow)
Commit message (Collapse)AuthorAgeLines
* input: kitty: don’t treat zero-length utf8/utf32 strings as textDaniel Eklöf2023-03-31-1/+1
| | | | | | This is a regression introduced in 3215d54f31c9e339598a34c9fa43f3dc3c5d1e42 Symptoms: e.g. arrow keys not working in vim/neovim
* input: (kitty kbd): the resulting UTF-8 string may translate to multiple UTF-32 codepointsDaniel Eklöf2023-03-30-12/+29
| | | | | | | | | | | | | | | | | | | | | | | | When this happened (for example, by specifying a custom compose sequence), the kitty keyboard protocol didn’t emit any text at all. This was caused by the utf32 codepoint being -1. This in turned was caused by us trying to convert the utf8 sequence to a *single* utf32 codepoint. This patch replaces the use of mbrtoc32() with a call to ambstoc32(), and the utf32 codepoint with an utf32 string. The kitty keyboard protocol is updated: * When determining if we’re dealing with text, check *all* codepoints in the utf32 string. * Add support for multiple codepoints when reporting "associated text". The first codepoint is the actual parameter in the emitted sequence, and the remaining codepoints are sub-parameters. I.e. the codepoints are colon separated. Closes #1288
* input: pipe-*: set current CWD when spawning the sub-processDaniel Eklöf2022-09-10-1/+1
| | | | Closes #1166
* terminal: don’t unref a not-yet-referenced key-binding setDaniel Eklöf2022-09-06-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Key-binding sets are bound to a seat/configuration pair. The conf reference is done when a new terminal instance is created. When that same terminal instance is destroyed, the key binding set is unref:ed. If the terminal instance is destroyed *before* the key binding set has been referenced, we’ll still unref it. This creates an imbalance. In particular, when the there is exactly one other terminal instance referencing that same key binding set, that terminal instance will trigger a foot server crash as soon as it receives a key press/release event. This happens because the next-to-last terminal instance brought the reference count of the binding set down to 0, causing it to be free:d. Thus, we *must* reference the binding set *before* we can error out (when instantiating a new terminal instance). At this point, we don’t yet have a valid terminal instance. But, that’s ok, because all the key_binding_new_for_term() did with the terminal instance was get the "struct wayland" and "struct config" pointers. So, rename the function and simply pass these pointers explicitly. Similarly, change key_binding_for() to take a "struct config" pointer, rather than a "struct terminal" pointer. Also rename key_binding_unref_term() -> key_binding_unref().
* input: ignore pointer motion events on unknown surfacesDaniel Eklöf2022-08-12-4/+12
| | | | | | | | | | | | | | In some cases, the compositor sends a pointer enter event with a NULL surface. It’s unclear if this is a compositor bug, or a race (where the compositor sends an enter event on a CSD surface at the same time foot unmaps the CSDs). Regardless, this causes seat->mouse_focus to be unset, which triggers a crash in foot on the next pointer motion event. This patch does two things: a) log a warning when we receive a pointer event with a NULL surface b) ignore motion events where seat->mouse_focus is NULL
* unicode-input: move input (key press) handling to unicode_mode_input()Daniel Eklöf2022-07-29-58/+1
|
* input: add new Unicode input modeDaniel Eklöf2022-07-29-1/+68
| | | | | | | | | | | | | | This mode is activated through the new key-bindings.unicode-input and search-bindings.unicode-input key bindings. When active, the user can “build” a Unicode codepoint by typing its hexadecimal value. Note that there’s no visual feedback in this mode. This is intentional. This mode is intended to be a fallback for users that don’t use an IME. Closes #1116
* input: kitty: always treat composed characters as ‘printable’Daniel Eklöf2022-07-28-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Certain dead key combinations results different escape sequences in foot, compared to kitty, when the kitty keyboard protocol is used. if (composed && is_text) key = utf32; else { key = xkb_keysym_to_utf32(sym_to_use); if (key == 0) return false; /* The *shifted* key. May be the same as the unshifted * key - if so, this is filtered out below, when * emitting the CSI */ alternate = xkb_keysym_to_utf32(sym); } If is_text=false, we’ll fall through to the non-composed logic. is_text is set to true if the character is printable *and* there aren’t any non-consumed modifiers enabled. shift+space is one example where shift is *not* consumed (typically - may be layouts where it is). As a result, pressing ", followed by shift+space with the international english keyboard layout (where " is a dead key) results in different sequences in foot and kitty. This patch fixes this by always treating composed characters as printable. Closes #1120
* input: don’t ignore keyboard enter/leave events when there’s no keymapDaniel Eklöf2022-06-28-6/+0
| | | | | | | | | | | The compositor _usually_ sends the keymap event *before* the enter event. But not always. Not (yet) having a keymap is not a reason to ignore the enter event (now, on the other hand, getting a key press/release event without a keymap is a compositor bug). Closes #1097
* osc: add support for OSC 133;A (prompt markers)Daniel Eklöf2022-06-16-1/+82
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds support for the OSC-133;A sequence, introduced by FinalTerm and implemented by iTerm2, Kitty and more. See https://iterm2.com/documentation-one-page.html#documentation-escape-codes.html. The shell emits the OSC just before printing the prompt. This lets the terminal know where, in the scrollback, there are prompts. We implement this using a simple boolean in the row struct ("this row has a prompt"). The prompt marker must be reflowed along with the text on window resizes. In an ideal world, erasing, or overwriting the cell where the OSC was emitted, would remove the prompt mark. Since we don't store this information in the cell struct, we can't do that. The best we can do is reset it in erase_line(). This works well enough in the "normal" screen, when used with a "normal" shell. It doesn't really work in fullscreen apps, on the alt screen. But that doesn't matter since we don't support jumping between prompts on the alt screen anyway. To be able to jump between prompts, two new key bindings have been added: prompt-prev and prompt-next, bound to ctrl+shift+z and ctrl+shift+x respectively. prompt-prev will jump to the previous, not currently visible, prompt, by moving the viewport, ensuring the prompt is at the top of the screen. prompt-next jumps to the next prompt, visible or not. Again, by moving the viewport to ensure the prompt is at the top of the screen. If we're at the bottom of the scrollback, the viewport is instead moved as far down as possible. Closes #30
* url-mode: add support for XDG activation when opening URLsDaniel Eklöf2022-05-05-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | First, add a ‘token’ argument to spawn(). When non-NULL, spawn() will set the ‘XDG_ACTIVATION_TOKEN’ environment variable in the forked process. If DISPLAY is non-NULL, we also set DESKTOP_STARTUP_ID, for compatibility with X11 applications. Note that failing to set either of these environment variables are considered non-fatal - i.e. we ignore failures. Next, add a helper function, wayl_get_activation_token(), to generate an XDG activation token, and call a user-provided callback when it’s ‘done (since token generation is asynchronous). This function takes an optional ‘seat’ and ‘serial’ arguments - when both are non-NULL/zero, we set the serial on the token. ‘win’ is a required argument, used to set the surface on the token. Re-write wayl_win_set_urgent() to use the new helper function. Finally, rewrite activate_url() to first try to get an activation token (and spawn the URL launcher in the token callback). If that fails, or if we don’t have XDG activation support, spawn the URL launcher immediately (like before this patch). Closes #1058
* input: assert serial received from compositor is non-zeroDaniel Eklöf2022-04-24-0/+6
|
* input: codespellDaniel Eklöf2022-04-20-1/+1
|
* input: copy libxkbcommon’s keysym_is_modifier()Daniel Eklöf2022-04-20-11/+13
| | | | | | | | | When determining whether a keysym is a modifier (to skip hiding the pointer when [mouse].hide-when-typing=yes), use the same matching logic xkbcommon does. This function, xkb_keysym_is_modifier() is unfortunately not part of the public API, which is why we copy it instead.
* wayland: refactor: remove ‘struct config’ pointer from wayland structDaniel Eklöf2022-04-17-11/+8
| | | | | | | | | | | | | | The global config doesn’t necessarily reflect the correct configuration to use - we should *always* use the current terminal instance’s conf pointer. * Move selection override modifier mask to the key_binding_set struct * Always warn if XDG activation is unavailable, not just if bell.urgent is set (we no longer have access to this information) * Pass ‘bool presentation_timings’ as a parameter to wayl_init() * Remove ‘presentation_timings’ member from the ‘terminal’ struct Closes #932
* key-binding: new API, for handling sets of key bindingsDaniel Eklöf2022-04-17-240/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Up until now, our Wayland seats have been tracking key bindings. This makes sense, since the seat’s keymap determines how the key bindings are resolved. However, tying bindings to the seat/keymap alone isn’t enough, since we also depend on the current configuration (i.e. user settings) when resolving a key binding. This means configurations that doesn’t match the wayland object’s configuration, currently don’t resolve key bindings correctly. This applies to footclients where the user has overridden key bindings on the command line (e.g. --override key-bindings.foo=bar). Thus, to correctly resolve key bindings, each set of key bindings must be tied *both* to a seat/keymap, *and* a configuration. This patch introduces a key-binding manager, with an API to add/remove/lookup, and load/unload keymaps from sets of key bindings. In the API, sets are tied to a seat and terminal instance, since this makes the most sense (we need to instantiate, or incref a set whenever a new terminal instance is created). Internally, the set is tied to a seat and the terminal’s configuration. Sets are *added* when a new seat is added, and when a new terminal instance is created. Since there can only be one instance of each seat, sets are always removed when a seat is removed. Terminals on the other hand can re-use the same configuration (and typically do). Thus, sets ref-count the configuration. In other words, when instantiating a new terminal, we may not have to instantiate a new set of key bindings, but can often be incref:ed instead. Whenever the keymap changes on a seat, all key bindings sets associated with that seat reloads (re-resolves) their key bindings. Closes #931
* url-mode: add a key binding that enables “persistent” URL modeDaniel Eklöf2022-04-17-4/+6
| | | | | | | This is an alternative to ‘show-urls-launch’, where we stay in URL mode after activating an URL. Closes #964
* wayland: optionally disable pointer input on subsurfacesDaniel Eklöf2022-04-16-18/+0
| | | | | | | | | | | | | | | | We have a number of sub-surfaces for which we are *not* interrested in pointer (or touch) input. Up until now, we’ve manually dealt with these, by recognizing these surfaces in all pointer events, and ignoring them. But, lo and behold, there are better ways of doing this. By clearing the subsurface’s input region, the compositor will do this for us - when a pointer is outside a surface’s input region, the event is passed to the next surface underneath it. This is exactly what we want! Do this for all subsurfaces, *except* the CSDs.
* input: improve XTerm compatibility when modifyOtherKeys=2Daniel Eklöf2022-04-10-1/+50
| | | | | | | | | | | | | | | | | | | Before this, foot always emitted a CSI if _any_ modifier was active. XTerm doesn’t behave quite like this. Instead, it appears to special-case shift somewhat: If the generated symbol (e.g ‘A’) is the upper case version of the pressed key’s base symbol (‘a’), and is in the range a-z, emit a CSI. If not emit a plain symbol: Examples (Swedish layout): * shift-a (generated symbol is ‘A’) emits a CSI * shift-, (generated symbol is ‘;’) emits ‘;’ * shift-alt-, (generated symbol is ‘;’) emits a CSI Closes #1009
* refactor: add a ‘range’ struct, grouping a start and end coord togetherDaniel Eklöf2022-04-09-2/+3
|
* input: don’t allow non-significant modifiers when matching untranslated symbolsDaniel Eklöf2022-03-20-5/+14
| | | | | | | | | | | | | | | | | | When matching “untranslated” bindings (by matching the base symbol of the key, e.g. ctrl+shift+2 in US layout), require that no non-significant modifiers are active. This fixes an issue where AltGr was “ignored”, and would cause certain combinations to match a key binding. Example: ctrl+altgr+0, on many European layouts matched against the default ctrl+0 (reset the font size), instead of emitting ^] To make this work, we now need to filter out “locked” modifiers (e.g. NumLock and CapsLock). Otherwise having e.g. NumLock active would prevent *all* untranslated matching to fail. Closes #983
* input: get_current_modifiers(): don’t crash if seat has no keyboardDaniel Eklöf2022-03-04-6/+15
| | | | Closes #963
* config/input: add scrollback-home|end key bindings (unbound by default)Daniel Eklöf2022-02-23-0/+14
|
* wip: map key combos to custom text strings (including escapes)Daniel Eklöf2022-02-16-0/+5
| | | | | | | | | | | | | With this, it is now possible to map key combos to custom escapes. The new bindings are defined in a new section, “text-bindings”, on the form “string=key combo”. The string can consist of printable characters, or \xNN style hex digits: [text-bindings] abcd = Control+a \x1b[A = Control+b Control+c Control+d # map ctrl+b/c/d to UP
* csi/input: remove private mode 27127Craig Barnes2022-02-09-7/+1
| | | | This effectively reverts commit 31c73f0cf01e1d0bdcd1435136b010c1c1ab442c.
* input/search/url: pass pointer-to key-binding struct to execute()Daniel Eklöf2022-02-09-17/+17
|
* config: ‘pipe’ is now optional ‘aux’ data in the key-binding structDaniel Eklöf2022-02-09-7/+7
| | | | | This allows us to add helper functions that e.g. compare bindings’ aux data in a generic way.
* input: call wayl_bindings_reset() when receiving a new keymapDaniel Eklöf2022-02-09-9/+1
|
* wayland: unify key- and mouse-binding structsDaniel Eklöf2022-02-09-17/+23
|
* fcft: adapt to API changes in fcft-3.xDaniel Eklöf2022-02-05-8/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fcft no longer uses wchar_t, but plain uint32_t to represent codepoints. Since we do a fair amount of string operations in foot, it still makes sense to use something that actually _is_ a string (or character), rather than an array of uint32_t. For this reason, we switch out all wchar_t usage in foot to char32_t. We also verify, at compile-time, that char32_t used UTF-32 (which is what fcft expects). Unfortunately, there are no string functions for char32_t. To avoid having to re-implement all wcs*() functions, we add a small wrapper layer of c32*() functions. These wrapper functions take char32_t arguments, but then simply call the corresponding wcs*() function. For this to work, wcs*() must _also_ be UTF-32 compatible. We can check for the presence of the __STDC_ISO_10646__ macro. If set, wchar_t is at least 4 bytes and its internal representation is UTF-32. FreeBSD does *not* define this macro, because its internal wchar_t representation depends on the current locale. It _does_ use UTF-32 _if_ the current locale is UTF-8. Since foot enforces UTF-8, we simply need to check if __FreeBSD__ is defined. Other fcft API changes: * fcft_glyph_rasterize() -> fcft_codepoint_rasterize() * font.space_advance has been removed * ‘tags’ have been removed from fcft_grapheme_rasterize() * ‘fcft_log_init()’ removed * ‘fcft_init()’ and ‘fcft_fini()’ must be explicitly called
* replace gettimeofday with clock_gettimePranjal Kole2022-01-15-5/+4
| | | | | | | | | | | | | POSIX.1-2008 has marked gettimeofday(2) as obsolete, recommending the use of clock_gettime(2) instead. CLOCK_MONOTONIC has been used instead of CLOCK_REALTIME because it is unaffected by manual changes in the system clock. This makes it better for our purposes, namely, measuring the difference between two points in time. tv_sec has been casted to long in most places since POSIX does not define the actual type of time_t.
* input: reset mouse button click counter when mouse movesDaniel Eklöf2022-01-13-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As described in #883, creating a block selection (with ctrl+BTN_LEFT), then *quickly* (within 300ms from) creating a new one, will, in fact, _not_ create a new block selection, but a ‘select-word-whitespace’ selection (ctrl+BTN_LEFT-2). A similar effect can be seen with plain selections (BTN_LEFT). Click and drag to make a selection, but *release*, and make a new selection within 300ms from the initial button press, and the new selection is suddenly a word-based selection. This happens because triggering a binding does *not* reset the button click counter. So, shouldn’t we just do that? No, because we rely on this behavior to handle single-, double- and triple-click actions. If we were to reset the button click handler, then we’d have to instead delay triggering the first action with 300ms, which would make things appear laggy. If we don’t do this, it would be impossible to double- and triple-click, since the single-click action would keep resetting the click counter. This patch takes a slightly different approach; we reset the click counter when the mouse has moved “too much”. For now, “too much” is when the cursor has moved to a different cell. This way, single-, double- and triple-clicks continue to work as before. But, creating actual selections, and then quickly releasing and starting a new selection produces the expected results. Closes #883
* input: reset view when pasting from primaryDaniel Eklöf2022-01-11-0/+1
| | | | | We’re already doing this for keyboard input, and regular clipboard pastes.
* SGR-Pixels mouse mode, closes #762Autumn Lamonte2022-01-01-1/+12
|
* input: apply scrollback.multplier in alterate scroll modeDaniel Eklöf2021-12-28-4/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | Before this patch, foot only applied [scrollback].multiplier on the normal screen, never the alt screen. However, scrolling can be done in two ways on the alt screen: If the application has enabled mouse support, we simply pass on the mouse scroll events to the application. Here, it makes sense to not apply the multiplier, and instead let the application choose how much to scroll for each scroll event. But, if the application has not enabled mouse support, we can still scroll by simulating the arrow keys being pressed - alternate scrolling (private mode 1007). This is enabled by default in foot (but can be disabled in foot.ini with the [mouse].alternate-scroll-mode setting). In this mode, it makes more sense to apply the multiplier. And that’s what this patch changes - the multiplier is now applied, on the alt screen, when the application has not enabled mouse support, and alternate scrolling has been enabled in foot. Closes #859
* input: kitty: don’t fallback to the XKB symbolDaniel Eklöf2021-12-16-4/+4
| | | | | | | | | | | When handling “generic” keys (i.e. keys not in the Kitty keymap), we use the pressed key’s Unicode codepoint as “key” in the kitty CSI. If we failed to convert the XKB symbol to a Unicode codepoint, we used to (before this patch), fallback to using the XKB symbol as is. This can never be correct... and it caused us to emit a meaningless CSI for XKB_KEY_ISO_Next_Group, which confused e.g. Kakoune.
* input: kitty: return the result of term_to_slave()Daniel Eklöf2021-12-12-2/+1
| | | | If term_to_slave() fails, then the key wasn’t ‘handled’...
* kitty: replace switch with a static keysym tableDaniel Eklöf2021-12-11-142/+36
|
* config: unify key- and mouse bindingsDaniel Eklöf2021-12-11-12/+10
| | | | | | | | | | | | | | With this patch, key- and mouse-bindings structs (the non-layout specific ones) are unified into a single struct. The logic that parses, and manages, the key- and mouse binding lists are almost identical. The *only* difference between a key- and a mouse binding is that key bindings have an XKB symbol, and mouse bindings a button and click-count. The new, unified, struct uses a union around these, and all functions that need to know which members to use/operate on now takes a ‘type’ parameter.
* config: do mouse binding collision detection after loading the confDaniel Eklöf2021-12-11-1/+1
|
* kitty: simplify: always calculate alternate/base keysDaniel Eklöf2021-12-08-14/+9
| | | | But only _emit_ them if report alternate has been enabled.
* kitty: when emitting associated text, don’t report mods/events unless necessaryDaniel Eklöf2021-12-08-6/+8
|
* kitty: report-alternate: apply base-layout key to composed charactersDaniel Eklöf2021-12-08-13/+15
|
* kitty: implement “base layout key” in “report alternate key”Daniel Eklöf2021-12-08-5/+31
|
* kitty: initial support for “report alternate key”Daniel Eklöf2021-12-08-1/+9
| | | | | | | | | | | | | | In this mode, the “shifted” and “base layout” keys are added to the CSIs, as sub-parameters to the “key” parameter. Note that this PR only implements the “shifted” key, not the “base layout key”. This is done by converting the original XKB symbol to it’s corresponding UTF-32 codepoint. If this codepoint is different from the one we use as “key” in the CSI, we add it as a sub-parameter. Related to #319
* kitty: only emit plain text on key press- and repeat eventsDaniel Eklöf2021-12-08-1/+1
| | | | That is, release events always generate CSIs
* kitty: add ISO_Level{3,5}_Shift keysDaniel Eklöf2021-12-08-0/+4
|
* kitty: composed characters with “report associated text”Daniel Eklöf2021-12-08-18/+20
| | | | | | | | | | The generic input handler now converts the composed character to it’s UTF-32 equivalent. This means we now provide a valid UTF-32 codepoint for both composed characters, and non-composed (plain-text) characters. Use this in the kitty protocol to simplify the logic around composed characters, by simply treating them as plain text.
* kitty: implement “report associated text”Daniel Eklöf2021-12-08-17/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | In this mode, key events that generate text now add a third CSI parameter, indicating the actual codepoint. Remember that we always use the *unshifted* key in the CSI escapes. With this mode, those CSI escapes now also included the text codepoint. I.e. what would have been emitted, had we not generated a CSI escape. As far as I can tell, this mode has no effect unless “report all keys as escape sequences” is enabled (reason being, without that, there aren’t any text events that generate CSIs - they’re always emitted as-is). Note that Kitty itself seems to be somewhat buggy in this mode. At least on Wayland, with my Swedish layout. For example ‘a’ and ‘A’ does generate the expected CSIs, but ‘å’ and ‘Å’ appears to be treated as non-text input. Furthermore, Kitty optimizes away the modifier parameter, if no modifiers are pressed (e.g. CSI 97;;97u), while we always emit the modifier (CSI 97;1;97u). Related to #319
* input: kitty: add support for “report all keys as escape codes”Daniel Eklöf2021-12-06-25/+55
|
* input: kitty: merge handling of plain-text and composed charactersDaniel Eklöf2021-12-04-88/+87
| | | | | | | | | | | | | | | | | | | | | | | | All plain-text and composed characters are now printed as-is, in a single place. Also fix handling of “generic” keys when emitted as escapes; don’t use the raw XKB symbol as key in the escape, convert it to a unicode code point first. For many symbols, these are the same. But not all. For now, we fallback to using the symbol as is if XKB fails to convert it to a codepoint. Not sure if we should simply drop the key press instead. Composed characters also need special treatment; we can’t use the symbol as is, since it typically refers to the last key pressed (i.e. not the composed character). And, that key is also (usually) a special “dead” key, which cannot be converted to a unicode codepoint. So, what we do is convert the generated utf8 string, and (try to) convert it to a wchar. If it succeeds, use that. If not, fallback to using the XKB symbol (as above).
* input: reset compose state on key *releases*, not pressesDaniel Eklöf2021-12-04-1/+1
|
* input: kitty: treat repeating == pressed when report-events is offDaniel Eklöf2021-12-04-1/+1
|
* input: kitty: add support for the “report event” mode (0b10)Daniel Eklöf2021-12-04-13/+38
|
* input: don’t ignore key release eventsDaniel Eklöf2021-12-04-43/+62
| | | | | | | | | | | | | Before this, key release events stopped the repeat timer, and then returned. Now, we run through the entire function. Most things are still only done on key press events. But, the goal here is to get to the keyboard protocol functions (and the kitty protocol in particular), and call them on release events too. This is in preparation for the kitty protocol mode 0b10, report event types.
* config, input: allow configuring select-override modifiersfeeptr@codeberg.org2021-12-02-6/+8
|
* input: always update the xcursor shape in pointer enter/motion eventsDaniel Eklöf2021-12-01-15/+10
| | | | | | | | | | | | | | | | Now that term_xcursor_update_for_seat() takes the current surface into account (i.e. doesn’t assume the cursor is over the main grid), there’s no longer any need to call render_xcursor_set() directly. Thus, we can simply call term_xcursor_update_for_seat() on **all** pointer enter and motion events. As long as we take care to update the internal state to reflect the, possibly new, current surface before doing so. Also make sure to **always** reset the seat’s “current” xcursor pointer on pointer leave events. This is done without actually sending anything to the compositor, but is necessary to ensure that we *do* send a request to update the xcursor on the next pointer enter event.
* input: fix debug log format specifier; ‘count’ is a size_tDaniel Eklöf2021-12-01-1/+1
|
* input: make csd_data variable ‘const’Daniel Eklöf2021-11-30-2/+1
|
* Merge branch 'window-menu'Daniel Eklöf2021-11-30-6/+20
|\
| * input: Add support for xdg_toplevl.show_window_menu()Jonas Ådahl2021-11-29-0/+10
| | | | | | | | | | This makes, if the compositor supports it, the window menu appear when right clicking on the title bar.
| * input: Update mouse x/y coordinates on wl_pointer_enterJonas Ådahl2021-11-29-5/+9
| | | | | | | | | | | | | | 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.
| * terminal: Make seat xcursor update focus awareJonas Ådahl2021-11-29-1/+1
| | | | | | | | | | | | | | 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.
* | input: regression: reset view (and cancel selection) on “handled” inputDaniel Eklöf2021-11-29-16/+18
| | | | | | | | | | | | 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.
* | input: regression: special keys don’t reset view and cancel selectionDaniel Eklöf2021-11-28-2/+4
| | | | | | | | | | This fixes an issue where e.g. holding down ctrl would cancel the selection, thus making it impossible to copy text to the clipboard.
* | input: kitty: use `XKB_CONSUMED_MODE_GTK` when retrieving consumed modsDaniel Eklöf2021-11-28-1/+2
| |
* | input: get_current_modifiers(): use xkb_state_key_get_consumed_mods2()Daniel Eklöf2021-11-28-2/+4
| | | | | | | | Explicitly request consumed modifiers using the `XKB` mode.
* | input: legacy: use ALEN(mod_param_map)Daniel Eklöf2021-11-28-1/+1
| |
* | input: grammar: “an UTF-8” -> “a UTF-8”Daniel Eklöf2021-11-28-4/+4
| |
* | input: legacy: reduce size of reply bufferDaniel Eklöf2021-11-28-1/+1
| | | | | | | | | | Its maximum size is known; the only two variables are two integers. We know the maximum length of an integer converted to a string.
* | input: only report modifiers when “Report all keys as escape codes” is enabledDaniel Eklöf2021-11-28-60/+16
| |
* | input: kitty: add shift/alt/ctrl/super/hyper/meta keysDaniel Eklöf2021-11-28-0/+48
| |
* | input: kitty: add ‘media’ keysDaniel Eklöf2021-11-28-0/+14
| |
* | input: kitty: map ISO_Left_Tab to TabDaniel Eklöf2021-11-28-0/+1
| |
* | input: rename ‘meta’ to ‘super’Daniel Eklöf2021-11-28-11/+11
| |
* | input: kitty: only emit CSIs for Caps- and Num-Lock when they aren’t modifiersDaniel Eklöf2021-11-28-2/+14
| |
* | input: handle “invalid” XKB modifiersDaniel Eklöf2021-11-28-30/+56
| | | | | | | | | | A modifier may not exist in a specific layout. This is indicated by XKB returning XKB_MOD_INVALID from xkb_keymap_mod_get_index().
* | input: kitty: disable CSI for Caps- and Num-LockDaniel Eklöf2021-11-28-2/+2
| | | | | | | | | | | | | | | | 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?
* | input: kitty: printables are emitted as text, even if Caps- or Num-Lock is in effectDaniel Eklöf2021-11-28-4/+15
| | | | | | | | | | | | | | | | | | | | 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.
* | input: get_current_modifiers() no longer strips insignificant modsDaniel Eklöf2021-11-28-34/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | input: kitty: use base symbol instead of lowering the symbolDaniel Eklöf2021-11-28-21/+139
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | input: wip: add support for kitty kbd protocol “Disambiguate escape codes”Daniel Eklöf2021-11-28-21/+193
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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).
* | input: enable repeat while COMPOSINGDaniel Eklöf2021-11-28-4/+2
| |
* | input: refactor: new function: legacy_kbd_protocol()Daniel Eklöf2021-11-28-105/+107
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* | input: finalize mouse selection on a pointer-leave event on the GRID surfaceDaniel Eklöf2021-11-25-1/+4
|/ | | | | | | | | If a mouse selection was ongoing, and the user switched workspace (probably using the keyboard...), and then back, the selection was still treated as ongoing, while all other mouse state has been reset. This meant the user had to tap at least once to stop the selection.
* input: add support for modifyOtherKeys=2Daniel Eklöf2021-11-13-5/+39
| | | | | | | | | | | | | | | | Similar to modifyOtherKeys=1 (foot’s default, and only, mode), except that: * All modifiers (and not just Ctrl) generate \E[27;m;n~ escapes * Regular keys (with modifiers) also generate \E[27;m;n~ escapes (for example, C-h no longer generates ^H, but \E[27;5;104~) For our keymap based lookups, this is handled by adding MOD_MODIFY_OTHER_KEYS_STATE<N> variants. For “generic” keys, we simply adjust the conditions for when to emit a \E[27;m;n~ escape - the only requirement is that at least one modifier is active.
* input: don’t apply [scrollback].multiplier when alt screen is in useDaniel Eklöf2021-11-13-4/+11
| | | | Closes #787
* input: clean up mouse scroll handlingDaniel Eklöf2021-10-27-8/+21
| | | | | | | | | | * Allow scrolling on the normal (non-alt) screen, when application is grabbing the mouse (when user presses Shift). * Use term_mouse_grabbed() instead of explicitly checking for MOUSE_NONE tracking. * Remove mouse tracking check from cmd_scrollback_{up,down}. Caller is expected to have done the check. * Don’t scroll down on mouse wheel tilt events.
* config: add [key-bindings].noop actionDaniel Eklöf2021-10-27-0/+3
| | | | | | | Key combinations assigned to this action will not be sent to the application. Closes #765
* input: update serial on each key press/release and mouse buttonDaniel Eklöf2021-10-20-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | The serial is used when copying/pasting data from the clipboard. Up until now, we’ve used the serial from the keyboard/mouse enter events. This works in most cases, but breaks in the following example: $ wl-copy WLCOPY /* Ctrl+Shift+v works fine (pastes "WLCOPY") */ $ printf "\033]52;c;eHl6\a" /* Ctrl+Shift+v pastes "WLCOPY" instead of "xyz" */ Shifting focus away and then back to the foot window, and re-executing the printf works, suggesting the “enter” serial is no longer valid after another process(?) has copied something to the clipboard. Updating the serial on key press/release (and the corresponding mouse serial on mouse button events) seems to fix this. I’ve also tested that “normal” copy/paste operations, within the same foot instance, and between foot and other applications, are still working. In at least river (wlroots based), and GNOME/mutter. Closes #753
* input: filter out non-significant modifiers when matching mouse bindingsDaniel Eklöf2021-10-06-15/+28
| | | | Closes #736
* input: check for ‘effective’ modifiers, not ‘depressed’Daniel Eklöf2021-10-02-6/+6
| | | | | | | When reading XKB modifier state, use XKB_STATE_MODS_EFFECTIVE, not XKB_STATE_MODS_DEPRESSED. This fixes handling of ‘sticky’ modifier keys.
* input: workaround GNOME issue with pointer button eventsDaniel Eklöf2021-09-12-45/+57
| | | | | | | | | | | | | | | | | Under certain circumstances, GNOME will send multiple pointer button press events, without any release or leave events in between. This trips up our button tracking. Workaround, by replacing the existing state for the pressed button with the new state. Previously, debug builds would assert (and thus crash), while release builds would have multiple states for the same button, causing (probably) issues like the title bar not being usable (as in, cannot be dragged, buttons not working etc). Hopefully closes #709
* input: implement support for mouse wheel left/rightDaniel Eklöf2021-08-07-19/+24
| | | | | | | | | | | | | We now emit button 6/7 events (when the client application grabs the mouse). This buttons map to mouse wheel horizontal scroll events. Or, left/right tilting, if you like. Wayland report these as ‘axis’ events (just like regular scroll wheel events), and thus we need to translate those scroll events to button events. libinput does not define any mouse buttons for wheel tilts, so we add our own defitions. These are added last in the BTN_* range, just before the BTN_JOYSTICK events.
* input: codespell: follwing -> followingDaniel Eklöf2021-08-06-1/+1
|
* input: workaround GNOME messing up pointer leave/enter after moving windowDaniel Eklöf2021-08-06-1/+47
| | | | | | | | | | GNOME doesn’t send pointer enter after finishing a window move. In subsequent move operations, it is also possible to make it skip sending pointer leave when starting the move operations. This caused foot to assert in debug builds, and add the same button multiple times to the list of buttons currently being pressed.
* term: consolidate shutdown related state into an anonymous structDaniel Eklöf2021-07-31-1/+1
|
* config: remove replaced/removed key bindings, instead of marking as ‘unused’Daniel Eklöf2021-06-30-6/+0
| | | | | | | | | | | | Instead of keeping removed/replaced key bindings in the key binding array (marked as ‘unused’), remove them, by compacting the array. The invariant is thus that there should be *no* entries in the key binding list with the `BIND_ACTION_NONE` for action. Add code to debug builds that verifies this, plus a unit test. Closes #614
* input: ignore ‘unused’ URL key bindings when mapping bindings to current keymapDaniel Eklöf2021-06-28-2/+0
| | | | | This is a temporary fix for #614. Long term fix is to remove the ‘replaced’ bindings from the array at config time.
* config: add new function config_clone()Daniel Eklöf2021-06-23-3/+4
|