mirror of
https://github.com/glfw/glfw.git
synced 2025-06-07 08:14:57 +00:00
Merge 36a3c1ef32
into d79afa8055
This commit is contained in:
commit
952789e2c0
4
.gitignore
vendored
4
.gitignore
vendored
@ -102,3 +102,7 @@ tests/triangle-vulkan
|
|||||||
tests/window
|
tests/window
|
||||||
tests/windows
|
tests/windows
|
||||||
|
|
||||||
|
# IDE caches
|
||||||
|
.cache/
|
||||||
|
.idea/
|
||||||
|
.vscode/
|
@ -525,6 +525,7 @@ GLFWbool _glfwConnectCocoa(int platformID, _GLFWplatform* platform)
|
|||||||
_glfwGetGammaRampCocoa,
|
_glfwGetGammaRampCocoa,
|
||||||
_glfwSetGammaRampCocoa,
|
_glfwSetGammaRampCocoa,
|
||||||
_glfwCreateWindowCocoa,
|
_glfwCreateWindowCocoa,
|
||||||
|
_glfwAttachWindowCocoa,
|
||||||
_glfwDestroyWindowCocoa,
|
_glfwDestroyWindowCocoa,
|
||||||
_glfwSetWindowTitleCocoa,
|
_glfwSetWindowTitleCocoa,
|
||||||
_glfwSetWindowIconCocoa,
|
_glfwSetWindowIconCocoa,
|
||||||
@ -694,4 +695,3 @@ void _glfwTerminateCocoa(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif // _GLFW_COCOA
|
#endif // _GLFW_COCOA
|
||||||
|
|
||||||
|
@ -215,6 +215,7 @@ int _glfwInitCocoa(void);
|
|||||||
void _glfwTerminateCocoa(void);
|
void _glfwTerminateCocoa(void);
|
||||||
|
|
||||||
GLFWbool _glfwCreateWindowCocoa(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig);
|
GLFWbool _glfwCreateWindowCocoa(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig);
|
||||||
|
GLFWbool _glfwAttachWindowCocoa(_GLFWwindow* window, intptr_t native, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig);
|
||||||
void _glfwDestroyWindowCocoa(_GLFWwindow* window);
|
void _glfwDestroyWindowCocoa(_GLFWwindow* window);
|
||||||
void _glfwSetWindowTitleCocoa(_GLFWwindow* window, const char* title);
|
void _glfwSetWindowTitleCocoa(_GLFWwindow* window, const char* title);
|
||||||
void _glfwSetWindowIconCocoa(_GLFWwindow* window, int count, const GLFWimage* images);
|
void _glfwSetWindowIconCocoa(_GLFWwindow* window, int count, const GLFWimage* images);
|
||||||
@ -299,4 +300,3 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
|
|||||||
const _GLFWctxconfig* ctxconfig,
|
const _GLFWctxconfig* ctxconfig,
|
||||||
const _GLFWfbconfig* fbconfig);
|
const _GLFWfbconfig* fbconfig);
|
||||||
void _glfwDestroyContextNSGL(_GLFWwindow* window);
|
void _glfwDestroyContextNSGL(_GLFWwindow* window);
|
||||||
|
|
||||||
|
@ -988,6 +988,15 @@ GLFWbool _glfwCreateWindowCocoa(_GLFWwindow* window,
|
|||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLFWbool _glfwAttachWindowCocoa(_GLFWwindow* window,
|
||||||
|
intptr_t native,
|
||||||
|
const _GLFWwndconfig* wndconfig,
|
||||||
|
const _GLFWctxconfig* ctxconfig,
|
||||||
|
const _GLFWfbconfig* fbconfig) {
|
||||||
|
_glfwInputError(GLFW_PLATFORM_ERROR, "Cocoa window attachment is not implemented");
|
||||||
|
return GLFW_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
void _glfwDestroyWindowCocoa(_GLFWwindow* window)
|
void _glfwDestroyWindowCocoa(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
@ -2055,4 +2064,3 @@ GLFWAPI id glfwGetCocoaWindow(GLFWwindow* handle)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif // _GLFW_COCOA
|
#endif // _GLFW_COCOA
|
||||||
|
|
||||||
|
@ -532,6 +532,7 @@ struct _GLFWwindow
|
|||||||
GLFWbool focusOnShow;
|
GLFWbool focusOnShow;
|
||||||
GLFWbool mousePassthrough;
|
GLFWbool mousePassthrough;
|
||||||
GLFWbool shouldClose;
|
GLFWbool shouldClose;
|
||||||
|
GLFWbool external;
|
||||||
void* userPointer;
|
void* userPointer;
|
||||||
GLFWbool doublebuffer;
|
GLFWbool doublebuffer;
|
||||||
GLFWvidmode videoMode;
|
GLFWvidmode videoMode;
|
||||||
@ -706,6 +707,7 @@ struct _GLFWplatform
|
|||||||
void (*setGammaRamp)(_GLFWmonitor*,const GLFWgammaramp*);
|
void (*setGammaRamp)(_GLFWmonitor*,const GLFWgammaramp*);
|
||||||
// window
|
// window
|
||||||
GLFWbool (*createWindow)(_GLFWwindow*,const _GLFWwndconfig*,const _GLFWctxconfig*,const _GLFWfbconfig*);
|
GLFWbool (*createWindow)(_GLFWwindow*,const _GLFWwndconfig*,const _GLFWctxconfig*,const _GLFWfbconfig*);
|
||||||
|
GLFWbool (*attachWindow)(_GLFWwindow*, intptr_t, const _GLFWwndconfig*,const _GLFWctxconfig*,const _GLFWfbconfig*);
|
||||||
void (*destroyWindow)(_GLFWwindow*);
|
void (*destroyWindow)(_GLFWwindow*);
|
||||||
void (*setWindowTitle)(_GLFWwindow*,const char*);
|
void (*setWindowTitle)(_GLFWwindow*,const char*);
|
||||||
void (*setWindowIcon)(_GLFWwindow*,int,const GLFWimage*);
|
void (*setWindowIcon)(_GLFWwindow*,int,const GLFWimage*);
|
||||||
|
@ -69,6 +69,7 @@ GLFWbool _glfwConnectNull(int platformID, _GLFWplatform* platform)
|
|||||||
_glfwGetGammaRampNull,
|
_glfwGetGammaRampNull,
|
||||||
_glfwSetGammaRampNull,
|
_glfwSetGammaRampNull,
|
||||||
_glfwCreateWindowNull,
|
_glfwCreateWindowNull,
|
||||||
|
_glfwAttachWindowNull,
|
||||||
_glfwDestroyWindowNull,
|
_glfwDestroyWindowNull,
|
||||||
_glfwSetWindowTitleNull,
|
_glfwSetWindowTitleNull,
|
||||||
_glfwSetWindowIconNull,
|
_glfwSetWindowIconNull,
|
||||||
@ -261,4 +262,3 @@ void _glfwTerminateNull(void)
|
|||||||
_glfwTerminateOSMesa();
|
_glfwTerminateOSMesa();
|
||||||
_glfwTerminateEGL();
|
_glfwTerminateEGL();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,6 +210,7 @@ GLFWbool _glfwGetGammaRampNull(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
|
|||||||
void _glfwSetGammaRampNull(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);
|
void _glfwSetGammaRampNull(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);
|
||||||
|
|
||||||
GLFWbool _glfwCreateWindowNull(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig);
|
GLFWbool _glfwCreateWindowNull(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig);
|
||||||
|
GLFWbool _glfwAttachWindowNull(_GLFWwindow* window, intptr_t native, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig);
|
||||||
void _glfwDestroyWindowNull(_GLFWwindow* window);
|
void _glfwDestroyWindowNull(_GLFWwindow* window);
|
||||||
void _glfwSetWindowTitleNull(_GLFWwindow* window, const char* title);
|
void _glfwSetWindowTitleNull(_GLFWwindow* window, const char* title);
|
||||||
void _glfwSetWindowIconNull(_GLFWwindow* window, int count, const GLFWimage* images);
|
void _glfwSetWindowIconNull(_GLFWwindow* window, int count, const GLFWimage* images);
|
||||||
@ -269,4 +270,3 @@ GLFWbool _glfwGetPhysicalDevicePresentationSupportNull(VkInstance instance, VkPh
|
|||||||
VkResult _glfwCreateWindowSurfaceNull(VkInstance instance, _GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
|
VkResult _glfwCreateWindowSurfaceNull(VkInstance instance, _GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
|
||||||
|
|
||||||
void _glfwPollMonitorsNull(void);
|
void _glfwPollMonitorsNull(void);
|
||||||
|
|
||||||
|
@ -104,6 +104,39 @@ static int createNativeWindow(_GLFWwindow* window,
|
|||||||
|
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
static int attachNativeWindow(_GLFWwindow* window,
|
||||||
|
intptr_t native,
|
||||||
|
const _GLFWwndconfig* wndconfig,
|
||||||
|
const _GLFWfbconfig* fbconfig)
|
||||||
|
{
|
||||||
|
if (window->monitor)
|
||||||
|
fitToMonitor(window);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (wndconfig->xpos == GLFW_ANY_POSITION && wndconfig->ypos == GLFW_ANY_POSITION)
|
||||||
|
{
|
||||||
|
window->null.xpos = 17;
|
||||||
|
window->null.ypos = 17;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
window->null.xpos = wndconfig->xpos;
|
||||||
|
window->null.ypos = wndconfig->ypos;
|
||||||
|
}
|
||||||
|
|
||||||
|
window->null.width = wndconfig->width;
|
||||||
|
window->null.height = wndconfig->height;
|
||||||
|
}
|
||||||
|
|
||||||
|
window->null.visible = wndconfig->visible;
|
||||||
|
window->null.decorated = wndconfig->decorated;
|
||||||
|
window->null.maximized = wndconfig->maximized;
|
||||||
|
window->null.floating = wndconfig->floating;
|
||||||
|
window->null.transparent = fbconfig->transparent;
|
||||||
|
window->null.opacity = 1.f;
|
||||||
|
|
||||||
|
return GLFW_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
@ -164,6 +197,61 @@ GLFWbool _glfwCreateWindowNull(_GLFWwindow* window,
|
|||||||
|
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
GLFWbool _glfwAttachWindowNull(_GLFWwindow* window,
|
||||||
|
intptr_t native,
|
||||||
|
const _GLFWwndconfig* wndconfig,
|
||||||
|
const _GLFWctxconfig* ctxconfig,
|
||||||
|
const _GLFWfbconfig* fbconfig)
|
||||||
|
{
|
||||||
|
if (!attachNativeWindow(window, native, wndconfig, fbconfig))
|
||||||
|
return GLFW_FALSE;
|
||||||
|
|
||||||
|
if (ctxconfig->client != GLFW_NO_API)
|
||||||
|
{
|
||||||
|
if (ctxconfig->source == GLFW_NATIVE_CONTEXT_API ||
|
||||||
|
ctxconfig->source == GLFW_OSMESA_CONTEXT_API)
|
||||||
|
{
|
||||||
|
if (!_glfwInitOSMesa())
|
||||||
|
return GLFW_FALSE;
|
||||||
|
if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
|
||||||
|
return GLFW_FALSE;
|
||||||
|
}
|
||||||
|
else if (ctxconfig->source == GLFW_EGL_CONTEXT_API)
|
||||||
|
{
|
||||||
|
if (!_glfwInitEGL())
|
||||||
|
return GLFW_FALSE;
|
||||||
|
if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
|
||||||
|
return GLFW_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_glfwRefreshContextAttribs(window, ctxconfig))
|
||||||
|
return GLFW_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wndconfig->mousePassthrough)
|
||||||
|
_glfwSetWindowMousePassthroughNull(window, GLFW_TRUE);
|
||||||
|
|
||||||
|
if (window->monitor)
|
||||||
|
{
|
||||||
|
_glfwShowWindowNull(window);
|
||||||
|
_glfwFocusWindowNull(window);
|
||||||
|
acquireMonitor(window);
|
||||||
|
|
||||||
|
if (wndconfig->centerCursor)
|
||||||
|
_glfwCenterCursorInContentArea(window);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (wndconfig->visible)
|
||||||
|
{
|
||||||
|
_glfwShowWindowNull(window);
|
||||||
|
if (wndconfig->focused)
|
||||||
|
_glfwFocusWindowNull(window);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return GLFW_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
void _glfwDestroyWindowNull(_GLFWwindow* window)
|
void _glfwDestroyWindowNull(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
@ -715,4 +803,3 @@ VkResult _glfwCreateWindowSurfaceNull(VkInstance instance,
|
|||||||
// This seems like the most appropriate error to return here
|
// This seems like the most appropriate error to return here
|
||||||
return VK_ERROR_EXTENSION_NOT_PRESENT;
|
return VK_ERROR_EXTENSION_NOT_PRESENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -672,6 +672,7 @@ GLFWbool _glfwConnectWin32(int platformID, _GLFWplatform* platform)
|
|||||||
_glfwGetGammaRampWin32,
|
_glfwGetGammaRampWin32,
|
||||||
_glfwSetGammaRampWin32,
|
_glfwSetGammaRampWin32,
|
||||||
_glfwCreateWindowWin32,
|
_glfwCreateWindowWin32,
|
||||||
|
_glfwAttachWindowWin32,
|
||||||
_glfwDestroyWindowWin32,
|
_glfwDestroyWindowWin32,
|
||||||
_glfwSetWindowTitleWin32,
|
_glfwSetWindowTitleWin32,
|
||||||
_glfwSetWindowIconWin32,
|
_glfwSetWindowIconWin32,
|
||||||
@ -777,4 +778,3 @@ void _glfwTerminateWin32(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif // _GLFW_WIN32
|
#endif // _GLFW_WIN32
|
||||||
|
|
||||||
|
@ -544,6 +544,7 @@ void _glfwRestoreVideoModeWin32(_GLFWmonitor* monitor);
|
|||||||
void _glfwGetHMONITORContentScaleWin32(HMONITOR handle, float* xscale, float* yscale);
|
void _glfwGetHMONITORContentScaleWin32(HMONITOR handle, float* xscale, float* yscale);
|
||||||
|
|
||||||
GLFWbool _glfwCreateWindowWin32(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig);
|
GLFWbool _glfwCreateWindowWin32(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig);
|
||||||
|
GLFWbool _glfwAttachWindowWin32(_GLFWwindow* window, intptr_t native, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig);
|
||||||
void _glfwDestroyWindowWin32(_GLFWwindow* window);
|
void _glfwDestroyWindowWin32(_GLFWwindow* window);
|
||||||
void _glfwSetWindowTitleWin32(_GLFWwindow* window, const char* title);
|
void _glfwSetWindowTitleWin32(_GLFWwindow* window, const char* title);
|
||||||
void _glfwSetWindowIconWin32(_GLFWwindow* window, int count, const GLFWimage* images);
|
void _glfwSetWindowIconWin32(_GLFWwindow* window, int count, const GLFWimage* images);
|
||||||
@ -625,4 +626,3 @@ void _glfwTerminateWGL(void);
|
|||||||
GLFWbool _glfwCreateContextWGL(_GLFWwindow* window,
|
GLFWbool _glfwCreateContextWGL(_GLFWwindow* window,
|
||||||
const _GLFWctxconfig* ctxconfig,
|
const _GLFWctxconfig* ctxconfig,
|
||||||
const _GLFWfbconfig* fbconfig);
|
const _GLFWfbconfig* fbconfig);
|
||||||
|
|
||||||
|
@ -1524,6 +1524,11 @@ GLFWbool _glfwCreateWindowWin32(_GLFWwindow* window,
|
|||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLFWbool _glfwAttachWindowWin32(_GLFWwindow* window, intptr_t native, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig) {
|
||||||
|
_glfwInputError(GLFW_PLATFORM_ERROR, "Win32 window attachment is not implemented");
|
||||||
|
return GLFW_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
void _glfwDestroyWindowWin32(_GLFWwindow* window)
|
void _glfwDestroyWindowWin32(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
if (window->monitor)
|
if (window->monitor)
|
||||||
@ -2542,4 +2547,3 @@ GLFWAPI HWND glfwGetWin32Window(GLFWwindow* handle)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif // _GLFW_WIN32
|
#endif // _GLFW_WIN32
|
||||||
|
|
||||||
|
52
src/window.c
52
src/window.c
@ -252,8 +252,55 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
|
|||||||
return (GLFWwindow*) window;
|
return (GLFWwindow*) window;
|
||||||
}
|
}
|
||||||
|
|
||||||
void glfwDefaultWindowHints(void)
|
GLFWAPI GLFWwindow* glfwAttachWindow(intptr_t nativeWindow, GLFWwindow* share) {
|
||||||
{
|
_GLFWfbconfig fbconfig;
|
||||||
|
_GLFWctxconfig ctxconfig;
|
||||||
|
_GLFWwndconfig wndconfig;
|
||||||
|
_GLFWwindow* window;
|
||||||
|
|
||||||
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
|
|
||||||
|
fbconfig = _glfw.hints.framebuffer;
|
||||||
|
ctxconfig = _glfw.hints.context;
|
||||||
|
wndconfig = _glfw.hints.window;
|
||||||
|
|
||||||
|
ctxconfig.share = (_GLFWwindow*) share;
|
||||||
|
if (ctxconfig.share)
|
||||||
|
{
|
||||||
|
if (ctxconfig.client == GLFW_NO_API ||
|
||||||
|
ctxconfig.share->context.client == GLFW_NO_API)
|
||||||
|
{
|
||||||
|
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_glfwIsValidContextConfig(&ctxconfig))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
window = calloc(1, sizeof(_GLFWwindow));
|
||||||
|
window->next = _glfw.windowListHead;
|
||||||
|
_glfw.windowListHead = window;
|
||||||
|
|
||||||
|
window->autoIconify = wndconfig.autoIconify;
|
||||||
|
window->cursorMode = GLFW_CURSOR_NORMAL;
|
||||||
|
window->external = GLFW_TRUE;
|
||||||
|
|
||||||
|
window->minwidth = GLFW_DONT_CARE;
|
||||||
|
window->minheight = GLFW_DONT_CARE;
|
||||||
|
window->maxwidth = GLFW_DONT_CARE;
|
||||||
|
window->maxheight = GLFW_DONT_CARE;
|
||||||
|
window->numer = GLFW_DONT_CARE;
|
||||||
|
window->denom = GLFW_DONT_CARE;
|
||||||
|
|
||||||
|
if (!_glfw.platform.attachWindow(window, nativeWindow, &wndconfig, &ctxconfig, &fbconfig))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return (GLFWwindow*) window;
|
||||||
|
}
|
||||||
|
|
||||||
|
void glfwDefaultWindowHints(void) {
|
||||||
|
|
||||||
_GLFW_REQUIRE_INIT();
|
_GLFW_REQUIRE_INIT();
|
||||||
|
|
||||||
// The default is OpenGL with minimum version 1.0
|
// The default is OpenGL with minimum version 1.0
|
||||||
@ -1150,4 +1197,3 @@ GLFWAPI void glfwPostEmptyEvent(void)
|
|||||||
_GLFW_REQUIRE_INIT();
|
_GLFW_REQUIRE_INIT();
|
||||||
_glfw.platform.postEmptyEvent();
|
_glfw.platform.postEmptyEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -443,6 +443,7 @@ GLFWbool _glfwConnectWayland(int platformID, _GLFWplatform* platform)
|
|||||||
_glfwGetGammaRampWayland,
|
_glfwGetGammaRampWayland,
|
||||||
_glfwSetGammaRampWayland,
|
_glfwSetGammaRampWayland,
|
||||||
_glfwCreateWindowWayland,
|
_glfwCreateWindowWayland,
|
||||||
|
_glfwAttachWindowWayland,
|
||||||
_glfwDestroyWindowWayland,
|
_glfwDestroyWindowWayland,
|
||||||
_glfwSetWindowTitleWayland,
|
_glfwSetWindowTitleWayland,
|
||||||
_glfwSetWindowIconWayland,
|
_glfwSetWindowIconWayland,
|
||||||
@ -946,4 +947,3 @@ void _glfwTerminateWayland(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif // _GLFW_WAYLAND
|
#endif // _GLFW_WAYLAND
|
||||||
|
|
||||||
|
@ -610,6 +610,7 @@ int _glfwInitWayland(void);
|
|||||||
void _glfwTerminateWayland(void);
|
void _glfwTerminateWayland(void);
|
||||||
|
|
||||||
GLFWbool _glfwCreateWindowWayland(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig);
|
GLFWbool _glfwCreateWindowWayland(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig);
|
||||||
|
GLFWbool _glfwAttachWindowWayland(_GLFWwindow* window, intptr_t native, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig);
|
||||||
void _glfwDestroyWindowWayland(_GLFWwindow* window);
|
void _glfwDestroyWindowWayland(_GLFWwindow* window);
|
||||||
void _glfwSetWindowTitleWayland(_GLFWwindow* window, const char* title);
|
void _glfwSetWindowTitleWayland(_GLFWwindow* window, const char* title);
|
||||||
void _glfwSetWindowIconWayland(_GLFWwindow* window, int count, const GLFWimage* images);
|
void _glfwSetWindowIconWayland(_GLFWwindow* window, int count, const GLFWimage* images);
|
||||||
|
@ -967,6 +967,38 @@ static GLFWbool createNativeSurface(_GLFWwindow* window,
|
|||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GLFWbool attachNativeSurface(_GLFWwindow* window,
|
||||||
|
intptr_t native,
|
||||||
|
const _GLFWwndconfig* wndconfig,
|
||||||
|
const _GLFWfbconfig* fbconfig) {
|
||||||
|
if (!native)
|
||||||
|
{
|
||||||
|
_glfwInputError(GLFW_PLATFORM_ERROR, "Wayland: supplied wl_surface is null");
|
||||||
|
return GLFW_FALSE;
|
||||||
|
}
|
||||||
|
window->wl.surface = (struct wl_surface*) native;
|
||||||
|
|
||||||
|
wl_proxy_set_tag((struct wl_proxy*) window->wl.surface, &_glfw.wl.tag);
|
||||||
|
wl_surface_add_listener(window->wl.surface,
|
||||||
|
&surfaceListener,
|
||||||
|
window);
|
||||||
|
|
||||||
|
window->wl.width = wndconfig->width;
|
||||||
|
window->wl.height = wndconfig->height;
|
||||||
|
window->wl.contentScale = 1;
|
||||||
|
window->wl.title = _glfw_strdup(wndconfig->title);
|
||||||
|
window->wl.appId = _glfw_strdup(wndconfig->wl.appId);
|
||||||
|
|
||||||
|
|
||||||
|
window->wl.maximized = wndconfig->maximized;
|
||||||
|
|
||||||
|
window->wl.transparent = fbconfig->transparent;
|
||||||
|
if (!window->wl.transparent)
|
||||||
|
setContentAreaOpaque(window);
|
||||||
|
|
||||||
|
return GLFW_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static void setCursorImage(_GLFWwindow* window,
|
static void setCursorImage(_GLFWwindow* window,
|
||||||
_GLFWcursorWayland* cursorWayland)
|
_GLFWcursorWayland* cursorWayland)
|
||||||
{
|
{
|
||||||
@ -2046,7 +2078,8 @@ GLFWbool _glfwCreateWindowWayland(_GLFWwindow* window,
|
|||||||
if (wndconfig->mousePassthrough)
|
if (wndconfig->mousePassthrough)
|
||||||
_glfwSetWindowMousePassthroughWayland(window, GLFW_TRUE);
|
_glfwSetWindowMousePassthroughWayland(window, GLFW_TRUE);
|
||||||
|
|
||||||
if (window->monitor || wndconfig->visible)
|
// don't
|
||||||
|
if (!window->external && (window->monitor || wndconfig->visible))
|
||||||
{
|
{
|
||||||
if (!createShellObjects(window))
|
if (!createShellObjects(window))
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
@ -2055,6 +2088,52 @@ GLFWbool _glfwCreateWindowWayland(_GLFWwindow* window,
|
|||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLFWbool _glfwAttachWindowWayland(_GLFWwindow* window,
|
||||||
|
intptr_t native,
|
||||||
|
const _GLFWwndconfig* wndconfig,
|
||||||
|
const _GLFWctxconfig* ctxconfig,
|
||||||
|
const _GLFWfbconfig* fbconfig) {
|
||||||
|
|
||||||
|
if (!attachNativeSurface(window, native, wndconfig, fbconfig))
|
||||||
|
return GLFW_FALSE;
|
||||||
|
if (ctxconfig->client != GLFW_NO_API)
|
||||||
|
{
|
||||||
|
if (ctxconfig->source == GLFW_EGL_CONTEXT_API ||
|
||||||
|
ctxconfig->source == GLFW_NATIVE_CONTEXT_API)
|
||||||
|
{
|
||||||
|
window->wl.egl.window = wl_egl_window_create(window->wl.surface,
|
||||||
|
wndconfig->width,
|
||||||
|
wndconfig->height);
|
||||||
|
if (!window->wl.egl.window)
|
||||||
|
{
|
||||||
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
|
"Wayland: Failed to create EGL window");
|
||||||
|
return GLFW_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_glfwInitEGL())
|
||||||
|
return GLFW_FALSE;
|
||||||
|
if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
|
||||||
|
return GLFW_FALSE;
|
||||||
|
}
|
||||||
|
else if (ctxconfig->source == GLFW_OSMESA_CONTEXT_API)
|
||||||
|
{
|
||||||
|
if (!_glfwInitOSMesa())
|
||||||
|
return GLFW_FALSE;
|
||||||
|
if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
|
||||||
|
return GLFW_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_glfwRefreshContextAttribs(window, ctxconfig))
|
||||||
|
return GLFW_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wndconfig->mousePassthrough)
|
||||||
|
_glfwSetWindowMousePassthroughWayland(window, GLFW_TRUE);
|
||||||
|
|
||||||
|
return GLFW_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
void _glfwDestroyWindowWayland(_GLFWwindow* window)
|
void _glfwDestroyWindowWayland(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
if (window == _glfw.wl.pointerFocus)
|
if (window == _glfw.wl.pointerFocus)
|
||||||
@ -2324,7 +2403,7 @@ void _glfwMaximizeWindowWayland(_GLFWwindow* window)
|
|||||||
|
|
||||||
void _glfwShowWindowWayland(_GLFWwindow* window)
|
void _glfwShowWindowWayland(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
if (!window->wl.libdecor.frame && !window->wl.xdg.toplevel)
|
if (!window->external && (!window->wl.libdecor.frame && !window->wl.xdg.toplevel))
|
||||||
{
|
{
|
||||||
// NOTE: The XDG surface and role are created here so command-line applications
|
// NOTE: The XDG surface and role are created here so command-line applications
|
||||||
// with off-screen windows do not appear in for example the Unity dock
|
// with off-screen windows do not appear in for example the Unity dock
|
||||||
@ -3173,4 +3252,3 @@ GLFWAPI struct wl_surface* glfwGetWaylandWindow(GLFWwindow* handle)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif // _GLFW_WAYLAND
|
#endif // _GLFW_WAYLAND
|
||||||
|
|
||||||
|
@ -1204,6 +1204,7 @@ GLFWbool _glfwConnectX11(int platformID, _GLFWplatform* platform)
|
|||||||
_glfwGetGammaRampX11,
|
_glfwGetGammaRampX11,
|
||||||
_glfwSetGammaRampX11,
|
_glfwSetGammaRampX11,
|
||||||
_glfwCreateWindowX11,
|
_glfwCreateWindowX11,
|
||||||
|
_glfwAttachWindowX11,
|
||||||
_glfwDestroyWindowX11,
|
_glfwDestroyWindowX11,
|
||||||
_glfwSetWindowTitleX11,
|
_glfwSetWindowTitleX11,
|
||||||
_glfwSetWindowIconX11,
|
_glfwSetWindowIconX11,
|
||||||
@ -1653,4 +1654,3 @@ void _glfwTerminateX11(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif // _GLFW_X11
|
#endif // _GLFW_X11
|
||||||
|
|
||||||
|
@ -615,4 +615,3 @@ GLFWAPI RROutput glfwGetX11Monitor(GLFWmonitor* handle)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif // _GLFW_X11
|
#endif // _GLFW_X11
|
||||||
|
|
||||||
|
@ -902,6 +902,7 @@ int _glfwInitX11(void);
|
|||||||
void _glfwTerminateX11(void);
|
void _glfwTerminateX11(void);
|
||||||
|
|
||||||
GLFWbool _glfwCreateWindowX11(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig);
|
GLFWbool _glfwCreateWindowX11(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig);
|
||||||
|
GLFWbool _glfwAttachWindowX11(_GLFWwindow* window, intptr_t native, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig);
|
||||||
void _glfwDestroyWindowX11(_GLFWwindow* window);
|
void _glfwDestroyWindowX11(_GLFWwindow* window);
|
||||||
void _glfwSetWindowTitleX11(_GLFWwindow* window, const char* title);
|
void _glfwSetWindowTitleX11(_GLFWwindow* window, const char* title);
|
||||||
void _glfwSetWindowIconX11(_GLFWwindow* window, int count, const GLFWimage* images);
|
void _glfwSetWindowIconX11(_GLFWwindow* window, int count, const GLFWimage* images);
|
||||||
@ -1001,4 +1002,3 @@ GLFWbool _glfwChooseVisualGLX(const _GLFWwndconfig* wndconfig,
|
|||||||
const _GLFWctxconfig* ctxconfig,
|
const _GLFWctxconfig* ctxconfig,
|
||||||
const _GLFWfbconfig* fbconfig,
|
const _GLFWfbconfig* fbconfig,
|
||||||
Visual** visual, int* depth);
|
Visual** visual, int* depth);
|
||||||
|
|
||||||
|
@ -2042,6 +2042,15 @@ GLFWbool _glfwCreateWindowX11(_GLFWwindow* window,
|
|||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLFWbool _glfwAttachWindowX11(_GLFWwindow* window,
|
||||||
|
intptr_t native,
|
||||||
|
const _GLFWwndconfig* wndconfig,
|
||||||
|
const _GLFWctxconfig* ctxconfig,
|
||||||
|
const _GLFWfbconfig* fbconfig) {
|
||||||
|
_glfwInputError(GLFW_PLATFORM_ERROR, "X11 window attachment is not implemented");
|
||||||
|
return GLFW_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
void _glfwDestroyWindowX11(_GLFWwindow* window)
|
void _glfwDestroyWindowX11(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
if (_glfw.x11.disabledCursorWindow == window)
|
if (_glfw.x11.disabledCursorWindow == window)
|
||||||
@ -3350,4 +3359,3 @@ GLFWAPI const char* glfwGetX11SelectionString(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif // _GLFW_X11
|
#endif // _GLFW_X11
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user