Handle full-screen capture IPC and reregister Screenshot Assist when its shortcut changes.

This commit is contained in:
CREDO23 2026-04-27 18:49:33 +02:00
parent f489fee2e8
commit 1c7362d9c6

View file

@ -2,10 +2,12 @@ import { app, ipcMain, shell } from 'electron';
import { IPC_CHANNELS } from './channels'; import { IPC_CHANNELS } from './channels';
import { import {
getPermissionsStatus, getPermissionsStatus,
hasScreenRecordingPermission,
requestAccessibility, requestAccessibility,
requestScreenRecording, requestScreenRecording,
restartApp, restartApp,
} from '../modules/permissions'; } from '../modules/permissions';
import { captureCurrentDisplayDataUrl } from '../modules/screen-region-picker';
import { import {
selectFolder, selectFolder,
addWatchedFolder, addWatchedFolder,
@ -27,7 +29,7 @@ import { getShortcuts, setShortcuts, type ShortcutConfig } from '../modules/shor
import { getAutoLaunchState, setAutoLaunch } from '../modules/auto-launch'; import { getAutoLaunchState, setAutoLaunch } from '../modules/auto-launch';
import { getActiveSearchSpaceId, setActiveSearchSpaceId } from '../modules/active-search-space'; import { getActiveSearchSpaceId, setActiveSearchSpaceId } from '../modules/active-search-space';
import { reregisterQuickAsk } from '../modules/quick-ask'; import { reregisterQuickAsk } from '../modules/quick-ask';
import { reregisterGeneralAssist } from '../modules/tray'; import { reregisterGeneralAssist, reregisterScreenshotAssist } from '../modules/tray';
import { import {
getDistinctId, getDistinctId,
getMachineId, getMachineId,
@ -78,6 +80,14 @@ export function registerIpcHandlers(): void {
restartApp(); restartApp();
}); });
ipcMain.handle(IPC_CHANNELS.CAPTURE_FULL_SCREEN, async () => {
if (!hasScreenRecordingPermission()) {
requestScreenRecording();
return null;
}
return captureCurrentDisplayDataUrl();
});
// Folder sync handlers // Folder sync handlers
ipcMain.handle(IPC_CHANNELS.FOLDER_SYNC_SELECT_FOLDER, () => selectFolder()); ipcMain.handle(IPC_CHANNELS.FOLDER_SYNC_SELECT_FOLDER, () => selectFolder());
@ -182,6 +192,7 @@ export function registerIpcHandlers(): void {
ipcMain.handle(IPC_CHANNELS.SET_SHORTCUTS, async (_event, config: Partial<ShortcutConfig>) => { ipcMain.handle(IPC_CHANNELS.SET_SHORTCUTS, async (_event, config: Partial<ShortcutConfig>) => {
const updated = await setShortcuts(config); const updated = await setShortcuts(config);
if (config.generalAssist) await reregisterGeneralAssist(); if (config.generalAssist) await reregisterGeneralAssist();
if (config.screenshotAssist) await reregisterScreenshotAssist();
if (config.quickAsk) await reregisterQuickAsk(); if (config.quickAsk) await reregisterQuickAsk();
trackEvent('desktop_shortcut_updated', { trackEvent('desktop_shortcut_updated', {
keys: Object.keys(config), keys: Object.keys(config),