Open probablykasper opened 3 years ago
@srsholmes was talking about how this could work in https://github.com/tauri-apps/tauri/issues/2258 (as well as behavior across multiple spaces, which idk if there should be another issue for?)
on hold until tauri-apps/tao#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
but it will be only for mac.
I will transfer to tao.
This can be achieved (at least on macos) by the work in https://github.com/tauri-apps/tao/issues/185. It might be possibly what the
ns_window.setLevel_(10000);
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 Cpu: M2
Hi Any updates on this one?
No new developments?
I was able to make it work in release app by combining @ParthJadhav's example and adding
<key>LSUIElement</key>
<true/>
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 ActivationPolicy::Accessory
and setVisibleOnAllWorkspaces(true)
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:
error[E0433]: failed to resolve: could not find `ActivationPolicy` in `tauri`
--> src/app/setup.rs:81:42
|
81 | app.set_activation_policy(tauri::ActivationPolicy::Accessory);
| ^^^^^^^^^^^^^^^^ could not find `ActivationPolicy` in `tauri`
|
note: found an item that was configured out
--> /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tauri-2.0.0-beta.17/src/lib.rs:209:18
|
209 | pub use runtime::ActivationPolicy;
| ^^^^^^^^^^^^^^^^
= note: the item is gated behind the `macos` feature
error[E0599]: no method named `set_activation_policy` found for mutable reference `&mut tauri::App` in the current scope
--> src/app/setup.rs:81:13
|
81 | app.set_activation_policy(tauri::ActivationPolicy::Accessory);
| ^^^^^^^^^^^^^^^^^^^^^ method not found in `&mut App`
Try add target_os
above the line:
#[cfg(target_os = "macos")]
app.set_activation_policy(tauri::ActivationPolicy::Accessory);
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:
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 cfg!
marco still compiles the code, it returns a boolean. #[cfg]
will conditionally compile the code.
Would allow for Spotlight-like panel windows.
Related:
StackOverflow 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