-
-
Notifications
You must be signed in to change notification settings - Fork 176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(macOS): add window.set_visible_on_fullscreen()
#189
Comments
@srsholmes was talking about how this could work in tauri-apps/tauri#2258 (as well as behavior across multiple spaces, which idk if there should be another issue for?) |
set_visible_on_all_workspaces()
on hold until #185 is done |
@amrbashir I don't think showing over fullscreen apps is necessarily the same as showing on all workspaces, though I don't know for sure |
I guess that is true, it doesn't have to be coupled with |
set_visible_on_all_workspaces()
set_visible_on_fullscreen()
set_visible_on_fullscreen()
window.set_visible_on_fullscreen()
This can be achieved (at least on macos) by the work in #185. It might be possibly what the
is doing. I havn't tested it without the setlevel, but I am able to have my tauri app show over full screen apps with the tweaks mentioned in that issue. |
Hey @srsholmes @probablykasper : #[tauri::command]
pub fn show_tauri_window(window: Window) {
let ns_window = window.ns_window().unwrap() as id;
unsafe {
let mut collection_behavior = ns_window.collectionBehavior();
collection_behavior |= NSWindowCollectionBehavior::NSWindowCollectionBehaviorCanJoinAllSpaces;
window.show().unwrap();
ns_window.setLevel_(10000);
}
} As suggested this should be able to show the window above any fullscreen application. But it doesn't do that on release versions. It works fine on dev but not on realease. MacOS: Ventura |
Hi |
No new developments? |
I was able to make it work in release app by combining @ParthJadhav's example and adding
to Info.plist as mentioned in https://stackoverflow.com/a/35452482/6475535 |
Hi, Do we have any update regarding this Issue |
@pewsheen can you research this and see if we can squeeze it before v2 rc? |
After some tries, I can make it work by setting Can someone else confirm this works? fn main() {
tauri::Builder::default()
.setup(| app | {
app.set_activation_policy(tauri::ActivationPolicy::Accessory);
Ok(())
})
.run(tauri::generate_context!())
.expect("error while running tauri application");
} import { Window } from '@tauri-apps/api/window';
const window = Window.getByLabel('main');
window?.setVisibleOnAllWorkspaces(true);
window?.setAlwaysOnTop(true); |
I can confirm. Tested using M1 on v2. I didn't use the js bindings, but setting the activation policy does work in having the window always on top. However, it doesn't seem to no-op on windows and linux. I tried placing it behind a macos cfg only, but it still fails for the other OSs on test builds in an action. The below is from an ubuntu-22.04 test build:
|
Try add #[cfg(target_os = "macos")]
app.set_activation_policy(tauri::ActivationPolicy::Accessory);
|
Weird. This was what I was using originally, but still causing failed builds. if cfg!(target_os = "macos") {
app.set_activation_policy(tauri::ActivationPolicy::Accessory);
}
... but the builds succeed now with this: #[cfg(target_os = "macos")]
{
app.set_activation_policy(tauri::ActivationPolicy::Accessory);
}
... Ideally we don't need a cfg guard at all, and it's just a no-op on unsupported OSs. |
I think that was because |
Would allow for Spotlight-like panel windows.
Related:
set_activation_policy
tauri#2258StackOverflow answers for showing window over fullscreen app:
This might be how Electron implements it? https://github.com/electron/electron/blob/81c143318ba04c9aff2a5bcb80e4a1e3d55e019f/shell/browser/native_window_mac.mm#L1297-L1318
The text was updated successfully, but these errors were encountered: