mirror of
https://github.com/heyman/heynote.git
synced 2024-11-24 17:03:19 +01:00
Add "Always on top" setting which makes Heynote stay on top of other programs
This commit is contained in:
parent
a7e0f53c35
commit
2f22951e9f
@ -33,6 +33,7 @@ const schema = {
|
|||||||
"bufferPath" : {type: "string", default: ""},
|
"bufferPath" : {type: "string", default: ""},
|
||||||
"showInDock": {type: "boolean", default: true},
|
"showInDock": {type: "boolean", default: true},
|
||||||
"showInMenu": {type: "boolean", default: false},
|
"showInMenu": {type: "boolean", default: false},
|
||||||
|
"alwaysOnTop": {type: "boolean", default: false},
|
||||||
"bracketClosing": {type: "boolean", default: false},
|
"bracketClosing": {type: "boolean", default: false},
|
||||||
|
|
||||||
// when default font settings are used, fontFamily and fontSize is not specified in the
|
// when default font settings are used, fontFamily and fontSize is not specified in the
|
||||||
@ -67,6 +68,7 @@ const defaults = {
|
|||||||
bufferPath: "",
|
bufferPath: "",
|
||||||
showInDock: true,
|
showInDock: true,
|
||||||
showInMenu: false,
|
showInMenu: false,
|
||||||
|
alwaysOnTop: false,
|
||||||
bracketClosing: false,
|
bracketClosing: false,
|
||||||
},
|
},
|
||||||
theme: "system",
|
theme: "system",
|
||||||
|
@ -225,14 +225,18 @@ function registerGlobalHotkey() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (win.isFocused()) {
|
if (win.isFocused()) {
|
||||||
if (!!app.hide) {
|
if (isMac) {
|
||||||
// app.hide() only available on macOS
|
// app.hide() only available on macOS
|
||||||
// We want to use app.hide() so that the menu bar also gets changed
|
// We want to use app.hide() so that the menu bar also gets changed
|
||||||
app?.hide()
|
app?.hide()
|
||||||
|
if (CONFIG.get("settings.alwaysOnTop")) {
|
||||||
|
// if alwaysOnTop is on, calling app.hide() won't hide the window
|
||||||
|
win.hide()
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
win.blur()
|
win.blur()
|
||||||
if (CONFIG.get("settings.showInMenu")) {
|
if (CONFIG.get("settings.showInMenu") || CONFIG.get("settings.alwaysOnTop")) {
|
||||||
// if we're using a tray icon we want to completely hide the window
|
// if we're using a tray icon, or alwaysOnTop is on, we want to completely hide the window
|
||||||
win.hide()
|
win.hide()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -275,11 +279,34 @@ function registerShowInMenu() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function registerAlwaysOnTop() {
|
||||||
|
if (CONFIG.get("settings.alwaysOnTop")) {
|
||||||
|
const disableAlwaysOnTop = () => {
|
||||||
|
win.setAlwaysOnTop(true, "floating");
|
||||||
|
win.setVisibleOnAllWorkspaces(true, {visibleOnFullScreen: true});
|
||||||
|
win.setFullScreenable(false);
|
||||||
|
}
|
||||||
|
// if we're in fullscreen mode, we need to exit fullscreen before we can set alwaysOnTop
|
||||||
|
if (win.isFullScreen()) {
|
||||||
|
// on Mac setFullScreen happens asynchronously, so we need to wait for the event before we can disable alwaysOnTop
|
||||||
|
win.once("leave-full-screen", disableAlwaysOnTop)
|
||||||
|
win.setFullScreen(false)
|
||||||
|
} else {
|
||||||
|
disableAlwaysOnTop()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
win.setAlwaysOnTop(false);
|
||||||
|
win.setVisibleOnAllWorkspaces(false);
|
||||||
|
win.setFullScreenable(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
app.whenReady().then(createWindow).then(async () => {
|
app.whenReady().then(createWindow).then(async () => {
|
||||||
initializeAutoUpdate(win)
|
initializeAutoUpdate(win)
|
||||||
registerGlobalHotkey()
|
registerGlobalHotkey()
|
||||||
registerShowInDock()
|
registerShowInDock()
|
||||||
registerShowInMenu()
|
registerShowInMenu()
|
||||||
|
registerAlwaysOnTop()
|
||||||
})
|
})
|
||||||
|
|
||||||
app.on("before-quit", () => {
|
app.on("before-quit", () => {
|
||||||
@ -328,6 +355,7 @@ ipcMain.handle('settings:set', async (event, settings) => {
|
|||||||
let showInDockChanged = settings.showInDock !== CONFIG.get("settings.showInDock");
|
let showInDockChanged = settings.showInDock !== CONFIG.get("settings.showInDock");
|
||||||
let showInMenuChanged = settings.showInMenu !== CONFIG.get("settings.showInMenu");
|
let showInMenuChanged = settings.showInMenu !== CONFIG.get("settings.showInMenu");
|
||||||
let bufferPathChanged = settings.bufferPath !== CONFIG.get("settings.bufferPath");
|
let bufferPathChanged = settings.bufferPath !== CONFIG.get("settings.bufferPath");
|
||||||
|
let alwaysOnTopChanged = settings.alwaysOnTop !== CONFIG.get("settings.alwaysOnTop");
|
||||||
CONFIG.set("settings", settings)
|
CONFIG.set("settings", settings)
|
||||||
|
|
||||||
win?.webContents.send(SETTINGS_CHANGE_EVENT, settings)
|
win?.webContents.send(SETTINGS_CHANGE_EVENT, settings)
|
||||||
@ -341,6 +369,9 @@ ipcMain.handle('settings:set', async (event, settings) => {
|
|||||||
if (showInMenuChanged) {
|
if (showInMenuChanged) {
|
||||||
registerShowInMenu()
|
registerShowInMenu()
|
||||||
}
|
}
|
||||||
|
if (alwaysOnTopChanged) {
|
||||||
|
registerAlwaysOnTop()
|
||||||
|
}
|
||||||
if (bufferPathChanged) {
|
if (bufferPathChanged) {
|
||||||
const buffer = loadBuffer()
|
const buffer = loadBuffer()
|
||||||
if (buffer.exists()) {
|
if (buffer.exists()) {
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
globalHotkey: this.initialSettings.globalHotkey,
|
globalHotkey: this.initialSettings.globalHotkey,
|
||||||
showInDock: this.initialSettings.showInDock,
|
showInDock: this.initialSettings.showInDock,
|
||||||
showInMenu: this.initialSettings.showInMenu,
|
showInMenu: this.initialSettings.showInMenu,
|
||||||
|
alwaysOnTop: this.initialSettings.alwaysOnTop,
|
||||||
bracketClosing: this.initialSettings.bracketClosing,
|
bracketClosing: this.initialSettings.bracketClosing,
|
||||||
autoUpdate: this.initialSettings.autoUpdate,
|
autoUpdate: this.initialSettings.autoUpdate,
|
||||||
bufferPath: this.initialSettings.bufferPath,
|
bufferPath: this.initialSettings.bufferPath,
|
||||||
@ -82,6 +83,7 @@
|
|||||||
globalHotkey: this.globalHotkey,
|
globalHotkey: this.globalHotkey,
|
||||||
showInDock: this.showInDock,
|
showInDock: this.showInDock,
|
||||||
showInMenu: this.showInMenu || !this.showInDock,
|
showInMenu: this.showInMenu || !this.showInDock,
|
||||||
|
alwaysOnTop: this.alwaysOnTop,
|
||||||
autoUpdate: this.autoUpdate,
|
autoUpdate: this.autoUpdate,
|
||||||
bracketClosing: this.bracketClosing,
|
bracketClosing: this.bracketClosing,
|
||||||
bufferPath: this.bufferPath,
|
bufferPath: this.bufferPath,
|
||||||
@ -184,7 +186,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="row" v-if="!isWebApp">
|
<div class="row" v-if="!isWebApp">
|
||||||
<div class="entry">
|
<div class="entry">
|
||||||
<h2>Show In</h2>
|
<h2>Window / Application</h2>
|
||||||
<label v-if="isMac">
|
<label v-if="isMac">
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
@ -207,6 +209,14 @@
|
|||||||
Show in system tray
|
Show in system tray
|
||||||
</template>
|
</template>
|
||||||
</label>
|
</label>
|
||||||
|
<label>
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
v-model="alwaysOnTop"
|
||||||
|
@change="updateSettings"
|
||||||
|
/>
|
||||||
|
Always on top
|
||||||
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row" v-if="!isWebApp">
|
<div class="row" v-if="!isWebApp">
|
||||||
|
Loading…
Reference in New Issue
Block a user