Skip to content

Commit

Permalink
In MacOS, only disable menu bar in exclusive fullscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
cixel committed Dec 19, 2019
1 parent 01203b2 commit 3c4db7e
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions src/platform_impl/macos/window_delegate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,10 +427,10 @@ extern "C" fn window_will_enter_fullscreen(this: &Object, _: Sel, _: id) {
}

extern "C" fn window_will_use_fullscreen_presentation_options(
_this: &Object,
this: &Object,
_: Sel,
_: id,
_proposed_options: NSUInteger,
proposed_options: NSUInteger,
) -> NSUInteger {
// Generally, games will want to disable the menu bar and the dock. Ideally,
// this would be configurable by the user. Unfortunately because of our
Expand All @@ -440,10 +440,24 @@ extern "C" fn window_will_use_fullscreen_presentation_options(
// still want to make this configurable for borderless fullscreen. Right now
// we don't, for consistency. If we do, it should be documented that the
// user-provided options are ignored in exclusive fullscreen.
(NSApplicationPresentationOptions::NSApplicationPresentationFullScreen
| NSApplicationPresentationOptions::NSApplicationPresentationHideDock
| NSApplicationPresentationOptions::NSApplicationPresentationHideMenuBar)
.bits()
let mut options: NSUInteger = proposed_options;
with_state(this, |state| {
state.with_window(|window| {
// window.fullscreen_presentation_options
trace!("Locked shared state in `window_will_use_fullscreen_presentation_options`");
let shared_state = window.shared_state.lock().unwrap();
if let Some(Fullscreen::Exclusive(_)) = shared_state.fullscreen {
options = (NSApplicationPresentationOptions::NSApplicationPresentationFullScreen
| NSApplicationPresentationOptions::NSApplicationPresentationHideDock
| NSApplicationPresentationOptions::NSApplicationPresentationHideMenuBar)
.bits();
}

trace!("Unlocked shared state in `window_will_use_fullscreen_presentation_options`");
})
});

options
}

/// Invoked when entered fullscreen
Expand Down

0 comments on commit 3c4db7e

Please sign in to comment.