Skip to content

Commit ea67fa9

Browse files
authored
Merge branch 'main' into frameworks
2 parents 34e99a0 + d1ed53d commit ea67fa9

File tree

8 files changed

+36
-54
lines changed

8 files changed

+36
-54
lines changed

Diff for: .ado/variables/vars.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ variables:
22
VmImageApple: macOS-13
33
slice_name: 'Xcode_15.0'
44
xcode_version: '/Applications/Xcode_15.0.app'
5-
ios_version: '17.0'
5+
ios_version: '17.0.1'
66
ios_simulator: 'iPhone 15'

Diff for: packages/react-native/React/Base/RCTUIKit.h

+2
Original file line numberDiff line numberDiff line change
@@ -495,8 +495,10 @@ NS_ASSUME_NONNULL_END
495495

496496
#if !TARGET_OS_OSX
497497
typedef UIApplication RCTUIApplication;
498+
typedef UIWindow RCTUIWindow;
498499
#else
499500
typedef NSApplication RCTUIApplication;
501+
typedef NSWindow RCTUIWindow;
500502
#endif
501503

502504
//

Diff for: packages/react-native/React/Base/RCTUtils.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,13 @@ RCT_EXTERN BOOL RCTRunningInAppExtension(void);
9393
#endif // [macOS]
9494

9595
// Returns the shared UIApplication instance, or nil if running in an App Extension
96-
RCT_EXTERN UIApplication *__nullable RCTSharedApplication(void);
96+
RCT_EXTERN RCTUIApplication *__nullable RCTSharedApplication(void); // [macOS]
9797

98-
#if !TARGET_OS_OSX // [macOS]
9998
// Returns the current main window, useful if you need to access the root view
10099
// or view controller
101-
RCT_EXTERN UIWindow *__nullable RCTKeyWindow(void);
100+
RCT_EXTERN RCTUIWindow *__nullable RCTKeyWindow(void); // [macOS]
102101

102+
#if !TARGET_OS_OSX // [macOS]
103103
// Returns the presented view controller, useful if you need
104104
// e.g. to present a modal view controller or alert over it
105105
RCT_EXTERN UIViewController *__nullable RCTPresentedViewController(void);

Diff for: packages/react-native/React/Base/RCTUtils.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ BOOL RCTRunningInAppExtension(void)
581581
}
582582
#endif // [macOS]
583583

584-
UIApplication *__nullable RCTSharedApplication(void)
584+
RCTUIApplication *__nullable RCTSharedApplication(void) // [macOS]
585585
{
586586
#if !TARGET_OS_OSX // [macOS]
587587
if (RCTRunningInAppExtension()) {
@@ -593,7 +593,7 @@ BOOL RCTRunningInAppExtension(void)
593593
#endif // macOS]
594594
}
595595

596-
RCTPlatformWindow *__nullable RCTKeyWindow(void) // [macOS]
596+
RCTUIWindow *__nullable RCTKeyWindow(void) // [macOS]
597597
{
598598
#if !TARGET_OS_OSX // [macOS]
599599
if (RCTRunningInAppExtension()) {

Diff for: packages/react-native/React/CoreModules/RCTDeviceInfo.mm

+5-13
Original file line numberDiff line numberDiff line change
@@ -108,18 +108,10 @@ static BOOL RCTIsIPhoneNotched()
108108
}
109109

110110

111-
#if !TARGET_OS_OSX // [macOS]
112-
NSDictionary *RCTExportedDimensions(CGFloat fontScale)
113-
#else // [macOS
114-
static NSDictionary *RCTExportedDimensions(RCTPlatformView *rootView)
115-
#endif // macOS]
111+
static NSDictionary *RCTExportedDimensions(CGFloat fontScale)
116112
{
117113
RCTAssertMainQueue();
118-
#if !TARGET_OS_OSX // [macOS]
119114
RCTDimensions dimensions = RCTGetDimensions(fontScale);
120-
#else // [macOS
121-
RCTDimensions dimensions = RCTGetDimensions(rootView);
122-
#endif // macOS]
123115
__typeof(dimensions.window) window = dimensions.window;
124116
NSDictionary<NSString *, NSNumber *> *dimsWindow = @{
125117
@"width" : @(window.width),
@@ -144,13 +136,13 @@ - (NSDictionary *)_exportedDimensions
144136
RCTAccessibilityManager *accessibilityManager =
145137
(RCTAccessibilityManager *)[_moduleRegistry moduleForName:"AccessibilityManager"];
146138
RCTAssert(accessibilityManager, @"Failed to get exported dimensions: AccessibilityManager is nil");
147-
CGFloat fontScale = accessibilityManager ? accessibilityManager.multiplier : 1.0;
148139
#if !TARGET_OS_OSX // [macOS]
149-
return RCTExportedDimensions(fontScale);
140+
CGFloat fontScale = accessibilityManager ? accessibilityManager.multiplier : 1.0;
150141
#else // [macOS
151-
// TODO: Saad - get root view here
152-
return RCTExportedDimensions(nil);
142+
CGFloat fontScale = 1.0;
153143
#endif // macOS]
144+
145+
return RCTExportedDimensions(fontScale);
154146
}
155147

156148
- (NSDictionary<NSString *, id> *)constantsToExport

Diff for: packages/react-native/React/UIUtils/RCTUIUtils.h

-4
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,7 @@ typedef struct {
2222
} window, screen;
2323
} RCTDimensions;
2424
extern __attribute__((visibility("default")))
25-
#if !TARGET_OS_OSX // [macOS]
2625
RCTDimensions RCTGetDimensions(CGFloat fontScale);
27-
#else // [macOS
28-
RCTDimensions RCTGetDimensions(RCTPlatformView *rootView);
29-
#endif // macOS]
3026

3127
#ifdef __cplusplus
3228
}

Diff for: packages/react-native/React/UIUtils/RCTUIUtils.m

+9-22
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@
99

1010
#import "RCTUtils.h"
1111

12-
#if !TARGET_OS_OSX // [macOS]
1312
RCTDimensions RCTGetDimensions(CGFloat fontScale)
14-
#else // [macOS
15-
RCTDimensions RCTGetDimensions(RCTPlatformView *rootView)
16-
#endif // macOS]
1713
{
1814
#if !TARGET_OS_OSX // [macOS]
1915
UIScreen *mainScreen = UIScreen.mainScreen;
@@ -24,20 +20,11 @@ RCTDimensions RCTGetDimensions(RCTPlatformView *rootView)
2420
// We fallback to screen size if a key window is not found.
2521
CGSize windowSize = mainWindow ? mainWindow.bounds.size : screenSize;
2622
#else // [macOS
27-
NSWindow *window = nil;
28-
NSSize windowSize;
29-
NSSize screenSize;
30-
if (rootView != nil) {
31-
window = [rootView window];
32-
windowSize = [window frame].size;
33-
} else {
34-
// We don't have a root view so fall back to the app's key window
35-
window = [NSApp keyWindow];
36-
windowSize = [window frame].size;
37-
}
38-
screenSize = [[window screen] frame].size;
39-
#endif
40-
23+
RCTUIWindow *window = RCTKeyWindow();
24+
NSSize windowSize = window ? [window frame].size : CGSizeMake(0, 0);
25+
NSSize screenSize = window ? [[window screen] frame].size : CGSizeMake(0, 0);
26+
CGFloat scale = window ? [[window screen] backingScaleFactor] : 1.0; // Default scale to 1.0 if window is nil
27+
#endif // macOS
4128
RCTDimensions result;
4229
#if !TARGET_OS_OSX // [macOS]
4330
typeof(result.screen) dimsScreen = {
@@ -48,13 +35,13 @@ RCTDimensions RCTGetDimensions(RCTPlatformView *rootView)
4835
typeof(result.screen) dimsScreen = {
4936
.width = screenSize.width,
5037
.height = screenSize.height,
51-
.scale = [[window screen] backingScaleFactor],
52-
.fontScale = 1};
38+
.scale = scale,
39+
.fontScale = fontScale};
5340
typeof(result.window) dimsWindow = {
5441
.width = windowSize.width,
5542
.height = windowSize.height,
56-
.scale = [[window screen] backingScaleFactor],
57-
.fontScale = 1};
43+
.scale = scale,
44+
.fontScale = fontScale};
5845
#endif // macOS]
5946
result.screen = dimsScreen;
6047
result.window = dimsWindow;

Diff for: packages/react-native/React/Views/RCTView.m

+14-9
Original file line numberDiff line numberDiff line change
@@ -1492,16 +1492,21 @@ - (BOOL)acceptsFirstResponder
14921492

14931493
- (void)updateTrackingAreas
14941494
{
1495-
if (_trackingArea) {
1496-
[self removeTrackingArea:_trackingArea];
1497-
}
1495+
BOOL hasMouseHoverEvent = self.onMouseEnter || self.onMouseLeave;
1496+
BOOL wouldRecreateIdenticalTrackingArea = hasMouseHoverEvent && _trackingArea && NSEqualRects(self.bounds, [_trackingArea rect]);
1497+
1498+
if (!wouldRecreateIdenticalTrackingArea) {
1499+
if (_trackingArea) {
1500+
[self removeTrackingArea:_trackingArea];
1501+
}
14981502

1499-
if (self.onMouseEnter || self.onMouseLeave) {
1500-
_trackingArea = [[NSTrackingArea alloc] initWithRect:self.bounds
1501-
options:NSTrackingActiveAlways|NSTrackingMouseEnteredAndExited
1502-
owner:self
1503-
userInfo:nil];
1504-
[self addTrackingArea:_trackingArea];
1503+
if (hasMouseHoverEvent) {
1504+
_trackingArea = [[NSTrackingArea alloc] initWithRect:self.bounds
1505+
options:NSTrackingActiveAlways|NSTrackingMouseEnteredAndExited
1506+
owner:self
1507+
userInfo:nil];
1508+
[self addTrackingArea:_trackingArea];
1509+
}
15051510
}
15061511

15071512
[super updateTrackingAreas];

0 commit comments

Comments
 (0)