Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions packages/react-native/React/CoreModules/RCTDeviceInfo.mm
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,14 @@ static BOOL RCTIsIPhoneNotched()
#if !TARGET_OS_OSX // [macOS]
NSDictionary *RCTExportedDimensions(CGFloat fontScale)
#else // [macOS
static NSDictionary *RCTExportedDimensions(RCTPlatformView *rootView)
static NSDictionary *RCTExportedDimensions(void)
#endif // macOS]
{
RCTAssertMainQueue();
#if !TARGET_OS_OSX // [macOS]
RCTDimensions dimensions = RCTGetDimensions(fontScale);
#else // [macOS
RCTDimensions dimensions = RCTGetDimensions(rootView);
RCTDimensions dimensions = RCTGetDimensions();
#endif // macOS]
__typeof(dimensions.window) window = dimensions.window;
NSDictionary<NSString *, NSNumber *> *dimsWindow = @{
Expand Down Expand Up @@ -148,8 +148,7 @@ - (NSDictionary *)_exportedDimensions
#if !TARGET_OS_OSX // [macOS]
return RCTExportedDimensions(fontScale);
#else // [macOS
// TODO: Saad - get root view here
return RCTExportedDimensions(nil);
return RCTExportedDimensions();
#endif // macOS]
}

Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/React/UIUtils/RCTUIUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ extern __attribute__((visibility("default")))
#if !TARGET_OS_OSX // [macOS]
RCTDimensions RCTGetDimensions(CGFloat fontScale);
#else // [macOS
RCTDimensions RCTGetDimensions(RCTPlatformView *rootView);
RCTDimensions RCTGetDimensions(void);
#endif // macOS]

#ifdef __cplusplus
Expand Down
28 changes: 10 additions & 18 deletions packages/react-native/React/UIUtils/RCTUIUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#if !TARGET_OS_OSX // [macOS]
RCTDimensions RCTGetDimensions(CGFloat fontScale)
#else // [macOS
RCTDimensions RCTGetDimensions(RCTPlatformView *rootView)
RCTDimensions RCTGetDimensions(void)
#endif // macOS]
{
#if !TARGET_OS_OSX // [macOS]
Expand All @@ -24,20 +24,12 @@ RCTDimensions RCTGetDimensions(RCTPlatformView *rootView)
// We fallback to screen size if a key window is not found.
CGSize windowSize = mainWindow ? mainWindow.bounds.size : screenSize;
#else // [macOS
NSWindow *window = nil;
NSSize windowSize;
NSSize screenSize;
if (rootView != nil) {
window = [rootView window];
windowSize = [window frame].size;
} else {
// We don't have a root view so fall back to the app's key window
window = [NSApp keyWindow];
windowSize = [window frame].size;
}
screenSize = [[window screen] frame].size;
NSWindow *window = [NSApp keyWindow];
NSSize windowSize = window ? [window frame].size : CGSizeMake(0, 0);
NSSize screenSize = window ? [[window screen] frame].size : CGSizeMake(0, 0);
CGFloat scale = window ? [[window screen] backingScaleFactor] : 1.0; // Default scale to 1.0 if window is nil
CGFloat fontScale = 1;
#endif

RCTDimensions result;
#if !TARGET_OS_OSX // [macOS]
typeof(result.screen) dimsScreen = {
Expand All @@ -48,13 +40,13 @@ RCTDimensions RCTGetDimensions(RCTPlatformView *rootView)
typeof(result.screen) dimsScreen = {
.width = screenSize.width,
.height = screenSize.height,
.scale = [[window screen] backingScaleFactor],
.fontScale = 1};
.scale = scale,
.fontScale = fontScale};
typeof(result.window) dimsWindow = {
.width = windowSize.width,
.height = windowSize.height,
.scale = [[window screen] backingScaleFactor],
.fontScale = 1};
.scale = scale,
.fontScale = fontScale};
#endif // macOS]
result.screen = dimsScreen;
result.window = dimsWindow;
Expand Down