diff options
| author | AAGaming <aa@mail.catvibers.me> | 2022-10-02 10:29:33 -0400 |
|---|---|---|
| committer | AAGaming <aa@mail.catvibers.me> | 2022-10-02 10:29:33 -0400 |
| commit | 19d5527bdfe2a1de9719dc4df838b22aed254797 (patch) | |
| tree | 73ee8b84409cbbca098bcbf828c83bf71784e784 /frontend/src/plugin-loader.tsx | |
| parent | ef51b96f082e63abb1db1f8eb5e0ba88e64d82a7 (diff) | |
| download | decky-loader-19d5527bdfe2a1de9719dc4df838b22aed254797.tar.gz decky-loader-19d5527bdfe2a1de9719dc4df838b22aed254797.zip | |
ACTUALLY FIX the friends focus workaround
Diffstat (limited to 'frontend/src/plugin-loader.tsx')
| -rw-r--r-- | frontend/src/plugin-loader.tsx | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/frontend/src/plugin-loader.tsx b/frontend/src/plugin-loader.tsx index b6df5a1f..e7fc7031 100644 --- a/frontend/src/plugin-loader.tsx +++ b/frontend/src/plugin-loader.tsx @@ -1,4 +1,16 @@ -import { ConfirmModal, ModalRoot, QuickAccessTab, Router, showModal, sleep, staticClasses } from 'decky-frontend-lib'; +import { + ConfirmModal, + ModalRoot, + Patch, + QuickAccessTab, + Router, + callOriginal, + findModuleChild, + replacePatch, + showModal, + sleep, + staticClasses, +} from 'decky-frontend-lib'; import { lazy } from 'react'; import { FaPlug } from 'react-icons/fa'; @@ -39,6 +51,8 @@ class PluginLoader extends Logger { // stores a list of plugin names which requested to be reloaded private pluginReloadQueue: { name: string; version?: string }[] = []; + private focusWorkaroundPatch?: Patch; + constructor() { super(PluginLoader.name); this.log('Initialized'); @@ -83,6 +97,38 @@ class PluginLoader extends Logger { initFilepickerPatches(); this.updateVersion(); + + const self = this; + + try { + // TODO remove all of this once Valve fixes the bug + const focusManager = findModuleChild((m) => { + if (typeof m !== 'object') return false; + for (let prop in m) { + if (m[prop]?.prototype?.TakeFocus) return m[prop]; + } + return false; + }); + + this.focusWorkaroundPatch = replacePatch(focusManager.prototype, 'TakeFocus', function () { + // @ts-ignore + const classList = this.m_node?.m_element.classList; + if ( + // @ts-ignore + (this.m_node?.m_element && classList.contains(staticClasses.TabGroupPanel)) || + classList.contains('FriendsListTab') || + classList.contains('FriendsTabList') || + classList.contains('FriendsListAndChatsSteamDeck') + ) { + self.debug('Intercepted friends re-focus'); + return true; + } + + return callOriginal; + }); + } catch (e) { + this.error('Friends focus patch failed', e); + } } public async updateVersion() { @@ -167,6 +213,7 @@ class PluginLoader extends Logger { this.routerHook.removeRoute('/decky/store'); this.routerHook.removeRoute('/decky/settings'); deinitFilepickerPatches(); + this.focusWorkaroundPatch?.unpatch(); } public unloadPlugin(name: string) { |
