2023-08-03 16:51:17 +02:00
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
2023-07-07 19:15:47 +02:00
|
|
|
// SPDX-FileCopyrightText: 2012 The glfw3-go Authors
|
|
|
|
// SPDX-FileCopyrightText: 2023 The Ebitengine Authors
|
|
|
|
|
2023-09-16 14:39:15 +02:00
|
|
|
//go:build freebsd || linux || netbsd || openbsd
|
2023-07-05 03:51:55 +02:00
|
|
|
|
2023-10-07 16:21:29 +02:00
|
|
|
package glfw
|
2023-07-05 03:51:55 +02:00
|
|
|
|
|
|
|
//#include <stdlib.h>
|
|
|
|
//#define GLFW_EXPOSE_NATIVE_X11
|
|
|
|
//#define GLFW_EXPOSE_NATIVE_GLX
|
|
|
|
//#define GLFW_INCLUDE_NONE
|
2023-10-07 09:36:55 +02:00
|
|
|
//#include "glfw3_unix.h"
|
|
|
|
//#include "glfw3native_unix.h"
|
2023-07-05 03:51:55 +02:00
|
|
|
import "C"
|
|
|
|
import "unsafe"
|
|
|
|
|
2023-10-07 13:25:14 +02:00
|
|
|
func GetX11Display() (*C.Display, error) {
|
2023-07-05 03:51:55 +02:00
|
|
|
ret := C.glfwGetX11Display()
|
2023-10-07 13:25:14 +02:00
|
|
|
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return ret, nil
|
2023-07-05 03:51:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetX11Adapter returns the RRCrtc of the monitor.
|
2023-10-07 13:25:14 +02:00
|
|
|
func (m *Monitor) GetX11Adapter() (C.RRCrtc, error) {
|
2023-07-05 03:51:55 +02:00
|
|
|
ret := C.glfwGetX11Adapter(m.data)
|
2023-10-07 13:25:14 +02:00
|
|
|
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
|
|
|
return 0, err
|
|
|
|
}
|
|
|
|
return ret, nil
|
2023-07-05 03:51:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetX11Monitor returns the RROutput of the monitor.
|
2023-10-07 13:25:14 +02:00
|
|
|
func (m *Monitor) GetX11Monitor() (C.RROutput, error) {
|
2023-07-05 03:51:55 +02:00
|
|
|
ret := C.glfwGetX11Monitor(m.data)
|
2023-10-07 13:25:14 +02:00
|
|
|
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
|
|
|
return 0, err
|
|
|
|
}
|
|
|
|
return ret, nil
|
2023-07-05 03:51:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetX11Window returns the Window of the window.
|
2023-10-07 13:25:14 +02:00
|
|
|
func (w *Window) GetX11Window() (C.Window, error) {
|
2023-07-05 03:51:55 +02:00
|
|
|
ret := C.glfwGetX11Window(w.data)
|
2023-10-07 13:25:14 +02:00
|
|
|
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
|
|
|
return 0, err
|
|
|
|
}
|
|
|
|
return ret, nil
|
2023-07-05 03:51:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetGLXContext returns the GLXContext of the window.
|
2023-10-07 13:25:14 +02:00
|
|
|
func (w *Window) GetGLXContext() (C.GLXContext, error) {
|
2023-07-05 03:51:55 +02:00
|
|
|
ret := C.glfwGetGLXContext(w.data)
|
2023-10-07 13:25:14 +02:00
|
|
|
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return ret, nil
|
2023-07-05 03:51:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetGLXWindow returns the GLXWindow of the window.
|
2023-10-07 13:25:14 +02:00
|
|
|
func (w *Window) GetGLXWindow() (C.GLXWindow, error) {
|
2023-07-05 03:51:55 +02:00
|
|
|
ret := C.glfwGetGLXWindow(w.data)
|
2023-10-07 13:25:14 +02:00
|
|
|
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
|
|
|
return 0, err
|
|
|
|
}
|
|
|
|
return ret, nil
|
2023-07-05 03:51:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetX11SelectionString sets the X11 selection string.
|
|
|
|
func SetX11SelectionString(str string) {
|
|
|
|
s := C.CString(str)
|
|
|
|
defer C.free(unsafe.Pointer(s))
|
|
|
|
C.glfwSetX11SelectionString(s)
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetX11SelectionString gets the X11 selection string.
|
|
|
|
func GetX11SelectionString() string {
|
|
|
|
s := C.glfwGetX11SelectionString()
|
|
|
|
return C.GoString(s)
|
|
|
|
}
|