summaryrefslogtreecommitdiff
path: root/src/Fl_cocoa.mm
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2020-10-11 10:42:51 +0200
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2020-10-11 10:43:01 +0200
commit5830226aab4428e77e7aa4078e0f544aef92f326 (patch)
treedabe68c4b460f676f8a212652cd105b8e55b7644 /src/Fl_cocoa.mm
parent1a841795d1bd6580cb696c21a22d3815b0b3f09a (diff)
Change procedure to capture window titlebar for macOS ≥ 10.15
That is necessary to support macOS Big Sur because previous procedure did not work for tabbed windows. The new procedure is potentially usable from macOS 10.5, but tested at this stage for macOS ≥ 10.15.
Diffstat (limited to 'src/Fl_cocoa.mm')
-rw-r--r--src/Fl_cocoa.mm17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm
index c7f4e41cc..f70cc62ec 100644
--- a/src/Fl_cocoa.mm
+++ b/src/Fl_cocoa.mm
@@ -4382,7 +4382,22 @@ void Fl_Cocoa_Window_Driver::draw_layer_to_context(CALayer *layer, CGContextRef
CGContextFillRect(gc, CGRectMake(0, 0, w, h));
}
CGContextSetShouldAntialias(gc, true);
- [layer renderInContext:gc]; // 10.5
+ if (fl_mac_os_version >= 101500) {
+ FLWindow *flwin = fl_xid(pWindow);
+ [flwin makeMainWindow];
+ [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:nil inMode:NSDefaultRunLoopMode dequeue:NO];
+ NSInteger win_id = [flwin windowNumber];
+ CFArrayRef array = CFArrayCreate(NULL, (const void**)&win_id, 1, NULL);
+ NSRect rr = [flwin frame];
+ rr.origin.y += rr.size.height - h;
+ rr.size.height = h;
+ rr.origin.y = CGDisplayBounds(CGMainDisplayID()).size.height - (rr.origin.y + rr.size.height);
+ CGImageRef img = CGWindowListCreateImageFromArray(rr, array, kCGWindowImageBoundsIgnoreFraming); // 10.5
+ CFRelease(array);
+ CGContextDrawImage(gc, CGRectMake(0, 0, w, h), img);
+ CGImageRelease(img);
+ } else
+ [layer renderInContext:gc]; // 10.5
CGContextRestoreGState(gc);
#endif
}