mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-10 10:11:46 +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();
|
||||
originalSize = win.getSize();
|
||||
|
||||
win.webContents.on("before-input-event", blockShortcutsInPiP);
|
||||
|
||||
win.setFullScreenable(false);
|
||||
await win.webContents.executeJavaScript(
|
||||
// Go fullscreen
|
||||
@ -40,6 +42,8 @@ const togglePiP = async (win) => {
|
||||
app.dock?.show();
|
||||
win.setAlwaysOnTop(true, "screen-saver", 1);
|
||||
} else {
|
||||
win.webContents.removeListener("before-input-event", blockShortcutsInPiP);
|
||||
|
||||
await win.webContents.executeJavaScript(
|
||||
// Exit fullscreen
|
||||
`
|
||||
@ -66,3 +70,10 @@ module.exports = (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