@@ -68,7 +68,9 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge
6868
6969 // TODO: Turn on layer backing just to avoid https://github.com/ptmt/react-native-desktop/issues/47
7070 // Maybe we could turn it off after the bug fixed in the future.
71- [self setWantsLayer: YES ];
71+ if (([self window ].styleMask & NSFullSizeContentViewWindowMask ) != NSFullSizeContentViewWindowMask ) {
72+ [self setWantsLayer: YES ];
73+ }
7274
7375 [self setNeedsLayout: NO ];
7476 [self setMaterial: NSVisualEffectMaterialLight ];
@@ -313,6 +315,7 @@ @implementation RCTRootContentView
313315 __weak RCTBridge *_bridge;
314316 RCTTouchHandler *_touchHandler;
315317 NSColor *_backgroundColor;
318+ CFTimeInterval _lastResizingAt;
316319}
317320
318321- (instancetype )initWithFrame : (CGRect)frame
@@ -321,6 +324,7 @@ - (instancetype)initWithFrame:(CGRect)frame
321324{
322325 if ((self = [super initWithFrame: frame])) {
323326 _bridge = bridge;
327+ _lastResizingAt = CACurrentMediaTime ();
324328 self.reactTag = reactTag;
325329 _touchHandler = [[RCTTouchHandler alloc ] initWithBridge: _bridge];
326330 [self addGestureRecognizer: _touchHandler];
@@ -367,25 +371,28 @@ - (void)mouseExited:(__unused NSEvent *)theEvent
367371 [[self window ] setAcceptsMouseMovedEvents: NO ];
368372}
369373
370- // TODO: fire onLayout or something?
371- // - (void)viewDidEndLiveResize
372- // {
373- // [self setFrame:[RCTSharedApplication() mainWindow].contentView. frame];
374- // }
374+ - ( void ) viewDidEndLiveResize
375+ {
376+ [ super viewDidEndLiveResize ];
377+ [_bridge.uiManager setFrame: self . frame forView: self ];
378+ }
375379
376380- (void )setFrame : (CGRect)frame
377381{
378382 super.frame = frame;
379383 if (self.reactTag && _bridge.isValid ) {
380- [_bridge.uiManager setFrame: frame forView: self ];
384+ if (!self.inLiveResize || (self.inLiveResize && (CACurrentMediaTime () - _lastResizingAt) > 0.026 )) {
385+ [_bridge.uiManager setFrame: frame forView: self ];
386+ _lastResizingAt = CACurrentMediaTime ();
387+ }
381388 }
382389}
383390
384391- (void )setBackgroundColor : (NSColor *)backgroundColor
385392{
386393 _backgroundColor = backgroundColor;
387394 if (self.reactTag && _bridge.isValid ) {
388- [_bridge.uiManager setBackgroundColor: backgroundColor forView: self ];
395+ [_bridge.uiManager setBackgroundColor: backgroundColor forView: self ];
389396 }
390397}
391398
0 commit comments