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
feat: add panel support for BrowserWindow #34388
feat: add panel support for BrowserWindow #34388
Conversation
💖 Thanks for opening this pull request! 💖 We use semantic commit messages to streamline the release process. Before your pull request can be merged, you should update your pull request title to start with a semantic prefix. Examples of commit messages with semantic prefixes:
Things that will help get your PR across the finish line:
We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can. |
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.
Hi! Thanks for opening this PR - however, all new PRs, especially semver-minor or major PRs, must target main
. Only then, when it's reviewed and merged, can it be backported to version branches.
Could you also talk a bit more in your PR body about the impetus for this PR? What use cases are you trying to address?
I really like this implementation of panels overall, as it's similar to third-party solutions but safer and cleaner. Pros
Cons
Non-activating panels are such a useful and desirable part of modern apps (floating palettes are everywhere!) and I think the risk is manageable. Still, it would be great to work toward replacing this implementation with a real NSPanel in the long term. If done right it would be a transparent change to users who adopt this API in its current form. |
c2a5559
to
6ef9d10
Compare
6ef9d10
to
64e1e71
Compare
Hey @codebytere I changed the target branch to "main" as suggested and changed the wording in browser-window to make it more clear what this new type achieves i.e makes the window float on top of full-screened apps. As per @mitchchn's comment, this pull request addresses a feature which has been previously requested. This is still obviously not the ideal solution, but a workaround. |
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.
API LGTM
Co-authored-by: Cheng Zhao <github@zcbenz.com>
Co-authored-by: Cheng Zhao <github@zcbenz.com>
Hey all, We started using this patch internally and found a weird bug. If we toggle the "resizable" property on BrowserWindow with type = "panel" the height of the window increases by 28 points (which is height of titlebar on Mac). I confirmed in Xcode that this is not a bug on the native implementation, so something is going wrong when SetCanResize and then Widget->OnSizeConstraintChanged() is called in chromium. I'm still looking into this, but wanted to share here in case anyone has experience with this and can pinpoint the issue more easily. Screen recording showing the issue - google drive link Fiddle code to repro: const mainWindow = new BrowserWindow({ let resizable = true; |
@isailaandrei Can you try placing |
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.
API LGTM
Congrats on merging your first pull request! 🎉🎉🎉 |
Release Notes Persisted
|
/trop run backport-to 20-x-y |
The backport process for this PR has been manually initiated - sending your PR to |
I have automatically backported this PR to "20-x-y", please check out #34665 |
Hey folks! A question: this implementation indeed makes the window/panel appear without taking focus. But it now also can't react to hover events anymore... 🤔 Would you know which additional properties would do this? Best, |
* feat: add NSPanel support for BrowserWindow * change header guard to satisfy linter * change panel wording in browser-window * Revert "change panel wording in browser-window" This reverts commit 6f3f80f. * change wording in browser-window * Update shell/browser/ui/cocoa/electron_native_widget_mac.mm Co-authored-by: Cheng Zhao <github@zcbenz.com> * Update shell/browser/ui/cocoa/electron_native_widget_mac.h Co-authored-by: Cheng Zhao <github@zcbenz.com> * Changed ScopedDisableResize class to allow for nesting Co-authored-by: andreiisaila <andreiisaila@microsoft.com> Co-authored-by: Cheng Zhao <github@zcbenz.com>
NSWindow does not support nonactivating panel styleMask 0x80 |
Description of Change
Created a new ElectronNSPanel window which inherits from ElectronNSWindow. This window mimics the behavior of NSPanel - visible on top of full screened apps, joins all spaces. To achieve this it adds the "NSWindowStyleMaskNonactivatingPanel" style mask, normally reserved for NSPanel, at runtime.
This is a workaround to avoid patching chromium and duplicating lots of window code.
Checklist
npm test
passesRelease Notes
notes: Added support for panel-like behavior. Window can float over full-screened apps.