From 4566538e1236a358f6ed26565b5a068b53496918 Mon Sep 17 00:00:00 2001 From: "Grigorii K. Shartsev" Date: Fri, 31 Jan 2025 10:34:53 +0100 Subject: [PATCH] perf(screensharing): make live preview optional Signed-off-by: Grigorii K. Shartsev --- src/main.js | 5 +- .../DesktopMediaSourceDialog.vue | 73 ++++++++++++++----- .../DesktopMediaSourcePreview.vue | 62 +++++++++------- .../DesktopMediaSourcePreviewLive.vue | 45 ++++++++++-- 4 files changed, 132 insertions(+), 53 deletions(-) diff --git a/src/main.js b/src/main.js index ccf9e667..52725ca7 100644 --- a/src/main.js +++ b/src/main.js @@ -13,7 +13,7 @@ const { createAuthenticationWindow } = require('./authentication/authentication. const { openLoginWebView } = require('./authentication/login.window.js') const { createHelpWindow } = require('./help/help.window.js') const { createUpgradeWindow } = require('./upgrade/upgrade.window.js') -const { systemInfo, isLinux, isMac, isWayland, isWindows } = require('./app/system.utils.ts') +const { systemInfo, isLinux, isMac, isWindows } = require('./app/system.utils.ts') const { createTalkWindow } = require('./talk/talk.window.js') const { createWelcomeWindow } = require('./welcome/welcome.window.js') const { installVueDevtools } = require('./install-vue-devtools.js') @@ -94,8 +94,7 @@ ipcMain.handle('app:getDesktopCapturerSources', async () => { return null } - // We cannot show live previews on Wayland, so we show thumbnails - const thumbnailWidth = isWayland ? 320 : 0 + const thumbnailWidth = 800 const sources = await desktopCapturer.getSources({ types: ['screen', 'window'], diff --git a/src/talk/renderer/screensharing/DesktopMediaSourceDialog.vue b/src/talk/renderer/screensharing/DesktopMediaSourceDialog.vue index 68de7af7..7244dc3a 100644 --- a/src/talk/renderer/screensharing/DesktopMediaSourceDialog.vue +++ b/src/talk/renderer/screensharing/DesktopMediaSourceDialog.vue @@ -9,8 +9,10 @@ import { computed, ref, watch } from 'vue' import IconCancel from '@mdi/svg/svg/cancel.svg?raw' import IconMonitorShare from '@mdi/svg/svg/monitor-share.svg?raw' import NcDialog from '@nextcloud/vue/dist/Components/NcDialog.js' +import NcDialogButton from '@nextcloud/vue/dist/Components/NcDialogButton.js' import NcEmptyContent from '@nextcloud/vue/dist/Components/NcEmptyContent.js' import NcLoadingIcon from '@nextcloud/vue/dist/Components/NcLoadingIcon.js' +import NcCheckboxRadioSwitch from '@nextcloud/vue/dist/Components/NcCheckboxRadioSwitch.js' import { t } from '@nextcloud/l10n' import { useWindowFocus } from '@vueuse/core' import DesktopMediaSourcePreview from './DesktopMediaSourcePreview.vue' @@ -20,23 +22,14 @@ const emit = defineEmits<{ (event: 'cancel'): void }>() +const livePreview = ref(false) const selectedSourceId = ref(null) const sources = ref(null) -const dialogButtons = computed(() => [ - { - label: t('talk_desktop', 'Cancel'), - icon: IconCancel, - callback: handleCancel, - }, - { - label: t('talk_desktop', 'Share screen'), - type: 'primary', - icon: IconMonitorShare, - disabled: !selectedSourceId.value, - callback: handleSubmit, - }, -]) +const screenSources = computed(() => sources.value?.filter((source) => source.id.startsWith('screen:') || source.id.startsWith('entire-desktop:'))) +const windowSources = computed(() => sources.value?.filter((source) => source.id.startsWith('window:'))) + +const singleSource = computed(() => sources.value && sources.value.length === 1) // On Wayland instead of the list of all available sources, // the system picker is used to have a list of a single selected source. @@ -46,6 +39,7 @@ const dialogButtons = computed(() => [ // - Sources list update is not possible // - There is no the entire-desktop option // See also: https://github.com/electron/electron/issues/27732 +const livePreviewAvailable = !window.systemInfo.isWayland if (!window.systemInfo.isWayland) { const isWindowFocused = useWindowFocus() watch(isWindowFocused, requestDesktopCapturerSources) @@ -125,30 +119,73 @@ function handleCancel() { diff --git a/src/talk/renderer/screensharing/DesktopMediaSourcePreview.vue b/src/talk/renderer/screensharing/DesktopMediaSourcePreview.vue index a62146a2..3c9a55e0 100644 --- a/src/talk/renderer/screensharing/DesktopMediaSourcePreview.vue +++ b/src/talk/renderer/screensharing/DesktopMediaSourcePreview.vue @@ -5,18 +5,15 @@ + +