Skip to content

fix(linux): keep KWin output order stable - #6183

Open
ZorudaRinku wants to merge 1 commit into
SunshineStream:masterfrom
ZorudaRinku:fix/kwingrab-output-sort-order
Open

ZorudaRinku wants to merge 1 commit into
SunshineStream:masterfrom
ZorudaRinku:fix/kwingrab-output-sort-order

Conversation

@ZorudaRinku

Copy link
Copy Markdown

Description

With KWin capture, the monitor list order changed every session if the primary monitor wasn't the leftmost one. The sort checked priority OR x OR y, so any comparison could win and two monitors could both be "first". On my setup (primary in the middle, a monitor at x=0 on the left) Ctrl+Alt+Shift+F1 and F2 kept swapping screens while F3 was always right.

The fix sorts by priority first, then x, then y. With 3 monitors on Plasma 6, F1/F2/F3 now always land on the same screen.

Screenshot

Issues Fixed or Closed

Roadmap Issues

Testing

No automated test. The sort lives inside the KWin screencast class and needs a live KWin session, and there are no kwingrab unit tests to extend. Tested by hand on CachyOS with Plasma 6, an RTX 3080 and an AMD iGPU, with 3 monitors (primary DP-2 at x=1920, HDMI-A-3 at x=0, DP-4 at x=4480). Before the fix the "[kwingrab] Found output" log order flipped between DP-2 and HDMI-A-3 across sessions and F1/F2 swapped screens. After it the order stays DP-2, HDMI-A-3, DP-4 and F1/F2/F3 always pick the same screen.

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
  • Tests have been added or updated for new or modified functionality, including regression tests for bug fixes

AI Usage

See our AI usage policy.

  • AI tools were used while preparing this PR

The sort checked priority OR x OR y, so any one comparison could win and two monitors could both count as first. If the primary monitor wasn't at x=0, the list came back in a different order each time and Ctrl+Alt+Shift+F1/F2 swapped screens. Now it sorts by priority, then x, then y.
@sonarqubecloud

Copy link
Copy Markdown

This branch has not been deployed

No deployments
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.

1 participant