-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(linux/portal): improve XDG portal capture for KDE and dual GPU systems #4510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(linux/portal): improve XDG portal capture for KDE and dual GPU systems #4510
Conversation
|
GCC 15.2.1 has some warnings around the portal grab |
This is not present in the glad version imported in Sunshine, plug the holes so that these functions may be used.
Add a new portal "grab" implementation that will request the necessary permissions over XDG portals and use Pipewire for video data streaming. This supports DMA-Buf buffer exchange for hardware accelerated encoding (VAAPI, nvenc), software encoding will only work with memory buffers.
Require GIO and PIPEWIRE packages for portal support and use SYSTEM include directories. Also, clarify the fatal error message order for missing dependencies.
Pipewire has been added to the dependency lists for FreeBSD, Arch, Fedora, Homebrew, and Debian-based packaging and build scripts. This ensures proper support and integration for systems using Pipewire.
A value of 2 indicates "Remember this Selection". Co-authored-by: Carson Katri <[email protected]>
70a1b64 to
9f0aefb
Compare
374b524 to
1f566aa
Compare
- Add KDE popup screen capture support - Add ScreenCast-only fallback when RemoteDesktop fails - Add restore_token support for session persistence - Handle dual GPU (Intel + NVIDIA) systems: use memory buffers for CUDA when display is on Intel, enable DMA-BUF when display is on NVIDIA - Add "XDG Portal" option to web UI capture dropdown - Add build instructions for XDG Portal support
- Add null checks in dbus_t destructor before g_object_unref calls - Fix loop variable scope by declaring EGLint i inside for loop - Unify create_session and create_screencast_session into create_portal_session() - Unify start_session and start_screencast_session into start_portal_session() - Refactor connect_to_portal() with helper functions to reduce cognitive complexity - Fix restore_token memory management by using std::string instead of raw pointer 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Use the C++ nullptr literal instead of the C-style NULL macro for improved type safety. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add restore token persistence to disk for auto-reconnection - Merge nested if statements for cleaner control flow - Make session_token parameter const where applicable - Rename shadowed parameters (out_pipewire_node, out_width, out_height) - Split variable declarations into separate statements - Use member initializer list in pipewire_t constructor - Replace strstr with std::string_view::find - Extract helper functions to reduce nesting depth 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Encapsulate restore_token in accessor function to avoid global variable - Make format_map static constexpr - Replace C-style arrays with std::array - Use std::string_view::contains instead of find 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Use inline variable for restore_token - Convert format_map to std::array - Use range-based for loops for format_map iteration 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Replace global variable with restore_token_t class using singleton pattern to satisfy SonarCloud's const global variable requirement. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Replace const std::string& with std::string_view in set() - Use const unique_ptr<string> to satisfy const global requirement 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
…ings Add session_cache_t singleton that caches portal D-Bus session data. This prevents creating multiple screen recording indicators in KDE system tray during encoder probing, as each portal session would otherwise show as a separate recording. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Detect hybrid GPU by checking for Intel vendor (0x8086) in DRM devices - Use memory buffers instead of DMA-BUF for CUDA on hybrid systems - Set row_pitch from pipewire buffer stride for correct CUDA copies - Return timeout when no pipewire buffer available yet 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Use const unique_ptr for inline static instance (satisfies const global rule) - Replace std::lock_guard with std::scoped_lock using CTAD 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1f566aa to
8abfeed
Compare
Use std::shared_ptr instead of std::unique_ptr for the singleton instance. shared_ptr captures the deleter at construction time when the type is complete, avoiding the incomplete type error with private destructor. Fixes compilation error reported by parkerlreed.
- Revert README.md build instructions (not appropriate for README) - Add XDG Portal option to FreeBSD capture dropdown
|
fixed all things from @ReenigneArcher , gcc 15 warning should be gone too @parkerlreed |
Always save the portal restore token when a new one is received, not just when the token was previously empty. This fixes KDE prompting to select a screen on every Sunshine restart. Also improve session_cache_t singleton to use aligned storage, avoiding destructor access issues.
9f0aefb to
5987970
Compare
6c6d896 to
01440ac
Compare
|
@Traine9 appologies, but when I rebase the PR branch, it looks like it always causes conflicts in the portalgrab.cpp. Any chance you can resolve the conflicts again. I think you should just be able to ignore the differences and use the code as is in your branch for portalgrab.cpp. |
|
@ReenigneArcher merged without force push now you should able to merge it |
|
7034c84
into
LizardByte:feat/linux/add-xdg-portal-grab
Bundle ReportChanges will increase total bundle size by 90 bytes (0.0%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: sunshine-esmAssets Changed:
Files in
|
|
Multi touch/pen/stylus seems to be completely non functional with this enabled. Trackpad works as expected. |




Summary
Test plan