mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
45da52cee7
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>
57 lines
1.1 KiB
Go
57 lines
1.1 KiB
Go
// SPDX-License-Identifier: Unlicense OR MIT
|
|
|
|
//go:build (linux && !android && !nox11) || freebsd || openbsd
|
|
// +build linux,!android,!nox11 freebsd openbsd
|
|
|
|
package app
|
|
|
|
import (
|
|
"unsafe"
|
|
|
|
"gioui.org/internal/egl"
|
|
)
|
|
|
|
type x11Context struct {
|
|
win *x11Window
|
|
*egl.Context
|
|
}
|
|
|
|
func (w *x11Window) NewContext() (context, error) {
|
|
disp := egl.NativeDisplayType(unsafe.Pointer(w.display()))
|
|
ctx, err := egl.NewContext(disp)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &x11Context{win: w, Context: ctx}, nil
|
|
}
|
|
|
|
func (c *x11Context) Release() {
|
|
if c.Context != nil {
|
|
c.Context.Release()
|
|
c.Context = nil
|
|
}
|
|
}
|
|
|
|
func (c *x11Context) Refresh() error {
|
|
c.Context.ReleaseSurface()
|
|
win, width, height := c.win.window()
|
|
eglSurf := egl.NativeWindowType(uintptr(win))
|
|
if err := c.Context.CreateSurface(eglSurf, width, height); err != nil {
|
|
return err
|
|
}
|
|
if err := c.Context.MakeCurrent(); err != nil {
|
|
return err
|
|
}
|
|
c.Context.EnableVSync(true)
|
|
c.Context.ReleaseCurrent()
|
|
return nil
|
|
}
|
|
|
|
func (c *x11Context) Lock() error {
|
|
return c.Context.MakeCurrent()
|
|
}
|
|
|
|
func (c *x11Context) Unlock() {
|
|
c.Context.ReleaseCurrent()
|
|
}
|