#Setting highest window level possible on macos to hide incoming notification

8 messages · Page 1 of 1 (latest)

wild sage
#

I need to find a way to set the window level of my app to be the highest possible when I am in fullscreen, so no even the incoming notifications (on the notification center) can be seen (img1).
Making set_always_on_top(true) does not do the job, maybe because the window level it sets it's not high enough:

  #[inline]
  pub fn set_always_on_top(&self, always_on_top: bool) {
    let level = if always_on_top {
      ffi::NSWindowLevel::NSFloatingWindowLevel
    } else {
      ffi::NSWindowLevel::NSNormalWindowLevel
    };
    unsafe { util::set_level_async(&self.ns_window, level) };
  }

Is there a way I can achieve this behaviour?

#

Setting highest window level possible on macos to hide incoming notification

dusky moat
#

you can use the objc2 crates directly eg ```rs
let nswin: &objc2_app_kit::NSWindow = main_window.ns_window().unwrap().cast();
nswin.setLevel(some_number);

#

though not sure if a high level is enough to be above notifications, never seen that behavior (as someone who only uses macos if needed)

wild sage
#

It is like when you lunch a game, that you enter fullscreen and you don't see your notifications anymore

#

I thought also about the Fullscreen:

          WindowMessage::SetFullscreen(fullscreen) => {
            if fullscreen {
              window.set_fullscreen(Some(Fullscreen::Borderless(None)))
            } else {
              window.set_fullscreen(None)
            }
          }
#

It might work to have the chance to use the Fullscree::Exclusive

#

Bc I saw in the impl that it sets the level to be:

        self
          .ns_window
          .setLevel(ffi::CGShieldingWindowLevel() as isize + 1);