control scene interactive state from frontend
This commit is contained in:
@@ -14,7 +14,7 @@ use crate::{
|
||||
},
|
||||
cursor::start_cursor_tracking,
|
||||
doll_editor::open_doll_editor_window,
|
||||
scene::open_splash_window,
|
||||
scene::{open_splash_window, set_scene_interactive},
|
||||
},
|
||||
state::{init_app_data, init_app_data_scoped, AppDataRefreshScope, FDOLL},
|
||||
};
|
||||
@@ -424,6 +424,7 @@ pub fn run() {
|
||||
save_client_config,
|
||||
open_client_config_manager,
|
||||
open_doll_editor_window,
|
||||
set_scene_interactive,
|
||||
start_auth_flow,
|
||||
logout_and_restart
|
||||
])
|
||||
|
||||
@@ -22,7 +22,7 @@ fn scene_interactive_state() -> Arc<AtomicBool> {
|
||||
.clone()
|
||||
}
|
||||
|
||||
fn update_scene_interactive(interactive: bool) {
|
||||
pub fn update_scene_interactive(interactive: bool) {
|
||||
let app_handle = get_app_handle();
|
||||
|
||||
if let Some(window) = app_handle.get_window(SCENE_WINDOW_LABEL) {
|
||||
@@ -38,6 +38,11 @@ fn update_scene_interactive(interactive: bool) {
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn set_scene_interactive(interactive: bool) {
|
||||
update_scene_interactive(interactive);
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
#[link(name = "ApplicationServices", kind = "framework")]
|
||||
extern "C" {
|
||||
@@ -98,17 +103,7 @@ fn start_scene_modifier_listener() {
|
||||
info!("Key down state chanegd!");
|
||||
let previous = state.swap(interactive, Ordering::SeqCst);
|
||||
if previous != interactive {
|
||||
if let Some(window) = app_handle.get_window(SCENE_WINDOW_LABEL) {
|
||||
if let Err(err) = window.set_ignore_cursor_events(!interactive) {
|
||||
error!("Failed to toggle scene cursor events: {}", err);
|
||||
}
|
||||
|
||||
if let Err(err) = window.emit("scene-interactive", &interactive) {
|
||||
error!("Failed to emit scene interactive event: {}", err);
|
||||
}
|
||||
} else {
|
||||
warn!("Scene window not available for interactive update");
|
||||
}
|
||||
update_scene_interactive(interactive);
|
||||
}
|
||||
last_interactive = interactive;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user