internal/cglfw: let functions return errors in native_linbsd.go

Updates #2703
This commit is contained in:
Hajime Hoshi 2023-10-07 20:25:14 +09:00
parent 6a5d46dc43
commit ee1c179c83

View File

@ -15,45 +15,57 @@ package cglfw
import "C" import "C"
import "unsafe" import "unsafe"
func GetX11Display() *C.Display { func GetX11Display() (*C.Display, error) {
ret := C.glfwGetX11Display() ret := C.glfwGetX11Display()
panicError() if err := fetchErrorIgnoringPlatformError(); err != nil {
return ret return nil, err
}
return ret, nil
} }
// GetX11Adapter returns the RRCrtc of the monitor. // GetX11Adapter returns the RRCrtc of the monitor.
func (m *Monitor) GetX11Adapter() C.RRCrtc { func (m *Monitor) GetX11Adapter() (C.RRCrtc, error) {
ret := C.glfwGetX11Adapter(m.data) ret := C.glfwGetX11Adapter(m.data)
panicError() if err := fetchErrorIgnoringPlatformError(); err != nil {
return ret return 0, err
}
return ret, nil
} }
// GetX11Monitor returns the RROutput of the monitor. // GetX11Monitor returns the RROutput of the monitor.
func (m *Monitor) GetX11Monitor() C.RROutput { func (m *Monitor) GetX11Monitor() (C.RROutput, error) {
ret := C.glfwGetX11Monitor(m.data) ret := C.glfwGetX11Monitor(m.data)
panicError() if err := fetchErrorIgnoringPlatformError(); err != nil {
return ret return 0, err
}
return ret, nil
} }
// GetX11Window returns the Window of the window. // GetX11Window returns the Window of the window.
func (w *Window) GetX11Window() C.Window { func (w *Window) GetX11Window() (C.Window, error) {
ret := C.glfwGetX11Window(w.data) ret := C.glfwGetX11Window(w.data)
panicError() if err := fetchErrorIgnoringPlatformError(); err != nil {
return ret return 0, err
}
return ret, nil
} }
// GetGLXContext returns the GLXContext of the window. // GetGLXContext returns the GLXContext of the window.
func (w *Window) GetGLXContext() C.GLXContext { func (w *Window) GetGLXContext() (C.GLXContext, error) {
ret := C.glfwGetGLXContext(w.data) ret := C.glfwGetGLXContext(w.data)
panicError() if err := fetchErrorIgnoringPlatformError(); err != nil {
return ret return nil, err
}
return ret, nil
} }
// GetGLXWindow returns the GLXWindow of the window. // GetGLXWindow returns the GLXWindow of the window.
func (w *Window) GetGLXWindow() C.GLXWindow { func (w *Window) GetGLXWindow() (C.GLXWindow, error) {
ret := C.glfwGetGLXWindow(w.data) ret := C.glfwGetGLXWindow(w.data)
panicError() if err := fetchErrorIgnoringPlatformError(); err != nil {
return ret return 0, err
}
return ret, nil
} }
// SetX11SelectionString sets the X11 selection string. // SetX11SelectionString sets the X11 selection string.