[MM-62205] Dynamically toggle widget window visibility when popout opens/closes (#3253)
* Dynamically toggle widget window visibility when popout opens/closes * Improve method naming
This commit is contained in:
@@ -153,6 +153,13 @@ describe('main/windows/callsWidgetWindow', () => {
|
||||
value: originalEnv,
|
||||
});
|
||||
});
|
||||
|
||||
it('widget window visibility should have been toggled', async () => {
|
||||
callsWidgetWindow.onShow();
|
||||
expect(callsWidgetWindow.win.setVisibleOnAllWorkspaces).toHaveBeenCalledWith(true, {skipTransformProcessType: true, visibleOnFullScreen: true});
|
||||
expect(callsWidgetWindow.win.setAlwaysOnTop).toHaveBeenCalledWith(true, 'screen-saver');
|
||||
expect(callsWidgetWindow.win.focus).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('close', () => {
|
||||
@@ -416,7 +423,22 @@ describe('main/windows/callsWidgetWindow', () => {
|
||||
};
|
||||
|
||||
const callsWidgetWindow = new CallsWidgetWindow();
|
||||
callsWidgetWindow.win = {
|
||||
setVisibleOnAllWorkspaces: jest.fn(),
|
||||
setAlwaysOnTop: jest.fn(),
|
||||
focus: jest.fn(),
|
||||
};
|
||||
|
||||
expect(callsWidgetWindow.win.setVisibleOnAllWorkspaces).not.toHaveBeenCalled();
|
||||
expect(callsWidgetWindow.win.setAlwaysOnTop).not.toHaveBeenCalled();
|
||||
|
||||
callsWidgetWindow.onPopOutCreate(popOut);
|
||||
|
||||
// Verify widget visibility has been toggled
|
||||
expect(callsWidgetWindow.win.setVisibleOnAllWorkspaces).toHaveBeenCalledWith(false);
|
||||
expect(callsWidgetWindow.win.setAlwaysOnTop).toHaveBeenCalledWith(false);
|
||||
expect(callsWidgetWindow.win.focus).not.toHaveBeenCalled();
|
||||
|
||||
expect(callsWidgetWindow.popOut).toBe(popOut);
|
||||
expect(WebContentsEventManager.addWebContentsEventListeners).toHaveBeenCalledWith(popOut.webContents);
|
||||
expect(redirectListener).toBeDefined();
|
||||
@@ -433,6 +455,11 @@ describe('main/windows/callsWidgetWindow', () => {
|
||||
closedListener();
|
||||
expect(callsWidgetWindow.popOut).not.toBeDefined();
|
||||
expect(mockContextMenuDispose).toHaveBeenCalled();
|
||||
|
||||
// Verify widget visibility has been toggled
|
||||
expect(callsWidgetWindow.win.setVisibleOnAllWorkspaces).toHaveBeenCalledWith(true, {skipTransformProcessType: true, visibleOnFullScreen: true});
|
||||
expect(callsWidgetWindow.win.setAlwaysOnTop).toHaveBeenCalledWith(true, 'screen-saver');
|
||||
expect(callsWidgetWindow.win.focus).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('getViewURL', () => {
|
||||
|
@@ -233,6 +233,23 @@ export class CallsWidgetWindow {
|
||||
ev.preventDefault();
|
||||
};
|
||||
|
||||
private setWidgetWindowStacking = ({onTop}: {onTop: boolean}) => {
|
||||
log.debug('setWidgetWindowStacking', onTop);
|
||||
|
||||
if (!this.win) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (onTop) {
|
||||
this.win.setVisibleOnAllWorkspaces(true, {visibleOnFullScreen: true, skipTransformProcessType: true});
|
||||
this.win.setAlwaysOnTop(true, 'screen-saver');
|
||||
this.win.focus();
|
||||
} else {
|
||||
this.win.setAlwaysOnTop(false);
|
||||
this.win.setVisibleOnAllWorkspaces(false);
|
||||
}
|
||||
};
|
||||
|
||||
private onShow = () => {
|
||||
log.debug('onShow');
|
||||
const mainWindow = MainWindow.get();
|
||||
@@ -240,9 +257,7 @@ export class CallsWidgetWindow {
|
||||
return;
|
||||
}
|
||||
|
||||
this.win.focus();
|
||||
this.win.setVisibleOnAllWorkspaces(true, {visibleOnFullScreen: true, skipTransformProcessType: true});
|
||||
this.win.setAlwaysOnTop(true, 'screen-saver');
|
||||
this.setWidgetWindowStacking({onTop: true});
|
||||
|
||||
const bounds = this.win.getBounds();
|
||||
const mainBounds = mainWindow.getBounds();
|
||||
@@ -288,6 +303,8 @@ export class CallsWidgetWindow {
|
||||
private onPopOutCreate = (win: BrowserWindow) => {
|
||||
this.popOut = win;
|
||||
|
||||
this.setWidgetWindowStacking({onTop: false});
|
||||
|
||||
// Let the webContentsEventManager handle links that try to open a new window.
|
||||
webContentsEventManager.addWebContentsEventListeners(this.popOut.webContents);
|
||||
|
||||
@@ -304,6 +321,7 @@ export class CallsWidgetWindow {
|
||||
this.popOut.on('closed', () => {
|
||||
delete this.popOut;
|
||||
contextMenu.dispose();
|
||||
this.setWidgetWindowStacking({onTop: true});
|
||||
});
|
||||
|
||||
// Set the userAgent so that the widget's popout is considered a desktop window in the webapp code.
|
||||
|
Reference in New Issue
Block a user