app: [macOS] trigger redraw on resize for context-less windows

Switching to using a CAMetalLayer as the layer backing our NSView
implementation broke programs such as the opengl example. Somehow, using
ANGLE on top of a CAMetalLayer (but not a CAEAGLLayer) stops resizes
from triggering redraws.

This change invalidates the view in setFrameSize, to force a redraw
and no longer rely on the implicit redraws.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2021-09-19 09:16:11 +02:00
parent 799ee3374d
commit d1b35bf1d7
+5 -1
View File
@@ -60,6 +60,10 @@ static void handleMouse(NSView *view, NSEvent *event, int typ, CGFloat dx, CGFlo
@end
@implementation GioView
- (void)setFrameSize:(NSSize)newSize {
[super setFrameSize:newSize];
[self setNeedsDisplay:YES];
}
// drawRect is called when OpenGL is used, displayLayer otherwise.
// Don't know why.
- (void)drawRect:(NSRect)r {
@@ -233,7 +237,7 @@ CFTypeRef gio_createView(void) {
@autoreleasepool {
NSRect frame = NSMakeRect(0, 0, 0, 0);
GioView* view = [[GioView alloc] initWithFrame:frame];
[view setWantsLayer:YES];
view.wantsLayer = YES;
view.layerContentsRedrawPolicy = NSViewLayerContentsRedrawDuringViewResize;
return CFBridgingRetain(view);
}