Skip to content

Commit f8ad608

Browse files
committed
Fix resize jank
1 parent c560f2e commit f8ad608

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

src/window-osx.mm

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -444,14 +444,6 @@ @implementation WindowImplObj
444444

445445
wi->view.glData->stop = false;
446446
wi->view.glData->thread = new std::thread(renderFrames, wi);
447-
448-
NSRect frame = [wi->window frame];
449-
frame.size = NSMakeSize(IOSurfaceGetWidth(wi->view.glData->surface),
450-
IOSurfaceGetHeight(wi->view.glData->surface));
451-
[wi->window setFrame: frame display: YES animate: NO];
452-
453-
[wi->view setFrameSize:NSMakeSize(IOSurfaceGetWidth(wi->view.glData->surface),
454-
IOSurfaceGetHeight(wi->view.glData->surface))];
455447
}
456448

457449
void WindowObjCInt::destroyIOSurface(std::string name)
@@ -476,8 +468,22 @@ @implementation WindowImplObj
476468
WindowInfo* wi = reinterpret_cast<WindowInfo*>(it->second);
477469

478470
NSWindow* parent = (NSWindow*)[wi->window parentWindow];
479-
NSRect frame = [parent frame];
480-
[wi->window setFrameOrigin:NSMakePoint(frame.origin.x + cx, frame.origin.y + cy)];
471+
NSRect parentFrame = [parent frame];
472+
473+
NSRect frame = [wi->window frame];
474+
frame.size = NSMakeSize(
475+
IOSurfaceGetWidth(wi->view.glData->surface),
476+
IOSurfaceGetHeight(wi->view.glData->surface)
477+
);
478+
479+
frame.origin.x = parentFrame.origin.x + cx;
480+
frame.origin.y = parentFrame.origin.y + cy;
481+
482+
[wi->view setFrameSize:NSMakeSize(IOSurfaceGetWidth(wi->view.glData->surface),
483+
IOSurfaceGetHeight(wi->view.glData->surface))];
484+
485+
[wi->window setFrame:frame display: YES animate: NO];
486+
481487
}
482488

483489
@end

0 commit comments

Comments
 (0)