mirror of
https://github.com/SteamDeckHomebrew/decky-loader.git
synced 2026-06-17 00:37:49 +00:00
Merge Tabs and Injection Fixes, bring back native Valve toaster (#238)
* Bring back component patch-based tabshook * better injection point * finally fix dumb loading error * fix QAM injection breaking after lock * shut up typescript * fix lock screen focusing issues * Bring back the Valve toaster! * Add support for stable steamos * fix focus bug on lock screen but actually * oops: remove extra console log * shut up typescript again * better fix for lockscreen bug * better probably * actually fix focus issues (WTF) Co-authored-by: AAGaming <aa@mail.catvibers.me>
This commit is contained in:
@@ -1,27 +1,21 @@
|
||||
import { FC, createContext, useContext, useEffect, useRef, useState } from 'react';
|
||||
import { FC, createContext, useContext, useState } from 'react';
|
||||
|
||||
const QuickAccessVisibleState = createContext<boolean>(true);
|
||||
|
||||
export const useQuickAccessVisible = () => useContext(QuickAccessVisibleState);
|
||||
|
||||
export const QuickAccessVisibleStateProvider: FC<{}> = ({ children }) => {
|
||||
const divRef = useRef<HTMLDivElement>(null);
|
||||
const [visible, setVisible] = useState<boolean>(false);
|
||||
useEffect(() => {
|
||||
const doc: Document | void | null = divRef?.current?.ownerDocument;
|
||||
if (!doc) return;
|
||||
setVisible(doc.visibilityState == 'visible');
|
||||
const onChange = (e: Event) => {
|
||||
setVisible(doc.visibilityState == 'visible');
|
||||
};
|
||||
doc.addEventListener('visibilitychange', onChange);
|
||||
return () => {
|
||||
doc.removeEventListener('visibilitychange', onChange);
|
||||
};
|
||||
}, [divRef]);
|
||||
return (
|
||||
<div ref={divRef}>
|
||||
<QuickAccessVisibleState.Provider value={visible}>{children}</QuickAccessVisibleState.Provider>
|
||||
</div>
|
||||
);
|
||||
export const QuickAccessVisibleStateProvider: FC<{ initial: boolean; setter: ((val: boolean) => {}[]) | never[] }> = ({
|
||||
children,
|
||||
initial,
|
||||
setter,
|
||||
}) => {
|
||||
const [visible, setVisible] = useState<boolean>(initial);
|
||||
const [prev, setPrev] = useState<boolean>(initial);
|
||||
// hack to use an array as a "pointer" to pass the setter up the tree
|
||||
setter[0] = setVisible;
|
||||
if (initial != prev) {
|
||||
setPrev(initial);
|
||||
setVisible(initial);
|
||||
}
|
||||
return <QuickAccessVisibleState.Provider value={visible}>{children}</QuickAccessVisibleState.Provider>;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user