mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Bug 1644212 - reintroduce an attribute to limit which windows allow full screen, r=xidorn,haik
Differential Revision: https://phabricator.services.mozilla.com/D79109
This commit is contained in:
parent
ba07c87114
commit
f5a71f797d
@ -55,6 +55,7 @@
|
||||
tabsintitlebar="true"
|
||||
windowtype="navigator:browser"
|
||||
macanimationtype="document"
|
||||
macnativefullscreen="true"
|
||||
screenX="4" screenY="4"
|
||||
sizemode="normal"
|
||||
retargetdocumentfocus="urlbar-input"
|
||||
|
@ -304,6 +304,7 @@ class nsCocoaWindow final : public nsBaseWidget, public nsPIWidgetCocoa {
|
||||
virtual void SetWindowTransform(const mozilla::gfx::Matrix& aTransform) override;
|
||||
virtual void SetWindowMouseTransparent(bool aIsTransparent) override;
|
||||
virtual void SetShowsToolbarButton(bool aShow) override;
|
||||
virtual void SetSupportsNativeFullscreen(bool aShow) override;
|
||||
virtual void SetWindowAnimationType(WindowAnimationType aType) override;
|
||||
virtual void SetDrawsTitle(bool aDrawTitle) override;
|
||||
virtual void SetUseBrightTitlebarForeground(bool aBrightForeground) override;
|
||||
|
@ -509,9 +509,6 @@ nsresult nsCocoaWindow::CreateNativeWindow(const NSRect& aRect, nsBorderStyle aB
|
||||
[mWindow setLevel:NSFloatingWindowLevel];
|
||||
newBehavior |= NSWindowCollectionBehaviorCanJoinAllSpaces;
|
||||
}
|
||||
if ((features & NSResizableWindowMask)) {
|
||||
newBehavior |= NSWindowCollectionBehaviorFullScreenPrimary;
|
||||
}
|
||||
[mWindow setCollectionBehavior:newBehavior];
|
||||
|
||||
[mWindow setContentMinSize:NSMakeSize(60, 60)];
|
||||
@ -1612,6 +1609,14 @@ void nsCocoaWindow::UpdateFullscreenState(bool aFullScreen, bool aNativeMode) {
|
||||
|
||||
inline bool nsCocoaWindow::ShouldToggleNativeFullscreen(bool aFullScreen,
|
||||
bool aUseSystemTransition) {
|
||||
// First check if this window supports entering native fullscreen.
|
||||
// This is set based on the macnativefullscreen attribute on the window's
|
||||
// document element.
|
||||
NSWindowCollectionBehavior colBehavior = [mWindow collectionBehavior];
|
||||
if (!(colBehavior & NSWindowCollectionBehaviorFullScreenPrimary)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mInNativeFullScreenMode) {
|
||||
// If we are using native fullscreen, go ahead to exit it.
|
||||
return true;
|
||||
@ -2329,6 +2334,28 @@ void nsCocoaWindow::SetShowsToolbarButton(bool aShow) {
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||
}
|
||||
|
||||
void nsCocoaWindow::SetSupportsNativeFullscreen(bool aSupportsNativeFullscreen) {
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
||||
|
||||
if (mWindow) {
|
||||
// This determines whether we tell cocoa that the window supports native
|
||||
// full screen. If we do so, and another window is in native full screen,
|
||||
// this window will also appear in native full screen. We generally only
|
||||
// want to do this for primary application windows. We'll set the
|
||||
// relevant macnativefullscreen attribute on those, which will lead to us
|
||||
// being called with aSupportsNativeFullscreen set to `true` here.
|
||||
NSWindowCollectionBehavior newBehavior = [mWindow collectionBehavior];
|
||||
if (aSupportsNativeFullscreen) {
|
||||
newBehavior |= NSWindowCollectionBehaviorFullScreenPrimary;
|
||||
} else {
|
||||
newBehavior &= ~NSWindowCollectionBehaviorFullScreenPrimary;
|
||||
}
|
||||
[mWindow setCollectionBehavior:newBehavior];
|
||||
}
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||
}
|
||||
|
||||
void nsCocoaWindow::SetWindowAnimationType(nsIWidget::WindowAnimationType aType) {
|
||||
mAnimationType = aType;
|
||||
}
|
||||
|
@ -183,6 +183,8 @@ class nsBaseWidget : public nsIWidget, public nsSupportsWeakReference {
|
||||
virtual void SetWindowShadowStyle(
|
||||
mozilla::StyleWindowShadow aStyle) override {}
|
||||
virtual void SetShowsToolbarButton(bool aShow) override {}
|
||||
virtual void SetSupportsNativeFullscreen(
|
||||
bool aSupportsNativeFullscreen) override {}
|
||||
virtual void SetWindowAnimationType(WindowAnimationType aType) override {}
|
||||
virtual void HideWindowChrome(bool aShouldHide) override {}
|
||||
virtual bool PrepareForFullscreenTransition(nsISupports** aData) override {
|
||||
|
@ -1141,6 +1141,17 @@ class nsIWidget : public nsISupports {
|
||||
*/
|
||||
virtual void SetShowsToolbarButton(bool aShow) = 0;
|
||||
|
||||
/*
|
||||
* On macOS, this method determines whether we tell cocoa that the window
|
||||
* supports native full screen. If we do so, and another window is in
|
||||
* native full screen, this window will also appear in native full screen.
|
||||
*
|
||||
* We generally only want to do this for primary application windows.
|
||||
*
|
||||
* Ignored on child widgets and on non-Mac platforms.
|
||||
*/
|
||||
virtual void SetSupportsNativeFullscreen(bool aSupportsNativeFullscreen) = 0;
|
||||
|
||||
enum WindowAnimationType {
|
||||
eGenericWindowAnimation,
|
||||
eDocumentWindowAnimation
|
||||
|
@ -1668,6 +1668,12 @@ void AppWindow::SyncAttributesToWidget() {
|
||||
|
||||
NS_ENSURE_TRUE_VOID(mWindow);
|
||||
|
||||
// "macnativefullscreen" attribute
|
||||
windowElement->GetAttribute(NS_LITERAL_STRING("macnativefullscreen"), attr);
|
||||
mWindow->SetSupportsNativeFullscreen(attr.LowerCaseEqualsLiteral("true"));
|
||||
|
||||
NS_ENSURE_TRUE_VOID(mWindow);
|
||||
|
||||
// "macanimationtype" attribute
|
||||
windowElement->GetAttribute(NS_LITERAL_STRING("macanimationtype"), attr);
|
||||
if (attr.EqualsLiteral("document")) {
|
||||
|
Loading…
Reference in New Issue
Block a user