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
+57
View File
@@ -0,0 +1,57 @@
// SPDX-License-Identifier: Unlicense OR MIT
package app
/*
#include <android/native_window_jni.h>
#include <EGL/egl.h>
*/
import "C"
import (
"unsafe"
"gioui.org/internal/egl"
)
type androidContext struct {
win *window
*egl.Context
}
func (w *window) NewContext() (context, error) {
ctx, err := egl.NewContext(nil)
if err != nil {
return nil, err
}
return &androidContext{win: w, Context: ctx}, nil
}
func (c *androidContext) Release() {
if c.Context != nil {
c.Context.Release()
c.Context = nil
}
}
func (c *androidContext) Refresh() error {
c.Context.ReleaseSurface()
var (
win *C.ANativeWindow
width, height int
)
win, width, height = c.win.nativeWindow(c.Context.VisualID())
if win == nil {
return nil
}
eglSurf := egl.NativeWindowType(unsafe.Pointer(win))
return c.Context.CreateSurface(eglSurf, width, height)
}
func (c *androidContext) Lock() error {
return c.Context.MakeCurrent()
}
func (c *androidContext) Unlock() {
c.Context.ReleaseCurrent()
}