app: merge app/internal/wm into package app

The app and app/internal/wm packages are tightly coupled, requiring
quite a bit of forwarding types, values and constants from the internal
package to export it. Further, no other package imports package wm.

This change merges the two packages.

While here, drop the pre-Go 1.14 SIGPIPE workaround.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2021-08-29 22:00:16 +02:00
parent fe52357141
commit 45da52cee7
46 changed files with 325 additions and 400 deletions
+74
View File
@@ -0,0 +1,74 @@
// SPDX-License-Identifier: Unlicense OR MIT
// +build darwin,!ios,nometal
@import AppKit;
#include <CoreFoundation/CoreFoundation.h>
#include <OpenGL/OpenGL.h>
#include "_cgo_export.h"
CALayer *gio_layerFactory(void) {
@autoreleasepool {
return [CALayer layer];
}
}
CFTypeRef gio_createGLContext(void) {
@autoreleasepool {
NSOpenGLPixelFormatAttribute attr[] = {
NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core,
NSOpenGLPFAColorSize, 24,
NSOpenGLPFAAccelerated,
// Opt-in to automatic GPU switching. CGL-only property.
kCGLPFASupportsAutomaticGraphicsSwitching,
NSOpenGLPFAAllowOfflineRenderers,
0
};
NSOpenGLPixelFormat *pixFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr];
NSOpenGLContext *ctx = [[NSOpenGLContext alloc] initWithFormat:pixFormat shareContext: nil];
return CFBridgingRetain(ctx);
}
}
void gio_setContextView(CFTypeRef ctxRef, CFTypeRef viewRef) {
NSOpenGLContext *ctx = (__bridge NSOpenGLContext *)ctxRef;
NSView *view = (__bridge NSView *)viewRef;
[view setWantsBestResolutionOpenGLSurface:YES];
[ctx setView:view];
}
void gio_clearCurrentContext(void) {
@autoreleasepool {
[NSOpenGLContext clearCurrentContext];
}
}
void gio_updateContext(CFTypeRef ctxRef) {
@autoreleasepool {
NSOpenGLContext *ctx = (__bridge NSOpenGLContext *)ctxRef;
[ctx update];
}
}
void gio_makeCurrentContext(CFTypeRef ctxRef) {
@autoreleasepool {
NSOpenGLContext *ctx = (__bridge NSOpenGLContext *)ctxRef;
[ctx makeCurrentContext];
}
}
void gio_lockContext(CFTypeRef ctxRef) {
@autoreleasepool {
NSOpenGLContext *ctx = (__bridge NSOpenGLContext *)ctxRef;
CGLLockContext([ctx CGLContextObj]);
}
}
void gio_unlockContext(CFTypeRef ctxRef) {
@autoreleasepool {
NSOpenGLContext *ctx = (__bridge NSOpenGLContext *)ctxRef;
CGLUnlockContext([ctx CGLContextObj]);
}
}