mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-07 02:15:34 +00:00
app: [macOS] synchronize rendering with Core Animation for smooth resizes
Magic incantations lifted from https://thume.ca/2019/06/19/glitchless-metal-window-resizing/ Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -195,6 +195,14 @@ static void setScreenFrame(CFTypeRef windowRef, CGFloat x, CGFloat y, CGFloat w,
|
||||
}
|
||||
}
|
||||
|
||||
static void resetLayerFrame(CFTypeRef viewRef) {
|
||||
@autoreleasepool {
|
||||
NSView* view = (__bridge NSView *)viewRef;
|
||||
NSRect r = view.frame;
|
||||
view.layer.frame = r;
|
||||
}
|
||||
}
|
||||
|
||||
static void hideWindow(CFTypeRef windowRef) {
|
||||
@autoreleasepool {
|
||||
NSWindow* window = (__bridge NSWindow *)windowRef;
|
||||
@@ -456,6 +464,9 @@ func (w *window) Configure(options []Option) {
|
||||
C.setWindowStandardButtonHidden(window, C.NSWindowCloseButton, barTrans)
|
||||
C.setWindowStandardButtonHidden(window, C.NSWindowMiniaturizeButton, barTrans)
|
||||
C.setWindowStandardButtonHidden(window, C.NSWindowZoomButton, barTrans)
|
||||
// When toggling the titlebar, the layer doesn't update its frame
|
||||
// until the next resize. Force it.
|
||||
C.resetLayerFrame(w.view)
|
||||
}
|
||||
w.ProcessEvent(ConfigEvent{Config: w.config})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user