From f48e1d4e63a183983d71e2f733a558777e2e5d46 Mon Sep 17 00:00:00 2001 From: Fadi Nahhas Date: Wed, 18 Mar 2026 20:09:48 +0200 Subject: [PATCH] Windows system cursor fix - updated baseline-browser-mapping - added #define NOMINMAX to dxgi-session.cpp - fixed GPU cache creation fail in electron/main.ts - excluded build from git --- .gitignore | 2 +- electron/main.ts | 2 + .../windows-capture/src/dxgi_session.cpp | 2 + package-lock.json | 12 +- package.json | 1 + scripts/build-cursor-monitor.mjs | 167 ++++++++++-------- scripts/build-windows-capture.mjs | 69 +++++--- 7 files changed, 144 insertions(+), 111 deletions(-) diff --git a/.gitignore b/.gitignore index 82f2650..2fbaf4b 100644 --- a/.gitignore +++ b/.gitignore @@ -30,5 +30,5 @@ release/** .history/ # Native capture build artifacts -electron/native/wgc-capture/build/ +electron/native/windows-capture/build/ electron/native/cursor-monitor/build/ diff --git a/electron/main.ts b/electron/main.ts index 0941493..0748802 100644 --- a/electron/main.ts +++ b/electron/main.ts @@ -10,6 +10,8 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url)) if (process.platform === 'darwin') { app.commandLine.appendSwitch('disable-features', 'MacCatapLoopbackAudioForScreenShare') +} else if (process.platform === 'win32') { + app.commandLine.appendSwitch('disable-gpu-shader-disk-cache') } export const RECORDINGS_DIR = path.join(app.getPath('userData'), 'recordings') diff --git a/electron/native/windows-capture/src/dxgi_session.cpp b/electron/native/windows-capture/src/dxgi_session.cpp index 76c9140..df2dac1 100644 --- a/electron/native/windows-capture/src/dxgi_session.cpp +++ b/electron/native/windows-capture/src/dxgi_session.cpp @@ -1,3 +1,5 @@ +#define NOMINMAX + #include "dxgi_session.h" #include diff --git a/package-lock.json b/package-lock.json index 2f3da42..30edb7b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -61,6 +61,7 @@ "@types/uuid": "^10.0.0", "@vitejs/plugin-react": "^4.2.1", "autoprefixer": "^10.4.21", + "baseline-browser-mapping": "^2.10.8", "electron": "^39.2.7", "electron-builder": "^26.7.0", "electron-icon-builder": "^2.0.1", @@ -5480,13 +5481,16 @@ "license": "MIT" }, "node_modules/baseline-browser-mapping": { - "version": "2.8.15", - "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.8.15.tgz", - "integrity": "sha512-qsJ8/X+UypqxHXN75M7dF88jNK37dLBRW7LeUzCPz+TNs37G8cfWy9nWzS+LS//g600zrt2le9KuXt0rWfDz5Q==", + "version": "2.10.8", + "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.10.8.tgz", + "integrity": "sha512-PCLz/LXGBsNTErbtB6i5u4eLpHeMfi93aUv5duMmj6caNu6IphS4q6UevDnL36sZQv9lrP11dbPKGMaXPwMKfQ==", "dev": true, "license": "Apache-2.0", "bin": { - "baseline-browser-mapping": "dist/cli.js" + "baseline-browser-mapping": "dist/cli.cjs" + }, + "engines": { + "node": ">=6.0.0" } }, "node_modules/bcrypt-pbkdf": { diff --git a/package.json b/package.json index a00e9fc..6c39e23 100644 --- a/package.json +++ b/package.json @@ -87,6 +87,7 @@ "@types/uuid": "^10.0.0", "@vitejs/plugin-react": "^4.2.1", "autoprefixer": "^10.4.21", + "baseline-browser-mapping": "^2.10.8", "electron": "^39.2.7", "electron-builder": "^26.7.0", "electron-icon-builder": "^2.0.1", diff --git a/scripts/build-cursor-monitor.mjs b/scripts/build-cursor-monitor.mjs index 387d528..a5ff20a 100644 --- a/scripts/build-cursor-monitor.mjs +++ b/scripts/build-cursor-monitor.mjs @@ -1,103 +1,114 @@ -import { execSync } from "node:child_process"; -import { existsSync, mkdirSync } from "node:fs"; -import path from "node:path"; +import { execSync } from 'node:child_process'; +import { mkdirSync, existsSync } from 'node:fs'; +import path from 'node:path'; const projectRoot = process.cwd(); -const sourceDir = path.join(projectRoot, "electron", "native", "cursor-monitor"); -const buildDir = path.join(sourceDir, "build"); +const sourceDir = path.join(projectRoot, 'electron', 'native', 'cursor-monitor'); +const buildDir = path.join(sourceDir, 'build'); -if (process.platform !== "win32") { - console.log("[build-cursor-monitor] Skipping: host platform is not Windows."); - process.exit(0); +if (process.platform !== 'win32') { + console.log('[build-cursor-monitor] Skipping: host platform is not Windows.'); + process.exit(0); } -if (!existsSync(path.join(sourceDir, "CMakeLists.txt"))) { - console.error("[build-cursor-monitor] CMakeLists.txt not found at", sourceDir); - process.exit(1); +if (!existsSync(path.join(sourceDir, 'CMakeLists.txt'))) { + console.error('[build-cursor-monitor] CMakeLists.txt not found at', sourceDir); + process.exit(1); } function findCmake() { - // Check PATH first - try { - execSync("cmake --version", { stdio: "pipe" }); - return "cmake"; - } catch { - // not on PATH - } - - // VS 2022 bundled CMake - const vsEditions = ["Community", "Professional", "Enterprise", "BuildTools"]; - for (const edition of vsEditions) { - const cmakePath = path.join( - "C:", - "Program Files", - "Microsoft Visual Studio", - "2022", - edition, - "Common7", - "IDE", - "CommonExtensions", - "Microsoft", - "CMake", - "CMake", - "bin", - "cmake.exe", - ); - if (existsSync(cmakePath)) { - return `"${cmakePath}"`; - } - } - - return null; + // Check PATH first (your standalone CMake) + try { + execSync('cmake --version', { stdio: 'pipe' }); + return 'cmake'; + } catch { + // not on PATH + } + + // Look for bundled CMake in Visual Studio (prefer 2026) + const vsYears = ['2026', '2022']; + const vsEditions = ['Community', 'Professional', 'Enterprise', 'BuildTools']; + + for (const year of vsYears) { + for (const edition of vsEditions) { + const cmakePath = path.join( + 'D:', // ← changed to D: because that's where your VS is + 'Program Files', + 'Microsoft Visual Studio', + year, + edition, + 'Common7', + 'IDE', + 'CommonExtensions', + 'Microsoft', + 'CMake', + 'CMake', + 'bin', + 'cmake.exe' + ); + if (existsSync(cmakePath)) { + console.log(`[build-cursor-monitor] Found CMake at: ${cmakePath}`); + return `"${cmakePath}"`; + } + } + } + + return null; } const cmake = findCmake(); + if (!cmake) { - console.error( - "[build-cursor-monitor] CMake not found. Install Visual Studio with C++ CMake tools or standalone CMake.", - ); - process.exit(1); + console.error( + '[build-cursor-monitor] CMake not found.\n' + + 'Make sure you have:\n' + + ' - Standalone CMake installed and in PATH, or\n' + + ' - Visual Studio 2026 with "Desktop development with C++" workload and "C++ CMake tools for Windows" component.' + ); + process.exit(1); } mkdirSync(buildDir, { recursive: true }); -console.log("[build-cursor-monitor] Configuring CMake..."); +console.log('[build-cursor-monitor] Configuring CMake with Visual Studio 18 2026...'); + try { - execSync(`${cmake} .. -G "Visual Studio 17 2022" -A x64`, { - cwd: buildDir, - stdio: "inherit", - timeout: 120000, - }); -} catch { - console.log("[build-cursor-monitor] VS 2022 generator not found, trying VS 2019..."); - try { - execSync(`${cmake} .. -G "Visual Studio 16 2019" -A x64`, { - cwd: buildDir, - stdio: "inherit", - timeout: 120000, - }); - } catch (innerError) { - console.error("[build-cursor-monitor] CMake configure failed:", innerError.message); - process.exit(1); - } + execSync(`${cmake} .. -G "Visual Studio 18 2026" -A x64`, { + cwd: buildDir, + stdio: 'inherit', + timeout: 120000, + }); +} catch (error) { + console.error('[build-cursor-monitor] CMake configure failed with VS 2026:'); + console.error(error.message || error); + console.log( + '\nQuick fixes:\n' + + '1. Delete the build folder: electron\\native\\cursor-monitor\\build\n' + + '2. Make sure VS 2026 has "C++ CMake tools for Windows" installed\n' + + '3. Run manually: cmake .. -G "Visual Studio 18 2026" -A x64 (from inside build folder)' + ); + process.exit(1); } -console.log("[build-cursor-monitor] Building..."); +console.log('[build-cursor-monitor] Building cursor-monitor (Release)...'); + try { - execSync(`${cmake} --build . --config Release`, { - cwd: buildDir, - stdio: "inherit", - timeout: 300000, - }); + execSync(`${cmake} --build . --config Release`, { + cwd: buildDir, + stdio: 'inherit', + timeout: 300000, + }); } catch (error) { - console.error("[build-cursor-monitor] Build failed:", error.message); - process.exit(1); + console.error('[build-cursor-monitor] Build failed:'); + console.error(error.message || error); + process.exit(1); } -const exePath = path.join(buildDir, "Release", "cursor-monitor.exe"); +const exePath = path.join(buildDir, 'Release', 'cursor-monitor.exe'); + if (existsSync(exePath)) { - console.log(`[build-cursor-monitor] Built successfully: ${exePath}`); + console.log(`[build-cursor-monitor] Built successfully: ${exePath}`); } else { - console.error("[build-cursor-monitor] Expected exe not found at", exePath); - process.exit(1); -} + console.error('[build-cursor-monitor] Expected executable not found at', exePath); + process.exit(1); +} \ No newline at end of file diff --git a/scripts/build-windows-capture.mjs b/scripts/build-windows-capture.mjs index bfdfa4d..eaee140 100644 --- a/scripts/build-windows-capture.mjs +++ b/scripts/build-windows-capture.mjs @@ -17,7 +17,7 @@ if (!existsSync(path.join(sourceDir, 'CMakeLists.txt'))) { } function findCmake() { - // Check PATH first + // Check PATH first (most common when CMake is installed standalone) try { execSync('cmake --version', { stdio: 'pipe' }); return 'cmake'; @@ -25,15 +25,20 @@ function findCmake() { // not on PATH } - // VS 2022 bundled CMake + // Look for bundled CMake in Visual Studio installations + const vsYears = ['2026', '2022']; // Prefer 2026, fallback to 2022 if needed const vsEditions = ['Community', 'Professional', 'Enterprise', 'BuildTools']; - for (const edition of vsEditions) { - const cmakePath = path.join( - 'C:', 'Program Files', 'Microsoft Visual Studio', '2022', edition, - 'Common7', 'IDE', 'CommonExtensions', 'Microsoft', 'CMake', 'CMake', 'bin', 'cmake.exe' - ); - if (existsSync(cmakePath)) { - return `"${cmakePath}"`; + + for (const year of vsYears) { + for (const edition of vsEditions) { + const cmakePath = path.join( + 'C:', 'Program Files', 'Microsoft Visual Studio', year, edition, + 'Common7', 'IDE', 'CommonExtensions', 'Microsoft', 'CMake', 'CMake', 'bin', 'cmake.exe' + ); + if (existsSync(cmakePath)) { + console.log(`[build-windows-capture] Found CMake at: ${cmakePath}`); + return `"${cmakePath}"`; + } } } @@ -41,35 +46,41 @@ function findCmake() { } const cmake = findCmake(); + if (!cmake) { - console.error('[build-windows-capture] CMake not found. Install Visual Studio with C++ CMake tools or standalone CMake.'); + console.error( + '[build-windows-capture] CMake not found.\n' + + 'Please install Visual Studio 2026 (with "Desktop development with C++" workload and "C++ CMake tools for Windows" component)\n' + + 'or install standalone CMake and add it to PATH.' + ); process.exit(1); } mkdirSync(buildDir, { recursive: true }); -console.log('[build-windows-capture] Configuring CMake...'); +console.log('[build-windows-capture] Configuring CMake with Visual Studio 18 2026...'); + try { - execSync(`${cmake} .. -G "Visual Studio 17 2022" -A x64`, { + execSync(`${cmake} .. -G "Visual Studio 18 2026" -A x64`, { cwd: buildDir, stdio: 'inherit', timeout: 120000, }); -} catch { - console.log('[build-windows-capture] VS 2022 generator not found, trying VS 2019...'); - try { - execSync(`${cmake} .. -G "Visual Studio 16 2019" -A x64`, { - cwd: buildDir, - stdio: 'inherit', - timeout: 120000, - }); - } catch (innerError) { - console.error('[build-windows-capture] CMake configure failed:', innerError.message); - process.exit(1); - } +} catch (error) { + console.error('[build-windows-capture] CMake configure failed with VS 2026:'); + console.error(error.message || error); + console.log( + '\nPossible fixes:\n' + + '1. Make sure Visual Studio 2026 has "Desktop development with C++" workload installed.\n' + + '2. Check "C++ CMake tools for Windows" component is installed.\n' + + '3. Delete the build folder and retry.\n' + + '4. Run "cmake .. -G \'Visual Studio 18 2026\' -A x64" manually in the native folder to debug.' + ); + process.exit(1); } -console.log('[build-windows-capture] Building native Windows capture helper...'); +console.log('[build-windows-capture] Building native Windows capture helper (Release)...'); + try { execSync(`${cmake} --build . --config Release`, { cwd: buildDir, @@ -77,14 +88,16 @@ try { timeout: 300000, }); } catch (error) { - console.error('[build-windows-capture] Build failed:', error.message); + console.error('[build-windows-capture] Build failed:'); + console.error(error.message || error); process.exit(1); } const exePath = path.join(buildDir, 'Release', 'windows-capture.exe'); + if (existsSync(exePath)) { console.log(`[build-windows-capture] Built successfully: ${exePath}`); } else { - console.error('[build-windows-capture] Expected exe not found at', exePath); + console.error('[build-windows-capture] Expected executable not found at', exePath); process.exit(1); -} +} \ No newline at end of file