chore: finalize electron desktop migration

This commit is contained in:
Mohamed Boudra
2026-03-21 01:50:00 +07:00
parent 77fb74c188
commit 111576e2ca
169 changed files with 6463 additions and 13191 deletions
@@ -0,0 +1,61 @@
import { app, BrowserWindow, ipcMain } from "electron";
export function registerWindowManager(): void {
ipcMain.handle("paseo:window:startDragging", (event) => {
const win = BrowserWindow.fromWebContents(event.sender);
// Desktop dragging is handled via CSS `-webkit-app-region: drag`.
// This handler exists only to satisfy the renderer bridge contract.
if (win) {
// No-op.
}
});
ipcMain.handle("paseo:window:toggleMaximize", (event) => {
const win = BrowserWindow.fromWebContents(event.sender);
if (!win) return;
if (win.isMaximized()) {
win.unmaximize();
} else {
win.maximize();
}
});
ipcMain.handle("paseo:window:isFullscreen", (event) => {
const win = BrowserWindow.fromWebContents(event.sender);
return win?.isFullScreen() ?? false;
});
ipcMain.handle("paseo:window:setBadgeCount", (_event, count?: number) => {
if (process.platform === "darwin" || process.platform === "linux") {
app.setBadgeCount(count ?? 0);
}
});
}
export function setupWindowResizeEvents(win: BrowserWindow): void {
win.on("resize", () => {
win.webContents.send("paseo:window:resized", {});
});
win.on("enter-full-screen", () => {
win.webContents.send("paseo:window:resized", {});
});
win.on("leave-full-screen", () => {
win.webContents.send("paseo:window:resized", {});
});
}
/**
* Prevent Electron from navigating to files dragged onto the window.
* The renderer handles drag-drop via standard HTML5 APIs instead.
*/
export function setupDragDropPrevention(win: BrowserWindow): void {
win.webContents.on("will-navigate", (event, url) => {
// Allow normal navigation (e.g. dev server hot-reload) but block file:// URLs
// that result from dropping files onto the window.
if (url.startsWith("file://")) {
event.preventDefault();
}
});
}