fix(wgc): preserve full-width display identifiers

This commit is contained in:
webadderall
2026-03-27 23:34:39 +11:00
parent 7750e5cdbb
commit 6cbef1e279
3 changed files with 7 additions and 10 deletions
+2 -2
View File
@@ -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");
@@ -27,20 +27,16 @@ std::vector<MonitorInfo> 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<int>(reinterpret_cast<intptr_t>(m.handle)) == displayId) {
if (static_cast<int64_t>(reinterpret_cast<intptr_t>(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) {
@@ -1,5 +1,6 @@
#pragma once
#include <cstdint>
#include <windows.h>
#include <string>
#include <vector>
@@ -14,5 +15,5 @@ struct MonitorInfo {
};
std::vector<MonitorInfo> enumerateMonitors();
HMONITOR findMonitorByDisplayId(int displayId);
HMONITOR findMonitorByDisplayId(int64_t displayId);
MonitorInfo getMonitorInfo(HMONITOR monitor);