Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 11, 2026

Fix XI_Motion Event Handling for Both Scroll and Mouse Motion

Problem Analysis

The current XI_Motion handler only processes scroll events and ignores regular mouse motion events, causing cursor movement to break when smooth scrolling is enabled.

Plan

  • Analyze the codebase and locate XI_Motion event handling in glfw/x11_window.c
  • Understand the issue: XI_Motion events override legacy MotionNotify when selected, but current handler only processes scroll events
  • Modify XI_Motion handler to process both scroll events AND regular mouse motion
  • Test that mouse cursor movement works correctly
  • Test that scroll events continue to work correctly
  • Verify no regressions in mouse handling

Technical Details

  • File: glfw/x11_window.c, lines 1336-1388
  • Current handler only processes events when scroll device is found
  • Need to add fallback to handle regular mouse motion using XIDeviceEvent position fields (event_x, event_y)
Original prompt

Problem

The current code has handling for scroll events via XI_MOTION, but this implementation breaks mouse move event handling. Both types of motion events need to be properly handled without interfering with each other.

Requirements

  1. Investigate the current XI_MOTION implementation: Find where XI_MOTION events are currently being handled for scroll events in the codebase (likely in X11-related input handling code).

  2. Fix the mouse motion event handling: The existing XI_MOTION scroll event handling is breaking mouse move events. Modify the code to properly differentiate between:

    • Scroll events (wheel/touchpad scrolling)
    • Mouse motion events (cursor movement)
  3. Ensure both event types work correctly:

    • Mouse motion events should update cursor position
    • Scroll events should continue to work as they currently do
    • One should not interfere with the other

Technical Context

  • This is related to XInput2 (XI2) event handling on X11
  • The XI_MOTION event type can represent different kinds of motion (mouse movement, scroll wheel, etc.)
  • The fix likely needs to check valuator data or event masks to distinguish between scroll and mouse motion
  • Look for code patterns that check for scroll valuators vs position valuators

Expected Outcome

After this fix:

  • Mouse cursor movement should work properly in kitty
  • Scroll events (both mouse wheel and touchpad) should continue to work
  • Both event types should be handled correctly through the XI_MOTION event path

This pull request was created from Copilot chat.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants