Forked from ninetyeights/macos window visible on all workspace
Created
February 4, 2024 03:33
-
-
Save Yiork/38fc94d58e75194b0703c5010cafe240 to your computer and use it in GitHub Desktop.
This file contains hidden or 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