mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-11-22 16:46:10 -08:00
fix(controller): pick up macOS presses while mpv is in front (#321)
This commit is contained in:
1 parent
fa3051f9cb
commit
8e29cb3c55
17 files changed
+614
-63
No files matched your search
+39
@@ -35,6 +35,11 @@ import { createDiscordRpcClient } from './main/runtime/discord-rpc-client.js';
|
||||
import { startAppControlServer } from './main/runtime/app-control-server';
|
||||
import { getAppControlSocketPath } from './shared/app-control';
|
||||
import { focusMacOSOverlayWindow } from './main/runtime/macos-overlay-window-focus';
|
||||
import {
|
||||
handleBackgroundControllerPress,
|
||||
resolveMacOSControllerWatchCommand,
|
||||
startMacOSControllerWatch,
|
||||
} from './main/runtime/macos-controller-watch';
|
||||
import { restoreMacOSMpvFocusAfterModalClose } from './main/runtime/macos-modal-focus-handoff';
|
||||
import {
|
||||
getDefaultPasswordStore,
|
||||
@@ -2417,3 +2422,37 @@ registerSubtitleGenerationIpc({
|
||||
openModal: () => openSubtitleGenerationModal(overlayModals.createOverlayHostedModalOpenDeps()),
|
||||
});
|
||||
app.on('before-quit', () => subtitleGenerationRuntime.cancel());
|
||||
|
||||
if (process.platform === 'darwin') {
|
||||
void app.whenReady().then(() => {
|
||||
const command = resolveMacOSControllerWatchCommand({
|
||||
resourcesPath: process.resourcesPath,
|
||||
mainDirname: __dirname,
|
||||
});
|
||||
if (!command) {
|
||||
logger.warn('macOS controller watch helper not found; controller needs overlay focus');
|
||||
return;
|
||||
}
|
||||
const controllerWatch = startMacOSControllerWatch({
|
||||
command,
|
||||
logger,
|
||||
onPress: (press) =>
|
||||
handleBackgroundControllerPress(press, {
|
||||
isControllerEnabled: () => configService.getConfig().controller.enabled,
|
||||
isMpvFocused: () => appState.windowTracker?.isTargetWindowFocused() ?? false,
|
||||
getModalWindow: () => overlayManager.getModalWindow(),
|
||||
getMainWindow: () => overlayManager.getMainWindow(),
|
||||
focusWindow: (window) =>
|
||||
focusMacOSOverlayWindow({
|
||||
platform: process.platform,
|
||||
getOverlayWindow: () => window,
|
||||
stealAppFocus: () => app.focus({ steal: true }),
|
||||
warn: (message, details) => logger.warn(message, details),
|
||||
}),
|
||||
replayPress: (window, index) =>
|
||||
window.webContents.send(IPC_CHANNELS.event.controllerBackgroundPress, index),
|
||||
}),
|
||||
});
|
||||
app.on('will-quit', () => controllerWatch.stop());
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user