Clean up debug logging spam
- Remove ~101 useless debug print statements from production code - Remove verbose resource debugging and repetitive status messages - Significantly reduce console noise while maintaining error visibility
This commit is contained in:
@@ -11,7 +11,6 @@ pub struct Steam {
|
|||||||
impl Steam {
|
impl Steam {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
let (client, single) = Client::init_app(AppId(1430270)).unwrap();
|
let (client, single) = Client::init_app(AppId(1430270)).unwrap();
|
||||||
println!("Steam client initialized successfully");
|
|
||||||
Self { client, single }
|
Self { client, single }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19,14 +18,12 @@ impl Steam {
|
|||||||
pub fn drop_item(&self) {
|
pub fn drop_item(&self) {
|
||||||
// Placeholder for item drop functionality
|
// Placeholder for item drop functionality
|
||||||
// The actual implementation would use the Steam API to trigger an item drop
|
// The actual implementation would use the Steam API to trigger an item drop
|
||||||
println!("Steam item drop triggered (placeholder)");
|
|
||||||
|
|
||||||
// In a real implementation with the correct API version, we would use:
|
// In a real implementation with the correct API version, we would use:
|
||||||
// self.client.get_inventory().trigger_item_drop(item_def_id);
|
// self.client.get_inventory().trigger_item_drop(item_def_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn shutdown(&self) {
|
pub fn shutdown(&self) {
|
||||||
println!("Steam client shutting down");
|
|
||||||
// The steamworks crate handles cleanup automatically when the client is dropped
|
// The steamworks crate handles cleanup automatically when the client is dropped
|
||||||
// But we can add any additional cleanup logic here if needed
|
// But we can add any additional cleanup logic here if needed
|
||||||
}
|
}
|
||||||
@@ -34,7 +31,6 @@ impl Steam {
|
|||||||
|
|
||||||
impl Drop for Steam {
|
impl Drop for Steam {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
println!("Steam client being dropped, performing cleanup");
|
|
||||||
self.shutdown();
|
self.shutdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,33 +55,24 @@ fn apply_cursor_by_index(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let cursor = &app_state.cursors[index];
|
let cursor = &app_state.cursors[index];
|
||||||
println!("Applying cursor: {} ({})", cursor.name, cursor.path);
|
|
||||||
|
|
||||||
// Verify the file exists
|
// Verify the file exists
|
||||||
if !Path::new(&cursor.path).exists() {
|
if !Path::new(&cursor.path).exists() {
|
||||||
println!("File doesn't exist: {}", cursor.path);
|
|
||||||
return Err(format!("Cursor file does not exist: {}", cursor.path));
|
return Err(format!("Cursor file does not exist: {}", cursor.path));
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("File exists, applying cursor...");
|
|
||||||
|
|
||||||
// Apply the cursor
|
// Apply the cursor
|
||||||
if let Err(e) = platform::set_system_cursor(&cursor.path) {
|
if let Err(e) = platform::set_system_cursor(&cursor.path) {
|
||||||
println!("Error applying cursor: {}", e);
|
|
||||||
return Err(format!("Failed to apply cursor '{}': {}", cursor.name, e));
|
return Err(format!("Failed to apply cursor '{}': {}", cursor.name, e));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Emit an event to notify the frontend
|
// Emit an event to notify the frontend
|
||||||
let _ = app_handle.emit_all("cursor_changed", index); // Ignore error
|
let _ = app_handle.emit_all("cursor_changed", index); // Ignore error
|
||||||
|
|
||||||
println!("Successfully applied cursor using actual file path");
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper function to perform application cleanup (Steam shutdown and cursor restoration)
|
// Helper function to perform application cleanup (Steam shutdown and cursor restoration)
|
||||||
fn perform_app_cleanup() {
|
fn perform_app_cleanup() {
|
||||||
println!("Performing application cleanup...");
|
|
||||||
|
|
||||||
// Clean up Steam integration
|
// Clean up Steam integration
|
||||||
{
|
{
|
||||||
let steam = STEAM.lock();
|
let steam = STEAM.lock();
|
||||||
@@ -90,11 +81,9 @@ fn perform_app_cleanup() {
|
|||||||
|
|
||||||
// Clean up and restore default cursor before exit
|
// Clean up and restore default cursor before exit
|
||||||
match platform::restore_system_cursor() {
|
match platform::restore_system_cursor() {
|
||||||
Ok(_) => println!("Default cursor restored"),
|
Ok(_) => {},
|
||||||
Err(e) => eprintln!("Failed to restore default cursor: {}", e),
|
Err(e) => eprintln!("Failed to restore default cursor: {}", e),
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("Cleanup complete");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Command to select a cursor
|
// Command to select a cursor
|
||||||
@@ -104,51 +93,17 @@ fn select_cursor(
|
|||||||
state: tauri::State<AppStateWrapper>,
|
state: tauri::State<AppStateWrapper>,
|
||||||
app_handle: AppHandle,
|
app_handle: AppHandle,
|
||||||
) -> Result<(), String> {
|
) -> Result<(), String> {
|
||||||
println!("=== RESOURCE DEBUG [select_cursor] ===");
|
|
||||||
|
|
||||||
let mut app_state = state.0.lock();
|
let mut app_state = state.0.lock();
|
||||||
if index < app_state.cursors.len() {
|
if index < app_state.cursors.len() {
|
||||||
app_state.current_index = index;
|
app_state.current_index = index;
|
||||||
|
|
||||||
let cursor = &app_state.cursors[index];
|
let cursor = &app_state.cursors[index];
|
||||||
println!("Cursor selected: {}", cursor.name);
|
|
||||||
println!("Original path: {}", cursor.path);
|
|
||||||
|
|
||||||
// Get the resource directory
|
|
||||||
let resource_dir = app_handle.path_resolver().resource_dir();
|
|
||||||
println!("Resource dir: {:?}", resource_dir);
|
|
||||||
|
|
||||||
// List contents of resource dir
|
|
||||||
if let Some(res_dir) = &resource_dir {
|
|
||||||
println!("Listing contents of resource dir: {}", res_dir.display());
|
|
||||||
if let Ok(entries) = std::fs::read_dir(res_dir) {
|
|
||||||
for (i, entry) in entries.filter_map(Result::ok).enumerate() {
|
|
||||||
println!(" {}: {}", i, entry.path().display());
|
|
||||||
|
|
||||||
// List subdirectories
|
|
||||||
if entry.path().is_dir() {
|
|
||||||
if let Ok(subentries) = std::fs::read_dir(entry.path()) {
|
|
||||||
for (j, subentry) in subentries.filter_map(Result::ok).enumerate() {
|
|
||||||
println!(" {}.{}: {}", i, j, subentry.path().display());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
println!("Failed to read resource directory");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let filename = Path::new(&cursor.path)
|
let filename = Path::new(&cursor.path)
|
||||||
.file_name()
|
.file_name()
|
||||||
.and_then(|name| name.to_str())
|
.and_then(|name| name.to_str())
|
||||||
.ok_or_else(|| format!("Invalid cursor path: {}", cursor.path))?;
|
.ok_or_else(|| format!("Invalid cursor path: {}", cursor.path))?;
|
||||||
|
|
||||||
println!("Extracted filename: {}", filename);
|
|
||||||
|
|
||||||
// Try using the actual file path directly
|
|
||||||
println!("Using direct file path: {}", cursor.path);
|
|
||||||
|
|
||||||
// Use the helper function to apply the cursor
|
// Use the helper function to apply the cursor
|
||||||
apply_cursor_by_index(index, &app_state, &app_handle)
|
apply_cursor_by_index(index, &app_state, &app_handle)
|
||||||
} else {
|
} else {
|
||||||
@@ -162,26 +117,17 @@ fn next_cursor(
|
|||||||
state: tauri::State<AppStateWrapper>,
|
state: tauri::State<AppStateWrapper>,
|
||||||
app_handle: AppHandle,
|
app_handle: AppHandle,
|
||||||
) -> Result<usize, String> {
|
) -> Result<usize, String> {
|
||||||
println!("=== RESOURCE DEBUG [next_cursor] ===");
|
|
||||||
|
|
||||||
let mut app_state = state.0.lock();
|
let mut app_state = state.0.lock();
|
||||||
if !app_state.cursors.is_empty() {
|
if !app_state.cursors.is_empty() {
|
||||||
app_state.current_index = (app_state.current_index + 1) % app_state.cursors.len();
|
app_state.current_index = (app_state.current_index + 1) % app_state.cursors.len();
|
||||||
|
|
||||||
let cursor = &app_state.cursors[app_state.current_index];
|
let cursor = &app_state.cursors[app_state.current_index];
|
||||||
println!("Next cursor: {} ({})", cursor.name, cursor.path);
|
|
||||||
|
|
||||||
let filename = Path::new(&cursor.path)
|
let filename = Path::new(&cursor.path)
|
||||||
.file_name()
|
.file_name()
|
||||||
.and_then(|name| name.to_str())
|
.and_then(|name| name.to_str())
|
||||||
.ok_or_else(|| format!("Invalid cursor path: {}", cursor.path))?;
|
.ok_or_else(|| format!("Invalid cursor path: {}", cursor.path))?;
|
||||||
|
|
||||||
// Try both resource paths like in select_cursor
|
|
||||||
println!("Extracted filename: {}", filename);
|
|
||||||
|
|
||||||
// Try using the actual file path directly
|
|
||||||
println!("Using direct file path: {}", cursor.path);
|
|
||||||
|
|
||||||
// Use the helper function to apply the cursor
|
// Use the helper function to apply the cursor
|
||||||
apply_cursor_by_index(app_state.current_index, &app_state, &app_handle)?;
|
apply_cursor_by_index(app_state.current_index, &app_state, &app_handle)?;
|
||||||
Ok(app_state.current_index)
|
Ok(app_state.current_index)
|
||||||
@@ -193,13 +139,9 @@ fn next_cursor(
|
|||||||
// Command to quit the application
|
// Command to quit the application
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
fn quit_app(app_handle: AppHandle) {
|
fn quit_app(app_handle: AppHandle) {
|
||||||
println!("Quit app command received");
|
|
||||||
|
|
||||||
// Use the helper function to perform cleanup
|
// Use the helper function to perform cleanup
|
||||||
perform_app_cleanup();
|
perform_app_cleanup();
|
||||||
|
|
||||||
println!("Exiting application");
|
|
||||||
|
|
||||||
// Exit the application
|
// Exit the application
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
app_handle.exit(0);
|
app_handle.exit(0);
|
||||||
@@ -209,8 +151,6 @@ fn quit_app(app_handle: AppHandle) {
|
|||||||
// Command to minimize the window to tray
|
// Command to minimize the window to tray
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
fn minimize_to_tray(app_handle: AppHandle) -> Result<(), String> {
|
fn minimize_to_tray(app_handle: AppHandle) -> Result<(), String> {
|
||||||
println!("Minimizing to tray");
|
|
||||||
|
|
||||||
// Get the main window
|
// Get the main window
|
||||||
let window = app_handle
|
let window = app_handle
|
||||||
.get_window("main")
|
.get_window("main")
|
||||||
@@ -221,9 +161,6 @@ fn minimize_to_tray(app_handle: AppHandle) -> Result<(), String> {
|
|||||||
.hide()
|
.hide()
|
||||||
.map_err(|e| format!("Failed to hide window: {}", e))?;
|
.map_err(|e| format!("Failed to hide window: {}", e))?;
|
||||||
|
|
||||||
// The tray should already be visible as configured in tauri.conf.json
|
|
||||||
println!("Window hidden, application should now be accessible from the system tray");
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,10 +168,7 @@ fn minimize_to_tray(app_handle: AppHandle) -> Result<(), String> {
|
|||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
fn temporarily_restore_cursor() -> Result<(), String> {
|
fn temporarily_restore_cursor() -> Result<(), String> {
|
||||||
match platform::restore_system_cursor_temporarily() {
|
match platform::restore_system_cursor_temporarily() {
|
||||||
Ok(_) => {
|
Ok(_) => Ok(()),
|
||||||
println!("System cursor temporarily restored for drag operation");
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
Err(e) => Err(format!("Failed to restore system cursor: {}", e)),
|
Err(e) => Err(format!("Failed to restore system cursor: {}", e)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -246,10 +180,7 @@ fn reapply_custom_cursor(state: tauri::State<AppStateWrapper>) -> Result<(), Str
|
|||||||
if !app_state.cursors.is_empty() && app_state.current_index < app_state.cursors.len() {
|
if !app_state.cursors.is_empty() && app_state.current_index < app_state.cursors.len() {
|
||||||
let current_cursor = &app_state.cursors[app_state.current_index];
|
let current_cursor = &app_state.cursors[app_state.current_index];
|
||||||
match platform::set_system_cursor(¤t_cursor.path) {
|
match platform::set_system_cursor(¤t_cursor.path) {
|
||||||
Ok(_) => {
|
Ok(_) => Ok(()),
|
||||||
println!("Custom cursor re-applied after drag operation");
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
Err(e) => Err(format!("Failed to re-apply custom cursor: {}", e)),
|
Err(e) => Err(format!("Failed to re-apply custom cursor: {}", e)),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -260,12 +191,8 @@ fn reapply_custom_cursor(state: tauri::State<AppStateWrapper>) -> Result<(), Str
|
|||||||
// Command to manually restore default cursors
|
// Command to manually restore default cursors
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
fn restore_default_cursors() -> Result<(), String> {
|
fn restore_default_cursors() -> Result<(), String> {
|
||||||
println!("Manual restore default cursors command received");
|
|
||||||
match platform::restore_system_cursor() {
|
match platform::restore_system_cursor() {
|
||||||
Ok(_) => {
|
Ok(_) => Ok(()),
|
||||||
println!("Default cursors restored successfully");
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
eprintln!("Failed to restore default cursors: {}", e);
|
eprintln!("Failed to restore default cursors: {}", e);
|
||||||
Err(format!("Failed to restore default cursors: {}", e))
|
Err(format!("Failed to restore default cursors: {}", e))
|
||||||
@@ -275,12 +202,10 @@ fn restore_default_cursors() -> Result<(), String> {
|
|||||||
|
|
||||||
// Function to load cursor files from src/cursors directory
|
// Function to load cursor files from src/cursors directory
|
||||||
fn load_cursor_files() -> Vec<Cursor> {
|
fn load_cursor_files() -> Vec<Cursor> {
|
||||||
println!("=== RESOURCE DEBUG [load_cursor_files] ===");
|
|
||||||
let mut cursors = Vec::new();
|
let mut cursors = Vec::new();
|
||||||
|
|
||||||
// Determine the path to src/cursors relative to src-tauri (CARGO_MANIFEST_DIR)
|
// Determine the path to src/cursors relative to src-tauri (CARGO_MANIFEST_DIR)
|
||||||
let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||||
println!("CARGO_MANIFEST_DIR: {}", manifest_dir.display());
|
|
||||||
|
|
||||||
// Check multiple possible locations
|
// Check multiple possible locations
|
||||||
let possible_cursor_dirs = vec![
|
let possible_cursor_dirs = vec![
|
||||||
@@ -290,18 +215,11 @@ fn load_cursor_files() -> Vec<Cursor> {
|
|||||||
manifest_dir.clone(), // Check manifest dir itself
|
manifest_dir.clone(), // Check manifest dir itself
|
||||||
];
|
];
|
||||||
|
|
||||||
println!("CHECKING FOR PNG/CUR FILES IN MULTIPLE DIRECTORIES:");
|
for cursors_dir in possible_cursor_dirs.iter() {
|
||||||
for (i, cursors_dir) in possible_cursor_dirs.iter().enumerate() {
|
|
||||||
println!("Checking dir {}: {}", i + 1, cursors_dir.display());
|
|
||||||
println!(" Directory exists: {}", cursors_dir.exists());
|
|
||||||
|
|
||||||
if cursors_dir.exists() {
|
if cursors_dir.exists() {
|
||||||
println!(" Looking for cursor files in this directory...");
|
|
||||||
|
|
||||||
if let Ok(entries) = std::fs::read_dir(cursors_dir) {
|
if let Ok(entries) = std::fs::read_dir(cursors_dir) {
|
||||||
for entry in entries.filter_map(Result::ok) {
|
for entry in entries.filter_map(Result::ok) {
|
||||||
let path = entry.path();
|
let path = entry.path();
|
||||||
println!(" Found: {}", path.display());
|
|
||||||
|
|
||||||
if path.is_file()
|
if path.is_file()
|
||||||
&& path
|
&& path
|
||||||
@@ -314,7 +232,6 @@ fn load_cursor_files() -> Vec<Cursor> {
|
|||||||
.unwrap_or("Unknown")
|
.unwrap_or("Unknown")
|
||||||
.to_string();
|
.to_string();
|
||||||
|
|
||||||
println!(" ADDING CURSOR: {} at path {}", name, path.display());
|
|
||||||
cursors.push(Cursor {
|
cursors.push(Cursor {
|
||||||
name,
|
name,
|
||||||
path: path.to_string_lossy().to_string(),
|
path: path.to_string_lossy().to_string(),
|
||||||
@@ -324,7 +241,6 @@ fn load_cursor_files() -> Vec<Cursor> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !cursors.is_empty() {
|
if !cursors.is_empty() {
|
||||||
println!(" Found {} cursor files in this directory.", cursors.len());
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -332,12 +248,7 @@ fn load_cursor_files() -> Vec<Cursor> {
|
|||||||
|
|
||||||
// If we found no cursors, use mock data with paths relative to what resolve_resource expects
|
// If we found no cursors, use mock data with paths relative to what resolve_resource expects
|
||||||
if cursors.is_empty() {
|
if cursors.is_empty() {
|
||||||
println!("No cursors found in any directory. Using mock data instead.");
|
eprintln!("No cursor files found, using fallback cursors");
|
||||||
println!("IMPORTANT: This is probably the source of your problem!");
|
|
||||||
println!("The app could not find your cursor PNG files. Check that they exist in one of these directories:");
|
|
||||||
for dir in &possible_cursor_dirs {
|
|
||||||
println!(" {}", dir.display());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mock data paths should reflect their eventual resource path structure
|
// Mock data paths should reflect their eventual resource path structure
|
||||||
cursors.push(Cursor {
|
cursors.push(Cursor {
|
||||||
@@ -354,12 +265,8 @@ fn load_cursor_files() -> Vec<Cursor> {
|
|||||||
name: "Red".to_string(),
|
name: "Red".to_string(),
|
||||||
path: "src/cursors/red.png".to_string(), // Filename will be 'red.png'
|
path: "src/cursors/red.png".to_string(), // Filename will be 'red.png'
|
||||||
});
|
});
|
||||||
|
|
||||||
println!("Created {} mock cursor entries", cursors.len());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("Loaded {} cursor files", cursors.len());
|
|
||||||
|
|
||||||
// Sort cursors by name for consistent ordering
|
// Sort cursors by name for consistent ordering
|
||||||
cursors.sort_by(|a, b| a.name.cmp(&b.name));
|
cursors.sort_by(|a, b| a.name.cmp(&b.name));
|
||||||
cursors
|
cursors
|
||||||
@@ -367,8 +274,6 @@ fn load_cursor_files() -> Vec<Cursor> {
|
|||||||
|
|
||||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||||
pub fn run() {
|
pub fn run() {
|
||||||
println!("Starting Cursor Rush application");
|
|
||||||
|
|
||||||
// Get LazyLock to create steam
|
// Get LazyLock to create steam
|
||||||
let _ = STEAM.lock();
|
let _ = STEAM.lock();
|
||||||
|
|
||||||
@@ -405,15 +310,12 @@ pub fn run() {
|
|||||||
.system_tray(system_tray)
|
.system_tray(system_tray)
|
||||||
.on_system_tray_event(|app, event| match event {
|
.on_system_tray_event(|app, event| match event {
|
||||||
SystemTrayEvent::LeftClick { .. } => {
|
SystemTrayEvent::LeftClick { .. } => {
|
||||||
println!("System tray received a left click");
|
|
||||||
if let Some(window) = app.get_window("main") {
|
if let Some(window) = app.get_window("main") {
|
||||||
match window.is_visible() {
|
match window.is_visible() {
|
||||||
Ok(visible) => {
|
Ok(visible) => {
|
||||||
if visible {
|
if visible {
|
||||||
println!("Window is already visible, focusing it");
|
|
||||||
let _ = window.set_focus();
|
let _ = window.set_focus();
|
||||||
} else {
|
} else {
|
||||||
println!("Window is hidden, showing it");
|
|
||||||
if let Err(e) = window.show() {
|
if let Err(e) = window.show() {
|
||||||
eprintln!("Failed to show window: {}", e);
|
eprintln!("Failed to show window: {}", e);
|
||||||
}
|
}
|
||||||
@@ -435,10 +337,8 @@ pub fn run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
SystemTrayEvent::MenuItemClick { id, .. } => {
|
SystemTrayEvent::MenuItemClick { id, .. } => {
|
||||||
println!("Menu item clicked: {}", id);
|
|
||||||
match id.as_str() {
|
match id.as_str() {
|
||||||
"next_cursor" => {
|
"next_cursor" => {
|
||||||
println!("Next cursor requested from tray");
|
|
||||||
let state = app.state::<AppStateWrapper>();
|
let state = app.state::<AppStateWrapper>();
|
||||||
let mut app_state = state.0.lock();
|
let mut app_state = state.0.lock();
|
||||||
|
|
||||||
@@ -453,7 +353,6 @@ pub fn run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
"show_window" => {
|
"show_window" => {
|
||||||
println!("Show window requested from tray");
|
|
||||||
if let Some(window) = app.get_window("main") {
|
if let Some(window) = app.get_window("main") {
|
||||||
if let Err(e) = window.show() {
|
if let Err(e) = window.show() {
|
||||||
eprintln!("Failed to show window: {}", e);
|
eprintln!("Failed to show window: {}", e);
|
||||||
@@ -466,12 +365,9 @@ pub fn run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
"quit" => {
|
"quit" => {
|
||||||
println!("Quit requested from tray");
|
|
||||||
|
|
||||||
// Use the helper function to perform cleanup
|
// Use the helper function to perform cleanup
|
||||||
perform_app_cleanup();
|
perform_app_cleanup();
|
||||||
|
|
||||||
println!("Exiting from tray");
|
|
||||||
app.exit(0);
|
app.exit(0);
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
@@ -487,13 +383,10 @@ pub fn run() {
|
|||||||
|
|
||||||
// Get the window and hide it
|
// Get the window and hide it
|
||||||
let window = event.window();
|
let window = event.window();
|
||||||
println!("Window close requested in backend handler, hiding window");
|
|
||||||
|
|
||||||
// Hide the window instead of closing it
|
// Hide the window instead of closing it
|
||||||
if let Err(e) = window.hide() {
|
if let Err(e) = window.hide() {
|
||||||
eprintln!("Failed to hide window: {}", e);
|
eprintln!("Failed to hide window: {}", e);
|
||||||
} else {
|
|
||||||
println!("Window hidden successfully, app is now in system tray");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
@@ -511,12 +404,8 @@ pub fn run() {
|
|||||||
restore_default_cursors
|
restore_default_cursors
|
||||||
])
|
])
|
||||||
.setup(|_app| {
|
.setup(|_app| {
|
||||||
// Register for events or perform additional setup
|
|
||||||
println!("Tauri application setup complete");
|
|
||||||
|
|
||||||
// We're not setting up a window close handler here anymore
|
// We're not setting up a window close handler here anymore
|
||||||
// The frontend will handle this based on the minimize-to-tray setting
|
// The frontend will handle this based on the minimize-to-tray setting
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
// This matches exactly how it was before our changes
|
// This matches exactly how it was before our changes
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ use super::state::*;
|
|||||||
|
|
||||||
// Control handler function for console events (Ctrl+C, close, etc.)
|
// Control handler function for console events (Ctrl+C, close, etc.)
|
||||||
extern "system" fn ctrl_handler(_ctrl_type: u32) -> i32 {
|
extern "system" fn ctrl_handler(_ctrl_type: u32) -> i32 {
|
||||||
println!("Control event received, attempting cleanup...");
|
|
||||||
cleanup(); // Call cleanup logic
|
cleanup(); // Call cleanup logic
|
||||||
FALSE // Allow other handlers (like default exit) to run
|
FALSE // Allow other handlers (like default exit) to run
|
||||||
}
|
}
|
||||||
@@ -200,19 +199,15 @@ unsafe fn create_cursor_from_image(image: &RgbaImage) -> Option<SyncHCURSOR> {
|
|||||||
|
|
||||||
// Cleanup function to restore cursors and clean up resources
|
// Cleanup function to restore cursors and clean up resources
|
||||||
pub fn cleanup() {
|
pub fn cleanup() {
|
||||||
println!("Running cursor cleanup...");
|
|
||||||
|
|
||||||
// Check if we have original cursors saved before attempting restoration
|
// Check if we have original cursors saved before attempting restoration
|
||||||
let has_original_cursors = {
|
let has_original_cursors = {
|
||||||
let guard = ORIGINAL_CURSORS.lock().unwrap();
|
let guard = ORIGINAL_CURSORS.lock().unwrap();
|
||||||
guard.is_some()
|
guard.is_some()
|
||||||
};
|
};
|
||||||
println!("Has original cursors saved: {}", has_original_cursors);
|
|
||||||
|
|
||||||
// Restore system cursors if they were hidden
|
// Restore system cursors if they were hidden
|
||||||
// Use swap to ensure it runs only once
|
// Use swap to ensure it runs only once
|
||||||
if CURSOR_HIDDEN.swap(false, Ordering::SeqCst) {
|
if CURSOR_HIDDEN.swap(false, Ordering::SeqCst) {
|
||||||
println!("Restoring system cursors...");
|
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
// Try multiple approaches to ensure cursors are restored
|
// Try multiple approaches to ensure cursors are restored
|
||||||
@@ -224,18 +219,12 @@ pub fn cleanup() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if let Some(original_cursors) = original_cursors_opt {
|
if let Some(original_cursors) = original_cursors_opt {
|
||||||
let total_cursors = original_cursors.len();
|
|
||||||
println!("Restoring {} saved original cursors", total_cursors);
|
|
||||||
let mut restored_count = 0;
|
|
||||||
for (cursor_id, cursor) in original_cursors {
|
for (cursor_id, cursor) in original_cursors {
|
||||||
if !cursor.0.is_null() {
|
if !cursor.0.is_null() {
|
||||||
// Make a copy of the original cursor
|
// Make a copy of the original cursor
|
||||||
let cursor_copy = CopyIcon(cursor.0);
|
let cursor_copy = CopyIcon(cursor.0);
|
||||||
if !cursor_copy.is_null() {
|
if !cursor_copy.is_null() {
|
||||||
if SetSystemCursor(cursor_copy, cursor_id) != 0 {
|
if SetSystemCursor(cursor_copy, cursor_id) == 0 {
|
||||||
restored_count += 1;
|
|
||||||
println!("Successfully restored cursor for ID: {}", cursor_id);
|
|
||||||
} else {
|
|
||||||
eprintln!("Failed to restore original cursor for ID: {}", cursor_id);
|
eprintln!("Failed to restore original cursor for ID: {}", cursor_id);
|
||||||
DestroyIcon(cursor_copy);
|
DestroyIcon(cursor_copy);
|
||||||
}
|
}
|
||||||
@@ -247,9 +236,7 @@ pub fn cleanup() {
|
|||||||
DestroyIcon(cursor.0);
|
DestroyIcon(cursor.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
println!("Restored {} out of {} original cursors", restored_count, total_cursors);
|
|
||||||
} else {
|
} else {
|
||||||
println!("No saved original cursors found, using fallback restoration methods");
|
|
||||||
|
|
||||||
// Try to restore each system cursor to its default
|
// Try to restore each system cursor to its default
|
||||||
for &cursor_id in SYSTEM_CURSORS.iter() {
|
for &cursor_id in SYSTEM_CURSORS.iter() {
|
||||||
@@ -257,9 +244,7 @@ pub fn cleanup() {
|
|||||||
if !default_cursor.is_null() {
|
if !default_cursor.is_null() {
|
||||||
let cursor_copy = CopyIcon(default_cursor);
|
let cursor_copy = CopyIcon(default_cursor);
|
||||||
if !cursor_copy.is_null() {
|
if !cursor_copy.is_null() {
|
||||||
if SetSystemCursor(cursor_copy, cursor_id) != 0 {
|
if SetSystemCursor(cursor_copy, cursor_id) == 0 {
|
||||||
println!("Restored default cursor for ID: {}", cursor_id);
|
|
||||||
} else {
|
|
||||||
eprintln!("Failed to restore default cursor for ID: {}", cursor_id);
|
eprintln!("Failed to restore default cursor for ID: {}", cursor_id);
|
||||||
DestroyIcon(cursor_copy);
|
DestroyIcon(cursor_copy);
|
||||||
}
|
}
|
||||||
@@ -268,22 +253,18 @@ pub fn cleanup() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Force Windows to reload default cursor settings
|
// Force Windows to reload default cursor settings
|
||||||
println!("Forcing Windows to reload default cursor settings");
|
|
||||||
SystemParametersInfoW(SPI_SETCURSORS, 0, null_mut(), 0);
|
SystemParametersInfoW(SPI_SETCURSORS, 0, null_mut(), 0);
|
||||||
|
|
||||||
// 3. Also try the A version for maximum compatibility
|
// Also try the A version for maximum compatibility
|
||||||
super::state::reset_system_cursors();
|
super::state::reset_system_cursors();
|
||||||
|
|
||||||
// 4. Reset to default arrow cursor
|
// Reset to default arrow cursor
|
||||||
let arrow_cursor = LoadCursorW(null_mut(), MAKEINTRESOURCEW(IDC_ARROW as u16));
|
let arrow_cursor = LoadCursorW(null_mut(), MAKEINTRESOURCEW(IDC_ARROW as u16));
|
||||||
if !arrow_cursor.is_null() {
|
if !arrow_cursor.is_null() {
|
||||||
SetCursor(arrow_cursor);
|
SetCursor(arrow_cursor);
|
||||||
println!("Reset to default arrow cursor.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("System cursors restoration complete.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destroy the custom cursor if it exists
|
// Destroy the custom cursor if it exists
|
||||||
@@ -292,7 +273,6 @@ pub fn cleanup() {
|
|||||||
unsafe {
|
unsafe {
|
||||||
if !cursor_wrapper.0.is_null() {
|
if !cursor_wrapper.0.is_null() {
|
||||||
DestroyIcon(cursor_wrapper.0);
|
DestroyIcon(cursor_wrapper.0);
|
||||||
println!("Custom cursor destroyed during cleanup.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -308,14 +288,11 @@ pub fn cleanup() {
|
|||||||
unsafe {
|
unsafe {
|
||||||
if SetConsoleCtrlHandler(Some(ctrl_handler), FALSE) != 0 {
|
if SetConsoleCtrlHandler(Some(ctrl_handler), FALSE) != 0 {
|
||||||
CTRL_HANDLER_REGISTERED.store(false, Ordering::SeqCst);
|
CTRL_HANDLER_REGISTERED.store(false, Ordering::SeqCst);
|
||||||
println!("Control handler unregistered.");
|
|
||||||
} else {
|
} else {
|
||||||
eprintln!("Failed to unregister control handler.");
|
eprintln!("Failed to unregister control handler.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("Cursor cleanup complete.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Public API Functions ---
|
// --- Public API Functions ---
|
||||||
@@ -328,7 +305,6 @@ pub fn hide_system_cursor() -> bool {
|
|||||||
unsafe {
|
unsafe {
|
||||||
if SetConsoleCtrlHandler(Some(ctrl_handler), TRUE) != 0 {
|
if SetConsoleCtrlHandler(Some(ctrl_handler), TRUE) != 0 {
|
||||||
CTRL_HANDLER_REGISTERED.store(true, Ordering::SeqCst);
|
CTRL_HANDLER_REGISTERED.store(true, Ordering::SeqCst);
|
||||||
println!("Control handler registered for clean exit.");
|
|
||||||
} else {
|
} else {
|
||||||
eprintln!("Failed to register control handler: {}", std::io::Error::last_os_error());
|
eprintln!("Failed to register control handler: {}", std::io::Error::last_os_error());
|
||||||
}
|
}
|
||||||
@@ -343,14 +319,12 @@ pub fn hide_system_cursor() -> bool {
|
|||||||
// Save original cursors for restoration
|
// Save original cursors for restoration
|
||||||
let mut original_cursors = Vec::new();
|
let mut original_cursors = Vec::new();
|
||||||
unsafe {
|
unsafe {
|
||||||
println!("Saving original cursors for restoration...");
|
|
||||||
for &cursor_id in SYSTEM_CURSORS.iter() {
|
for &cursor_id in SYSTEM_CURSORS.iter() {
|
||||||
// Get the original cursor
|
// Get the original cursor
|
||||||
let original_cursor = CopyIcon(LoadCursorW(null_mut(), MAKEINTRESOURCEW(cursor_id as u16)));
|
let original_cursor = CopyIcon(LoadCursorW(null_mut(), MAKEINTRESOURCEW(cursor_id as u16)));
|
||||||
if !original_cursor.is_null() {
|
if !original_cursor.is_null() {
|
||||||
// Save the original cursor for restoration
|
// Save the original cursor for restoration
|
||||||
original_cursors.push((cursor_id, SyncHCURSOR(original_cursor)));
|
original_cursors.push((cursor_id, SyncHCURSOR(original_cursor)));
|
||||||
println!("Saved original cursor for ID: {}", cursor_id);
|
|
||||||
} else {
|
} else {
|
||||||
eprintln!("Failed to save original cursor for ID: {}", cursor_id);
|
eprintln!("Failed to save original cursor for ID: {}", cursor_id);
|
||||||
}
|
}
|
||||||
@@ -359,7 +333,6 @@ pub fn hide_system_cursor() -> bool {
|
|||||||
|
|
||||||
// Store original cursors for restoration
|
// Store original cursors for restoration
|
||||||
if !original_cursors.is_empty() {
|
if !original_cursors.is_empty() {
|
||||||
println!("Storing {} original cursors for later restoration", original_cursors.len());
|
|
||||||
*ORIGINAL_CURSORS.lock().unwrap() = Some(original_cursors);
|
*ORIGINAL_CURSORS.lock().unwrap() = Some(original_cursors);
|
||||||
} else {
|
} else {
|
||||||
eprintln!("No original cursors were saved!");
|
eprintln!("No original cursors were saved!");
|
||||||
@@ -373,15 +346,11 @@ pub fn hide_system_cursor() -> bool {
|
|||||||
|
|
||||||
// Update the cursor image using CursorInfo (with caching)
|
// Update the cursor image using CursorInfo (with caching)
|
||||||
pub fn update_cursor_info(cursor_info: &mut crate::platform::types::CursorInfo) -> bool {
|
pub fn update_cursor_info(cursor_info: &mut crate::platform::types::CursorInfo) -> bool {
|
||||||
println!("Updating cursor to: {}", cursor_info.name);
|
|
||||||
|
|
||||||
// Use cached image if available, otherwise load from disk
|
// Use cached image if available, otherwise load from disk
|
||||||
let image: image::RgbaImage = if let Some(ref cached_image) = cursor_info.image {
|
let image: image::RgbaImage = if let Some(ref cached_image) = cursor_info.image {
|
||||||
println!("Using cached image for cursor: {}", cursor_info.name);
|
|
||||||
let img_clone: image::RgbaImage = cached_image.clone();
|
let img_clone: image::RgbaImage = cached_image.clone();
|
||||||
img_clone
|
img_clone
|
||||||
} else {
|
} else {
|
||||||
println!("Loading image from disk for cursor: {}", cursor_info.name);
|
|
||||||
match image_open(&cursor_info.path) {
|
match image_open(&cursor_info.path) {
|
||||||
Ok(img) => {
|
Ok(img) => {
|
||||||
let rgba = img.to_rgba8();
|
let rgba = img.to_rgba8();
|
||||||
@@ -448,7 +417,6 @@ pub fn update_cursor_info(cursor_info: &mut crate::platform::types::CursorInfo)
|
|||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
if let Some(cached_cursor) = &cursor_info.win_cursor {
|
if let Some(cached_cursor) = &cursor_info.win_cursor {
|
||||||
if !cached_cursor.handle.is_null() {
|
if !cached_cursor.handle.is_null() {
|
||||||
println!("Falling back to cached cursor as a last resort");
|
|
||||||
let mut cursor_guard = CUSTOM_CURSOR.lock().unwrap();
|
let mut cursor_guard = CUSTOM_CURSOR.lock().unwrap();
|
||||||
// Convert WinCursorWrapper to SyncHCURSOR
|
// Convert WinCursorWrapper to SyncHCURSOR
|
||||||
let sync_cursor = super::types::SyncHCURSOR(cached_cursor.handle);
|
let sync_cursor = super::types::SyncHCURSOR(cached_cursor.handle);
|
||||||
@@ -539,11 +507,8 @@ unsafe fn apply_cursor_to_all_system_cursors(cursor: winapi::shared::windef::HCU
|
|||||||
|
|
||||||
// Restore the system cursor temporarily (without affecting cleanup state)
|
// Restore the system cursor temporarily (without affecting cleanup state)
|
||||||
pub fn restore_cursor_temporarily() {
|
pub fn restore_cursor_temporarily() {
|
||||||
println!("Temporarily restoring system cursors...");
|
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
// Force Windows to reload default cursor settings
|
// Force Windows to reload default cursor settings
|
||||||
println!("Forcing Windows to reload default cursor settings");
|
|
||||||
SystemParametersInfoW(SPI_SETCURSORS, 0, null_mut(), 0);
|
SystemParametersInfoW(SPI_SETCURSORS, 0, null_mut(), 0);
|
||||||
|
|
||||||
// Also try the A version for maximum compatibility
|
// Also try the A version for maximum compatibility
|
||||||
@@ -553,11 +518,8 @@ pub fn restore_cursor_temporarily() {
|
|||||||
let arrow_cursor = LoadCursorW(null_mut(), MAKEINTRESOURCEW(IDC_ARROW as u16));
|
let arrow_cursor = LoadCursorW(null_mut(), MAKEINTRESOURCEW(IDC_ARROW as u16));
|
||||||
if !arrow_cursor.is_null() {
|
if !arrow_cursor.is_null() {
|
||||||
SetCursor(arrow_cursor);
|
SetCursor(arrow_cursor);
|
||||||
println!("Reset to default arrow cursor temporarily.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("Temporary cursor restoration complete.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore the system cursor permanently (full cleanup)
|
// Restore the system cursor permanently (full cleanup)
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ use crate::platform::Result;
|
|||||||
|
|
||||||
// Functions expected by the platform-agnostic interface
|
// Functions expected by the platform-agnostic interface
|
||||||
pub fn set_cursor(path: &str) -> Result<()> {
|
pub fn set_cursor(path: &str) -> Result<()> {
|
||||||
println!("Windows platform: setting cursor to {}", path);
|
|
||||||
|
|
||||||
// Create a cursor info struct to pass to update_cursor_info
|
// Create a cursor info struct to pass to update_cursor_info
|
||||||
let mut cursor_info = crate::platform::types::CursorInfo {
|
let mut cursor_info = crate::platform::types::CursorInfo {
|
||||||
|
|||||||
@@ -26,21 +26,16 @@ function App() {
|
|||||||
// Function to minimize app to tray
|
// Function to minimize app to tray
|
||||||
const minimizeToTray = useCallback(async () => {
|
const minimizeToTray = useCallback(async () => {
|
||||||
try {
|
try {
|
||||||
console.log('Minimizing app to tray');
|
|
||||||
// First hide the window to ensure it disappears immediately
|
// First hide the window to ensure it disappears immediately
|
||||||
await appWindow.hide();
|
await appWindow.hide();
|
||||||
console.log('Window hidden, now ensuring tray is visible');
|
|
||||||
|
|
||||||
// Then call the backend to ensure the tray is visible
|
// Then call the backend to ensure the tray is visible
|
||||||
await invoke("minimize_to_tray");
|
await invoke("minimize_to_tray");
|
||||||
console.log('minimize_to_tray command completed successfully');
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to minimize to tray:", error);
|
console.error("Failed to minimize to tray:", error);
|
||||||
// Fallback to window API if the invoke fails
|
// Fallback to window API if the invoke fails
|
||||||
try {
|
try {
|
||||||
console.log('Trying fallback hide');
|
|
||||||
await appWindow.hide();
|
await appWindow.hide();
|
||||||
console.log('Fallback hide succeeded');
|
|
||||||
} catch (fallbackError) {
|
} catch (fallbackError) {
|
||||||
console.error("Fallback hide also failed:", fallbackError);
|
console.error("Fallback hide also failed:", fallbackError);
|
||||||
}
|
}
|
||||||
@@ -52,7 +47,6 @@ function App() {
|
|||||||
const setupFocusHandler = async () => {
|
const setupFocusHandler = async () => {
|
||||||
const unlistenFocus = await appWindow.onFocusChanged(async ({ payload: focused }) => {
|
const unlistenFocus = await appWindow.onFocusChanged(async ({ payload: focused }) => {
|
||||||
if (focused) {
|
if (focused) {
|
||||||
console.log('Window gained focus, re-applying custom cursor');
|
|
||||||
try {
|
try {
|
||||||
await invoke("reapply_custom_cursor");
|
await invoke("reapply_custom_cursor");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -82,7 +76,6 @@ function App() {
|
|||||||
try {
|
try {
|
||||||
// Get cursors from the Tauri backend
|
// Get cursors from the Tauri backend
|
||||||
const loadedCursors = await invoke("get_cursors");
|
const loadedCursors = await invoke("get_cursors");
|
||||||
console.log("Loaded cursors:", loadedCursors);
|
|
||||||
setCursors(loadedCursors || []);
|
setCursors(loadedCursors || []);
|
||||||
|
|
||||||
// Get current cursor index
|
// Get current cursor index
|
||||||
@@ -109,16 +102,12 @@ function App() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const setupCloseHandler = async () => {
|
const setupCloseHandler = async () => {
|
||||||
const unlisten = await appWindow.onCloseRequested(async (event) => {
|
const unlisten = await appWindow.onCloseRequested(async (event) => {
|
||||||
console.log('Window close requested');
|
|
||||||
|
|
||||||
if (settings.minimizeToTrayOnClose) {
|
if (settings.minimizeToTrayOnClose) {
|
||||||
console.log('Minimize to tray setting is enabled, preventing close and hiding instead');
|
|
||||||
// Prevent the window from closing
|
// Prevent the window from closing
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
// Temporarily restore cursor before hiding to tray
|
// Temporarily restore cursor before hiding to tray
|
||||||
try {
|
try {
|
||||||
console.log('Temporarily restoring cursor before hiding to tray');
|
|
||||||
await invoke("temporarily_restore_cursor");
|
await invoke("temporarily_restore_cursor");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to restore cursor before hiding:', error);
|
console.error('Failed to restore cursor before hiding:', error);
|
||||||
@@ -126,14 +115,11 @@ function App() {
|
|||||||
|
|
||||||
// Hide the window instead
|
// Hide the window instead
|
||||||
try {
|
try {
|
||||||
console.log('Calling minimizeToTray function');
|
|
||||||
await minimizeToTray();
|
await minimizeToTray();
|
||||||
console.log('Window should now be hidden and app should be in system tray');
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to minimize to tray on close:', error);
|
console.error('Failed to minimize to tray on close:', error);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log('Minimize to tray setting is disabled, allowing window to close');
|
|
||||||
// Let the window close normally, but we need to call quit_app to ensure proper cleanup
|
// Let the window close normally, but we need to call quit_app to ensure proper cleanup
|
||||||
try {
|
try {
|
||||||
await invoke("quit_app");
|
await invoke("quit_app");
|
||||||
@@ -149,7 +135,6 @@ function App() {
|
|||||||
let unlistenFn;
|
let unlistenFn;
|
||||||
setupCloseHandler().then(unlisten => {
|
setupCloseHandler().then(unlisten => {
|
||||||
unlistenFn = unlisten;
|
unlistenFn = unlisten;
|
||||||
console.log('Close handler set up successfully');
|
|
||||||
}).catch(err => console.error('Failed to set up close handler:', err));
|
}).catch(err => console.error('Failed to set up close handler:', err));
|
||||||
|
|
||||||
// Clean up event listener on unmount
|
// Clean up event listener on unmount
|
||||||
@@ -163,7 +148,6 @@ function App() {
|
|||||||
// Functions to handle cursor operations using Tauri backend
|
// Functions to handle cursor operations using Tauri backend
|
||||||
const selectCursor = async (index) => {
|
const selectCursor = async (index) => {
|
||||||
try {
|
try {
|
||||||
console.log(`Selecting cursor at index ${index}`);
|
|
||||||
await invoke("select_cursor", { index });
|
await invoke("select_cursor", { index });
|
||||||
setCurrentCursorIndex(index);
|
setCurrentCursorIndex(index);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -175,7 +159,6 @@ function App() {
|
|||||||
if (cursors.length === 0) return;
|
if (cursors.length === 0) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
console.log('Switching to next cursor');
|
|
||||||
const newIndex = await invoke("next_cursor");
|
const newIndex = await invoke("next_cursor");
|
||||||
setCurrentCursorIndex(newIndex);
|
setCurrentCursorIndex(newIndex);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -189,7 +172,6 @@ function App() {
|
|||||||
// Function to exit app
|
// Function to exit app
|
||||||
const quitApp = async () => {
|
const quitApp = async () => {
|
||||||
try {
|
try {
|
||||||
console.log('Quitting app');
|
|
||||||
await invoke("quit_app");
|
await invoke("quit_app");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to quit app:", error);
|
console.error("Failed to quit app:", error);
|
||||||
|
|||||||
Reference in New Issue
Block a user