aboutsummaryrefslogtreecommitdiff
path: root/input.c (follow)
Commit message (Collapse)AuthorAgeLines
* keymap: handle shift+tab combos correctly, after consuming modifiersDaniel Eklöf2021-03-08-2/+2
| | | | | | | | | | | | | | | | | | | | | Shift+Tab is an odd bird in XKB; it produces a shifted variant of tab, ISO_Left_Tab, with Shift being a consumed modifier. From a terminal perspective, Tab and ISO_Left_Tab are the same key, with Shift+Tab generating ‘CSI Z’, and all other combos generating a ‘CSI 27;mods;9~’ escape. Before, when we didn’t filter out consumed modifiers, we could simply re-use the keymap for Tab when translating ISO_Left_Tab. This is no longer possible, since shift has been filtered out. As a result, Shift+Tab no longer generated ‘CSI Z’, but ‘\t’. I.e as if shift wasn’t being pressed. This patch adds a separate keymap table for ISO_Left_Tab. It’s MOD_ANY entry corresponds to Shift+Tab, and emits ‘CSI Z’. All its other entries *exclude* shift (since it has been consumed), *but*, the encoded modifier (in the escape sequences) *include* shift.
* input: do not include consumed modifiers in the set sent to the clientDaniel Eklöf2021-03-08-5/+5
| | | | | | | When sending a key escape sequence to the client application, do not include consumed modifiers. Fixes part of #376
* input: repair key combos containing both explicit modifier and shifted symbolDaniel Eklöf2021-03-04-5/+123
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If a user-provided key combo contains both an explicit modifier, and the shifted symbol it produces, replace the symbol with its un-shifted version. Example: Control+Shift+U contains both ‘Shift’, and ‘U’, where ‘Shift’ is the modifier that shifts ‘u’ to ‘U’. Such modifiers are “consumed”, i.e. filtered out, when matching key combos. As such, Control+Shift+U will never trigger since we’ll never be able to match the consumed modifier ‘Shift’. The above combo can be written in two ways: - Control+U - Control+Shift+u To be able to detect that Control+Shift+U is an invalid combination, we need to check all *shifted* symbols for all key *codes*. Once we’ve detected a shifted symbol (and where it differs from the un-shifted symbol), we loop all modifier sets that produce the shift level where our shifted symbol is. For each such set, check if it intersects with the user-provided key combo’s modifier set. If there is an intersection, it means the user provided a key combo containing a modifier and symbol, such that the modifier is consumed when the symbol is produced. In this case, we replace the symbol with its un-shifted version.
* input: rewrite of how we match foot’s own key bindingsDaniel Eklöf2021-03-04-14/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bindings are matched in one out of three ways: * By translated (by XKB) symbols * By untranslated symbols * By raw key codes A translated symbol is affected by pressed modifiers, some of which can be “consumed”. Consumed modifiers to not partake in the comparison with the binding’s modifiers. In this mode, ctrl+shift+2 maps to ctrl+@ on a US layout. Untranslated symbols, or un-shifted symbols refer to the “base” symbol of the pressed key, i.e. it’s unaffected by modifiers. In this mode, consumed modifiers *do* partake in the comparison with the binding’s modifiers, and ctrl+shift+2 maps to ctrl+shift+2 on a US layout. More examples: ctrl+shift+u maps to ctrl+U in the translated lookup, while ctrl+shift+u maps to ctrl+shift+u in the untranslated lookup. Finally, we also match raw key codes. This allows our bindings to work using the same physical keys when the user switches between latin and non-latin layouts. This means key bindings in foot.ini *must* not include both +shift+ and a *shifted* key. I.e. ctrl+shift+U is not a valid combo as it cannot be triggered. Unfortunately, this was how you were supposed to write bindings up until now... so, we try to detect such bindings, log a deprecation warning and then “fix” the binding for the user. When specifying bindings in foot.ini, both ctrl+U and ctrl+shift+u are valid, and will work. The latter is preferred though, since we cannot detect the raw key code for the former variant. Personally, I also prefer the latter one because it is more explicit; it’s more obvious which keys are involved. However, in some cases it makes more sense to use the other variant. Typically for non-letter combos.
* input: ask XKB for consumed modifiers, but don’t actually use them just yetDaniel Eklöf2021-03-04-10/+11
|
* input: mutter has been seen sending NULL surfaces in pointer enterDaniel Eklöf2021-03-04-0/+5
|
* input: exit URLs mode on mouse button eventsDaniel Eklöf2021-03-04-0/+1
| | | | This makes URLs mode behave like scrollback search mode.
* url-mode: use ‘jump-label-letters’ as the alphabet for key sequencesDaniel Eklöf2021-02-13-1/+1
| | | | | | | Instead of hard coding the alphabet to “sadfjklewcmpgh”, use the letters from ‘jump-label-letters’. Closes #355
* Convert all but 2 remaining uses of xassert(false) to BUG("...")Craig Barnes2021-02-10-2/+2
|
* Convert some more uses of xassert(false) to BUG("...")Craig Barnes2021-02-09-2/+2
|
* Convert some uses of xassert(false) to BUG("some error message")Craig Barnes2021-02-09-1/+1
|
* key-bindings: refactor: use a single type for all key bindingsDaniel Eklöf2021-02-08-49/+16
| | | | | | | | | | | | | | | | Up until now, the various key binding modes (“normal”, “search” and “url”) have used their own struct definitions for their key bindings. The only reason for this was to have a properly typed “action” (using the appropriate “action” enum). This caused lots of duplicated code. This patch refactors this to use a single struct definition for the “unparsed” key bindings handled by the configuration, and another single definition for “parsed” bindings used while handling input. This allows us to implement configuration parsing, keymap translation and so on using one set of functions, regardless of key binding mode.
* url-mode: urls_collect(): URL list pointer as an argumentDaniel Eklöf2021-02-07-3/+3
|
* url-mode: underline URLs using the color from colors.urlsDaniel Eklöf2021-02-07-0/+1
| | | | | | | | | | | | | | | | | | | | | | This is implemented by allocating one of the (few!) remaining bits in the cells’ attribute struct to indicate the cell should be “URL highlighted”. render_cell() looks at this bit and draws an underline using the color from colors.urls (defaults to regular3 - i.e. yellow). A new function, url_tag_cells(), iterates the currently detected URLs and sets the new ‘url’ attribute flag on the affected cells. Note: this is done in a separate function to keep urls_collect() free from as many dependencies as possible. urls_reset() is updated to *clear* the ‘url’ flag (and thus implicitly also results in a grid refresh, _if_ there were any URLs). We now exit URL mode on *any* client application input. This needs to be so since we can’t know if the URLs we previously detected are still valid.
* input: mouse events on jump label surfaces do nothingDaniel Eklöf2021-02-07-0/+4
|
* config: add show-urls-copy actionDaniel Eklöf2021-02-07-2/+8
| | | | | | This works just like show-urls-launch, except that instead of opening the URL (typically using xdg-open), it is placed in the clipboard when activated.
* config: rename ‘show-urls’ to ‘show-urls-launch’Daniel Eklöf2021-02-07-1/+1
|
* urls: initial support for detecting URLs and rendering jump-labelsDaniel Eklöf2021-02-07-2/+11
| | | | The jump labels work, but is currently hardcoded to use xdg-open
* config: add infrastructure to handle URL mode specific key bindingsDaniel Eklöf2021-02-07-0/+28
| | | | | | * Add “show-urls” action to regular key bindings * Add url-bindings section to foot.ini * Add “cancel” action to URL mode key bindings
* input: don’t execute mouse bindings when the application is grabbing the mouseDaniel Eklöf2021-02-02-94/+74
| | | | | | | | | | | | | | | | | | | When the application is grabbing the mouse, we require ‘shift’ to be pressed to be able to use foot’s mouse bindings. Otherwise the mouse event is sent to the application. This wasn’t being enforced consistently; each and every mouse **only** action was checking the mouse grab state, but e.g. *primary paste* (which can be used as both a key binding and a mouse binding) was not. The fix is actually quite simple: don’t even try to execute *any* mouse bindings when the application is grabbing the mouse (unless shift is pressed). This fixes an issue where e.g. middle mouse button events (using the default mouse bindings) were never seen by any mouse grabbing client applications.
* debug: rename assert() to xassert(), to avoid clashing with <assert.h>Craig Barnes2021-01-16-28/+28
|
* input: don’t enable keyboard repeat timer when repeat rate is zeroDaniel Eklöf2021-01-16-0/+3
| | | | | | | | | | wayland-client-protocol.h: Negative values for either rate or delay are illegal. A rate of zero will disable any repeating (regardless of the value of delay). This fixes a division-by-zero crash.
* Add xsnprintf() and remove some unnecessary strlen(3) callsCraig Barnes2021-01-14-2/+3
|
* config: add ‘select-extend-character-wise’ bind actionDaniel Eklöf2021-01-14-1/+11
| | | | | | | This forces the (new) selection mode to be character-wise when extending a word- or line-wise selection. Default key binding is ctrl+RMB.
* selection: combine enum selection_kind with selection_semanticDaniel Eklöf2021-01-06-10/+6
|
* selection: use selection_start() to initialize word/row-based selectionDaniel Eklöf2021-01-04-7/+10
| | | | | | This removes the selection_mark_word() and selection_mark_row() functions. To start a word/row-based selection, use selection_start() with SELECTION_SEMANTIC_{WORD,ROW}
* selection: wip: update selection word-wise when initial selection was by wordDaniel Eklöf2021-01-04-2/+4
|
* input: don’t try to close an invalid FDDaniel Eklöf2021-01-04-3/+4
|
* input: don’t assert when receiving a button release without a press eventDaniel Eklöf2021-01-04-1/+20
|
* input: remove non-existing state from debug logDaniel Eklöf2020-12-23-1/+1
|
* input: make sure ‘surf_kind’ is not uninitializedDaniel Eklöf2020-12-12-1/+1
|
* input: rework mouse button/motion handlingDaniel Eklöf2020-12-12-91/+120
| | | | | | | | | | | | | | | | | | | Store a list of currently pressed buttons, and which surface they belong to (i.e. which surface that received the press). Then, in motion events (with a button pressed, aka drag operations), send the event to the “original” surface (that received the press). Also send release events to the originating surface. This means a surface receiving a press will always receive a corresponding release. And no one will receive a release event without a corresponding press event. Motion events with a button pressed will *always* use the *first* button that was pressed. I.e. if you press a button, start dragging, and then press another button, we keep generating motion events for the *first* button.
* input: report mouse drag events also when the pointer is outside the gridDaniel Eklöf2020-12-11-4/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As long as the mouse button was *pressed* while the pointer was inside the grid, we want to keep reporting motion events until the button is released. Even when the pointer moves outside the grid (but in this case, the reported coordinates are bounded by the grid size). This patch also tries to improve multi-button handling (i.e. multiple buttons pressed at the same time), and the events we report to the client for these, in the following ways: * Motion events now report the *initial* button. That is, if you start a drag operation with the LEFT button, then press RIGHT (before releasing LEFT), keep reporting LEFT in the motion events. * Mouse release events are reported for *any* button, as long as the pointer is *inside* the grid, *or*, the button released was the button used to start a drag operation. The last point is important; if we have reported a button press followed by motion events (i.e. a drag operation), we need to report the button release, *even* if the pointer is outside the grid. Note that the client may receive unbalanced button press/release events in the following ways if the user pressed one, and then a second button *inside* the grid, then releases the *first* button (possibly outside the grid), and finally releases the *second* button *outside* the grid. In this case, both buttons will report press events. The first button will report a release event since it is the initial button in the drag operation. However, we don’t track the fact that the second button is being pressed, and thus if it is released outside the grid, it wont generate a release event.
* Merge branch 'remove-deprecated-things'Daniel Eklöf2020-12-09-2/+0
|\
| * config: remove support for scrollback-up and scrollback-downDaniel Eklöf2020-12-08-2/+0
| |
* | ime: render pre-edit textDaniel Eklöf2020-12-07-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | ime: wip: commit all changes in ‘done()’Daniel Eklöf2020-12-07-1/+3
|/
* Merge branch 'modify-escape-key'Daniel Eklöf2020-12-01-1/+7
|\ | | | | | | Closes #225
| * csi: add new private mode that makes the Escape key emit "\E[27;1;27~"Craig Barnes2020-11-29-1/+7
| | | | | | | | | | | | | | | | | | | | This mode can be set by client programs with the DECSET, DECRST, XTSAVE and XTRESTORE sequences by using 27127 as the parameter. The sequence "\E[27;1;27~" is encoded in the same way as is done by xterm's "modifyOtherKeys" mode. Even though xterm itself never emits such a sequence for the Escape key, many programs already have support for parsing this style of key sequence.
* | input: relax requirements for overriding keypad application modeDaniel Eklöf2020-12-01-7/+1
| | | | | | | | | | | | Don’t require NumLock to be locked. Foot has no idea _which_ modifier the user has mapped NumLock to, meaning we really cannot require it to be locked.
* | input: improved debug logging of pressed keysDaniel Eklöf2020-11-30-10/+9
|/
* keymap: use same lookup table for Tab and ISO_Left_TabDaniel Eklöf2020-11-19-2/+2
| | | | | | | | | | | | | | With XKB, Shift+Tab maps to XKB_KEY_ISO_Left_Tab, not XKB_Key_Tab. Previously, we had two different lookup tables for the two. The tab table was correctly populated, while the ISO-left tab wasn’t. As a result, all Shift+Tab combos (except Shift+Tab itself) was wrong, and resulted in the same escape sequence as Shift+Tab. Fix by using the same table for both tab and ISO-left tab. Closes #210
* input: enforce ‘numerical’ keypad mode when Num Lock override is enabledDaniel Eklöf2020-11-11-4/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | When num lock override has been enabled via “CSI?1035h” (the default), keypad is always considered to be in ‘numerical’ mode. This affects how keypad keys are translated to escape sequences when Num Lock is active. The keypad has four modes: * Num Lock off, numerical mode * Num Lock off, application mode * Num Lock on, numerical mode * Num Lock on, application mode The keymap is identical for numerical and application mode when Num Lock is off, meaning the keypad effectively has three different modes. In XTerm, numerical and application mode _can_ be the same, **if** the ‘numLock’ resource is set to true (the default). It is only when ‘numLock’ is false that the application mode is actually used. This patch changes foot to do the same. We don’t expose an option, but do implement “CSI ? 1035”. Closes #194
* input: track num lock stateDaniel Eklöf2020-11-11-0/+4
|
* input: use XKB_MOD_NAME_* macros instead of hard-coded stringsDaniel Eklöf2020-11-11-4/+4
|
* input: ignore keymap if we don’t recognize its formatDaniel Eklöf2020-11-09-9/+26
|
* config: add support for pipe-* actions in mouse bindingsDaniel Eklöf2020-11-06-2/+3
| | | | Closes #183
* input: don’t use seat->kbd_focus as terminal when processing a key pressDaniel Eklöf2020-11-03-15/+25
| | | | | | | | | | | | When converting mouse scroll events to keyboard input (in alternate scroll mode), we need to use seat->mouse_focus, not seat->kbd_focus. To enable this, break out key press/release handling code to a separate function that takes an explicit term argument. Call this function from keyboard_key(), input_repeat() and in alternate scroll mode. Closes #179
* input: handle XKB errorsDaniel Eklöf2020-10-20-58/+72
| | | | | | | | | | | * Don’t de-reference the xkb context/keymap/state if we failed to instantiate them. * Don’t try to send a translated utf8 key sequence if the translation failed. * Handle xkb_compose_state_get_utf8() and xkb_state_key_get_utf8() returning more than 64 bytes. This _may_ fix #171.
* input: don’t allow diagonal resize when tiledDaniel Eklöf2020-10-20-8/+12
|
* input: don’t crash if xkbcommon cannot find a compose fileDaniel Eklöf2020-10-19-8/+24
| | | | | | | | Handle xkb_compose_table_new_from_locale() returning NULL. When this happens, log a warning that “dead keys” will be disabled, and make sure to never de-reference the compose table pointer. Closes #170
* Merge branch 'releases/1.5' into masterDaniel Eklöf2020-10-13-7/+9
|\
| * input: regression: don’t pass on mouse click to application if we consumed itDaniel Eklöf2020-10-13-7/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | When we ‘consume’ a mouse button event (i.e. when we have a shortcut mapped to it), the event should *not* be passed on to the client application. In 5f64c5c33590a41afd3f621870c6abd89b859073, button handling was refactored and unfortunately introduced a regression where we once again started passing consumed button presses to the client application. Fixes #168
| * input: trackpad scroll: correctly convert pixel movements to line movementsDaniel Eklöf2020-10-11-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | Trackpad scroll movements are in pixels. Foot previously “translated” these directly to line movements (i.e. a one pixel scroll event was translated into a one line scroll). Now we use the line height of the terminal and correctly convert pixels to lines. This makes the trackpad scroll speed in foot consistent with the scroll speed in e.g. Alacritty and Kitty.
| * input: mouse: match binding if binding’s click count is *less*Daniel Eklöf2020-10-11-6/+18
| | | | | | | | | | | | | | | | | | | | | | Allow a mouse binding to match even if its click count is less than the actual click count. If there are multiple bindings that match, use the one with the highest click count (that less than, or equal to the actual click count). Closes #146
* | input: comment: ‘measures’ -> ‘measured’Daniel Eklöf2020-10-11-1/+1
| |
* | input: comment: ‘fast’ -> ‘faster’Daniel Eklöf2020-10-11-1/+1
| |
* | selection: auto-scroll: add SELECTION_SCROLL_NOT as a scroll ‘direction’Daniel Eklöf2020-10-11-7/+22
| |
* | input: auto-scroll: apply scrollback.multiplier to the interval divisorDaniel Eklöf2020-10-11-2/+3
| |
* | selection: auto-scroll: selection keeps scrolling while mouse is outside gridDaniel Eklöf2020-10-11-7/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Moving the mouse outside the grid while we have an on-going selection now starts a timer. The interval of this timer depends on the mouse’s distance from the grid - the further away the mouse is, the shorter interval. On each timer timeout, we scroll one line, and update the selection. Thus, the shorter the interval, the faster we scroll. The timer is canceled as soon as the mouse enters the grid again, or the selection is either canceled or finalized. The timer FD is created and destroyed on-demand. Most of the logic is now in selection.c. The exception is the calculation of the timer interval, which depends on the mouse’s position. Thus, this is done in input.c. The scroll+selection update logic needs to know a) which direction we’re scrolling in, and b) which *column* the selection should be updated with. If the mouse is outside the grid’s left or right margins, the stored mouse column will be -1. I.e. we don’t know whether the mouse is on the left or right side of the grid. This is why the caller, that starts the timer, must provide this value. The same applies to top and bottom margins, but since we already have the scroll *direction*, which row value to use can be derived from this.
* | input: motion: scroll up/down while selectingDaniel Eklöf2020-10-11-1/+13
| | | | | | | | | | | | | | | | | | | | If the cursor moves above the grid top, or below the grid bottom, while selecting text, scroll up/down the scrollback before updating the selection. TODO: this only scrolls when the mouse is *moved*. I.e. you can’t move the cursor outside the grid once and for all, and then let foot auto-scroll.
* | input: trackpad scroll: correctly convert pixel movements to line movementsDaniel Eklöf2020-09-29-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | Trackpad scroll movements are in pixels. Foot previously “translated” these directly to line movements (i.e. a one pixel scroll event was translated into a one line scroll). Now we use the line height of the terminal and correctly convert pixels to lines. This makes the trackpad scroll speed in foot consistent with the scroll speed in e.g. Alacritty and Kitty.
* | input: mouse: match binding if binding’s click count is *less*Daniel Eklöf2020-09-27-6/+18
|/ | | | | | | | | | | Allow a mouse binding to match even if its click count is less than the actual click count. If there are multiple bindings that match, use the one with the highest click count (that less than, or equal to the actual click count). Closes #146
* input: mouse_scroll(): refactorDaniel Eklöf2020-09-15-36/+35
|
* input: don’t use stale keycodes for arrow-up/downDaniel Eklöf2020-09-15-11/+10
| | | | | | | The keycodes will change if the seat’s keymap changes. Make sure we only do alternate scrolling if the seat has a keyboard, and use the *current* layout’s keycodes for arrow up/down (instead of the *first* layout’s).
* input: don’t do alternate mode scrolling if application is grabbing mouseDaniel Eklöf2020-09-15-1/+2
|
* input: don’t do grid scrollback if mouse events are being capturedDaniel Eklöf2020-09-15-3/+2
|
* key-binding: deprecate scrollback-up/down, add scrollback-up/down-lineDaniel Eklöf2020-09-10-2/+12
| | | | | | | | This deprecates/renames scrollback-up/down to scrollback-up/down-page. It also renames scrollback-up/down-half to scrollback-up/down-half-page, and adds the new bindings scrollback-up/down-line.
* config: add scrollback-{up,down}-half key bindingsDaniel Eklöf2020-09-09-0/+8
| | | | | | | | These new bindings scroll up/down half a page in the scrollback (instead of the full page scrolled by ‘scrollback-{up,down}’). Closes #128.
* input: fix assertion when pressing first one mouse button, then anotherDaniel Eklöf2020-09-07-55/+54
|
* Cast printf formatter %p arguments to void*Daniel Eklöf2020-08-23-10/+11
|
* don't use empty struct initializersDaniel Eklöf2020-08-23-4/+4
|
* input: inhibit mouse events to client when a binding has consumed itDaniel Eklöf2020-08-22-36/+59
| | | | | | | | | | This introduces a new state to a seat's mouse struct, 'consumed'. It is set on a mouse *press* event that is claimed by a mouse binding. It is cleared after a mouse *release* event. While set, *no* mouse motion or button events are sent to the client application.
* Fix some spelling mistakesCraig Barnes2020-08-15-2/+2
|
* input: mouse motion: don't update selection while scrollback searchingDaniel Eklöf2020-08-14-2/+4
| | | | | When we are doing a scrollback search, the selection *is* ongoing. We still don't want to update the selection when the mouse moves.
* input: bindings: calculate 'cursor_is_on_grid' once onlyDaniel Eklöf2020-08-14-18/+8
|
* input: mouse-bindings: ignore ShiftDaniel Eklöf2020-08-14-3/+9
| | | | | | | | Shift is used to enable selection when the client application is grabbing the mouse. As such, mouse bindings *never* have Shift as a modifier, but should still trigger when Shift is being pressed.
* input: mouse-bindings: check selection is enabled/possible and that pointer is on gridDaniel Eklöf2020-08-14-13/+33
| | | | | | | | | | We shouldn't start or modify a selection if selection isn't possible (i.e. client application is grabbing the mouse, and user isn't holding Shift). We also shouldn't start or modify a selection if the pointer is outside the grid (updating an ongoing selection on motion events is an exception to this).
* config: mouse bindings: add select-begin-block and select-rowDaniel Eklöf2020-08-14-14/+19
|
* config: add mouse specific bind actionsDaniel Eklöf2020-08-14-34/+27
| | | | | | | | | | | | | | | | | | | | This extends the "normal" bind action enum with mouse specific actions. When parsing key bindings, we only check up to the last valid keyboard binding, while mouse bindings support *both* key actions and mouse actions. The new actions are: * select-begin: starts an interactive selection * select-extend: interactively extend an existing selection * select-word: select word under cursor * select-word-whitespace: select word under cursor, where the only word separating characters are whitespace characters. The old hard-coded selection "bindings" have been converted to instead use these actions, via default bindings added to the configuration.
* Merge branch 'modifiers-in-mouse-bindings' into masterDaniel Eklöf2020-08-14-114/+142
|\
| * config: key/mouse bindings: refactor: less parsing in keyboard_enter()Daniel Eklöf2020-08-13-198/+120
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This simplifies the handling of mouse and keyboard bindings. Before, the bindings where parsed *both* when loading the configuration, and then on every keyboard enter event. This was done since keys require a keymap to be decoded. Something we don't have at configuration time. The idea was that at config time, we used a default keymap just to verify the key combo strings were valid. The following has changed: * The bindings in the config struct is now *one* key combo per entry. Previously, it was one *action* per entry, and each entry had one or more key combos. Doing it this way makes it easier when converting the binding in the keyboard enter event (which previously had to expand the combos anyway). * The bindings in the config struct no longer contains any unparsed strings. A key binding contains a decoded 'modifier' struct (which specifies whether e.g. ctrl, or shift, or ctrl+shift must be pressed for the binding to be used). It also contains a decoded XKB keysym. * A mouse binding in the config struct is similar to a key binding, except it contains the button, and click count instead of the XKB key sym. * The modifiers in the user-specified key combo is decoded at config time, by using the pre-defined XKB constants XKB_MOD_NAME_<modifier>. The result is stored in a 'modifiers' struct, which is just a collection of booleans; one for each supported modifier. The supported modifiers are: shift, ctrl, alt and meta/super. * The key sym is decoded at config time using xkb_keysym_from_name(). This call does *not* depend on a keymap. * The mouse button is decoded at config time using a hardcoded mapping table (just like before). * The click count is currently hard-coded to 1. * In the keyboard enter event, all we need to do is pre-compute the xkb_mod_mask_t variable for each key/mouse binding, and find all the *key codes* that map to the (already decoded) symbol. For mouse bindings, the modifiers are the *only* reason we convert the mouse bindings at all. In fact, on button events, we check if the seat has a keyboard. If not, we use the mouse bindings from the configuration directly, and simply filter out those with a non-empty set of modifiers.
| * input: pointer-leave: don't reset mouse properties with memset()Daniel Eklöf2020-08-13-1/+6
| | | | | | | | | | Using memset() also clears the mouse bindings. This is both incorrect, and leaked memory.
| * config: wip: add support for modifiers in mouse bindingsDaniel Eklöf2020-08-13-6/+107
| | | | | | | | | | | | | | Mouse bindings can now include modifiers. They are specified in pretty much the same way as in keyboard bindings: Control+BTN_LEFT
* | input: don't crash on mouse motion events on the render timer surfaceDaniel Eklöf2020-08-14-0/+4
|/
* Convert most dynamic allocations to use functions from xmalloc.hCraig Barnes2020-08-08-2/+3
|
* Merge branch 'selection-improvements' into masterDaniel Eklöf2020-08-08-32/+81
|\ | | | | | | Closes #70
| * input: motion: improve commentDaniel Eklöf2020-08-08-2/+1
| |
| * input: pointer-enter: add comment describing what we're doingDaniel Eklöf2020-08-08-0/+6
| |
| * input: motion: regression: check for RMB when updating selectionDaniel Eklöf2020-08-08-4/+6
| | | | | | | | | | | | | | | | | | | | While refactoring this code, the check for LMB or RMB got changed to LMB or "any button". This fixes that. It also adds a boolean 'cursor_is_on_grid', which should make the code easier to read and understand.
| * input: scrolling: don't send events to client if cursor is outside gridDaniel Eklöf2020-08-07-1/+8
| |
| * input: mouse: motion/enter: cleanup inside/outside grid handlingDaniel Eklöf2020-08-07-29/+49
| |
| * input: button: button events aren't passed to clients, when cursor is outside gridDaniel Eklöf2020-08-07-9/+9
| | | | | | | | | | | | | | | | | | | | Don't send mouse button escapes to a mouse grabbing client when the cursor is outside the grid (i.e. when it is inside the margins). Also don't do *any* kind of selection when the cursor is outside the grid. Previously, we only checked this for selection_start(), but e.g. double clicking would run selection_extend(), or selection_mark_word() etc.
| * input: motion: do selection update even if cursor is outside the gridDaniel Eklöf2020-08-07-9/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, the selection was only updated when the mouse cursor was inside the grid. This makes it difficult to e.g. do large selections fast, since you often end up moving the cursor outside the grid, or outside the terminal window even. Now, we update the selection regardless of *where* the cursor is. This is done by bounding the row/col we pass to 'selection_update()' to the grid, while still setting the seat's row/col to -1 when the cursor is outside the grid, to ensure the xcursor etc are set correctly. Care must also be taken to *not* pass any motion events to a mouse grabbing client, when the cursor is outside the grid. Closes #70.
| * input: fix col/row calculation when cursor is in the top or left marginDaniel Eklöf2020-08-07-4/+8
| | | | | | | | | | | | | | | | | | This fixes an issue where the col/row were incorrectly set to 0 instead of -1, when the mouse cursor was inside the grid margins. This resulted in e.g. the mouse cursor having the wrong shape, and foot incorrectly handling mouse events as if they were inside the grid.
* | Replace GCC "unused" and "format" attributes with portable macrosCraig Barnes2020-08-07-2/+2
|/
* input: disable debug logginDaniel Eklöf2020-08-04-1/+1
|
* input: ignore ISO Level 3 Shift (AltGr) when hiding the mouse cursorDaniel Eklöf2020-08-04-1/+2
|
* config: move cursor.hide-when-typing to mouse.hide-when-typingDaniel Eklöf2020-08-04-1/+1
|
* config: add scrollback.multiplier optionDaniel Eklöf2020-08-03-2/+3
| | | | | | | This option is used to multiply the mouse scroll amount for mouse and trackpad based scrollback scrolling. Closes #54.