feat(screensharing): list and share minimized windows on Windows - #1825
Open
vladopol wants to merge 1 commit into
Open
feat(screensharing): list and share minimized windows on Windows#1825vladopol wants to merge 1 commit into
vladopol wants to merge 1 commit into
Conversation
On Windows, Chromium/WebRTC omits minimized (iconic) windows from desktopCapturer.getSources() because they are not rendered and cannot produce frames. They are therefore missing from the "Choose what to share" picker, which is especially painful for full-screen Remote Desktop windows that have to be minimized to reach Talk. Enumerate top-level windows natively via user32 (koffi FFI) and add the minimized ones that desktopCapturer omits, shown with a "Minimized" badge, the window's own icon and no live preview. When such a window is selected, restore it (ShowWindowAsync + SetForegroundWindow) so WebRTC can capture it, then start sharing - the approach suggested in nextcloud#1788. The icon is read from the window itself (WM_GETICON / class icon) and converted from its HICON via GDI, matching the icon Windows shows in the taskbar and the one desktopCapturer provides for non-minimized windows. koffi is a prebuilt, MIT-licensed FFI module. It is loaded lazily and only on Windows, kept out of the webpack bundle and packaged for win32 only via a packageAfterCopy hook, with its .node unpacked from the asar archive. Signed-off-by: Vladimir Poluliashenko <vladopol@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On Windows, minimized (iconic) windows are missing from the "Choose what to share" picker: Chromium/WebRTC omits them from
desktopCapturer.getSources()because a minimized window isn't rendered and can't produce frames (#1788). This especially hurts full-screen Remote Desktop windows, which have to be minimized to reach Talk — and then vanish from the picker.This enumerates top-level windows natively and adds the minimized ones the capturer omits. On selection the window is restored so WebRTC can capture it, then sharing starts — the approach @ShGKme suggested in #1788 (enumerate via the Windows API, then activate the window like Zoom).
What it does
user32(koffi FFI):EnumWindowswith the standard Alt‑Tab filter (visible, unowned, not a tool window, has a title, not DWM‑cloaked).WM_GETICON(with a timeout so an unresponsive window can't block the picker) and converted from itsHICON, matching the icon Windows shows in the taskbar and the onedesktopCapturerprovides for non‑minimized windows. No live preview — they have no frames until restored.ShowWindowAsync(SW_RESTORE)+SetForegroundWindow) before capture. Electron encodes the HWND in the window sourceId (window:<HWND>:0), so it stays valid after restoring.Dependency
Adds
koffi(MIT, prebuilt — no node‑gyp/compilation). It is loaded lazily and only on Windows; kept out of the webpack bundle (external) and packaged for the target win32 arch only via apackageAfterCopyhook, with its.nodeunpacked from the asar archive. It is not shipped on macOS/Linux.Testing
Verified on Windows 10 and 11 as a normal user: minimized windows (including Remote Desktop and non‑ASCII titles) are listed with the correct window icon, restore correctly on Share, and stream. Non‑minimized sharing is unchanged.
ts:checkandeslintpass.Notes
NcDialog's minimum content height, not specific to this change.Closes #1788