Правки в ядре для показа окна поверх всех окон при звонке

This commit is contained in:
RoyceDa
2026-03-18 18:28:37 +02:00
parent 41d7a89830
commit 824b1fec65
5 changed files with 58 additions and 9 deletions

View File

@@ -1,4 +1,4 @@
import { BrowserWindow, shell, ipcMain, nativeTheme, screen, powerMonitor } from 'electron'
import { BrowserWindow, shell, ipcMain, nativeTheme, screen, powerMonitor, app } from 'electron'
import { join } from 'path'
import fs from 'fs'
import { WORKING_DIR } from './constants';
@@ -45,7 +45,8 @@ export function createAppWindow(preloaderWindow?: BrowserWindow): void {
nodeIntegrationInSubFrames: true,
nodeIntegrationInWorker: true,
webSecurity: false,
allowRunningInsecureContent: true
allowRunningInsecureContent: true,
autoplayPolicy: 'no-user-gesture-required'
}
});
@@ -73,6 +74,7 @@ export function createAppWindow(preloaderWindow?: BrowserWindow): void {
}
export function foundationIpcRegistration(mainWindow: BrowserWindow) {
let bounceId: number | null = null;
ipcMain.removeAllListeners('window-resize');
ipcMain.removeAllListeners('window-resizeble');
ipcMain.removeAllListeners('window-theme');
@@ -86,6 +88,38 @@ export function foundationIpcRegistration(mainWindow: BrowserWindow) {
ipcMain.removeHandler('window-minimize');
ipcMain.removeHandler('showItemInFolder');
ipcMain.removeHandler('openExternal');
ipcMain.removeHandler('window-top');
ipcMain.removeHandler('window-priority-normal');
ipcMain.handle('window-top', () => {
if (mainWindow.isMinimized()){
mainWindow.restore();
}
mainWindow.setAlwaysOnTop(true, "screen-saver"); // самый высокий уровень
mainWindow.setVisibleOnAllWorkspaces(true, { visibleOnFullScreen: true });
mainWindow.show();
mainWindow.focus();
if (process.platform === "darwin") {
/**
* Только в macos! Подпрыгивание иконки в Dock
*/
bounceId = app.dock!.bounce("critical");
}
})
ipcMain.handle('window-priority-normal', () => {
mainWindow.setAlwaysOnTop(false);
mainWindow.setVisibleOnAllWorkspaces(false);
if(process.platform === "darwin" && bounceId !== null){
/**
* Только в macos! Отмена подпрыгивания иконки в Dock
*/
app.dock!.cancelBounce(bounceId);
bounceId = null;
}
})
ipcMain.handle('open-dev-tools', () => {
if (mainWindow.webContents.isDevToolsOpened()) {