Skip to content

Conversation

@herboh
Copy link

@herboh herboh commented Feb 4, 2026

Description

PR #4607 added logical dimension tracking and scalar_tpcoords scaling support for the kmsgrab (KMS/DRM) capture backend, but my configuration (niri, multimonitor, scaled hidpi output) was still mapping input to the wrong portion of the desktop.

This PR tries to mirror the pattern used in kmsgrab.cpp to wlgrab.cpp:

  • Adds env_logical_width / env_logical_height statics to the wl namespace
  • Sets logical_width, logical_height, env_logical_width, env_logical_height on the display object during wlr_t::init()

Additionally, the touch and pen passthrough functions in input.cpp are updated to normalize coordinates relative to the streamed monitor rather than the full desktop.

Screenshot

Issues Fixed or Closed

Roadmap Issues

Type of Change

  • feat: New feature (non-breaking change which adds functionality)
  • fix: Bug fix (non-breaking change which fixes an issue)
  • docs: Documentation only changes
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semicolons, etc.)
  • refactor: Code change that neither fixes a bug nor adds a feature
  • perf: Code change that improves performance
  • test: Adding missing tests or correcting existing tests
  • build: Changes that affect the build system or external dependencies
  • ci: Changes to CI configuration files and scripts
  • chore: Other changes that don't modify src or test files
  • revert: Reverts a previous commit
  • BREAKING CHANGE: Introduces a breaking change (can be combined with any type above)

Checklist

  • Code follows the style guidelines of this project
  • Code has been self-reviewed
  • Code has been commented, particularly in hard-to-understand areas
  • Code docstring/documentation-blocks for new or existing methods/components have been added or updated
  • Unit tests have been added or updated for any new or modified functionality

AI Usage

  • None: No AI tools were used in creating this PR
  • Light: AI provided minor assistance (formatting, simple suggestions)
  • Moderate: AI helped with code generation or debugging specific parts
  • Heavy: AI generated most or all of the code changes

@herboh herboh force-pushed the fix/niri-touch-scaling branch from 95a0fea to 8f4ff1d Compare February 4, 2026 08:31
@herboh herboh marked this pull request as draft February 4, 2026 08:33
@herboh herboh changed the title Fix touch input misalignment on scaled wayland outputs (wlgrab) fix(linux): fix touch misalignment for wlgrab on scaled outputs Feb 4, 2026
@herboh herboh marked this pull request as ready for review February 4, 2026 08:45
@ReenigneArcher
Copy link
Member

@juliosanz could you review please?

Copy link
Contributor

@juliosanz juliosanz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

KMS still works just fine like it did in PR #4607. Changes made are in wlgrab.cpp and, indeed, mirror those made to kmsgrab.cpp.

At first glance, these changes should absolutely make things work right in wlroots. I don't have an installation at hand to try it myself, though. @Dregu pointed out some issues my PR had in wlroots, perhaps they can test it better.

@herboh herboh force-pushed the fix/niri-touch-scaling branch from fa9465d to 0da3334 Compare February 6, 2026 00:44
@herboh
Copy link
Author

herboh commented Feb 6, 2026

Follow up commit to address the Sonar issues with duplication in input.cpp.

  • added a helper function for touch and pen to use for monitor normalization
  • removed wlgrab.cpp globals to instead compute local dimensions during wlgrab init
  • renamed variables wlgrab.cpp to avoid shadowing a class field

No functional changes, just to better match the guidelines.

@ReenigneArcher
Copy link
Member

Follow up commit to address the Sonar issues with duplication in input.cpp.

* added a helper function for touch and pen to use for monitor normalization

* removed `wlgrab.cpp` globals to instead compute local dimensions during wlgrab init

* renamed variables `wlgrab.cpp` to avoid shadowing a class field

No functional changes, just to better match the guidelines.

Thank you! Really appreciate when we can get some of this code cleaned up!

@codecov
Copy link

codecov bot commented Feb 8, 2026

Bundle Report

Bundle size has no change ✅

@ReenigneArcher
Copy link
Member

There's some issues building the docs:

Generating code for file src/home/docs/checkouts/readthedocs.org/user_builds/sunshinestream/checkouts/4665/src/input.cpp:907: error: argument 'input' of command @param is not found in the argument list of input::monitor_touch_port(const input::touch_port_t &touch_port, std::pair< float, float > &coords)
--
/home/docs/checkouts/readthedocs.org/user_builds/sunshinestream/checkouts/4665/src/input.cpp:907: error: argument 'packet' of command @param is not found in the argument list of input::monitor_touch_port(const input::touch_port_t &touch_port, std::pair< float, float > &coords)
/home/docs/checkouts/readthedocs.org/user_builds/sunshinestream/checkouts/4665/src/input.cpp:907: error: The following parameters of input::monitor_touch_port(const input::touch_port_t &touch_port, std::pair< float, float > &coords) are not documented:
parameter 'touch_port'
parameter 'coords'

@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 8, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
19.6% Duplication on New Code (required ≤ 2%)
2 Duplicated Blocks on New Code (required ≤ 0)

See analysis details on SonarQube Cloud

Comment on lines +929 to 930

void passthrough(std::shared_ptr<input_t> &input, PSS_TOUCH_PACKET packet) {
Copy link
Member

@ReenigneArcher ReenigneArcher Feb 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
void passthrough(std::shared_ptr<input_t> &input, PSS_TOUCH_PACKET packet) {
/**
* @brief Called to pass a touch message to the platform backend.
* @param input The input context pointer.
* @param packet The touch packet.
*/
void passthrough(std::shared_ptr<input_t> &input, PSS_TOUCH_PACKET packet) {

I think the docs were accidentally removed from this function?

@Dregu
Copy link
Contributor

Dregu commented Feb 8, 2026

perhaps they can test it better

Well I don't use touch, but at least the things I do use, mouse on scaled wlr and kms, still seem to work fine 👍🏻

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.

Touch input is wrong on multi-monitor configurations on Linux

4 participants