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.
This commit is contained in:
+9
-9
@@ -2,21 +2,21 @@
|
||||
|
||||
## 1. Input fixes
|
||||
|
||||
- [ ] 1.1 Set `pd->x`/`pd->y` in `pointer_enter_handler` from `wl_fixed_to_double(sx/sy)` in `tpointer.c`; verify by running the app and confirming the pattern preview renders at the entry cell when the pointer enters without further motion
|
||||
- [ ] 1.2 Add `pointer_set_motion_handler()` to `tpointer.c`/`tpointer.h` mirroring the button-handler pattern, register it in `wlgol.c` to store logical cursor position, and stop reading `pointer_data.x/y` in `loop_update()`; verify with `cmake --build ./build` and `ctest --test-dir build` plus a run checking that painting still follows the cursor
|
||||
- [x] 1.1 Set `pd->x`/`pd->y` in `pointer_enter_handler` from `wl_fixed_to_double(sx/sy)` in `tpointer.c`; verify by running the app and confirming the pattern preview renders at the entry cell when the pointer enters without further motion
|
||||
- [x] 1.2 Add `pointer_set_motion_handler()` to `tpointer.c`/`tpointer.h` mirroring the button-handler pattern, register it in `wlgol.c` to store logical cursor position, and stop reading `pointer_data.x/y` in `loop_update()`; verify with `cmake --build ./build` and `ctest --test-dir build` plus a run checking that painting still follows the cursor
|
||||
|
||||
## 2. Actions and default bindings
|
||||
|
||||
- [ ] 2.1 Implement `ACTION_CLEAR` in `wlgol.c` as `grid_clear(&grid)` + `screen_dirty = 1`; verify by pressing the clear binding with cells on the grid and observing them disappear
|
||||
- [ ] 2.2 Add `"g" = "toggle_grid"` and `"c" = "clear"` to `default_file_content` in `config.c` and to the built-in defaults; verify with `ctest --test-dir build` (config tests) and a run pressing both keys on a fresh default config
|
||||
- [ ] 2.3 Extend `tests/test_config.c` to assert lookup of the new default bindings (`g` -> ACTION_TOGGLE_GRID, `c` -> ACTION_CLEAR) and verify with `ctest --test-dir build`
|
||||
- [x] 2.1 Implement `ACTION_CLEAR` in `wlgol.c` as `grid_clear(&grid)` + `screen_dirty = 1`; verify by pressing the clear binding with cells on the grid and observing them disappear
|
||||
- [x] 2.2 Add `"g" = "toggle_grid"` and `"c" = "clear"` to `default_file_content` in `config.c` and to the built-in defaults; verify with `ctest --test-dir build` (config tests) and a run pressing both keys on a fresh default config
|
||||
- [x] 2.3 Extend `tests/test_config.c` to assert lookup of the new default bindings (`g` -> ACTION_TOGGLE_GRID, `c` -> ACTION_CLEAR) and verify with `ctest --test-dir build`
|
||||
|
||||
## 3. Buffer lifecycle on resize
|
||||
|
||||
- [ ] 3.1 In `canvas_resize`, park the outgoing `wl_buffer`/`wl_shm_pool` in `canvas.old_buffer`/`old_pool` instead of destroying them immediately (munmap of old data stays immediate), and destroy them from `wl_buffer_release_handler`; verify by resizing the window repeatedly at fractional scale and confirming no artifacts or crashes (`WAYLAND_DEBUG=1` shows no destroy-before-release)
|
||||
- [x] 3.1 In `canvas_resize`, park the outgoing `wl_buffer`/`wl_shm_pool` in `canvas.old_buffer`/`old_pool` instead of destroying them immediately (munmap of old data stays immediate), and destroy them from `wl_buffer_release_handler`; verify by resizing the window repeatedly at fractional scale and confirming no artifacts or crashes (`WAYLAND_DEBUG=1` shows no destroy-before-release)
|
||||
|
||||
## 4. Cleanup (behavior-neutral)
|
||||
|
||||
- [ ] 4.1 Remove `show_lines` from `grid_t` and its uses, keeping the `show_grid_lines` flag; verify with `ctest --test-dir build` and the grid-line toggle key
|
||||
- [ ] 4.2 Free `grid`, `grid_back`, `grid_rendered` after the main loop exits; verify with valgrind (or a leak-checker run of a short session) reporting no leaks from those buffers
|
||||
- [ ] 4.3 Remove the dead `ok ? 220 : 220` ternary and check `ftruncate`'s return value in `canvas_resize`; verify with `cmake --build ./build` producing no new warnings
|
||||
- [x] 4.1 Remove `show_lines` from `grid_t` and its uses, keeping the `show_grid_lines` flag; verify with `ctest --test-dir build` and the grid-line toggle key
|
||||
- [x] 4.2 Free `grid`, `grid_back`, `grid_rendered` after the main loop exits; verify with valgrind (or a leak-checker run of a short session) reporting no leaks from those buffers
|
||||
- [x] 4.3 Remove the dead `ok ? 220 : 220` ternary and check `ftruncate`'s return value in `canvas_resize`; verify with `cmake --build ./build` producing no new warnings
|
||||
@@ -28,6 +28,10 @@ The system SHALL report mouse positions and grid cells in logical coordinates re
|
||||
- **WHEN** the user clicks on a scaled display
|
||||
- **THEN** the selected grid cell matches the visual location of the cursor
|
||||
|
||||
#### Scenario: Pointer entry without motion
|
||||
- **WHEN** the pointer enters the canvas surface at a position and no motion event follows
|
||||
- **THEN** the reported cursor position matches the entry point in logical coordinates
|
||||
|
||||
### Requirement: Rendering uses physical resolution
|
||||
The system SHALL render all content at physical resolution so that lines and cells stay sharp at the active scale.
|
||||
|
||||
|
||||
@@ -6,13 +6,21 @@ Allows users to configure keyboard shortcuts that map key combinations to applic
|
||||
## Requirements
|
||||
|
||||
### Requirement: Default bindings are available without configuration
|
||||
The system SHALL provide built-in default bindings for all documented actions, including digits 1-4 selecting the Glider, Blinker, Block, and Toad patterns, Space rotating, Escape cancelling, and Ctrl+Q quitting.
|
||||
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.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user