mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-08 02:45:38 +00:00
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
|
@end
|
||||||
|
|
||||||
@implementation GioView
|
@implementation GioView
|
||||||
|
- (void)setFrameSize:(NSSize)newSize {
|
||||||
|
[super setFrameSize:newSize];
|
||||||
|
[self setNeedsDisplay:YES];
|
||||||
|
}
|
||||||
// drawRect is called when OpenGL is used, displayLayer otherwise.
|
// drawRect is called when OpenGL is used, displayLayer otherwise.
|
||||||
// Don't know why.
|
// Don't know why.
|
||||||
- (void)drawRect:(NSRect)r {
|
- (void)drawRect:(NSRect)r {
|
||||||
@@ -233,7 +237,7 @@ CFTypeRef gio_createView(void) {
|
|||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
NSRect frame = NSMakeRect(0, 0, 0, 0);
|
NSRect frame = NSMakeRect(0, 0, 0, 0);
|
||||||
GioView* view = [[GioView alloc] initWithFrame:frame];
|
GioView* view = [[GioView alloc] initWithFrame:frame];
|
||||||
[view setWantsLayer:YES];
|
view.wantsLayer = YES;
|
||||||
view.layerContentsRedrawPolicy = NSViewLayerContentsRedrawDuringViewResize;
|
view.layerContentsRedrawPolicy = NSViewLayerContentsRedrawDuringViewResize;
|
||||||
return CFBridgingRetain(view);
|
return CFBridgingRetain(view);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user