Skip to content

fix(linux/xdgportal): Improve multi-monitor support and work around breaking kmsgrab#4969

Open
Kishi85 wants to merge 3 commits intoLizardByte:masterfrom
Kishi85:xdgportalgrab-ignore-invalid-streams
Open

fix(linux/xdgportal): Improve multi-monitor support and work around breaking kmsgrab#4969
Kishi85 wants to merge 3 commits intoLizardByte:masterfrom
Kishi85:xdgportalgrab-ignore-invalid-streams

Conversation

@Kishi85
Copy link
Copy Markdown
Contributor

@Kishi85 Kishi85 commented Apr 10, 2026

Description

Follow up to #4931 that adds a few safety checks to selected pipewire streams and also re-adds the stream sorting by position that was lost during the final commit restructuring of said PR.

It also changes how finalizing portal security is done (dropping CAP_SYS_ADMIN + setting PR_DUMPABLE) to not break kmsgrab by dropping capabilties as before #4931.

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

This adds a few safety checks to stream selection for displays and
re-adds the missing stream sorting that seems to have gotten lost
during the commit restructuring in PR#4931
@Kishi85
Copy link
Copy Markdown
Contributor Author

Kishi85 commented Apr 10, 2026

@ReenigneArcher would be great to see this in ASAP as I've managed to accidentally remove the stream sorting in my final commit re-structure on #4931 and now the streams are random in the order coming from the portal.

This might also help identifying the issues in #4968

…portal display

Introducing multi-monitor support required connecting to the portal
early for display name enumeration. This will finalize_portal_security
and drop CAP_SYS_ADMIN before KMS encoder probing, breaking it.

To work around the issue finalize_portal_security on first display init
and return a dummy display name until portal display encoder probing
starts (dropping CAP_SYS_ADMIN as before PR#4931).

Display re-enumeration is done on client connect so no functionality is
lost.
@Kishi85 Kishi85 changed the title fix(linux/xdgportal): Improve pipewire stream selection and sorting fix(linux/xdgportal): Improve multi-monitor and work-around issue related to kmsgrab. Apr 10, 2026
@Kishi85 Kishi85 changed the title fix(linux/xdgportal): Improve multi-monitor and work-around issue related to kmsgrab. fix(linux/xdgportal): Improve multi-monitor support and work around breaking kmsgrab. Apr 10, 2026
@Kishi85
Copy link
Copy Markdown
Contributor Author

Kishi85 commented Apr 10, 2026

Now also fixes kmsgrab by not dropping CAP_SYS_ADMIN earlier than before #4931.

@Kishi85
Copy link
Copy Markdown
Contributor Author

Kishi85 commented Apr 10, 2026

@psyke83 Could you Cross-Check if I've missed anything in 4fbad45 ? Looks good on my end for all the usual test cases from #4931 and the issue with probing.

@psyke83
Copy link
Copy Markdown
Contributor

psyke83 commented Apr 10, 2026

@Kishi85

Can confirm this resolves the issue with kmsgrab failing to initialize when probed via default capture = auto (or capture unset) case. Aside from that, multi-monitor still looks to be working fine on KDE (GNOME not working is expected), and resolution change + XDG stop still works fine on both KDE and GNOME. Tested with the problematic system_tray = disabled setting and everything is still working fine.

I was thinking that finalize_portal_security() may be better suited with a more generic name and moved to a platform function in misc.cpp just in case other/future capture methods also need dropped capabilities, but that's not important right now, or relevant to this PR. Looks good to me.

Since the singleton is now just storing persistent runtime information
for portalgrab, reflect this in the type name
@Kishi85 Kishi85 force-pushed the xdgportalgrab-ignore-invalid-streams branch from 28528d4 to ada081d Compare April 10, 2026 09:17
@sonarqubecloud
Copy link
Copy Markdown

@Kishi85 Kishi85 changed the title fix(linux/xdgportal): Improve multi-monitor support and work around breaking kmsgrab. fix(linux/xdgportal): Improve multi-monitor support and work around breaking kmsgrab Apr 10, 2026
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.

Can't find GPU or display after latest update version 2026.409.171120

2 participants