Remove unused screen share methods (#2445)

This commit is contained in:
Axel Eriksson authored and GitHub committed 2025-09-01 10:16:04 +02:00
1 parent dc72015753
commit 8f5034f4f7
5 files changed
-190

No files matched your search

-13
View File
@@ -102,7 +102,6 @@ jest.mock('../src/app/window-handler', () => {
closeAllWindows: jest.fn(),
closeWindow: jest.fn(),
createNotificationSettingsWindow: jest.fn(),
createScreenPickerWindow: jest.fn(),
createScreenSharingIndicatorWindow: jest.fn(),
isOnline: false,
updateVersionInfo: jest.fn(),
@@ -399,18 +398,6 @@ describe('main api handler', () => {
expect(spy).toBeCalledWith(...expectedValue);
});
it('should call `openScreenPickerWindow` correctly', () => {
const spy = jest.spyOn(windowHandler, 'createScreenPickerWindow');
const value = {
cmd: apiCmds.openScreenPickerWindow,
sources: [],
id: 3,
};
const expectedValue = [{ send: expect.any(Function) }, [], 3];
ipcMain.send(apiName.symphonyApi, value);
expect(spy).toBeCalledWith(...expectedValue);
});
it('should call `popupMenu` correctly', () => {
const fromWebContentsMocked = {
isDestroyed: jest.fn(),
-32
View File
@@ -219,15 +219,6 @@ ipcMain.on(
}
}
break;
case apiCmds.openScreenPickerWindow:
if (Array.isArray(arg.sources) && typeof arg.id === 'number') {
windowHandler.createScreenPickerWindow(
event.sender,
arg.sources,
arg.id,
);
}
break;
case apiCmds.popupMenu: {
const browserWin = BrowserWindow.fromWebContents(
event.sender,
@@ -308,7 +299,6 @@ ipcMain.on(
appStateHandler.preventDisplaySleep(arg.isInMeeting);
if (!arg.isInMeeting) {
displayMediaRequestHandler.closeScreenPickerWindow();
windowHandler.closeScreenPickerWindow();
windowHandler.closeScreenSharingIndicator();
}
}
@@ -711,28 +701,6 @@ const logApiCallParams = (arg: any) => {
)}`,
);
break;
case apiCmds.openScreenPickerWindow:
const sources = arg.sources.map((source: any) => {
return {
name: source.name,
id: source.id,
thumbnail: 'hidden',
display_id: source.display_id,
appIcon: source.appIcon,
};
});
const openScreenPickerDetails = {
...arg,
sources,
};
logger.info(
`main-api-handler: - ${apiCmd} - Properties: ${JSON.stringify(
openScreenPickerDetails,
null,
2,
)}`,
);
break;
case apiCmds.sendLogs:
const logFiles = 'hidden';
const logDetails = {
-143
View File
@@ -4,7 +4,6 @@ import {
BrowserWindow,
BrowserWindowConstructorOptions,
crashReporter,
DesktopCapturerSource,
dialog,
Event,
ipcMain,
@@ -200,7 +199,6 @@ export class WindowHandler {
private mainWindow: ICustomBrowserWindow | null = null;
private aboutAppWindow: Electron.BrowserWindow | null = null;
private screenPickerWindow: Electron.BrowserWindow | null = null;
private screenPickerPlaceholderWindow: Electron.BrowserWindow | null = null;
private screenSharingIndicatorWindow: Electron.BrowserWindow | null = null;
private screenSharingFrameWindow: Electron.BrowserWindow | null = null;
private basicAuthWindow: Electron.BrowserWindow | null = null;
@@ -1051,12 +1049,6 @@ export class WindowHandler {
}
break;
case 'screen-sharing-indicator':
if (
this.screenPickerPlaceholderWindow &&
windowExists(this.screenPickerPlaceholderWindow)
) {
this.screenPickerPlaceholderWindow.close();
}
if (winKey) {
const browserWindow = this.windows[winKey];
@@ -1608,141 +1600,6 @@ export class WindowHandler {
}
}
/**
* Creates a screen picker window
*
* @param window
* @param sources
* @param id
*/
public createScreenPickerWindow(
window: WebContents,
sources: DesktopCapturerSource[],
id: number,
): void {
if (this.screenPickerWindow && windowExists(this.screenPickerWindow)) {
this.screenPickerWindow.close();
}
const opts: ICustomBrowserWindowConstructorOpts = this.getWindowOpts(
{
alwaysOnTop: true,
autoHideMenuBar: true,
frame: false,
modal: false,
height: isMac ? 519 : 523,
width: 580,
show: false,
fullscreenable: false,
},
{
devTools: isDevEnv,
},
);
this.screenPickerWindow = createComponentWindow('screen-picker', opts);
this.moveWindow(this.screenPickerWindow);
this.screenPickerWindow.webContents.once('did-finish-load', () => {
if (!this.screenPickerWindow || !windowExists(this.screenPickerWindow)) {
return;
}
this.screenPickerWindow.webContents.setZoomFactor(1);
this.screenPickerWindow.webContents.setVisualZoomLevelLimits(1, 1);
this.screenPickerWindow.webContents.send('screen-picker-data', {
sources,
id,
});
this.addWindow(opts.winKey, this.screenPickerWindow);
});
const screenSourceSelect = (_event, source) => {
if (source != null) {
logger.info(`window-handler: screen-source-select`, source, id);
this.closeScreenSharingIndicator();
const timeoutValue = 300;
setTimeout(() => {
this.drawScreenShareIndicatorFrame(source);
if (isMac) {
const windows = BrowserWindow.getAllWindows();
windows.map((window: BrowserWindow) => {
if (window.getMediaSourceId() === source.id) {
window.show();
}
});
}
}, timeoutValue);
}
};
ipcMain.on('screen-source-select', screenSourceSelect);
ipcMain.once('screen-source-selected', (_event, source) => {
logger.info(`window-handler: screen-source-selected`, source, id);
if (source == null) {
this.closeScreenSharingIndicator();
if (
this.screenPickerPlaceholderWindow &&
windowExists(this.screenPickerPlaceholderWindow)
) {
this.screenPickerPlaceholderWindow.close();
this.screenPickerPlaceholderWindow = null;
}
} else {
// SDA-3646 hack for macOS: whenever we try to close the penultimate window (here screensharing screen picker), Electron activates the last Electron window
// This behaviour was observed while trying to upgrade from Electron 14 to Electron 17
// Here the hack to solve that issue is to create a new invisible BrowserWindow.
this.screenPickerPlaceholderWindow = new BrowserWindow({
title: 'Screen sharing - Symphony',
width: 0,
height: 0,
transparent: true,
frame: false,
x: 0,
y: 0,
resizable: false,
movable: false,
fullscreenable: false,
roundedCorners: isWindows11 || isMac ? true : false,
thickFrame: isWindowsOS ? false : true,
});
this.screenPickerPlaceholderWindow.show();
}
window.send('start-share' + id, source);
if (this.screenPickerWindow && windowExists(this.screenPickerWindow)) {
// SDA-3635 hack
setTimeout(() => this.screenPickerWindow?.close(), 500);
}
});
this.screenPickerWindow.once('closed', () => {
ipcMain.removeListener('screen-source-select', screenSourceSelect);
this.removeWindow(opts.winKey);
this.screenPickerWindow = null;
if (isWindowsOS) {
if (
this.screenPickerPlaceholderWindow &&
windowExists(this.screenPickerPlaceholderWindow)
) {
this.screenPickerPlaceholderWindow.close();
this.screenPickerPlaceholderWindow = null;
}
}
});
}
/**
* Closes a screen picker window if it exists
*
*/
public closeScreenPickerWindow() {
if (this.screenPickerWindow && windowExists(this.screenPickerWindow)) {
this.screenPickerWindow.close();
}
}
/**
* Closes screen sharing indicator
*
-1
View File
@@ -20,7 +20,6 @@ export enum apiCmds {
showNotificationSettings = 'show-notification-settings',
sanitize = 'sanitize',
bringToFront = 'bring-to-front',
openScreenPickerWindow = 'open-screen-picker-window',
popupMenu = 'popup-menu',
optimizeMemoryConsumption = 'optimize-memory-consumption',
optimizeMemoryRegister = 'optimize-memory-register',
-1
View File
@@ -572,7 +572,6 @@ Writes some thing to the file</textarea
showNotificationSettings: 'show-notification-settings',
sanitize: 'sanitize',
bringToFront: 'bring-to-front',
openScreenPickerWindow: 'open-screen-picker-window',
popupMenu: 'popup-menu',
optimizeMemoryConsumption: 'optimize-memory-consumption',
optimizeMemoryRegister: 'optimize-memory-register',