mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-03 16:35:36 +00:00
0e592f8bc6
The NSViewGlobalFrameDidChangeNotification notification is documented to be fired every time [NSOpenGLContext update] needs to be called. However, the notification fails to fire on my setup when a window is moved to a display with a different pixel scale, which leads to incorrectly sized output. This change gets rid of the notification and updates the context before every frame. Signed-off-by: Elias Naur <mail@eliasnaur.com>
55 lines
1023 B
Go
55 lines
1023 B
Go
// SPDX-License-Identifier: Unlicense OR MIT
|
|
|
|
// +build linux,!android,!nox11 freebsd openbsd
|
|
|
|
package wm
|
|
|
|
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 {
|
|
return nil
|
|
}
|
|
|
|
func (c *x11Context) MakeCurrent() 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)
|
|
return nil
|
|
}
|
|
|
|
func (c *x11Context) Lock() {}
|
|
|
|
func (c *x11Context) Unlock() {}
|