From c6e29c331455af64e6e6838ff3a9552a05d0fc64 Mon Sep 17 00:00:00 2001 From: sawka Date: Wed, 17 Aug 2022 13:26:03 -0700 Subject: [PATCH] proof of concept, open window --- src/emain.ts | 33 +++++++++++++++++++++++++++++++++ static/remotes.html | 1 + 2 files changed, 34 insertions(+) create mode 100644 static/remotes.html diff --git a/src/emain.ts b/src/emain.ts index f88434f91..9856b0492 100644 --- a/src/emain.ts +++ b/src/emain.ts @@ -39,11 +39,38 @@ let menu = electron.Menu.buildFromTemplate(menuTemplate); electron.Menu.setApplicationMenu(menu); let MainWindow = null; +let RemotesWindow = null; function getMods(input : any) { return {meta: input.meta, shift: input.shift, ctrl: input.ctrl, alt: input.alt}; } +function cancelNav(event : any, url : any) { + console.log("cancel navigation", url); + event.preventDefault(); +} + +function createRemotesWindow() { + if (RemotesWindow != null) { + console.log("remotes exists"); + return; + } + console.log("create remotes window"); + let win = new electron.BrowserWindow({ + width: 800, + height: 600, + webPreferences: { + preload: path.join(__dirname, "../src/preload.js"), + }, + }); + RemotesWindow = win; + win.loadFile("../static/remotes.html"); + win.on("close", () => { + RemotesWindow = null; + }); + win.webContents.on("will-navigate", cancelNav); +} + function createWindow() { let win = new electron.BrowserWindow({ width: 1800, @@ -73,6 +100,11 @@ function createWindow() { } return; } + if (input.code == "KeyR" && input.meta && input.alt) { + createRemotesWindow(); + e.preventDefault(); + return; + } if (input.meta && (input.code == "ArrowUp" || input.code == "ArrowDown")) { if (input.code == "ArrowUp") { win.webContents.send("meta-arrowup"); @@ -97,6 +129,7 @@ function createWindow() { return; } }); + win.webContents.on("will-navigate", cancelNav); return win; } diff --git a/static/remotes.html b/static/remotes.html new file mode 100644 index 000000000..5b850941b --- /dev/null +++ b/static/remotes.html @@ -0,0 +1 @@ +

Remotes!