mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 17:35:36 +00:00
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:
+15
-2
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user