Skip to content

Commit

Permalink
Temporary workaround for screensharing in wayland
Browse files Browse the repository at this point in the history
  • Loading branch information
jijojosephk committed Jul 20, 2023
1 parent 281877f commit 5f3ffe4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
20 changes: 18 additions & 2 deletions app/browser/tools/chromeApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,33 @@ const disableAutogain = require('./disableAutogain');
// In new versions of electron, contextIsolation is set to true by default.
// We should explicitly set it to false when creating BrowserWindow

var _getDisplayMedia;

function init(config) {
window.addEventListener('DOMContentLoaded', () => {
MediaDevices.prototype.getDisplayMedia = customGetDisplayMedia;
if (process.env.XDG_SESSION_TYPE === 'wayland') {
_getDisplayMedia = navigator.mediaDevices.getDisplayMedia;
navigator.mediaDevices.getDisplayMedia = customGetDisplayMediaWayland;
} else {
MediaDevices.prototype.getDisplayMedia = customGetDisplayMediaX11;
}

if (config.disableAutogain) {
disableAutogain();
}
});
}

function customGetDisplayMedia() {
async function customGetDisplayMediaWayland(...args) {
var displaySurface = 'monitor';
if (confirm('Press OK for windows Cancel for monitors?')) {
displaySurface = 'window';
}
args[0].video = { displaySurface };
return _getDisplayMedia.apply(navigator.mediaDevices, args);
}

function customGetDisplayMediaX11() {
return new Promise((resolve, reject) => {
// Request main process to allow access to screen sharing
ipcRenderer.once('select-source', (event, source) => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "teams-for-linux",
"version": "1.2.7",
"version": "1.2.8",
"main": "app/index.js",
"description": "Unofficial client for Microsoft Teams for Linux",
"homepage": "https://github.com/IsmaelMartinez/teams-for-linux",
Expand Down

0 comments on commit 5f3ffe4

Please sign in to comment.