Files
wlgol/openspec/specs/keyboard-bindings/spec.md
T
arek d20f4d5481 fix(input): honor pointer entry position and make clear work
Pointer enter ignored the surface position, so the pattern preview
rendered at a stale cell until the first motion event. The clear
action only printed a message and toggle_grid had no default key
binding, leaving both unreachable without a hand-written config.

Set the cursor position from the enter event, implement clear via
grid_clear plus a dirty flag, and add g/c default bindings in both
the built-in table and the generated config template. Also defer
wl_buffer destruction on resize until the compositor releases it,
route pointer motion through a handler hook instead of reading
pointer_data directly, and clean up dead code (show_lines, unused
ternary, unchecked ftruncate, unfreed grid buffers). Fixes a
wl_callback proxy leak from frame-callback overwrite. Syncs the
keyboard-bindings and display-scaling specs and archives the
fix-review-findings change.
2026-11-11 18:04:50 +01:00

68 lines
3.1 KiB
Markdown

# keyboard-bindings Specification
## Purpose
Allows users to configure keyboard shortcuts that map key combinations to application actions, with sensible built-in defaults when no configuration file exists.
## Requirements
### Requirement: Default bindings are available without configuration
The system SHALL provide built-in default bindings for every supported action — digits 1-0 selecting the ten built-in patterns, Space rotating, Escape cancelling, Ctrl+Q quitting, P pausing, N stepping, +/- changing simulation speed, G toggling grid lines, and C clearing the grid.
#### Scenario: No config file present
- **WHEN** the application starts and `~/.config/wlgol/keys.conf` does not exist
- **THEN** the application uses the built-in default bindings
- **AND** creates the config file with the default contents
#### Scenario: Clear without configuration
- **WHEN** the default bindings are active and the user presses C
- **THEN** the clear action is triggered
#### Scenario: Toggle grid lines without configuration
- **WHEN** the default bindings are active and the user presses G
- **THEN** the toggle_grid action is triggered
### Requirement: Configuration file overrides defaults by merge
The system SHALL read `~/.config/wlgol/keys.conf` as TOML when it exists and merge its entries over the built-in defaults, so only specified keys change.
#### Scenario: Partial override
- **WHEN** the config file defines a binding for key "1" only
- **THEN** key "1" uses the configured action
- **AND** all other keys keep their default bindings
#### Scenario: Full replacement of a key
- **WHEN** the config file defines a binding for a key that has a default
- **THEN** the configured action replaces the default for that key
### Requirement: Key combinations are modifier-aware
The system SHALL match a binding only when the modifiers required by the binding are active, supporting Ctrl, Shift, Alt, and Super.
#### Scenario: Modifier required
- **WHEN** the user presses Q while Ctrl is held and a `ctrl+q = quit` binding exists
- **THEN** the quit action is triggered
#### Scenario: Modifier not held
- **WHEN** the user presses Q without Ctrl while a `ctrl+q = quit` binding exists
- **THEN** the quit action is not triggered by that binding
### Requirement: Readable key aliases are supported
The system SHALL accept human-readable key names such as space, escape, enter, and arrow names in binding keys.
#### Scenario: Alias binding
- **WHEN** the config file contains `space = rotate`
- **THEN** pressing the space bar triggers the rotate action
### Requirement: Malformed entries are ignored
The system SHALL ignore malformed or unrecognized binding entries and continue using defaults for the affected keys.
#### Scenario: Invalid entry
- **WHEN** the config file contains an entry with an unknown action
- **THEN** that entry is ignored
- **AND** the application still starts successfully
### Requirement: Actions trigger on key press
The system SHALL dispatch a bound action when the corresponding key is pressed, not on release.
#### Scenario: Press triggers action
- **WHEN** the user presses a key with a valid binding
- **THEN** the bound action is invoked once for that press