Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ @implementation RCTViewComponentView {
BOOL _hasMouseOver;
BOOL _hasClipViewBoundsObserver;
NSTrackingArea *_trackingArea;
BOOL _allowsVibrancy;
#endif // macOS]
NSMutableArray<RCTUIView *> *_reactSubviews; // [macOS]
NSSet<NSString *> *_Nullable _propKeysManagedByAnimated_DO_NOT_USE_THIS_IS_BROKEN;
Expand All @@ -81,6 +82,10 @@ - (instancetype)initWithFrame:(CGRect)frame
#endif // [macOS]
_useCustomContainerView = NO;
_removeClippedSubviews = NO;
#if TARGET_OS_OSX // [macOS
_allowsVibrancy = NO;
self.mouseDownCanMoveWindow = YES;
#endif // macOS]
}
return self;
}
Expand Down Expand Up @@ -141,6 +146,11 @@ - (void)resetCursorRects
[self addCursorRect:self.bounds cursor:cursor];
}
}

- (BOOL)allowsVibrancy
{
return _allowsVibrancy;
}
#endif // macOS]

#if !TARGET_OS_OSX
Expand Down Expand Up @@ -593,6 +603,21 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &
}

#if TARGET_OS_OSX // [macOS
// `acceptsFirstMouse`
if (oldViewProps.acceptsFirstMouse != newViewProps.acceptsFirstMouse) {
self.acceptsFirstMouse = newViewProps.acceptsFirstMouse;
}

// `mouseDownCanMoveWindow`
if (oldViewProps.mouseDownCanMoveWindow != newViewProps.mouseDownCanMoveWindow) {
self.mouseDownCanMoveWindow = newViewProps.mouseDownCanMoveWindow;
}

// `allowsVibrancy`
if (oldViewProps.allowsVibrancy != newViewProps.allowsVibrancy) {
_allowsVibrancy = newViewProps.allowsVibrancy;
}

// `draggedTypes`
if (oldViewProps.draggedTypes != newViewProps.draggedTypes) {
if (!oldViewProps.draggedTypes.empty()) {
Expand Down Expand Up @@ -712,6 +737,11 @@ - (void)prepareForRecycle
_isJSResponder = NO;
_removeClippedSubviews = NO;
_reactSubviews = [NSMutableArray new];
#if TARGET_OS_OSX // [macOS
_allowsVibrancy = NO;
self.acceptsFirstMouse = NO;
self.mouseDownCanMoveWindow = YES;
#endif // macOS]
}

- (void)setPropKeysManagedByAnimated_DO_NOT_USE_THIS_IS_BROKEN:(NSSet<NSString *> *_Nullable)props
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,34 @@ HostPlatformViewProps::HostPlatformViewProps(
rawProps,
"tooltip",
sourceProps.tooltip,
{})) {}
{})),
acceptsFirstMouse(
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
? sourceProps.acceptsFirstMouse
: convertRawProp(
context,
rawProps,
"acceptsFirstMouse",
sourceProps.acceptsFirstMouse,
{})),
allowsVibrancy(
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
? sourceProps.allowsVibrancy
: convertRawProp(
context,
rawProps,
"allowsVibrancy",
sourceProps.allowsVibrancy,
{})),
mouseDownCanMoveWindow(
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
? sourceProps.mouseDownCanMoveWindow
: convertRawProp(
context,
rawProps,
"mouseDownCanMoveWindow",
sourceProps.mouseDownCanMoveWindow,
{})) {}

#define VIEW_EVENT_CASE_MACOS(eventType) \
case CONSTEXPR_RAW_PROPS_KEY_HASH("on" #eventType): { \
Expand Down Expand Up @@ -122,6 +149,9 @@ void HostPlatformViewProps::setProp(
RAW_SET_PROP_SWITCH_CASE_BASIC(keyUpEvents);
RAW_SET_PROP_SWITCH_CASE_BASIC(draggedTypes);
RAW_SET_PROP_SWITCH_CASE_BASIC(tooltip);
RAW_SET_PROP_SWITCH_CASE_BASIC(acceptsFirstMouse);
RAW_SET_PROP_SWITCH_CASE_BASIC(allowsVibrancy);
RAW_SET_PROP_SWITCH_CASE_BASIC(mouseDownCanMoveWindow);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,9 @@ class HostPlatformViewProps : public BaseViewProps {
std::vector<std::string> draggedTypes{};

std::optional<std::string> tooltip{};

bool acceptsFirstMouse{false};
bool allowsVibrancy{false};
bool mouseDownCanMoveWindow{true};
};
} // namespace facebook::react
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@
namespace facebook::react::HostPlatformViewTraitsInitializer {

inline bool formsStackingContext(const ViewProps& props) {
return false;
return props.allowsVibrancy ||
props.mouseDownCanMoveWindow ||
props.acceptsFirstMouse ||
props.hostPlatformEvents.bits.any();
}

inline bool formsView(const ViewProps& props) {
return props.focusable ||
props.hostPlatformEvents[HostPlatformViewEvents::Offset::MouseEnter] ||
props.hostPlatformEvents[HostPlatformViewEvents::Offset::MouseLeave];
return props.focusable;
}

} // namespace facebook::react::HostPlatformViewTraitsInitializer
Loading