replace device_query with tauri API so no need for accessibility perm

on darwin
This commit is contained in:
2026-09-06 01:42:36 +08:00
parent 6e1d89f517
commit ce0fb10073
16 changed files with 209 additions and 655 deletions
+18 -33
View File
@@ -2,37 +2,30 @@ use tauri::{AppHandle, Manager, WebviewUrl};
const WINDOW_LABEL: &str = "onboarding";
async fn show(handle: &AppHandle, accessibility_only: bool) -> Result<(), String> {
pub async fn show_initial(handle: &AppHandle) -> Result<(), String> {
if let Some(window) = handle.get_webview_window(WINDOW_LABEL) {
if accessibility_only {
window
.eval("window.location.href = '/onboarding?step=accessibility'")
.map_err(|error| error.to_string())?;
}
window.unminimize().map_err(|error| error.to_string())?;
window.show().map_err(|error| error.to_string())?;
return window.set_focus().map_err(|error| error.to_string());
}
let page = if accessibility_only {
"/onboarding?step=accessibility"
} else {
"/onboarding"
};
let window =
tauri::WebviewWindowBuilder::new(handle, WINDOW_LABEL, WebviewUrl::App(page.into()))
.title(crate::settings::text(
handle,
crate::settings::NativeText::OnboardingTitle,
))
.inner_size(680.0, 520.0)
.min_inner_size(680.0, 520.0)
.transparent(true)
.resizable(false)
.maximizable(false)
.center()
.build()
.map_err(|error| error.to_string())?;
let window = tauri::WebviewWindowBuilder::new(
handle,
WINDOW_LABEL,
WebviewUrl::App("/onboarding".into()),
)
.title(crate::settings::text(
handle,
crate::settings::NativeText::OnboardingTitle,
))
.inner_size(680.0, 520.0)
.min_inner_size(680.0, 520.0)
.transparent(true)
.resizable(false)
.maximizable(false)
.center()
.build()
.map_err(|error| error.to_string())?;
let handle = handle.clone();
window.on_window_event(move |event| {
@@ -44,11 +37,3 @@ async fn show(handle: &AppHandle, accessibility_only: bool) -> Result<(), String
});
Ok(())
}
pub async fn show_initial(handle: &AppHandle) -> Result<(), String> {
show(handle, false).await
}
pub async fn show_accessibility_page(handle: &AppHandle) -> Result<(), String> {
show(handle, true).await
}
+12 -5
View File
@@ -1,4 +1,4 @@
use std::{sync::RwLock, time::Duration};
use std::sync::RwLock;
use serde::Deserialize;
use specta::Type;
@@ -82,15 +82,22 @@ pub const WINDOW_LABEL: &str = "scene";
fn track_scene_hitboxes(app_handle: AppHandle, window: tauri::WebviewWindow) {
tauri::async_runtime::spawn(async move {
let mut ignores_cursor = true;
let mut interval = tokio::time::interval(Duration::from_millis(16));
let mut interval = tokio::time::interval(crate::cursor::SYSTEM_CURSOR_POLL_INTERVAL);
interval.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Skip);
loop {
interval.tick().await;
let cursor = match app_handle.cursor_position() {
Ok(cursor) => cursor,
let cursor = match app_handle
.state::<crate::cursor::CursorPositionProvider>()
.latest()
{
Ok(Some(cursor)) => cursor,
Ok(None) => continue,
Err(error) => {
eprintln!("Failed to read cursor position for scene hit-testing: {error}");
eprintln!(
"Failed to read shared cursor position for scene hit-testing: {error}"
);
continue;
}
};