2020 -->
2121
2222<script setup>
23- import { computed , onMounted , ref } from ' vue'
23+ import { computed , onBeforeUnmount , onMounted , ref } from ' vue'
2424
2525import MdiCancel from ' @mdi/svg/svg/cancel.svg?raw'
2626import MdiMonitorShare from ' @mdi/svg/svg/monitor-share.svg?raw'
@@ -34,6 +34,13 @@ import DesktopMediaSourcePreview from './DesktopMediaSourcePreview.vue'
3434
3535const 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+
3744const selectedSourceId = ref (null )
3845const 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+
92108onMounted (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