-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[v3] Add option for showing the toolbar in fullscreen mode on macOS #3282
[v3] Add option for showing the toolbar in fullscreen mode on macOS #3282
Conversation
Important Auto Review SkippedAuto reviews are disabled on base/target branches other than the default branch. Please add the base/target branch pattern to the list of additional branches to be reviewed in the settings. Please check the settings in the CodeRabbit UI or the To trigger a single review, invoke the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
if ( toolbar == nil ) { | ||
return; | ||
} | ||
[window setToolbarStyle:style]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The windowSetToolbarStyle
had previously a wrong implementation and was unused. I changed it to the correct implementation and used it to replace the code that was previously at lines 452–457.
@@ -443,30 +443,28 @@ void windowSetHideTitle(void* nsWindow, bool hideTitle) { | |||
} | |||
|
|||
// Set Window use toolbar | |||
void windowSetUseToolbar(void* nsWindow, bool useToolbar, int toolbarStyle) { | |||
void windowSetUseToolbar(void* nsWindow, bool useToolbar) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The signature of this method has changed because the style configuration is now done through the windowSetToolbarStyle
method, as per the comment at line 467.
@@ -1146,11 +1153,12 @@ func (w *macosWebviewWindow) run() { | |||
C.windowSetHideTitleBar(w.nsWindow, C.bool(titleBarOptions.Hide)) | |||
C.windowSetHideTitle(w.nsWindow, C.bool(titleBarOptions.HideTitle)) | |||
C.windowSetFullSizeContent(w.nsWindow, C.bool(titleBarOptions.FullSizeContent)) | |||
if titleBarOptions.UseToolbar { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check has been removed as the involved methods work correctly in any case.
@@ -241,6 +241,9 @@ - (void)webView:(nonnull WKWebView *)webView stopURLSchemeTask:(nonnull id<WKURL | |||
} | |||
} | |||
} | |||
- (NSApplicationPresentationOptions)window:(NSWindow *)window willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main change is here: a new property on the delegate interface is used as a flag to either keep the default presentation options, or enable the NSApplicationPresentationAutoHideToolbar
option, thus hiding the toolbar.
Thanks for spending time on this and making such a comprehensive PR 🙏 As we currently have no API for adding anything to the toolbar, I'm wondering if this should be default behaviour? If later on, we have APIs to add elements to the toolbar, we could reintroduce this flag, but maybe invert it: |
Thank you for taking the time to review the PR! As regards flipping the flag, I too had thought about it afterwards and completely second the proposal. This way, the original behaviour from v2 becomes the default and the change is completely transparent to the average consumer. As regards removing the flag altogether, it makes no difference to me as I don't actually need it. However, I'd like to argue briefly in favour of keeping it:
Let me know what you think about it, and afterwards I can edit the patch. |
You make some great points above and on the whole, I agree. Simply changing the Hide to Show might be enough for this PR. If you wanted to take it one step further, how about a method to set the value on the |
Ok, thanks! I am gonna edit the PR. As regards adding the method, no other title bar parameter is reconfigurable atm, so it feels strange to have a method just for this one option. I won't go for it right now. As I read your message I thought I'd whip up a further PR for titlebar reconfiguration in general, but I keep getting second thoughts about it, as I just can't see the use case... Should someone ask for it, it should take very little time anyways. |
Please note that I am gonna force-push here to keep things clean |
e33bd91
to
8679461
Compare
Great stuff! Thanks so much 👍 |
Thank you!! |
Description
When the MacTitleBar.UseToolbar option is enabled, the system toolbar is shown on macOS windows. Currently, when the windows are switched to fullscreen mode, the toolbar remains visible.
Although this might be desirable sometimes, in most common cases it is not the expected behaviour, as the full-screen toolbar cannot be made transparent and therefore clashes with the look of the application.
This patch introduces a new option in the
MacTitleBar
struct that when enabled hides the toolbar automatically upon entering fullscreen mode. It also enables the option by default in the predefined titlebar styles.Type of change
How Has This Been Tested?
The new
hide-macos-toolbar
example creates two windows shocasing the two possible configurations of the new flag.Test Configuration
Checklist:
mkdocs-website/docs/en/changelog.md
with details of this PR