app/internal/wm: [macOS] use NSView+NSOpenGLContext, not NSOpenGLContextView

NSOpenGLContextView couples the window manager logic tightly with
OpenGL. Use generic NSViews, and attach NSOpenGLContext just like the
other platforms.

This change prepares for supporting GPU contexts created by clients as
well as a future Metal port.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2021-05-14 16:48:14 +02:00
parent fcca1c11ee
commit 1d4bf04aa1
6 changed files with 170 additions and 126 deletions
+15 -2
View File
@@ -56,7 +56,8 @@ type Window struct {
}
type callbacks struct {
w *Window
w *Window
funcs chan func()
}
// queue is an event.Queue implementation that distributes system events
@@ -104,6 +105,7 @@ func NewWindow(options ...Option) *Window {
driverFuncs: make(chan func()),
dead: make(chan struct{}),
}
w.callbacks.funcs = make(chan func())
w.callbacks.w = w
go w.run(opts)
return w
@@ -299,11 +301,22 @@ func (c *callbacks) SetDriver(d wm.Driver) {
func (c *callbacks) Event(e event.Event) {
select {
case c.w.in <- e:
<-c.w.ack
for {
select {
case <-c.w.ack:
return
case f := <-c.funcs:
f()
}
}
case <-c.w.dead:
}
}
func (c *callbacks) Func(f func()) {
c.funcs <- f
}
func (w *Window) waitAck() {
// Send a dummy event; when it gets through we
// know the application has processed the previous event.