Skip to content

Apply held keyboard modifiers to mouse and scroll events - #1438

Merged
lujjjh merged 2 commits into
linearmouse:mainfrom
GtechGovind:fix/held-modifier-mouse-events
Oct 10, 2026
Merged

lujjjh merged 2 commits into
linearmouse:mainfrom
GtechGovind:fix/held-modifier-mouse-events

Conversation

@GtechGovind

Copy link
Copy Markdown
Contributor

What

I propagate held keyboard modifiers to mouse and scroll events.

Why

A button mapping can hold a modifier such as Shift, but the current event path only adds held modifiers to keyboard events. That lets the modifier work while typing while leaving click and scroll events without the held modifier flags.

Changes

  • Apply held modifiers to mouse movement, button, drag, and scroll events while preserving flags already present on the event.
  • Apply the flags before button and wheel mapping recognition.
  • Preserve the synthetic-event bypass and the existing modifier clearing for explicitly remapped mouse buttons.
  • Add KeyKit and transformer regressions for click/scroll propagation and modifier release.

Validation

  • make lint — passed.
  • KeyKit KeySimulatorEventFieldsTests — 4 passed.
  • ButtonMappingTransformerTests — 81 passed.
  • make test XCODEBUILD_ARGS=CODE_SIGNING_ALLOWED=NO — module suites passed; 1,116 app tests ran with one unrelated UI-environment failure in HoverWindowQueryTests.testOwnSettingsWindowCanBeQueriedDuringOpening (window ID was 0).

@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: linearmouse/linearmouse/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e10f0b07-3cbb-4235-b1d2-05fed39f59ae

📥 Commits

Reviewing files that changed from the base of the PR and between 8eea186 and df60f68.


📒 Files selected for processing (2)
  • LinearMouse/EventTransformer/ButtonMappingTransformer.swift
  • LinearMouseUnitTests/EventTransformer/ButtonMappingTransformerTests.swift

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.



📝 Walkthrough

Walkthrough

Simulated modifier flags now apply to pointer and scroll events as well as key events. Button mapping uses the modified flags. Tests cover flag preservation, Shift-qualified wheel mapping, and partial wheel input across modifier changes.

Changes

Simulated Modifier Flags

Layer / File(s) Summary
Apply held flags to supported events
Modules/KeyKit/Sources/KeyKit/KeySimulator.swift, Modules/KeyKit/Tests/KeyKitTests/KeySimulatorEventFieldsTests.swift
KeySimulator.modifiedCGEventFlags(of:) now accepts key, modifier, mouse movement, mouse-button, drag, and scroll-wheel events. The test checks that held Shift combines with existing Command flags, applies to scroll events, and stops applying after release.
Use modified flags in button mapping
LinearMouse/EventTransformer/ButtonMappingTransformer.swift, LinearMouseUnitTests/EventTransformer/ButtonMappingTransformerTests.swift
ButtonMappingTransformer applies simulated flags to key, pointer, and scroll events. Tests check flag preservation, Shift-qualified wheel mapping, and partial wheel input across modifier changes.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: lujjjh


Merge Risk | ⚪ Minimal · up to df60f

Merge Risk: ⚪ Minimal · up to df60f

Held keyboard modifiers now apply to mouse and scroll events, and existing event flags are kept. Tests cover click and scroll propagation, modifier release, and partial wheel input across modifier changes. No merge-blocking risk is evident.

Security Architecture Review

Security architecture risk: 🔵 Low · up to df60f

Held modifiers now influence mouse and scroll actions as intended. Existing synthetic-event, remapping, and release safeguards remain intact, and no introduced security defect was established. The effects in receiving applications have not been validated end to end.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The directly supported exposure is local desktop input passing through the existing event pipeline: held modifiers can select different configured pointer or wheel actions and accompany forwarded events into receiving applications. The exact effects in those applications remain outside the inspected scope.

Trust Boundaries and Controls

  • observed — Synthetic LinearMouse events still bypass transformation before modifier propagation. Explicit mouse remapping still clears modifier flags, and generated synthetic clicks retain their synthetic marker. These controls counter recursive processing and unintended modifier inheritance on explicitly remapped buttons.

Resilience and Maintainability Implications

  • observed — Scroll modifier changes discard partial accumulated movement. Ended or cancelled scroll events invoke gesture termination through defer, while retained momentum stays bound to its original mapping and action rather than selecting another mapping after modifier changes. Transformer deactivation resets recognition lanes and releases executor state.

Pre-merge checks | Passed 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description check Passed The description clearly explains the propagation of held keyboard modifiers to mouse and scroll events, the rationale, the implementation changes, and validation results.
Title check Passed The title is concise, specific, and accurately summarizes the main change: applying held keyboard modifiers to mouse and scroll events.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@GtechGovind
GtechGovind marked this pull request as ready for review October 7, 2026 07:58
@lujjjh lujjjh added the bug Something isn't working label Oct 10, 2026
@lujjjh
lujjjh merged commit 1a6c3f4 into linearmouse:main Oct 10, 2026
2 checks passed
@lujjjh

lujjjh commented Oct 10, 2026

Copy link
Copy Markdown
Collaborator

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants