Skip to content

[feat] add window.set_level API #466

Open
@tauri-bot

Description

@tauri-bot

This issue has been upstreamed from tauri-apps/tauri#4620

Describe the problem

I hope that the window layer can be set by setLevel.

Describe the solution you'd like

#![cfg_attr(
    all(not(debug_assertions), target_os = "windows"),
    windows_subsystem = "windows"
)]

use tauri::{LogicalPosition, Manager, Position};

fn main() {
    let context = tauri::generate_context!();

    tauri::Builder::default()
        .setup(|app| {
            let main_window = app.get_window("main").unwrap();

            #[cfg(target_os = "macos")]
            {
                use cocoa::appkit::{NSMainMenuWindowLevel, NSWindow};
                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());
                }
            } 
            // main_window.set_level(WindowLevel::MainMenu+1); // ideal setup
 
            Ok(())
        })
        .menu(tauri::Menu::os_default(&context.package_info().name))
        .run(context)
        .expect("error while running tauri application");
}

Alternatives considered

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    📬Proposal

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions