Tray notification icon dot

This commit is contained in:
Natsumi
2025-10-30 01:16:17 +11:00
parent 814a66abea
commit 3836b9b4ce
15 changed files with 90 additions and 35 deletions

View File

@@ -161,28 +161,6 @@ if (!gotTheLock) {
});
}
ipcMain.handle('getArch', () => {
return process.arch.toString();
});
ipcMain.handle('applyWindowSettings', (event, position, size, state) => {
if (position) {
mainWindow.setPosition(parseInt(position.x), parseInt(position.y));
}
if (size) {
mainWindow.setSize(parseInt(size.width), parseInt(size.height));
}
if (state) {
if (state === '0') {
mainWindow.restore();
} else if (state === '1') {
mainWindow.restore();
} else if (state === '2') {
mainWindow.maximize();
}
}
});
ipcMain.handle('dialog:openFile', async () => {
const result = await dialog.showOpenDialog(mainWindow, {
properties: ['openFile'],
@@ -278,6 +256,14 @@ ipcMain.handle(
}
);
ipcMain.handle('app:getArch', () => {
return process.arch.toString();
});
ipcMain.handle('app:setTrayIconNotification', (event, notify) => {
setTrayIconNotification(notify);
});
function tryRelaunchWithArgs(args) {
if (
process.platform !== 'linux' ||
@@ -536,21 +522,35 @@ function destroyHmdOverlayWindow() {
hmdOverlayWindow = undefined;
}
let tray = null;
let trayIcon = null;
let trayIconNotify = null;
function createTray() {
let tray = null;
if (process.platform === 'darwin') {
const image = nativeImage.createFromPath(
path.join(rootDir, 'images/VRCX.png')
);
tray = new Tray(image.resize({ width: 16, height: 16 }));
trayIcon = image.resize({ width: 16, height: 16 });
const imageNotify = nativeImage.createFromPath(
path.join(rootDir, 'images/VRCX_notify.png')
);
trayIconNotify = imageNotify.resize({ width: 16, height: 16 });
} else if (process.platform === 'linux') {
const image = nativeImage.createFromPath(
path.join(rootDir, 'images/VRCX.png')
);
tray = new Tray(image.resize({ width: 64, height: 64 }));
trayIcon = image.resize({ width: 64, height: 64 });
const imageNotify = nativeImage.createFromPath(
path.join(rootDir, 'images/VRCX_notify.png')
);
trayIconNotify = imageNotify.resize({ width: 64, height: 64 });
} else {
tray = new Tray(path.join(rootDir, 'images/VRCX.ico'));
trayIcon = path.join(rootDir, 'images/VRCX.ico');
trayIconNotify = path.join(rootDir, 'images/VRCX_notify.ico');
}
tray = new Tray(trayIcon);
const contextMenu = Menu.buildFromTemplate([
{
label: 'Open',
@@ -583,6 +583,10 @@ function createTray() {
});
}
function setTrayIconNotification(notify) {
tray.setImage(notify ? trayIconNotify : trayIcon);
}
async function installVRCX() {
console.log('Home path:', homePath);
console.log('AppImage path:', appImagePath);

View File

@@ -22,7 +22,9 @@ contextBridge.exposeInMainWorld('interopApi', {
const validChannels = ['launch-command'];
contextBridge.exposeInMainWorld('electron', {
getArch: () => ipcRenderer.invoke('getArch'),
getArch: () => ipcRenderer.invoke('app:getArch'),
setTrayIconNotification: (notify) =>
ipcRenderer.invoke('app:setTrayIconNotification', notify),
openFileDialog: () => ipcRenderer.invoke('dialog:openFile'),
openDirectoryDialog: () => ipcRenderer.invoke('dialog:openDirectory'),
onWindowPositionChanged: (callback) =>