mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 15:23:51 +00:00
Bug 1737831 - Also detect when the screen has a notch and, if so, don't shift by the menubar height either. r=mac-reviewers,mstange
This should fix the M1 mac case. Not sure if the SDKDeclarations bits is in the right place, hopefully it is. Differential Revision: https://phabricator.services.mozilla.com/D134632
This commit is contained in:
parent
80f7e0408a
commit
6ed36db472
@ -118,6 +118,11 @@ AXTextMarkerRef AXTextMarkerRangeCopyStartMarker(AXTextMarkerRangeRef text_marke
|
||||
AXTextMarkerRef AXTextMarkerRangeCopyEndMarker(AXTextMarkerRangeRef text_marker_range);
|
||||
}
|
||||
|
||||
@interface NSScreen (NSScreen12_0)
|
||||
// https://developer.apple.com/documentation/appkit/nsscreen/3882821-safeareainsets?language=objc&changes=latest_major
|
||||
@property(readonly) NSEdgeInsets safeAreaInsets;
|
||||
@end
|
||||
|
||||
#endif
|
||||
|
||||
#endif // SDKDefines_h
|
||||
|
@ -3686,6 +3686,15 @@ static const NSString* kStateWantsTitleDrawn = @"wantsTitleDrawn";
|
||||
}
|
||||
}
|
||||
|
||||
static bool ScreenHasNotch(nsCocoaWindow* aGeckoWindow) {
|
||||
if (@available(macOS 12.0, *)) {
|
||||
nsCOMPtr<nsIScreen> widgetScreen = aGeckoWindow->GetWidgetScreen();
|
||||
NSScreen* cocoaScreen = ScreenHelperCocoa::CocoaScreenForScreen(widgetScreen);
|
||||
return cocoaScreen.safeAreaInsets.top != 0.0f;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
- (void)updateTitlebarShownAmount:(CGFloat)aShownAmount {
|
||||
NSInteger styleMask = [self styleMask];
|
||||
if (!(styleMask & NSWindowStyleMaskFullScreen)) {
|
||||
@ -3714,7 +3723,7 @@ static const NSString* kStateWantsTitleDrawn = @"wantsTitleDrawn";
|
||||
// [ToolbarWindow titlebarHeight]. titlebarHeight returns 0 when we're in
|
||||
// fullscreen.
|
||||
CGFloat shiftByPixels = mInitialTitlebarHeight * aShownAmount;
|
||||
if (!gMenubarAlwaysShownInFullScreen) {
|
||||
if (!gMenubarAlwaysShownInFullScreen && !ScreenHasNotch(geckoWindow)) {
|
||||
shiftByPixels += mMenuBarHeight * aShownAmount;
|
||||
}
|
||||
// Use mozilla::DesktopToLayoutDeviceScale rather than the
|
||||
|
Loading…
Reference in New Issue
Block a user