forked from joejulian/gio
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:
+5
-1
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user