mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 10:31:47 +00:00
Block some shortcuts (esc, f) in PiP
This commit is contained in:
@ -20,6 +20,8 @@ const togglePiP = async (win) => {
|
|||||||
originalPosition = win.getPosition();
|
originalPosition = win.getPosition();
|
||||||
originalSize = win.getSize();
|
originalSize = win.getSize();
|
||||||
|
|
||||||
|
win.webContents.on("before-input-event", blockShortcutsInPiP);
|
||||||
|
|
||||||
win.setFullScreenable(false);
|
win.setFullScreenable(false);
|
||||||
await win.webContents.executeJavaScript(
|
await win.webContents.executeJavaScript(
|
||||||
// Go fullscreen
|
// Go fullscreen
|
||||||
@ -40,6 +42,8 @@ const togglePiP = async (win) => {
|
|||||||
app.dock?.show();
|
app.dock?.show();
|
||||||
win.setAlwaysOnTop(true, "screen-saver", 1);
|
win.setAlwaysOnTop(true, "screen-saver", 1);
|
||||||
} else {
|
} else {
|
||||||
|
win.webContents.removeListener("before-input-event", blockShortcutsInPiP);
|
||||||
|
|
||||||
await win.webContents.executeJavaScript(
|
await win.webContents.executeJavaScript(
|
||||||
// Exit fullscreen
|
// Exit fullscreen
|
||||||
`
|
`
|
||||||
@ -66,3 +70,10 @@ module.exports = (win) => {
|
|||||||
await togglePiP(win);
|
await togglePiP(win);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const blockShortcutsInPiP = (event, input) => {
|
||||||
|
const blockedShortcuts = ["f", "escape"];
|
||||||
|
if (blockedShortcuts.includes(input.key.toLowerCase())) {
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user