aboutsummaryrefslogtreecommitdiff
path: root/input.c (follow)
Commit message (Collapse)AuthorAgeLines
* 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.
* input: hide-when-typing: ignore modifiersDaniel Eklöf2020-08-03-1/+7
|
* input: don't hide cursor if key is 'shift'Daniel Eklöf2020-08-01-5/+7
| | | | | Since shift is used to enable selecting text in mouse-grabbing applications, hiding the cursor in this case is counter productive.
* config: add 'hide-when-typing'Daniel Eklöf2020-07-31-6/+19
| | | | | | When enabled, the mouse cursor is hidden when the user types in the terminal. It is un-hidden when the user moves the mouse, or when the window loses keyboard focus.
* config: add 'pipe-selected' key bindingDaniel Eklöf2020-07-31-4/+23
| | | | | | | This works just like pipe-visible and pipe-scrollback, but pipes the user-selected text, if any, to the external tool. Closes #51
* config: tokenize key bindings' pipe command when loading the configurationDaniel Eklöf2020-07-30-18/+6
| | | | | | This allows us to detect syntax errors early on, and is also more efficient since we don't have to re-tokenize the command line every time the binding is executed.
* Merge branch 'master' into scrollback-position-indicatorDaniel Eklöf2020-07-27-1/+1
|\
| * selection: extending a selection is now interactiveDaniel Eklöf2020-07-27-1/+1
| | | | | | | | | | That is, a selection extension can be resized just like an ordinary extension.
* | input: handle the scrollback indicator surface in pointer eventsDaniel Eklöf2020-07-26-0/+4
| |
* | input: margins are not selectableDaniel Eklöf2020-07-26-14/+26
|/ | | | | | | | | | | | | * Fix col/row calculation in pointer-enter event; we did not take the margins into account. * seat->mouse.col,row are now set to -1 if the cursor is inside the margins. That is, col/row are only ever valid when the mouse is actually over the grid, and not in the margins. * Use regular 'left-ptr' mouse cursor when mouse is inside the margins, to not make the user think he/she can start a selection. Besides making things clearer, this also fixes a crash that occurred if you started a selection in e.g. the right margin.
* input: pipe: avoid goto's where variables may be uninitializedDaniel Eklöf2020-07-22-6/+9
|
* input: pipe-{visible,scrollback}: redirect stdout/stderr to /dev/nullDaniel Eklöf2020-07-15-1/+13
|
* input: commentsDaniel Eklöf2020-07-15-1/+3
|
* conf: bindings: allow several mappings for the same actionDaniel Eklöf2020-07-15-15/+13
| | | | | If the bindings has different pipe command associated with them, treat them as different actions.
* input: wip: initial support for piping scrollback/view to external toolsDaniel Eklöf2020-07-15-7/+132
|
* input: parse_key_binding: free key-codes list if 'bindings' is NULLDaniel Eklöf2020-07-15-1/+2
|
* conf: add definitions for pipe-{scrollback,view} bindingsDaniel Eklöf2020-07-15-0/+5
|
* input: keyboard: keymap: close(fd) on early-return when failing to mmapDaniel Eklöf2020-07-14-0/+1
|
* input: keyboard: keymap: use xkb_keymap_new_from_buffer()Daniel Eklöf2020-07-14-2/+4
|
* input: keyboard: detect failure to mmap keymapDaniel Eklöf2020-07-14-0/+17
|
* input: include seat name in debug log outputDaniel Eklöf2020-07-11-4/+4
|
* seat: use separate 'enter' serials for keyboard and mouseDaniel Eklöf2020-07-09-4/+6
|
* multi-seat: improve handling of multiple (mouse) pointersDaniel Eklöf2020-07-09-34/+37
| | | | | | | | * xcursor always set for all pointers * xcursor sometimes not updated when it should be * mouse grabbed state wasn't per seat, but global (i.e. "does at least one seat enable mouse grabbing") * selection enabled state wasn't per seat
* focus in/out: terminal checks whether it is a state change or notDaniel Eklöf2020-07-09-17/+3
|
* input: only call term_kbd_focus_{in,out}() on actual state changeDaniel Eklöf2020-07-09-7/+20
| | | | | | That is, only call term_kbd_focus_in() if we're the *first* seat focusing that terminal, and only call term_kbd_focus_out() if we're the *last* seat that focused it.
* xcursor: trigger theme reload in pointer-enter eventDaniel Eklöf2020-07-08-0/+3
| | | | | | | | | | | | | | | | Previously, we triggered a theme reload on output changes. This is completely wrong. We may get a new output with a scale different from the output the pointer is actually on. Now, we store the current scale along with the theme. We then trigger a call to reload the xcursor theme *every* time the pointer enters a surface. When it does, we use the current scale factor of the terminal that owns that surface. If the terminal covers multiple outputs, with different scale factors, we'll use the largest scale factor. This may not be 100% correct. But to fix that, we'd need to track which regions of a surface are mapped on which outputs. Too complicated I say.
* multi-seat: re-enable selection support (excluding OSC 52)Daniel Eklöf2020-07-08-14/+17
|
* multi-seat: re-enable scrollback search supportDaniel Eklöf2020-07-08-1/+1
|
* multi-seat: re-enable mouse button+motion reporting supportDaniel Eklöf2020-07-08-6/+16
|
* multi-seat: enable xcursor theme support againDaniel Eklöf2020-07-08-4/+4
|
* wip: multi-seat supportDaniel Eklöf2020-07-08-180/+190
| | | | | Compiles and runs, but mouse, clipboard and other things have been disabled.
* input: add key mapping for XKB_KEY_KP_DecimalDaniel Eklöf2020-06-27-0/+1
|
* selection: don't automatically no-op operations if selection isn't enabledDaniel Eklöf2020-05-16-14/+17
| | | | | | | | | | | | | | | | | | 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.
* util.h: new header file defining commonly used macrosDaniel Eklöf2020-05-01-2/+1
|
* misc: replace all explicit zero-initializers with empty initializersDaniel Eklöf2020-04-13-2/+2
|
* mbstate: fix compile warning on systems where mbstate_t isn't an integralDaniel Eklöf2020-04-13-1/+1
| | | | | An empty initializer still ensures the entire object is zero-initialized.
* input: slow trackpad scrolling now eventually scroll a lineDaniel Eklöf2020-04-10-1/+17
| | | | | | | | | | | | | | | 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.
* input: right mouse click extends the current selectionDaniel Eklöf2020-04-04-0/+4
|
* input: hardcoded left mouse button handler requires click-count <= 3Daniel Eklöf2020-04-04-1/+1
| | | | | | | | 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).
* input: only cancel selection on left mouse button clicksDaniel Eklöf2020-04-04-4/+3
|
* search: replace hard-coded key bindings with "user configurable" onesDaniel Eklöf2020-03-18-24/+40
| | | | | | | | 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.
* input: bindings: don't match raw key code alone - mods must also matchDaniel Eklöf2020-03-18-1/+4
|
* input: bind key bindings to raw key codes tooDaniel Eklöf2020-03-18-1/+43
| | | | | | | | | | | | | | | | | | | | | | | | 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).
* input: key-binding: log error when we fail to translate to XKB symbolDaniel Eklöf2020-03-18-1/+10
|
* input: remove Sway 1.2 keyboard/pointer workaroundsDaniel Eklöf2020-03-14-52/+0
| | | | | | | | | | | | | | | 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.
* input: add debug logs to all keyboard/pointer enter/leave/action eventsDaniel Eklöf2020-03-14-4/+22
|
* input: maximize: unset fullscreen before toggling maximized stateDaniel Eklöf2020-03-12-0/+2
|
* config: mouse-bindings: verify button isn't already mappedDaniel Eklöf2020-03-12-0/+4
| | | | | | | | | 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`).
* config/input: implement mouse bindingsDaniel Eklöf2020-03-12-9/+21
| | | | | | | | | | * 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.
* bindings: add minimize/maximize/fullscreen actionsDaniel Eklöf2020-03-12-0/+18
| | | | These actions are by default not bound to anything.
* input: parse_key_binding_for_action: export functionDaniel Eklöf2020-03-09-4/+4
|
* input: parse_key_binding_for_action: repair LOG_DBG statementDaniel Eklöf2020-03-09-1/+1
|
* search: add support for user configurable key bindingsDaniel Eklöf2020-03-08-7/+12
| | | | No default bindings defined yet, though.
* input: convert the rest of the normal key bindings to configurable bindingsDaniel Eklöf2020-03-08-81/+90
| | | | | | | | | | | | | | | | | 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.
* wip: initial framework for dealing with key/mouse bindings in different modesDaniel Eklöf2020-03-08-17/+80
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* render: never render CSD and/or search box "immediately"Daniel Eklöf2020-03-06-9/+2
| | | | | | | | | | 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.
* input: do a full CSD repaint on pointer motion over CSD buttonsDaniel Eklöf2020-03-03-31/+12
| | | | This fixes repainting issues on mutter.
* csd: initial implementation of minimize/maximize/close buttonsDaniel Eklöf2020-03-02-0/+81
|
* input: don't change xcursor if active surface isn't the main gridDaniel Eklöf2020-03-02-1/+1
|
* config: make CSD user configurableDaniel Eklöf2020-03-02-16/+15
| | | | | | | | | | | | | | 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.
* input: raise window 'move' timeout to 200msDaniel Eklöf2020-03-01-1/+1
| | | | | 100ms was a bit low and prevented double-tap on touchpads from working.
* input: use xdg_toplevel_resize_edge enum typeDaniel Eklöf2020-03-01-2/+2
|
* input: start window move right away if user starts dragging the windowDaniel Eklöf2020-02-29-0/+19
| | | | | | | | | | | | 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.
* input: fix 'unused variable' warning (release builds)Daniel Eklöf2020-02-29-1/+2
|