Show the menu bar in borderless fullscreen on macOS (#2053)
* In MacOS, only disable menu bar in exclusive fullscreen * Save and restore fullscreen options in set_fullscreen * Don't always cache presentation options when entering exclusive fullscreen This commit caches presentation options when entering exclusive fullscreen only if we're coming from borderless fullscreen. Then, when transitioning from exclusive -> borderless, if no cached presentation options are present, then the default borderless options are applied. This fixes the menu bar being unavailable when taking the following path: [not fullscreen] -> [exclusive fullscreen] -> [borderless fullscreen]. Without this commit, the presentation options from [not fullscreen] were being cached and then applied to [borderless fullscreen]. * Restore the window level when switching to exclusive fullscreen The hack of using `CGShieldingWindowLevel() + 1` in borderless fullscreen needs to be undone when switching from [borderless] -> [exclusive] fullscreen, otherwise there are menu bar glitches when following a path through [borderless] -> [exclusive] -> [borderless] modes. Now, this might appear to conflict with the 'always on top' feature which uses the 'floating window' level, but this feature appears to be broken anyway when entering and exiting fullscreen with an always-on-top window. So, rather than introducing logic to attempt to restore to the 'floating' level here, I think it's better to do the simple thing for now and then introduce logic for always-on-top windows when fixing the overall fullscreen behaviour. * Update the changelog Co-authored-by: Ehden Sinai <ehdens@gmail.com> Co-authored-by: Francesca Lovebloom <francesca@brainiumstudios.com>
This commit is contained in:
parent
3ecbea3c39
commit
f2de8475fc
3 changed files with 59 additions and 9 deletions
|
|
@ -482,10 +482,10 @@ extern "C" fn window_will_exit_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
|
||||
|
|
@ -495,10 +495,22 @@ 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| {
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue