Robotics-Sensors
/
organization-bellande-robotics-sensors-inovation-center-website-application
Public
forked from RonaldsonBellande/organization-bellande-robotics-sensors-inovation-center-website-application
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3d00cc5
commit 4c3cf62
Showing
2 changed files
with
24 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,119 +1,47 @@ | ||
const { app, globalShortcut, BrowserWindow, session } = require('electron'); | ||
const path = require('path'); | ||
const { switchFullscreenState } = require('./windowManager.js'); | ||
const { app, BrowserWindow } = require('electron'); | ||
|
||
var homePage = 'https://robotics-sensors.github.io'; | ||
var userAgent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.3'; | ||
// Application configuration | ||
const appConfig = { | ||
homePageURL: 'https://robotics-sensors.github.io', | ||
userAgent: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.3', | ||
}; | ||
|
||
console.log('Using user agent: ' + userAgent); | ||
console.log('Process arguments: ' + process.argv); | ||
console.log(`Using user agent: ${appConfig.userAgent}`); | ||
console.log(`Process arguments: ${process.argv}`); | ||
|
||
// Configure Electron command line switches | ||
app.commandLine.appendSwitch('enable-features', 'VaapiVideoDecoder,WaylandWindowDecorations,RawDraw'); | ||
|
||
app.commandLine.appendSwitch( | ||
'disable-features', | ||
'UseChromeOSDirectVideoDecoder' | ||
); | ||
app.commandLine.appendSwitch('disable-features', 'UseChromeOSDirectVideoDecoder'); | ||
app.commandLine.appendSwitch('enable-accelerated-mjpeg-decode'); | ||
app.commandLine.appendSwitch('enable-accelerated-video'); | ||
app.commandLine.appendSwitch('ignore-gpu-blocklist'); | ||
app.commandLine.appendSwitch('enable-native-gpu-memory-buffers'); | ||
app.commandLine.appendSwitch('enable-gpu-rasterization'); | ||
app.commandLine.appendSwitch('enable-zero-copy'); | ||
app.commandLine.appendSwitch('enable-gpu-memory-buffer-video-frames'); | ||
app.commandLine.appendSwitch('use-gl'); | ||
|
||
async function createWindow() { | ||
// Create the main application window | ||
async function createMainWindow() { | ||
const mainWindow = new BrowserWindow({ | ||
fullscreenable: true, | ||
webPreferences: { | ||
preload: path.join(__dirname, 'preload.js'), | ||
contextIsolation: false, | ||
userAgent: userAgent, | ||
userAgent: appConfig.userAgent, | ||
}, | ||
}); | ||
|
||
if (process.argv.includes('--direct-start')) { | ||
mainWindow.loadURL(homePage); | ||
} else { | ||
mainWindow.loadURL(homePage); | ||
} | ||
|
||
await mainWindow.loadURL(appConfig.homePageURL); | ||
return mainWindow; | ||
} | ||
|
||
// Initialize the application | ||
app.whenReady().then(async () => { | ||
createWindow(); | ||
await createMainWindow(); | ||
|
||
app.on('activate', async function() { | ||
app.on('activate', async () => { | ||
if (BrowserWindow.getAllWindows().length === 0) { | ||
createWindow(); | ||
await createMainWindow(); | ||
} | ||
}); | ||
|
||
const { globalShortcut, BrowserWindow } = require('electron'); | ||
|
||
// Register global shortcuts | ||
const window = BrowserWindow.getAllWindows()[0]; | ||
globalShortcut.register('Super+F', async () => { | ||
switchFullscreenState(window); | ||
}); | ||
|
||
globalShortcut.register('F11', async () => { | ||
switchFullscreenState(window); | ||
}); | ||
|
||
globalShortcut.register('Alt+F4', async () => { | ||
app.quit(); | ||
}); | ||
|
||
globalShortcut.register('Alt+Home', async () => { | ||
window.loadURL(homePage); | ||
}); | ||
|
||
globalShortcut.register('F4', async () => { | ||
app.quit(); | ||
}); | ||
|
||
globalShortcut.register('Control+Shift+I', () => { | ||
window.webContents.toggleDevTools(); | ||
}); | ||
|
||
globalShortcut.register('Esc', async () => { | ||
// Handle 'Esc' key press event | ||
window.webContents.sendInputEvent({ | ||
type: 'keyDown', | ||
keyCode: 'Esc' | ||
}); | ||
window.webContents.sendInputEvent({ | ||
type: 'char', | ||
keyCode: 'Esc' | ||
}); | ||
window.webContents.sendInputEvent({ | ||
type: 'keyUp', | ||
keyCode: 'Esc' | ||
}); | ||
}); | ||
}); | ||
|
||
app.on('browser-window-created', async function(e, window) { | ||
window.setBackgroundColor('#1A1D1F'); | ||
window.setMenu(null); | ||
|
||
window.webContents.setUserAgent(userAgent); | ||
|
||
window.webContents.on('new-window', (event, url) => { | ||
event.preventDefault(); | ||
BrowserWindow.getAllWindows()[0].loadURL(url); | ||
// Quit the application when all windows are closed | ||
app.on('window-all-closed', async () => { | ||
if (process.platform !== 'darwin') { | ||
app.quit(); | ||
} | ||
}); | ||
|
||
}); | ||
|
||
app.on('will-quit', async () => { | ||
globalShortcut.unregisterAll(); | ||
}); | ||
|
||
app.on('window-all-closed', async function() { | ||
if (process.platform !== 'darwin') { | ||
app.quit(); | ||
} | ||
}); |