Skip to content

Commit

Permalink
enabled custom tray only for mac
Browse files Browse the repository at this point in the history
  • Loading branch information
corn-potage committed Jul 29, 2024
1 parent ba324a9 commit 54c9096
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions src/main/tray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,9 @@ import { NodeStoppedBy } from '../common/node.js';
import logger from './logger';
import { createWindow, fullQuit, getMainWindow } from './main';
import { stopAllNodePackages } from './nodePackageManager.js';
import { isLinux, isWindows } from './platform';
import { isLinux, isWindows, isMac } from './platform';
import { getPodmanDetails } from './podman/details.js';
import {
getNiceNodeMachine,
startMachineIfCreated,
stopMachineIfCreated,
} from './podman/machine';
import { getNiceNodeMachine, stopMachineIfCreated } from './podman/machine';
import { openPodmanModal } from './podman/podman.js';
import { getUserNodePackages } from './state/nodePackages';
import { openNodePackageScreen } from './state/nodePackages.js';
Expand Down Expand Up @@ -203,7 +199,7 @@ function createCustomTrayWindow() {
contextIsolation: false,
nodeIntegration: true,
},
vibrancy: process.platform === 'darwin' ? 'sidebar' : undefined,
vibrancy: isMac() ? 'sidebar' : undefined,
});

trayWindow.loadURL(`file://${_getAssetPath('trayIndex.html')}`);
Expand Down Expand Up @@ -387,12 +383,12 @@ function toggleCustomTrayWindow() {
let x;
let y;

if (process.platform === 'darwin') {
if (isMac()) {
x = Math.round(
trayBounds.x + trayBounds.width / 2 - windowBounds.width / 2,
);
y = Math.round(trayBounds.y + trayBounds.height);
} else if (process.platform === 'win32') {
} else if (isWindows()) {
const display = screen.getPrimaryDisplay(); // Get the primary display details
const workArea = display.workArea;
x = Math.round(
Expand Down Expand Up @@ -435,20 +431,23 @@ export const initialize = (getAssetPath: (...paths: string[]) => string) => {
}

tray = new Tray(icon);
createCustomTrayWindow();

// if (process.env.NODE_ENV === 'development') {
// trayWindow?.webContents.openDevTools();
// }
// updateTrayMenu();
if (isMac()) {
createCustomTrayWindow();
} else {
updateTrayMenu();
}

tray.on('click', () => {
// on windows, default is open/show window on click
// on mac, default is open menu on click (no code needed)
// on linux?
toggleCustomTrayWindow();
updateCustomTrayMenu();
// updateTrayMenu();
if (isMac()) {
toggleCustomTrayWindow();
updateCustomTrayMenu();
} else {
updateTrayMenu();
}

if (isWindows()) {
const window = getMainWindow();
if (window) {
Expand Down

0 comments on commit 54c9096

Please sign in to comment.