mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-04 17:05:38 +00:00
app,app/internal/wm: fold context MakeCurrent/ReleaseCurrent into Lock/Unlock
While here, make context Refresh useful and remove the redundant MakeCurrent from the window loop. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -35,33 +35,23 @@ func (c *context) Release() {
|
||||
}
|
||||
|
||||
func (c *context) Refresh() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *context) MakeCurrent() error {
|
||||
c.Context.ReleaseSurface()
|
||||
var (
|
||||
win *C.ANativeWindow
|
||||
width, height int
|
||||
)
|
||||
// Run on main thread. Deadlock is avoided because MakeCurrent is only
|
||||
// called during a FrameEvent.
|
||||
c.win.callbacks.Run(func() {
|
||||
win, width, height = c.win.nativeWindow(c.Context.VisualID())
|
||||
})
|
||||
win, width, height = c.win.nativeWindow(c.Context.VisualID())
|
||||
if win == nil {
|
||||
return nil
|
||||
}
|
||||
eglSurf := egl.NativeWindowType(unsafe.Pointer(win))
|
||||
if err := c.Context.CreateSurface(eglSurf, width, height); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := c.Context.MakeCurrent(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return c.Context.CreateSurface(eglSurf, width, height)
|
||||
}
|
||||
|
||||
func (c *context) Lock() {}
|
||||
func (c *context) Lock() error {
|
||||
return c.Context.MakeCurrent()
|
||||
}
|
||||
|
||||
func (c *context) Unlock() {}
|
||||
func (c *context) Unlock() {
|
||||
c.Context.ReleaseCurrent()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user