Created
September 12, 2023 14:18
-
-
Save ninetyeights/ddfbe532f5485b761dc5db122e26cfa9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Prevents additional console window on Windows in release, DO NOT REMOVE!! | |
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] | |
use tauri::{Manager, Window}; | |
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command | |
#[tauri::command] | |
fn greet(name: &str) -> String { | |
format!("Hello, {}! You've been greeted from Rust!", name) | |
} | |
fn main() { | |
tauri::Builder::default() | |
.setup(|app| { | |
let main_window = app.get_window("main").unwrap(); | |
#[cfg(target_os = "macos")] | |
{ | |
use cocoa::appkit::{NSMainMenuWindowLevel, NSWindow, NSWindowCollectionBehavior}; | |
use cocoa::base::id; | |
let ns_win = main_window.ns_window().unwrap() as id; | |
unsafe { | |
ns_win.setLevel_(((NSMainMenuWindowLevel + 1) as u64).try_into().unwrap()); | |
ns_win.setCollectionBehavior_(NSWindowCollectionBehavior::NSWindowCollectionBehaviorCanJoinAllSpaces); | |
// ns_win.setCollectionBehavior_(NSWindowCollectionBehavior::NSWindowCollectionBehaviorMoveToActiveSpace); | |
} | |
} | |
Ok(()) | |
}) | |
.invoke_handler(tauri::generate_handler![greet]) | |
.run(tauri::generate_context!()) | |
.expect("error while running tauri application"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment