app: [API] refactor app.ViewEvent to support wayland

This commit changes the definition of app.ViewEvent on Unix systems
to be an interface implemented by two different concrete types:
X11ViewEvent and WaylandViewEvent. Each provides the necessary fields
for custom rendering on its display protocol.

This is a breaking change for all users of app.ViewEvent on
Linux/BSD, as it now is an interface instead of a concrete type.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
This commit is contained in:
Chris Waldon
2022-01-31 12:53:56 -05:00
committed by Elias Naur
parent 74acc90789
commit 7204632c39
3 changed files with 33 additions and 9 deletions
+10 -4
View File
@@ -248,12 +248,19 @@ func newWLWindow(callbacks *callbacks, options []Option) error {
defer w.destroy()
w.w.SetDriver(w)
// Finish and commit setup from createNativeWindow.
w.Configure(options)
C.wl_surface_commit(w.surf)
if err := w.loop(); err != nil {
panic(err)
}
w.w.Event(WaylandViewEvent{
Display: unsafe.Pointer(w.display()),
Surface: unsafe.Pointer(w.surf),
})
defer w.w.Event(WaylandViewEvent{})
err := w.loop()
w.w.Event(system.DestroyEvent{Err: err})
}()
return nil
}
@@ -1308,7 +1315,6 @@ func (w *window) loop() error {
default:
}
if w.dead {
w.w.Event(system.DestroyEvent{})
break
}
w.draw()