mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-06-10 15:13:32 -07:00
fix(overlay): restore mpv focus and pointer state on macOS (#104)
This commit is contained in:
@@ -417,17 +417,25 @@ test('modal window path makes visible main overlay click-through until modal clo
|
||||
assert.equal(mainWindow.ignoreMouseEvents, true);
|
||||
});
|
||||
|
||||
test('modal window path hides visible main overlay until modal closes', () => {
|
||||
test('modal window path restores visible main overlay before modal input deactivates', () => {
|
||||
const mainWindow = createMockWindow();
|
||||
mainWindow.visible = true;
|
||||
const modalWindow = createMockWindow();
|
||||
const runtime = createOverlayModalRuntimeService({
|
||||
getMainWindow: () => mainWindow as never,
|
||||
getModalWindow: () => modalWindow as never,
|
||||
createModalWindow: () => modalWindow as never,
|
||||
getModalGeometry: () => ({ x: 0, y: 0, width: 400, height: 300 }),
|
||||
setModalWindowBounds: () => {},
|
||||
});
|
||||
const events: string[] = [];
|
||||
const runtime = createOverlayModalRuntimeService(
|
||||
{
|
||||
getMainWindow: () => mainWindow as never,
|
||||
getModalWindow: () => modalWindow as never,
|
||||
createModalWindow: () => modalWindow as never,
|
||||
getModalGeometry: () => ({ x: 0, y: 0, width: 400, height: 300 }),
|
||||
setModalWindowBounds: () => {},
|
||||
},
|
||||
{
|
||||
onModalStateChange: (active: boolean): void => {
|
||||
events.push(`state:${active}:visible:${mainWindow.isVisible()}`);
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
runtime.sendToActiveOverlayWindow(
|
||||
'youtube:picker-open',
|
||||
@@ -444,8 +452,88 @@ test('modal window path hides visible main overlay until modal closes', () => {
|
||||
|
||||
runtime.handleOverlayModalClosed('youtube-track-picker');
|
||||
|
||||
assert.equal(mainWindow.getShowCount(), 0);
|
||||
assert.equal(mainWindow.isVisible(), false);
|
||||
assert.equal(mainWindow.getShowCount(), 1);
|
||||
assert.equal(mainWindow.isVisible(), true);
|
||||
assert.deepEqual(events, ['state:true:visible:true', 'state:false:visible:true']);
|
||||
});
|
||||
|
||||
test('modal window path runs final close handoff before modal input deactivates', () => {
|
||||
const mainWindow = createMockWindow();
|
||||
mainWindow.visible = true;
|
||||
const modalWindow = createMockWindow();
|
||||
const events: string[] = [];
|
||||
const runtime = createOverlayModalRuntimeService(
|
||||
{
|
||||
getMainWindow: () => mainWindow as never,
|
||||
getModalWindow: () => modalWindow as never,
|
||||
createModalWindow: () => modalWindow as never,
|
||||
getModalGeometry: () => ({ x: 0, y: 0, width: 400, height: 300 }),
|
||||
setModalWindowBounds: () => {},
|
||||
},
|
||||
{
|
||||
onFinalModalClosed: (): void => {
|
||||
events.push(`handoff:visible:${mainWindow.isVisible()}`);
|
||||
},
|
||||
onModalStateChange: (active: boolean): void => {
|
||||
events.push(`state:${active}:visible:${mainWindow.isVisible()}`);
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
runtime.sendToActiveOverlayWindow(
|
||||
'youtube:picker-open',
|
||||
{ sessionId: 'yt-1' },
|
||||
{
|
||||
restoreOnModalClose: 'youtube-track-picker',
|
||||
preferModalWindow: true,
|
||||
},
|
||||
);
|
||||
runtime.notifyOverlayModalOpened('youtube-track-picker');
|
||||
runtime.handleOverlayModalClosed('youtube-track-picker');
|
||||
|
||||
assert.deepEqual(events, [
|
||||
'state:true:visible:true',
|
||||
'handoff:visible:true',
|
||||
'state:false:visible:true',
|
||||
]);
|
||||
});
|
||||
|
||||
test('modal runtime deactivates modal state when final close handoff throws', () => {
|
||||
const mainWindow = createMockWindow();
|
||||
mainWindow.visible = true;
|
||||
const modalWindow = createMockWindow();
|
||||
const events: string[] = [];
|
||||
const runtime = createOverlayModalRuntimeService(
|
||||
{
|
||||
getMainWindow: () => mainWindow as never,
|
||||
getModalWindow: () => modalWindow as never,
|
||||
createModalWindow: () => modalWindow as never,
|
||||
getModalGeometry: () => ({ x: 0, y: 0, width: 400, height: 300 }),
|
||||
setModalWindowBounds: () => {},
|
||||
},
|
||||
{
|
||||
onFinalModalClosed: (): void => {
|
||||
events.push('handoff');
|
||||
throw new Error('handoff failed');
|
||||
},
|
||||
onModalStateChange: (active: boolean): void => {
|
||||
events.push(`state:${active}`);
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
runtime.sendToActiveOverlayWindow(
|
||||
'youtube:picker-open',
|
||||
{ sessionId: 'yt-1' },
|
||||
{
|
||||
restoreOnModalClose: 'youtube-track-picker',
|
||||
preferModalWindow: true,
|
||||
},
|
||||
);
|
||||
runtime.notifyOverlayModalOpened('youtube-track-picker');
|
||||
|
||||
assert.doesNotThrow(() => runtime.handleOverlayModalClosed('youtube-track-picker'));
|
||||
assert.deepEqual(events, ['state:true', 'handoff', 'state:false']);
|
||||
});
|
||||
|
||||
test('modal runtime notifies callers when modal input state becomes active/inactive', () => {
|
||||
|
||||
Reference in New Issue
Block a user