Skip to content

Commit a8dd3d9

Browse files
SDA-4865 - Fix screen picker window focus issue (#2367)
* SDA-4865 - Fix focus issue * SDA-4865 - Close existing indicator * SDA-4865 - Move top on focus * SDA-4865 - Set always on top on focus * SDA-4865 - Set always on top on select screen
1 parent 48b83d8 commit a8dd3d9

1 file changed

Lines changed: 25 additions & 15 deletions

File tree

src/app/display-media-request-handler.ts

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
import {
2-
BaseWindow,
3-
BrowserWindow,
4-
desktopCapturer,
5-
ipcMain,
6-
session,
7-
} from 'electron';
1+
import { BrowserWindow, desktopCapturer, ipcMain, session } from 'electron';
82
import { NOTIFICATION_WINDOW_TITLE } from '../common/api-interface';
93
import { isDevEnv, isMac, isWindowsOS } from '../common/env';
104
import { logger } from '../common/logger';
@@ -48,7 +42,6 @@ class DisplayMediaRequestHandler {
4842
width: 580,
4943
show: false,
5044
fullscreenable: false,
51-
parent: windowHandler.getMainWindow() as BaseWindow,
5245
},
5346
{ devTools: isDevEnv },
5447
);
@@ -57,11 +50,7 @@ class DisplayMediaRequestHandler {
5750
'screen-picker',
5851
browserWindowOptions,
5952
);
60-
61-
this.screenPickerWindow.on('blur', () => {
62-
this.screenPickerWindow?.setAlwaysOnTop(true);
63-
this.screenPickerWindow?.focus();
64-
});
53+
windowHandler.moveWindow(this.screenPickerWindow);
6554

6655
this.screenPickerWindow.on('closed', () => {
6756
this.screenPickerWindow = null;
@@ -78,6 +67,16 @@ class DisplayMediaRequestHandler {
7867
}
7968
});
8069

70+
this.screenPickerWindow.on('focus', () => {
71+
if (
72+
this.screenPickerWindow &&
73+
windowExists(this.screenPickerWindow)
74+
) {
75+
this.screenPickerWindow.setAlwaysOnTop(true);
76+
this.screenPickerWindow.moveTop();
77+
}
78+
});
79+
8180
this.screenPickerWindow.webContents.once('did-finish-load', () => {
8281
if (!this.screenPickerWindow) {
8382
return;
@@ -94,8 +93,19 @@ class DisplayMediaRequestHandler {
9493
mainWebContents.send('screen-picker-data', updatedSources);
9594

9695
ipcMain.on('screen-source-select', (_event, source) => {
97-
if (source) {
98-
windowHandler.drawScreenShareIndicatorFrame(source);
96+
if (source != null) {
97+
windowHandler.closeScreenSharingIndicator();
98+
const timeoutValue = 300;
99+
setTimeout(() => {
100+
windowHandler.drawScreenShareIndicatorFrame(source);
101+
if (
102+
this.screenPickerWindow &&
103+
windowExists(this.screenPickerWindow)
104+
) {
105+
this.screenPickerWindow.setAlwaysOnTop(true);
106+
this.screenPickerWindow.moveTop();
107+
}
108+
}, timeoutValue);
99109
}
100110
logger.info('display-media-request-handler: source selected', source);
101111
});

0 commit comments

Comments
 (0)