From 6cbef1e279ef17f9b999ee4c4fc1cea823e76daa Mon Sep 17 00:00:00 2001 From: webadderall <131426131+webadderall@users.noreply.github.com> Date: Fri, 27 Mar 2026 20:18:05 +1100 Subject: [PATCH] fix(wgc): preserve full-width display identifiers --- electron/native/wgc-capture/src/main.cpp | 4 ++-- electron/native/wgc-capture/src/monitor_utils.cpp | 10 +++------- electron/native/wgc-capture/src/monitor_utils.h | 3 ++- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/electron/native/wgc-capture/src/main.cpp b/electron/native/wgc-capture/src/main.cpp index 8dd4f930..dd80bee2 100644 --- a/electron/native/wgc-capture/src/main.cpp +++ b/electron/native/wgc-capture/src/main.cpp @@ -24,7 +24,7 @@ static std::mutex g_stopMutex; static std::condition_variable g_stopCv; struct CaptureConfig { - int displayId = 0; + int64_t displayId = 0; int64_t windowHandle = 0; std::string outputPath; std::string audioOutputPath; @@ -96,7 +96,7 @@ static bool parseSimpleJson(const std::string& json, CaptureConfig& config) { config.outputPath = findString("outputPath"); if (config.outputPath.empty()) return false; - int displayId = findInt("displayId"); + int64_t displayId = findInt64("displayId"); if (displayId >= 0) config.displayId = displayId; int64_t windowHandle = findInt64("windowHandle"); diff --git a/electron/native/wgc-capture/src/monitor_utils.cpp b/electron/native/wgc-capture/src/monitor_utils.cpp index 25203ebf..e6b0d03d 100644 --- a/electron/native/wgc-capture/src/monitor_utils.cpp +++ b/electron/native/wgc-capture/src/monitor_utils.cpp @@ -27,20 +27,16 @@ std::vector enumerateMonitors() { } // Electron uses the HMONITOR handle value cast to a number as the display ID. -HMONITOR findMonitorByDisplayId(int displayId) { +HMONITOR findMonitorByDisplayId(int64_t displayId) { auto monitors = enumerateMonitors(); for (const auto& m : monitors) { - if (static_cast(reinterpret_cast(m.handle)) == displayId) { + if (static_cast(reinterpret_cast(m.handle)) == displayId) { return m.handle; } } - if (!monitors.empty()) { - return monitors[0].handle; - } - - return MonitorFromPoint({0, 0}, MONITOR_DEFAULTTOPRIMARY); + return nullptr; } MonitorInfo getMonitorInfo(HMONITOR monitor) { diff --git a/electron/native/wgc-capture/src/monitor_utils.h b/electron/native/wgc-capture/src/monitor_utils.h index 513e3105..8889410d 100644 --- a/electron/native/wgc-capture/src/monitor_utils.h +++ b/electron/native/wgc-capture/src/monitor_utils.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include #include @@ -14,5 +15,5 @@ struct MonitorInfo { }; std::vector enumerateMonitors(); -HMONITOR findMonitorByDisplayId(int displayId); +HMONITOR findMonitorByDisplayId(int64_t displayId); MonitorInfo getMonitorInfo(HMONITOR monitor);