mirror of
https://github.com/sascha-hemi/homeassistant-desktop.git
synced 2026-03-21 03:04:10 +01:00
v1.4.8 - add fullscreen mode
fixes window mispositioning on launch added #59
This commit is contained in:
@@ -18,11 +18,13 @@ Just download the latest version for your platform from the [releases section](h
|
||||
- supports multiple instances of Home Assistant (including automatic switching)
|
||||
- automatic instance discovery using bonjour
|
||||
- right-click context menu for settings / reset / quit the app
|
||||
- global keyboard shortcut (Cmd / Ctrl + Alt + X) can be enabled to show / hide Home Assistant
|
||||
- updates are installed automatically if a new version is available (restart required)
|
||||
- global keyboard shortcut (Cmd/Ctrl + Alt + X) can be enabled to show / hide Home Assistant
|
||||
- fullscreen mode (Cmd/Ctrl + Alt + Return)
|
||||
- automatic updates (if not disabled in context menu)
|
||||
|
||||
## 04. November 2021 - changes:
|
||||
## Recent hanges:
|
||||
|
||||
- added fullscreen mode
|
||||
- added arm64 builds (experimental)
|
||||
- updated electron (v8 to v13) + dependencies
|
||||
|
||||
|
||||
43
app.js
43
app.js
@@ -15,6 +15,7 @@ const AutoLaunch = require("auto-launch");
|
||||
const Positioner = require("electron-traywindow-positioner");
|
||||
const Store = require("electron-store");
|
||||
const bonjour = require("bonjour")();
|
||||
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||
const registerKeyboardShortcut = () => {
|
||||
globalShortcut.register("CommandOrControl+Alt+X", () => {
|
||||
if (window.isVisible()) window.hide();
|
||||
@@ -311,6 +312,15 @@ const getMenu = () => {
|
||||
createMainWindow(store.get("detachedMode"));
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "Use Fullscreen",
|
||||
type: "checkbox",
|
||||
checked: window.isFullScreen(),
|
||||
accelerator: "CommandOrControl+Alt+Return",
|
||||
click: () => {
|
||||
toggleFullScreen();
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "separator",
|
||||
},
|
||||
@@ -363,6 +373,8 @@ const getMenu = () => {
|
||||
store.delete("windowSizeDetached");
|
||||
store.delete("windowSize");
|
||||
store.delete("windowPosition");
|
||||
store.delete("fullScreen");
|
||||
store.delete("detachedMode");
|
||||
app.relaunch();
|
||||
app.exit();
|
||||
}
|
||||
@@ -410,9 +422,13 @@ const createMainWindow = (show = false) => {
|
||||
window.webContents.insertCSS(
|
||||
"::-webkit-scrollbar { display: none; } body { -webkit-user-select: none; }"
|
||||
);
|
||||
|
||||
if (store.get("detachedMode") && process.platform === "darwin") {
|
||||
window.webContents.insertCSS("body { -webkit-app-region: drag; }");
|
||||
}
|
||||
|
||||
// let code = `document.addEventListener("mousemove", () => { ipcRenderer.send("mousemove"); });`;
|
||||
// window.webContents.executeJavaScript(code);
|
||||
});
|
||||
|
||||
if (store.get("detachedMode")) {
|
||||
@@ -428,6 +444,9 @@ const createMainWindow = (show = false) => {
|
||||
}
|
||||
|
||||
window.on("resize", (e) => {
|
||||
// ignore resize event when using fullscreen mode
|
||||
if (window.isFullScreen()) return e;
|
||||
|
||||
if (!store.get("disableHover") || resizeEvent) {
|
||||
store.set("disableHover", true);
|
||||
resizeEvent = e;
|
||||
@@ -465,8 +484,10 @@ const createMainWindow = (show = false) => {
|
||||
if (!store.get("detachedMode") && !window.isAlwaysOnTop()) window.hide();
|
||||
});
|
||||
|
||||
window.setAlwaysOnTop(store.get("stayOnTop"));
|
||||
window.setAlwaysOnTop(!!store.get("stayOnTop"));
|
||||
if (window.isAlwaysOnTop() || show) showWindow();
|
||||
|
||||
toggleFullScreen(!!store.get("fullScreen"));
|
||||
};
|
||||
|
||||
const showWindow = () => {
|
||||
@@ -555,15 +576,26 @@ const setWindowFocusTimer = () => {
|
||||
}, 110);
|
||||
};
|
||||
|
||||
app.on("ready", () => {
|
||||
app.on("ready", async () => {
|
||||
checkAutoStart();
|
||||
useAutoUpdater();
|
||||
|
||||
createTray();
|
||||
// workaround for initial window misplacement due to traybounds being incorrect
|
||||
while (tray.getBounds().x === 0 || process.uptime() >= 1) {
|
||||
await delay(15);
|
||||
}
|
||||
|
||||
createMainWindow(!store.has("currentInstance"));
|
||||
startAvailabilityCheck();
|
||||
|
||||
// register shortcut
|
||||
if (store.get("shortcutEnabled")) registerKeyboardShortcut();
|
||||
|
||||
globalShortcut.register("CommandOrControl+Alt+Return", () => {
|
||||
toggleFullScreen();
|
||||
});
|
||||
|
||||
// disable hover for first start
|
||||
if (!store.has("currentInstance")) store.set("disableHover", true);
|
||||
// enable auto update by default
|
||||
@@ -574,6 +606,13 @@ app.on("will-quit", () => {
|
||||
unregisterKeyboardShortcut();
|
||||
});
|
||||
|
||||
const toggleFullScreen = (mode = !window.isFullScreen()) => {
|
||||
store.set("fullScreen", mode);
|
||||
window.setFullScreen(mode);
|
||||
if (mode) window.setAlwaysOnTop(true);
|
||||
else window.setAlwaysOnTop(store.get("stayOnTop"));
|
||||
};
|
||||
|
||||
const currentInstance = (url = null) => {
|
||||
if (url) {
|
||||
store.set("currentInstance", store.get("allInstances").indexOf(url));
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/mrvnklm/homeassistant-desktop"
|
||||
},
|
||||
"version": "1.4.7",
|
||||
"version": "1.4.8",
|
||||
"description": "Desktop App (Windows / macOS / Linux) for Home Assistant built with Electron",
|
||||
"main": "app.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user