Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
Open new window from taskbar
SiriusXTe5213640d7b7
diff --git a/src/services/window.ts b/src/services/window.tsindex e22ca382b8..89415f74d8 100644--- a/src/services/window.ts+++ b/src/services/window.ts@@ -7,7 +7,7 @@ import log from "./log.js";import sqlInit from "./sql_init.js";import cls from "./cls.js";import keyboardActionsService from "./keyboard_actions.js";-import remoteMain from "@electron/remote/main/index.js"+import remoteMain from "@electron/remote/main/index.js";import { App, BrowserWindow, WebContents, ipcMain } from 'electron';import { fileURLToPath } from "url";@@ -46,6 +46,17 @@ ipcMain.on('create-extra-window', (event, arg) => {});async function createMainWindow(app: App) {+ app.setUserTasks([+ {+ program: process.execPath,+ arguments: '--new-window',+ iconPath: process.execPath,+ iconIndex: 0,+ title: 'Open New Window',+ description: 'Open new window'+ }+ ]);+const windowStateKeeper = (await import('electron-window-state')).default; // should not be statically importedconst mainWindowState = windowStateKeeper({@@ -57,7 +68,7 @@ async function createMainWindow(app: App) {const spellcheckEnabled = optionService.getOptionBool('spellCheckEnabled');const { BrowserWindow } = (await import('electron')); // should not be statically imported-+mainWindow = new BrowserWindow({x: mainWindowState.x,y: mainWindowState.y,@@ -82,10 +93,12 @@ async function createMainWindow(app: App) {configureWebContents(mainWindow.webContents, spellcheckEnabled);- app.on('second-instance', () => {- // Someone tried to run a second instance, we should focus our window.- // see www.ts "requestSingleInstanceLock" for the rest of this logic with explanation- if (mainWindow) {+ app.on('second-instance', (event, commandLine) => {+ if (commandLine.includes('--new-window')) {+ createExtraWindow("");+ } else if (mainWindow) {+ // Someone tried to run a second instance, we should focus our window.+ // see www.ts "requestSingleInstanceLock" for the rest of this logic with explanationif (mainWindow.isMinimized()) {mainWindow.restore();}