Skip to content

Commit

Permalink
Fix resize jank
Browse files Browse the repository at this point in the history
  • Loading branch information
EddyGharbi committed Mar 5, 2020
1 parent c560f2e commit f8ad608
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions src/window-osx.mm
Original file line number Diff line number Diff line change
Expand Up @@ -444,14 +444,6 @@ @implementation WindowImplObj

wi->view.glData->stop = false;
wi->view.glData->thread = new std::thread(renderFrames, wi);

NSRect frame = [wi->window frame];
frame.size = NSMakeSize(IOSurfaceGetWidth(wi->view.glData->surface),
IOSurfaceGetHeight(wi->view.glData->surface));
[wi->window setFrame: frame display: YES animate: NO];

[wi->view setFrameSize:NSMakeSize(IOSurfaceGetWidth(wi->view.glData->surface),
IOSurfaceGetHeight(wi->view.glData->surface))];
}

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

NSWindow* parent = (NSWindow*)[wi->window parentWindow];
NSRect frame = [parent frame];
[wi->window setFrameOrigin:NSMakePoint(frame.origin.x + cx, frame.origin.y + cy)];
NSRect parentFrame = [parent frame];

NSRect frame = [wi->window frame];
frame.size = NSMakeSize(
IOSurfaceGetWidth(wi->view.glData->surface),
IOSurfaceGetHeight(wi->view.glData->surface)
);

frame.origin.x = parentFrame.origin.x + cx;
frame.origin.y = parentFrame.origin.y + cy;

[wi->view setFrameSize:NSMakeSize(IOSurfaceGetWidth(wi->view.glData->surface),
IOSurfaceGetHeight(wi->view.glData->surface))];

[wi->window setFrame:frame display: YES animate: NO];

}

@end

0 comments on commit f8ad608

Please sign in to comment.