Skip to content

Commit 0c1bc9a

Browse files
committed
feat(screensharing): re-request sources with interval for new windows
Signed-off-by: Grigorii K. Shartsev <me@shgk.me>
1 parent bc7849a commit 0c1bc9a

1 file changed

Lines changed: 27 additions & 1 deletion

File tree

src/talk/renderer/components/DesktopMediaSourceDialog.vue

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
-->
2121

2222
<script setup>
23-
import { computed, onMounted, ref } from 'vue'
23+
import { computed, onBeforeUnmount, onMounted, ref } from 'vue'
2424
2525
import MdiCancel from '@mdi/svg/svg/cancel.svg?raw'
2626
import MdiMonitorShare from '@mdi/svg/svg/monitor-share.svg?raw'
@@ -34,6 +34,13 @@ import DesktopMediaSourcePreview from './DesktopMediaSourcePreview.vue'
3434
3535
const emit = defineEmits(['submit', 'cancel'])
3636
37+
const RE_REQUEST_SOURCES_TIMEOUT = 1000
38+
39+
// On Wayland getting each stream for the live preview requests user to select the source via system dialog again
40+
// Instead - show static images.
41+
// See: https://github.com/electron/electron/issues/27732
42+
const previewType = window.OS.isWayland ? 'thumbnail' : 'live'
43+
3744
const selectedSourceId = ref(null)
3845
const sources = ref(null)
3946
@@ -89,13 +96,32 @@ const handleVideoSuspend = (source) => {
8996
}
9097
}
9198
99+
let reRequestTimeout
100+
101+
const scheduleRequestDesktopCaprutererSources = () => {
102+
reRequestTimeout = setTimeout(async () => {
103+
await requestDesktopCapturerSources()
104+
scheduleRequestDesktopCaprutererSources()
105+
}, RE_REQUEST_SOURCES_TIMEOUT)
106+
}
107+
92108
onMounted(async () => {
93109
await requestDesktopCapturerSources()
94110
95111
// Preselect the first media source if any
96112
if (!selectedSourceId.value) {
97113
selectedSourceId.value = sources.value[0]?.id
98114
}
115+
116+
if (previewType === 'live') {
117+
scheduleRequestDesktopCaprutererSources()
118+
}
119+
})
120+
121+
onBeforeUnmount(() => {
122+
if (reRequestTimeout) {
123+
clearTimeout(reRequestTimeout)
124+
}
99125
})
100126
</script>
101127

0 commit comments

Comments
 (0)