Update GLFW sources
This commit is contained in:
parent
d6cda5d3bf
commit
9a64523d95
72 changed files with 37076 additions and 4907 deletions
189
raylib/external/glfw/src/wl_window.c
vendored
189
raylib/external/glfw/src/wl_window.c
vendored
|
@ -1,5 +1,5 @@
|
|||
//========================================================================
|
||||
// GLFW 3.2 Wayland - www.glfw.org
|
||||
// GLFW 3.3 Wayland - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>
|
||||
//
|
||||
|
@ -105,7 +105,7 @@ static void checkScaleChange(_GLFWwindow* window)
|
|||
int monitorScale;
|
||||
|
||||
// Check if we will be able to set the buffer scale or not.
|
||||
if (_glfw.wl.wl_compositor_version < 3)
|
||||
if (_glfw.wl.compositorVersion < 3)
|
||||
return;
|
||||
|
||||
// Get the scale factor from the highest scale monitor.
|
||||
|
@ -189,6 +189,24 @@ static void setOpaqueRegion(_GLFWwindow* window)
|
|||
wl_region_destroy(region);
|
||||
}
|
||||
|
||||
static void setIdleInhibitor(_GLFWwindow* window, GLFWbool enable)
|
||||
{
|
||||
if (enable && !window->wl.idleInhibitor && _glfw.wl.idleInhibitManager)
|
||||
{
|
||||
window->wl.idleInhibitor =
|
||||
zwp_idle_inhibit_manager_v1_create_inhibitor(
|
||||
_glfw.wl.idleInhibitManager, window->wl.surface);
|
||||
if (!window->wl.idleInhibitor)
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Wayland: Idle inhibitor creation failed");
|
||||
}
|
||||
else if (!enable && window->wl.idleInhibitor)
|
||||
{
|
||||
zwp_idle_inhibitor_v1_destroy(window->wl.idleInhibitor);
|
||||
window->wl.idleInhibitor = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static GLFWbool createSurface(_GLFWwindow* window,
|
||||
const _GLFWwndconfig* wndconfig)
|
||||
{
|
||||
|
@ -212,43 +230,48 @@ static GLFWbool createSurface(_GLFWwindow* window,
|
|||
window->wl.height = wndconfig->height;
|
||||
window->wl.scale = 1;
|
||||
|
||||
// TODO: make this optional once issue #197 is fixed.
|
||||
setOpaqueRegion(window);
|
||||
if (!window->wl.transparent)
|
||||
setOpaqueRegion(window);
|
||||
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
static GLFWbool createShellSurface(_GLFWwindow* window)
|
||||
{
|
||||
window->wl.shell_surface = wl_shell_get_shell_surface(_glfw.wl.shell,
|
||||
window->wl.surface);
|
||||
if (!window->wl.shell_surface)
|
||||
window->wl.shellSurface = wl_shell_get_shell_surface(_glfw.wl.shell,
|
||||
window->wl.surface);
|
||||
if (!window->wl.shellSurface)
|
||||
return GLFW_FALSE;
|
||||
|
||||
wl_shell_surface_add_listener(window->wl.shell_surface,
|
||||
wl_shell_surface_add_listener(window->wl.shellSurface,
|
||||
&shellSurfaceListener,
|
||||
window);
|
||||
|
||||
if (window->wl.title)
|
||||
wl_shell_surface_set_title(window->wl.shell_surface, window->wl.title);
|
||||
wl_shell_surface_set_title(window->wl.shellSurface, window->wl.title);
|
||||
|
||||
if (window->monitor)
|
||||
{
|
||||
wl_shell_surface_set_fullscreen(
|
||||
window->wl.shell_surface,
|
||||
window->wl.shellSurface,
|
||||
WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,
|
||||
0,
|
||||
window->monitor->wl.output);
|
||||
setIdleInhibitor(window, GLFW_TRUE);
|
||||
}
|
||||
else if (window->wl.maximized)
|
||||
{
|
||||
wl_shell_surface_set_maximized(window->wl.shell_surface, NULL);
|
||||
wl_shell_surface_set_maximized(window->wl.shellSurface, NULL);
|
||||
setIdleInhibitor(window, GLFW_FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
wl_shell_surface_set_toplevel(window->wl.shell_surface);
|
||||
wl_shell_surface_set_toplevel(window->wl.shellSurface);
|
||||
setIdleInhibitor(window, GLFW_FALSE);
|
||||
}
|
||||
|
||||
wl_surface_commit(window->wl.surface);
|
||||
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
|
@ -388,15 +411,28 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
|||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig)
|
||||
{
|
||||
window->wl.transparent = fbconfig->transparent;
|
||||
|
||||
if (!createSurface(window, wndconfig))
|
||||
return GLFW_FALSE;
|
||||
|
||||
if (ctxconfig->client != GLFW_NO_API)
|
||||
{
|
||||
if (!_glfwInitEGL())
|
||||
return GLFW_FALSE;
|
||||
if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
|
||||
return GLFW_FALSE;
|
||||
if (ctxconfig->source == GLFW_EGL_CONTEXT_API ||
|
||||
ctxconfig->source == GLFW_NATIVE_CONTEXT_API)
|
||||
{
|
||||
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 (wndconfig->title)
|
||||
|
@ -411,7 +447,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
|||
}
|
||||
else
|
||||
{
|
||||
window->wl.shell_surface = NULL;
|
||||
window->wl.shellSurface = NULL;
|
||||
window->wl.visible = GLFW_FALSE;
|
||||
}
|
||||
|
||||
|
@ -437,14 +473,17 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
|
|||
_glfwInputWindowFocus(window, GLFW_FALSE);
|
||||
}
|
||||
|
||||
if (window->wl.idleInhibitor)
|
||||
zwp_idle_inhibitor_v1_destroy(window->wl.idleInhibitor);
|
||||
|
||||
if (window->context.destroy)
|
||||
window->context.destroy(window);
|
||||
|
||||
if (window->wl.native)
|
||||
wl_egl_window_destroy(window->wl.native);
|
||||
|
||||
if (window->wl.shell_surface)
|
||||
wl_shell_surface_destroy(window->wl.shell_surface);
|
||||
if (window->wl.shellSurface)
|
||||
wl_shell_surface_destroy(window->wl.shellSurface);
|
||||
|
||||
if (window->wl.surface)
|
||||
wl_surface_destroy(window->wl.surface);
|
||||
|
@ -458,8 +497,8 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
|
|||
if (window->wl.title)
|
||||
free(window->wl.title);
|
||||
window->wl.title = strdup(title);
|
||||
if (window->wl.shell_surface)
|
||||
wl_shell_surface_set_title(window->wl.shell_surface, title);
|
||||
if (window->wl.shellSurface)
|
||||
wl_shell_surface_set_title(window->wl.shellSurface, title);
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowIcon(_GLFWwindow* window,
|
||||
|
@ -501,7 +540,8 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
|
|||
window->wl.width = width;
|
||||
window->wl.height = height;
|
||||
wl_egl_window_resize(window->wl.native, scaledWidth, scaledHeight, 0, 0);
|
||||
setOpaqueRegion(window);
|
||||
if (!window->wl.transparent)
|
||||
setOpaqueRegion(window);
|
||||
_glfwInputFramebufferSize(window, scaledWidth, scaledHeight);
|
||||
}
|
||||
|
||||
|
@ -534,6 +574,15 @@ void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
|
|||
// implemented, but for now just leave everything as 0.
|
||||
}
|
||||
|
||||
void _glfwPlatformGetWindowContentScale(_GLFWwindow* window,
|
||||
float* xscale, float* yscale)
|
||||
{
|
||||
if (xscale)
|
||||
*xscale = (float) window->wl.scale;
|
||||
if (yscale)
|
||||
*yscale = (float) window->wl.scale;
|
||||
}
|
||||
|
||||
void _glfwPlatformIconifyWindow(_GLFWwindow* window)
|
||||
{
|
||||
// TODO: move to xdg_shell instead of wl_shell.
|
||||
|
@ -546,8 +595,8 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window)
|
|||
// TODO: also do the same for iconified.
|
||||
if (window->monitor || window->wl.maximized)
|
||||
{
|
||||
if (window->wl.shell_surface)
|
||||
wl_shell_surface_set_toplevel(window->wl.shell_surface);
|
||||
if (window->wl.shellSurface)
|
||||
wl_shell_surface_set_toplevel(window->wl.shellSurface);
|
||||
|
||||
window->wl.maximized = GLFW_FALSE;
|
||||
}
|
||||
|
@ -557,10 +606,10 @@ void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
|
|||
{
|
||||
if (!window->monitor && !window->wl.maximized)
|
||||
{
|
||||
if (window->wl.shell_surface)
|
||||
if (window->wl.shellSurface)
|
||||
{
|
||||
// Let the compositor select the best output.
|
||||
wl_shell_surface_set_maximized(window->wl.shell_surface, NULL);
|
||||
wl_shell_surface_set_maximized(window->wl.shellSurface, NULL);
|
||||
}
|
||||
window->wl.maximized = GLFW_TRUE;
|
||||
}
|
||||
|
@ -570,7 +619,7 @@ void _glfwPlatformShowWindow(_GLFWwindow* window)
|
|||
{
|
||||
if (!window->monitor)
|
||||
{
|
||||
if (!window->wl.shell_surface)
|
||||
if (!window->wl.shellSurface)
|
||||
createShellSurface(window);
|
||||
window->wl.visible = GLFW_TRUE;
|
||||
}
|
||||
|
@ -580,12 +629,19 @@ void _glfwPlatformHideWindow(_GLFWwindow* window)
|
|||
{
|
||||
if (!window->monitor)
|
||||
{
|
||||
if (window->wl.shell_surface)
|
||||
wl_shell_surface_destroy(window->wl.shell_surface);
|
||||
if (window->wl.shellSurface)
|
||||
wl_shell_surface_destroy(window->wl.shellSurface);
|
||||
window->wl.visible = GLFW_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
|
||||
{
|
||||
// TODO
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Wayland: Window attention request not implemented yet");
|
||||
}
|
||||
|
||||
void _glfwPlatformFocusWindow(_GLFWwindow* window)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
|
@ -601,16 +657,18 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
|||
if (monitor)
|
||||
{
|
||||
wl_shell_surface_set_fullscreen(
|
||||
window->wl.shell_surface,
|
||||
window->wl.shellSurface,
|
||||
WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,
|
||||
refreshRate * 1000, // Convert Hz to mHz.
|
||||
monitor->wl.output);
|
||||
setIdleInhibitor(window, GLFW_TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
wl_shell_surface_set_toplevel(window->wl.shell_surface);
|
||||
wl_shell_surface_set_toplevel(window->wl.shellSurface);
|
||||
setIdleInhibitor(window, GLFW_FALSE);
|
||||
}
|
||||
_glfwInputWindowMonitorChange(window, monitor);
|
||||
_glfwInputWindowMonitor(window, monitor);
|
||||
}
|
||||
|
||||
int _glfwPlatformWindowFocused(_GLFWwindow* window)
|
||||
|
@ -634,6 +692,41 @@ int _glfwPlatformWindowMaximized(_GLFWwindow* window)
|
|||
return window->wl.maximized;
|
||||
}
|
||||
|
||||
int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
|
||||
{
|
||||
return window->wl.transparent;
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled)
|
||||
{
|
||||
// TODO
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Wayland: Window attribute setting not implemented yet");
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled)
|
||||
{
|
||||
// TODO
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Wayland: Window attribute setting not implemented yet");
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
|
||||
{
|
||||
// TODO
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Wayland: Window attribute setting not implemented yet");
|
||||
}
|
||||
|
||||
float _glfwPlatformGetWindowOpacity(_GLFWwindow* window)
|
||||
{
|
||||
return 1.f;
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity)
|
||||
{
|
||||
}
|
||||
|
||||
void _glfwPlatformPollEvents(void)
|
||||
{
|
||||
handleEvents(0);
|
||||
|
@ -680,12 +773,17 @@ void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
|
|||
_glfwPlatformSetCursor(window, window->wl.currentCursor);
|
||||
}
|
||||
|
||||
const char* _glfwPlatformGetKeyName(int key, int scancode)
|
||||
const char* _glfwPlatformGetScancodeName(int scancode)
|
||||
{
|
||||
// TODO
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int _glfwPlatformGetKeyScancode(int key)
|
||||
{
|
||||
return _glfw.wl.scancodes[key];
|
||||
}
|
||||
|
||||
int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
|
||||
const GLFWimage* image,
|
||||
int xhot, int yhot)
|
||||
|
@ -945,14 +1043,14 @@ void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)
|
|||
}
|
||||
}
|
||||
|
||||
void _glfwPlatformSetClipboardString(_GLFWwindow* window, const char* string)
|
||||
void _glfwPlatformSetClipboardString(const char* string)
|
||||
{
|
||||
// TODO
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Wayland: Clipboard setting not implemented yet");
|
||||
}
|
||||
|
||||
const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
|
||||
const char* _glfwPlatformGetClipboardString(void)
|
||||
{
|
||||
// TODO
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
|
@ -960,28 +1058,21 @@ const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
char** _glfwPlatformGetRequiredInstanceExtensions(uint32_t* count)
|
||||
void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
|
||||
{
|
||||
char** extensions;
|
||||
if (!_glfw.vk.KHR_surface || !_glfw.vk.KHR_wayland_surface)
|
||||
return;
|
||||
|
||||
*count = 0;
|
||||
|
||||
if (!_glfw.vk.KHR_wayland_surface)
|
||||
return NULL;
|
||||
|
||||
extensions = calloc(2, sizeof(char*));
|
||||
extensions[0] = strdup("VK_KHR_surface");
|
||||
extensions[1] = strdup("VK_KHR_wayland_surface");
|
||||
|
||||
*count = 2;
|
||||
return extensions;
|
||||
extensions[0] = "VK_KHR_surface";
|
||||
extensions[1] = "VK_KHR_wayland_surface";
|
||||
}
|
||||
|
||||
int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,
|
||||
VkPhysicalDevice device,
|
||||
uint32_t queuefamily)
|
||||
{
|
||||
PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR vkGetPhysicalDeviceWaylandPresentationSupportKHR =
|
||||
PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR
|
||||
vkGetPhysicalDeviceWaylandPresentationSupportKHR =
|
||||
(PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR)
|
||||
vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceWaylandPresentationSupportKHR");
|
||||
if (!vkGetPhysicalDeviceWaylandPresentationSupportKHR)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue