mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-04-20 14:38:58 -04:00
move focus event to JS with built-in events
This commit is contained in:
@@ -2,16 +2,6 @@ use tauri::{GlobalWindowEvent, Runtime, Window, Wry};
|
||||
|
||||
pub(crate) fn handle_window_event(event: GlobalWindowEvent<Wry>) {
|
||||
match event.event() {
|
||||
tauri::WindowEvent::Focused(_focus) => {
|
||||
// let fullscreen = event.window().is_fullscreen().unwrap_or(false);
|
||||
|
||||
// println!("fullscreen, {}", fullscreen);
|
||||
|
||||
// #[cfg(target_os = "macos")]
|
||||
// event
|
||||
// .window()
|
||||
// .set_transparent_titlebar(!fullscreen, !fullscreen);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,12 +45,23 @@ function App() {
|
||||
}
|
||||
|
||||
const [platform, setPlatform] = useState<Platform>('macOS');
|
||||
const [focused, setFocused] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
os.platform().then((platform) => setPlatform(getPlatform(platform)));
|
||||
invoke('app_ready');
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const unlistenFocus = listen('tauri://focus', () => setFocused(true));
|
||||
const unlistenBlur = listen('tauri://blur', () => setFocused(false));
|
||||
|
||||
return () => {
|
||||
unlistenFocus.then((unlisten) => unlisten());
|
||||
unlistenBlur.then((unlisten) => unlisten());
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<SpacedriveInterface
|
||||
useMemoryRouter
|
||||
@@ -64,6 +75,7 @@ function App() {
|
||||
}): Promise<string | string[]> {
|
||||
return dialog.open(options);
|
||||
}}
|
||||
isFocused={focused}
|
||||
onClose={() => appWindow.close()}
|
||||
onFullscreen={() => appWindow.setFullscreen(true)}
|
||||
onMinimize={() => appWindow.minimize()}
|
||||
|
||||
@@ -51,6 +51,7 @@ export interface AppProps {
|
||||
onMinimize?: () => void;
|
||||
onFullscreen?: () => void;
|
||||
onOpen?: (path: string) => void;
|
||||
isFocused?: boolean;
|
||||
useMemoryRouter: boolean;
|
||||
demoMode?: boolean;
|
||||
}
|
||||
@@ -214,6 +215,9 @@ export default function App(props: AppProps) {
|
||||
|
||||
console.log('App props', props);
|
||||
|
||||
// default prop values
|
||||
props.isFocused ??= true;
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* @ts-ignore */}
|
||||
|
||||
Reference in New Issue
Block a user