[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,
|
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', () => {
|
describe('close', () => {
|
||||||
@@ -416,7 +423,22 @@ describe('main/windows/callsWidgetWindow', () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const callsWidgetWindow = new 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);
|
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(callsWidgetWindow.popOut).toBe(popOut);
|
||||||
expect(WebContentsEventManager.addWebContentsEventListeners).toHaveBeenCalledWith(popOut.webContents);
|
expect(WebContentsEventManager.addWebContentsEventListeners).toHaveBeenCalledWith(popOut.webContents);
|
||||||
expect(redirectListener).toBeDefined();
|
expect(redirectListener).toBeDefined();
|
||||||
@@ -433,6 +455,11 @@ describe('main/windows/callsWidgetWindow', () => {
|
|||||||
closedListener();
|
closedListener();
|
||||||
expect(callsWidgetWindow.popOut).not.toBeDefined();
|
expect(callsWidgetWindow.popOut).not.toBeDefined();
|
||||||
expect(mockContextMenuDispose).toHaveBeenCalled();
|
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', () => {
|
it('getViewURL', () => {
|
||||||
|
@@ -233,6 +233,23 @@ export class CallsWidgetWindow {
|
|||||||
ev.preventDefault();
|
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 = () => {
|
private onShow = () => {
|
||||||
log.debug('onShow');
|
log.debug('onShow');
|
||||||
const mainWindow = MainWindow.get();
|
const mainWindow = MainWindow.get();
|
||||||
@@ -240,9 +257,7 @@ export class CallsWidgetWindow {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.win.focus();
|
this.setWidgetWindowStacking({onTop: true});
|
||||||
this.win.setVisibleOnAllWorkspaces(true, {visibleOnFullScreen: true, skipTransformProcessType: true});
|
|
||||||
this.win.setAlwaysOnTop(true, 'screen-saver');
|
|
||||||
|
|
||||||
const bounds = this.win.getBounds();
|
const bounds = this.win.getBounds();
|
||||||
const mainBounds = mainWindow.getBounds();
|
const mainBounds = mainWindow.getBounds();
|
||||||
@@ -288,6 +303,8 @@ export class CallsWidgetWindow {
|
|||||||
private onPopOutCreate = (win: BrowserWindow) => {
|
private onPopOutCreate = (win: BrowserWindow) => {
|
||||||
this.popOut = win;
|
this.popOut = win;
|
||||||
|
|
||||||
|
this.setWidgetWindowStacking({onTop: false});
|
||||||
|
|
||||||
// Let the webContentsEventManager handle links that try to open a new window.
|
// Let the webContentsEventManager handle links that try to open a new window.
|
||||||
webContentsEventManager.addWebContentsEventListeners(this.popOut.webContents);
|
webContentsEventManager.addWebContentsEventListeners(this.popOut.webContents);
|
||||||
|
|
||||||
@@ -304,6 +321,7 @@ export class CallsWidgetWindow {
|
|||||||
this.popOut.on('closed', () => {
|
this.popOut.on('closed', () => {
|
||||||
delete this.popOut;
|
delete this.popOut;
|
||||||
contextMenu.dispose();
|
contextMenu.dispose();
|
||||||
|
this.setWidgetWindowStacking({onTop: true});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Set the userAgent so that the widget's popout is considered a desktop window in the webapp code.
|
// 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