Update main.js

This commit is contained in:
Anirudh Sevugan 2025-06-17 19:11:32 -05:00 committed by GitHub
parent 8019ca9924
commit a440cf6a9e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -6,8 +6,10 @@ const { pathToFileURL } = require("url");
let didRegisterShortcuts = false;
if (process.platform === 'darwin') {
app.commandLine.appendSwitch('disable-features', 'Metal');
app.commandLine.appendSwitch('use-gl', 'desktop');
if (process.argv.includes('--use-gl')) {
app.commandLine.appendSwitch('disable-features', 'Metal');
app.commandLine.appendSwitch('use-gl', 'desktop');
}
}
@ -88,18 +90,19 @@ const createWindow = (onReadyCallback) => {
mainWindow.loadFile("index.html");
if (process.platform === 'darwin') {
mainWindow.webContents.on('did-finish-load', () => {
mainWindow.webContents.executeJavaScript("navigator.userAgent").then(ua => {
console.log("User Agent:", ua);
});
mainWindow.webContents.executeJavaScript("chrome.loadTimes ? chrome.loadTimes() : {}").then(loadTimes => {
console.log("GPU Info (legacy):", loadTimes);
});
});
}
if (process.platform === 'darwin') {
if (process.argv.includes('--use-gl')) {
mainWindow.webContents.on('did-finish-load', () => {
mainWindow.webContents.executeJavaScript("navigator.userAgent").then(ua => {
console.log("User Agent:", ua);
});
mainWindow.webContents.executeJavaScript("chrome.loadTimes ? chrome.loadTimes() : {}").then(loadTimes => {
console.log("GPU Info (legacy):", loadTimes);
});
});
}
}
mainWindow.once("ready-to-show", () => {
if (onReadyCallback) onReadyCallback();
@ -108,6 +111,7 @@ if (process.platform === 'darwin') {
setupContextMenu();
};
// Set up context menu (prevents errors if `mainWindow` is undefined)
const setupContextMenu = () => {
if (!mainWindow) return;