feat(screensharing): list and share minimized windows on Windows - #1825
feat(screensharing): list and share minimized windows on Windows#1825vladopol wants to merge 1 commit into
Conversation
|
Hello there, We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 Thank you for contributing to Nextcloud and we hope to hear from you soon! (If you believe you should not receive this message, you can add yourself to the blocklist.) |
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>
66d39d6 to
3048ddb
Compare
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