Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -250,4 +250,5 @@ jobs:
release/**/*.AppImage
release/**/*.zsync
release/**/*.deb
release/**/*.pacman
retention-days: 30
4 changes: 3 additions & 1 deletion electron-builder.json5
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@
},
"linux": {
"target": [
"AppImage"
"AppImage",
"deb",
"pacman"
],
"icon": "icons/icons/png",
"artifactName": "${productName}-Linux-${version}.${ext}",
Expand Down
121 changes: 76 additions & 45 deletions electron/ipc/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,21 @@ function isPathAllowed(filePath: string): boolean {
return getAllowedReadDirs().some((dir) => isPathWithinDir(resolved, dir));
}

/**
* Helper function to build dialog options with a parent window only when it's valid.
* This prevents passing stale or destroyed BrowserWindow references to dialog calls.
*/
function buildDialogOptions<T extends Electron.OpenDialogOptions | Electron.SaveDialogOptions>(
baseOptions: T,
parentWindow: BrowserWindow | null,
): T & { parent?: BrowserWindow } {
const mainWindow = parentWindow;
if (mainWindow && !mainWindow.isDestroyed()) {
return { ...baseOptions, parent: mainWindow };
}
return baseOptions;
}

function hasAllowedImportVideoExtension(filePath: string): boolean {
return ALLOWED_IMPORT_VIDEO_EXTENSIONS.has(path.extname(filePath).toLowerCase());
}
Expand Down Expand Up @@ -834,14 +849,18 @@ export function registerIpcHandlers(
? [{ name: mainT("dialogs", "fileDialogs.gifImage"), extensions: ["gif"] }]
: [{ name: mainT("dialogs", "fileDialogs.mp4Video"), extensions: ["mp4"] }];

const result = await dialog.showSaveDialog({
title: isGif
? mainT("dialogs", "fileDialogs.saveGif")
: mainT("dialogs", "fileDialogs.saveVideo"),
defaultPath: path.join(app.getPath("downloads"), fileName),
filters,
properties: ["createDirectory", "showOverwriteConfirmation"],
});
const dialogOptions = buildDialogOptions(
{
title: isGif
? mainT("dialogs", "fileDialogs.saveGif")
: mainT("dialogs", "fileDialogs.saveVideo"),
defaultPath: path.join(app.getPath("downloads"), fileName),
filters,
properties: ["createDirectory", "showOverwriteConfirmation"],
},
getMainWindow(),
);
const result = await dialog.showSaveDialog(dialogOptions);

if (result.canceled || !result.filePath) {
return {
Expand Down Expand Up @@ -876,18 +895,22 @@ export function registerIpcHandlers(
});
ipcMain.handle("open-video-file-picker", async () => {
try {
const result = await dialog.showOpenDialog({
title: mainT("dialogs", "fileDialogs.selectVideo"),
defaultPath: RECORDINGS_DIR,
filters: [
{
name: mainT("dialogs", "fileDialogs.videoFiles"),
extensions: ["webm", "mp4", "mov", "avi", "mkv"],
},
{ name: mainT("dialogs", "fileDialogs.allFiles"), extensions: ["*"] },
],
properties: ["openFile"],
});
const dialogOptions = buildDialogOptions(
{
title: mainT("dialogs", "fileDialogs.selectVideo"),
defaultPath: RECORDINGS_DIR,
filters: [
{
name: mainT("dialogs", "fileDialogs.videoFiles"),
extensions: ["webm", "mp4", "mov", "avi", "mkv"],
},
{ name: mainT("dialogs", "fileDialogs.allFiles"), extensions: ["*"] },
],
properties: ["openFile"],
},
getMainWindow(),
);
const result = await dialog.showOpenDialog(dialogOptions);

if (result.canceled || result.filePaths.length === 0) {
return { success: false, canceled: true };
Expand Down Expand Up @@ -966,18 +989,22 @@ export function registerIpcHandlers(
? safeName
: `${safeName}.${PROJECT_FILE_EXTENSION}`;

const result = await dialog.showSaveDialog({
title: mainT("dialogs", "fileDialogs.saveProject"),
defaultPath: path.join(RECORDINGS_DIR, defaultName),
filters: [
{
name: mainT("dialogs", "fileDialogs.openscreenProject"),
extensions: [PROJECT_FILE_EXTENSION],
},
{ name: "JSON", extensions: ["json"] },
],
properties: ["createDirectory", "showOverwriteConfirmation"],
});
const dialogOptions = buildDialogOptions(
{
title: mainT("dialogs", "fileDialogs.saveProject"),
defaultPath: path.join(RECORDINGS_DIR, defaultName),
filters: [
{
name: mainT("dialogs", "fileDialogs.openscreenProject"),
extensions: [PROJECT_FILE_EXTENSION],
},
{ name: "JSON", extensions: ["json"] },
],
properties: ["createDirectory", "showOverwriteConfirmation"],
},
getMainWindow(),
);
const result = await dialog.showSaveDialog(dialogOptions);

if (result.canceled || !result.filePath) {
return {
Expand Down Expand Up @@ -1008,19 +1035,23 @@ export function registerIpcHandlers(

ipcMain.handle("load-project-file", async () => {
try {
const result = await dialog.showOpenDialog({
title: mainT("dialogs", "fileDialogs.openProject"),
defaultPath: RECORDINGS_DIR,
filters: [
{
name: mainT("dialogs", "fileDialogs.openscreenProject"),
extensions: [PROJECT_FILE_EXTENSION],
},
{ name: "JSON", extensions: ["json"] },
{ name: mainT("dialogs", "fileDialogs.allFiles"), extensions: ["*"] },
],
properties: ["openFile"],
});
const dialogOptions = buildDialogOptions(
{
title: mainT("dialogs", "fileDialogs.openProject"),
defaultPath: RECORDINGS_DIR,
filters: [
{
name: mainT("dialogs", "fileDialogs.openscreenProject"),
extensions: [PROJECT_FILE_EXTENSION],
},
{ name: "JSON", extensions: ["json"] },
{ name: mainT("dialogs", "fileDialogs.allFiles"), extensions: ["*"] },
],
properties: ["openFile"],
},
getMainWindow(),
);
const result = await dialog.showOpenDialog(dialogOptions);

if (result.canceled || result.filePaths.length === 0) {
return { success: false, canceled: true, message: "Open project canceled" };
Expand Down
12 changes: 12 additions & 0 deletions electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ if (process.platform === "darwin") {
app.commandLine.appendSwitch("disable-features", "MacCatapLoopbackAudioForScreenShare");
}

// Enable Wayland support for proper screen capture and window management
// on Wayland compositors (Hyprland, GNOME, KDE, etc.)
if (process.platform === "linux") {
const isWayland =
process.env.XDG_SESSION_TYPE === "wayland" || process.env.WAYLAND_DISPLAY !== undefined;
if (isWayland) {
app.commandLine.appendSwitch("ozone-platform", "wayland");
// Enable WebRTCPipeWireCapturer for screen capture on Wayland
app.commandLine.appendSwitch("enable-features", "WaylandWindowDrag,WebRTCPipeWireCapturer");
}
}

export const RECORDINGS_DIR = path.join(app.getPath("userData"), "recordings");

async function ensureRecordingsDir() {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"preview": "vite preview",
"build:mac": "tsc && vite build && electron-builder --mac",
"build:win": "tsc && vite build && electron-builder --win",
"build:linux": "tsc && vite build && electron-builder --linux AppImage deb",
"build:linux": "tsc && vite build && electron-builder --linux AppImage deb pacman",
Comment thread
siddharthvaddem marked this conversation as resolved.
"test": "vitest --run",
"test:watch": "vitest",
"build-vite": "tsc && vite build",
Expand Down
Loading