diff --git a/src/equicordplugins/instantScreenshare/index.tsx b/src/equicordplugins/instantScreenshare/index.tsx index 322b61f7b..abc3e0c02 100644 --- a/src/equicordplugins/instantScreenshare/index.tsx +++ b/src/equicordplugins/instantScreenshare/index.tsx @@ -11,7 +11,7 @@ import { Devs, EquicordDevs } from "@utils/constants"; import definePlugin from "@utils/types"; import { VoiceState } from "@vencord/discord-types"; import { findByCodeLazy, findStoreLazy } from "@webpack"; -import { ChannelStore, MediaEngineStore, PermissionsBits, PermissionStore, SelectedChannelStore, showToast, Toasts, UserStore, VoiceActions } from "@webpack/common"; +import { ChannelStore, MediaEngineStore, PermissionsBits, PermissionStore, SelectedChannelStore, showToast, Toasts, UserStore, VoiceActions, WindowStore } from "@webpack/common"; import { getCurrentMedia, settings } from "./utils"; @@ -21,6 +21,7 @@ const StreamPreviewSettings = getUserSettingLazy("voiceAndVideo", "disableStream const ApplicationStreamingSettingsStore = findStoreLazy("ApplicationStreamingSettingsStore"); async function autoStartStream(instant = true) { + if (!instant && !WindowStore.isFocused() && settings.store.focusDiscord) return; const selected = SelectedChannelStore.getVoiceChannelId(); if (!selected) return; @@ -89,7 +90,7 @@ export default definePlugin({ predicate: () => settings.store.keybindScreenshare, replacement: { match: /\[\i\.\i\.DISCONNECT_FROM_VOICE_CHANNEL/, - replace: '["INSTANT_SCREEN_SHARE"]:{onTrigger(){$self.autoStartStream(false)},keyEvents:{keyUp:!1,keyDown:!0,blurred:!1,focused:!0}},$&' + replace: '["INSTANT_SCREEN_SHARE"]:{onTrigger(){$self.autoStartStream(false)},keyEvents:{keyUp:!1,keyDown:!0}},$&' }, }, { diff --git a/src/equicordplugins/instantScreenshare/utils.tsx b/src/equicordplugins/instantScreenshare/utils.tsx index 36a0756af..b6dbbece8 100644 --- a/src/equicordplugins/instantScreenshare/utils.tsx +++ b/src/equicordplugins/instantScreenshare/utils.tsx @@ -53,12 +53,17 @@ export const settings = definePluginSettings({ restartNeeded: true, default: false, }, + focusDiscord: { + type: OptionType.BOOLEAN, + description: "Only start screenshare with keybind when Discord is focused", + default: true, + }, toolboxManagement: { type: OptionType.BOOLEAN, description: "Enable/Disable Instant Screenshare", default: true, hidden: true, - } + }, }); export async function getCurrentMedia() {