Compare commits

...

7 Commits

Author SHA1 Message Date
Saksham Goyal
e439e9c040
Merge ac84815697 into dbadda2683 2025-12-12 08:22:07 -06:00
Camilla Löwy
dbadda2683 Formatting 2025-12-05 13:33:10 +01:00
Camilla Löwy
08449b7183 Linux: Add missing header for ioctl
Fixes #2778
2025-12-04 20:30:12 +01:00
Camilla Löwy
1ce855b0b1 Wayland: Fix missing checks for optional protocol 2025-12-04 20:30:12 +01:00
Camilla Löwy
ebff6606ee Simplify test for shared library build 2025-11-17 22:57:23 +01:00
Saksham Goyal
ac84815697
Fix 2025-10-03 12:11:41 -04:00
Saksham Goyal
3bec79d0a8
Clang++ build for windows 2025-10-03 11:48:30 -04:00
24 changed files with 108 additions and 89 deletions

1
.gitignore vendored
View File

@ -102,3 +102,4 @@ tests/triangle-vulkan
tests/window
tests/windows
*.o

View File

@ -38,11 +38,7 @@ set(GLFW_LIBRARY_TYPE "${GLFW_LIBRARY_TYPE}" CACHE STRING
"Library type override for GLFW (SHARED, STATIC, OBJECT, or empty to follow BUILD_SHARED_LIBS)")
if (GLFW_LIBRARY_TYPE)
if (GLFW_LIBRARY_TYPE STREQUAL "SHARED")
set(GLFW_BUILD_SHARED_LIBRARY TRUE)
else()
set(GLFW_BUILD_SHARED_LIBRARY FALSE)
endif()
string(COMPARE EQUAL "${GLFW_LIBRARY_TYPE}" "SHARED" GLFW_BUILD_SHARED_LIBRARY)
else()
set(GLFW_BUILD_SHARED_LIBRARY ${BUILD_SHARED_LIBS})
endif()

View File

@ -162,6 +162,7 @@ video tutorials.
- Marcel Metz
- Liam Middlebrook
- mightgoyardstill
- Mihail
- Ave Milia
- Icyllis Milica
- Jonathan Miller

View File

@ -146,11 +146,14 @@ information on what to include when reporting a bug.
from a modal to the content area
- [Wayland] Bugfix: free modules at end of terminate function to resolve
potential segmentation fault (#2744)
- [Wayland] Bugfix: Confining or disabling the cursor could segfault on
compositors without `pointer-constraints-unstable-v1`
- [X11] Bugfix: Running without a WM could trigger an assert (#2593,#2601,#2631)
- [X11] Bugfix: Occasional crash when an idle display awakes (#2766)
- [X11] Bugfix: Prevent BadWindow when creating small windows with a content scale
less than 1 (#2754)
- [X11] Bugfix: Clamp width and height to >= 1 to prevent BadValue error and app exit
- [Linux] Bugfix: The header for `ioctl` was only implicitly included (#2778)
- [Null] Added Vulkan 'window' surface creation via `VK_EXT_headless_surface`
- [Null] Added EGL context creation on Mesa via `EGL_MESA_platform_surfaceless`
- [EGL] Allowed native access on Wayland with `GLFW_CONTEXT_CREATION_API` set to

View File

@ -359,7 +359,7 @@ GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window,
window->context.source = ctxconfig->source;
window->context.client = GLFW_OPENGL_API;
previous = _glfwPlatformGetTls(&_glfw.contextSlot);
previous = (_GLFWwindow *)_glfwPlatformGetTls(&_glfw.contextSlot);
glfwMakeContextCurrent((GLFWwindow*) window);
if (_glfwPlatformGetTls(&_glfw.contextSlot) != window)
return GLFW_FALSE;
@ -620,7 +620,7 @@ GLFWAPI void glfwMakeContextCurrent(GLFWwindow* handle)
_GLFWwindow* window = (_GLFWwindow*) handle;
_GLFWwindow* previous;
previous = _glfwPlatformGetTls(&_glfw.contextSlot);
previous = (_GLFWwindow *)_glfwPlatformGetTls(&_glfw.contextSlot);
if (window && window->context.client == GLFW_NO_API)
{
@ -642,7 +642,7 @@ GLFWAPI void glfwMakeContextCurrent(GLFWwindow* handle)
GLFWAPI GLFWwindow* glfwGetCurrentContext(void)
{
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
return _glfwPlatformGetTls(&_glfw.contextSlot);
return (GLFWwindow *)_glfwPlatformGetTls(&_glfw.contextSlot);
}
GLFWAPI void glfwSwapBuffers(GLFWwindow* handle)
@ -668,7 +668,7 @@ GLFWAPI void glfwSwapInterval(int interval)
_GLFW_REQUIRE_INIT();
window = _glfwPlatformGetTls(&_glfw.contextSlot);
window = (_GLFWwindow *)_glfwPlatformGetTls(&_glfw.contextSlot);
if (!window)
{
_glfwInputError(GLFW_NO_CURRENT_CONTEXT,
@ -686,7 +686,7 @@ GLFWAPI int glfwExtensionSupported(const char* extension)
_GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
window = _glfwPlatformGetTls(&_glfw.contextSlot);
window = (_GLFWwindow *)_glfwPlatformGetTls(&_glfw.contextSlot);
if (!window)
{
_glfwInputError(GLFW_NO_CURRENT_CONTEXT,
@ -752,7 +752,7 @@ GLFWAPI GLFWglproc glfwGetProcAddress(const char* procname)
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
window = _glfwPlatformGetTls(&_glfw.contextSlot);
window = (_GLFWwindow *)_glfwPlatformGetTls(&_glfw.contextSlot);
if (!window)
{
_glfwInputError(GLFW_NO_CURRENT_CONTEXT,
@ -762,4 +762,3 @@ GLFWAPI GLFWglproc glfwGetProcAddress(const char* procname)
return window->context.getProcAddress(procname);
}

View File

@ -123,10 +123,10 @@ static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig,
return GLFW_FALSE;
}
nativeConfigs = _glfw_calloc(nativeCount, sizeof(EGLConfig));
nativeConfigs = (EGLConfig *)_glfw_calloc(nativeCount, sizeof(EGLConfig));
eglGetConfigs(_glfw.egl.display, nativeConfigs, nativeCount, &nativeCount);
usableConfigs = _glfw_calloc(nativeCount, sizeof(_GLFWfbconfig));
usableConfigs = (_GLFWfbconfig *)_glfw_calloc(nativeCount, sizeof(_GLFWfbconfig));
usableCount = 0;
for (i = 0; i < nativeCount; i++)
@ -312,7 +312,7 @@ static int extensionSupportedEGL(const char* extension)
static GLFWglproc getProcAddressEGL(const char* procname)
{
_GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot);
_GLFWwindow* window = (_GLFWwindow *)_glfwPlatformGetTls(&_glfw.contextSlot);
assert(window != NULL);
if (window->context.egl.client)
@ -968,4 +968,3 @@ GLFWAPI int glfwGetEGLConfig(GLFWwindow* handle, EGLConfig* config)
*config = window->context.egl.config;
return GLFW_TRUE;
}

View File

@ -205,8 +205,8 @@ char** _glfwParseUriList(char* text, int* count)
(*count)++;
path = _glfw_calloc(strlen(line) + 1, 1);
paths = _glfw_realloc(paths, *count * sizeof(char*));
path = (char*)_glfw_calloc(strlen(line) + 1, 1);
paths = (char**)_glfw_realloc(paths, *count * sizeof(char*));
paths[*count - 1] = path;
while (*line)
@ -231,7 +231,7 @@ char** _glfwParseUriList(char* text, int* count)
char* _glfw_strdup(const char* source)
{
const size_t length = strlen(source);
char* result = _glfw_calloc(length + 1, 1);
char* result = (char*)_glfw_calloc(length + 1, 1);
strcpy(result, source);
return result;
}
@ -357,10 +357,10 @@ void _glfwInputError(int code, const char* format, ...)
if (_glfw.initialized)
{
error = _glfwPlatformGetTls(&_glfw.errorSlot);
error = (_GLFWerror*)_glfwPlatformGetTls(&_glfw.errorSlot);
if (!error)
{
error = _glfw_calloc(1, sizeof(_GLFWerror));
error = (_GLFWerror*)_glfw_calloc(1, sizeof(_GLFWerror));
_glfwPlatformSetTls(&_glfw.errorSlot, error);
_glfwPlatformLockMutex(&_glfw.errorLock);
error->next = _glfw.errorListHead;
@ -505,7 +505,7 @@ GLFWAPI int glfwGetError(const char** description)
*description = NULL;
if (_glfw.initialized)
error = _glfwPlatformGetTls(&_glfw.errorSlot);
error = (_GLFWerror*)_glfwPlatformGetTls(&_glfw.errorSlot);
else
error = &_glfwMainThreadError;
@ -525,4 +525,3 @@ GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun cbfun)
_GLFW_SWAP(GLFWerrorfun, _glfwErrorCallback, cbfun);
return cbfun;
}

View File

@ -489,7 +489,7 @@ void _glfwInitGamepadMappings(void)
{
size_t i;
const size_t count = sizeof(_glfwDefaultMappings) / sizeof(char*);
_glfw.mappings = _glfw_calloc(count, sizeof(_GLFWmapping));
_glfw.mappings = (_GLFWmapping *)_glfw_calloc(count, sizeof(_GLFWmapping));
for (i = 0; i < count; i++)
{
@ -520,9 +520,9 @@ _GLFWjoystick* _glfwAllocJoystick(const char* name,
js = _glfw.joysticks + jid;
js->allocated = GLFW_TRUE;
js->axes = _glfw_calloc(axisCount, sizeof(float));
js->buttons = _glfw_calloc(buttonCount + (size_t) hatCount * 4, 1);
js->hats = _glfw_calloc(hatCount, 1);
js->axes = (float *)_glfw_calloc(axisCount, sizeof(float));
js->buttons = (unsigned char *)_glfw_calloc(buttonCount + (size_t) hatCount * 4, 1);
js->hats = (unsigned char *)_glfw_calloc(hatCount, 1);
js->axisCount = axisCount;
js->buttonCount = buttonCount;
js->hatCount = hatCount;
@ -858,7 +858,7 @@ GLFWAPI GLFWcursor* glfwCreateCursor(const GLFWimage* image, int xhot, int yhot)
return NULL;
}
cursor = _glfw_calloc(1, sizeof(_GLFWcursor));
cursor = (_GLFWcursor *)_glfw_calloc(1, sizeof(_GLFWcursor));
cursor->next = _glfw.cursorListHead;
_glfw.cursorListHead = cursor;
@ -892,7 +892,7 @@ GLFWAPI GLFWcursor* glfwCreateStandardCursor(int shape)
return NULL;
}
cursor = _glfw_calloc(1, sizeof(_GLFWcursor));
cursor = (_GLFWcursor *)_glfw_calloc(1, sizeof(_GLFWcursor));
cursor->next = _glfw.cursorListHead;
_glfw.cursorListHead = cursor;
@ -1303,7 +1303,7 @@ GLFWAPI int glfwUpdateGamepadMappings(const char* string)
{
_glfw.mappingCount++;
_glfw.mappings =
_glfw_realloc(_glfw.mappings,
(_GLFWmapping *)_glfw_realloc(_glfw.mappings,
sizeof(_GLFWmapping) * _glfw.mappingCount);
_glfw.mappings[_glfw.mappingCount - 1] = mapping;
}

View File

@ -32,6 +32,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/inotify.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <errno.h>
#include <dirent.h>

View File

@ -39,8 +39,8 @@
//
static int compareVideoModes(const void* fp, const void* sp)
{
const GLFWvidmode* fm = fp;
const GLFWvidmode* sm = sp;
const GLFWvidmode* fm = (const GLFWvidmode*)fp;
const GLFWvidmode* sm = (const GLFWvidmode*)sp;
const int fbpp = fm->redBits + fm->greenBits + fm->blueBits;
const int sbpp = sm->redBits + sm->greenBits + sm->blueBits;
const int farea = fm->width * fm->height;
@ -102,7 +102,7 @@ void _glfwInputMonitor(_GLFWmonitor* monitor, int action, int placement)
{
_glfw.monitorCount++;
_glfw.monitors =
_glfw_realloc(_glfw.monitors,
(_GLFWmonitor **)_glfw_realloc(_glfw.monitors,
sizeof(_GLFWmonitor*) * _glfw.monitorCount);
if (placement == _GLFW_INSERT_FIRST)
@ -170,7 +170,7 @@ void _glfwInputMonitorWindow(_GLFWmonitor* monitor, _GLFWwindow* window)
//
_GLFWmonitor* _glfwAllocMonitor(const char* name, int widthMM, int heightMM)
{
_GLFWmonitor* monitor = _glfw_calloc(1, sizeof(_GLFWmonitor));
_GLFWmonitor* monitor = (_GLFWmonitor*) _glfw_calloc(1, sizeof(_GLFWmonitor));
monitor->widthMM = widthMM;
monitor->heightMM = heightMM;
@ -199,9 +199,9 @@ void _glfwFreeMonitor(_GLFWmonitor* monitor)
//
void _glfwAllocGammaArrays(GLFWgammaramp* ramp, unsigned int size)
{
ramp->red = _glfw_calloc(size, sizeof(unsigned short));
ramp->green = _glfw_calloc(size, sizeof(unsigned short));
ramp->blue = _glfw_calloc(size, sizeof(unsigned short));
ramp->red = (unsigned short*)_glfw_calloc(size, sizeof(unsigned short));
ramp->green = (unsigned short*)_glfw_calloc(size, sizeof(unsigned short));
ramp->blue = (unsigned short*)_glfw_calloc(size, sizeof(unsigned short));
ramp->size = size;
}
@ -484,7 +484,7 @@ GLFWAPI void glfwSetGamma(GLFWmonitor* handle, float gamma)
if (!original)
return;
values = _glfw_calloc(original->size, sizeof(unsigned short));
values = (unsigned short*)_glfw_calloc(original->size, sizeof(unsigned short));
for (i = 0; i < original->size; i++)
{
@ -552,4 +552,3 @@ GLFWAPI void glfwSetGammaRamp(GLFWmonitor* handle, const GLFWgammaramp* ramp)
_glfw.platform.setGammaRamp(monitor, ramp);
}

View File

@ -103,7 +103,7 @@ void _glfwGetMonitorWorkareaNull(_GLFWmonitor* monitor,
GLFWvidmode* _glfwGetVideoModesNull(_GLFWmonitor* monitor, int* found)
{
GLFWvidmode* mode = _glfw_calloc(1, sizeof(GLFWvidmode));
GLFWvidmode* mode = (GLFWvidmode*)_glfw_calloc(1, sizeof(GLFWvidmode));
*mode = getVideoMode();
*found = 1;
return mode;
@ -157,4 +157,3 @@ void _glfwSetGammaRampNull(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
memcpy(monitor->null.ramp.green, ramp->green, sizeof(short) * ramp->size);
memcpy(monitor->null.ramp.blue, ramp->blue, sizeof(short) * ramp->size);
}

View File

@ -706,8 +706,8 @@ void _glfwGetRequiredInstanceExtensionsNull(char** extensions)
if (!_glfw.vk.KHR_surface || !_glfw.vk.EXT_headless_surface)
return;
extensions[0] = "VK_KHR_surface";
extensions[1] = "VK_EXT_headless_surface";
extensions[0] = (char*)"VK_KHR_surface";
extensions[1] = (char*)"VK_EXT_headless_surface";
}
GLFWbool _glfwGetPhysicalDevicePresentationSupportNull(VkInstance instance,
@ -746,4 +746,3 @@ VkResult _glfwCreateWindowSurfaceNull(VkInstance instance,
return err;
}

View File

@ -112,7 +112,7 @@ GLFWbool _glfwInitVulkan(int mode)
return GLFW_FALSE;
}
ep = _glfw_calloc(count, sizeof(VkExtensionProperties));
ep = (VkExtensionProperties*)_glfw_calloc(count, sizeof(VkExtensionProperties));
err = vkEnumerateInstanceExtensionProperties(NULL, &count, ep);
if (err)

View File

@ -134,7 +134,7 @@ static int choosePixelFormatWGL(_GLFWwindow* window,
nativeCount = _glfw_min(nativeCount, extensionCount);
}
usableConfigs = _glfw_calloc(nativeCount, sizeof(_GLFWfbconfig));
usableConfigs = (_GLFWfbconfig *)_glfw_calloc(nativeCount, sizeof(_GLFWfbconfig));
for (i = 0; i < nativeCount; i++)
{
@ -346,7 +346,7 @@ static void swapBuffersWGL(_GLFWwindow* window)
static void swapIntervalWGL(int interval)
{
_GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot);
_GLFWwindow* window = (_GLFWwindow*)_glfwPlatformGetTls(&_glfw.contextSlot);
assert(window != NULL);
window->context.wgl.interval = interval;
@ -412,7 +412,7 @@ GLFWbool _glfwInitWGL(void)
if (_glfw.wgl.instance)
return GLFW_TRUE;
_glfw.wgl.instance = _glfwPlatformLoadModule("opengl32.dll");
_glfw.wgl.instance = (HINSTANCE)_glfwPlatformLoadModule("opengl32.dll");
if (!_glfw.wgl.instance)
{
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,

View File

@ -81,7 +81,7 @@ static GLFWbool loadLibraries(void)
return GLFW_FALSE;
}
_glfw.win32.user32.instance = _glfwPlatformLoadModule("user32.dll");
_glfw.win32.user32.instance = (HINSTANCE)_glfwPlatformLoadModule("user32.dll");
if (!_glfw.win32.user32.instance)
{
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
@ -100,7 +100,7 @@ static GLFWbool loadLibraries(void)
_glfw.win32.user32.GetSystemMetricsForDpi_ = (PFN_GetSystemMetricsForDpi)
_glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "GetSystemMetricsForDpi");
_glfw.win32.dinput8.instance = _glfwPlatformLoadModule("dinput8.dll");
_glfw.win32.dinput8.instance = (HINSTANCE)_glfwPlatformLoadModule("dinput8.dll");
if (_glfw.win32.dinput8.instance)
{
_glfw.win32.dinput8.Create = (PFN_DirectInput8Create)
@ -121,7 +121,7 @@ static GLFWbool loadLibraries(void)
for (i = 0; names[i]; i++)
{
_glfw.win32.xinput.instance = _glfwPlatformLoadModule(names[i]);
_glfw.win32.xinput.instance = (HINSTANCE)_glfwPlatformLoadModule(names[i]);
if (_glfw.win32.xinput.instance)
{
_glfw.win32.xinput.GetCapabilities = (PFN_XInputGetCapabilities)
@ -134,7 +134,7 @@ static GLFWbool loadLibraries(void)
}
}
_glfw.win32.dwmapi.instance = _glfwPlatformLoadModule("dwmapi.dll");
_glfw.win32.dwmapi.instance = (HINSTANCE)_glfwPlatformLoadModule("dwmapi.dll");
if (_glfw.win32.dwmapi.instance)
{
_glfw.win32.dwmapi.IsCompositionEnabled = (PFN_DwmIsCompositionEnabled)
@ -147,7 +147,7 @@ static GLFWbool loadLibraries(void)
_glfwPlatformGetModuleSymbol(_glfw.win32.dwmapi.instance, "DwmGetColorizationColor");
}
_glfw.win32.shcore.instance = _glfwPlatformLoadModule("shcore.dll");
_glfw.win32.shcore.instance = (HINSTANCE)_glfwPlatformLoadModule("shcore.dll");
if (_glfw.win32.shcore.instance)
{
_glfw.win32.shcore.SetProcessDpiAwareness_ = (PFN_SetProcessDpiAwareness)
@ -156,7 +156,7 @@ static GLFWbool loadLibraries(void)
_glfwPlatformGetModuleSymbol(_glfw.win32.shcore.instance, "GetDpiForMonitor");
}
_glfw.win32.ntdll.instance = _glfwPlatformLoadModule("ntdll.dll");
_glfw.win32.ntdll.instance = (HINSTANCE)_glfwPlatformLoadModule("ntdll.dll");
if (_glfw.win32.ntdll.instance)
{
_glfw.win32.ntdll.RtlVerifyVersionInfo_ = (PFN_RtlVerifyVersionInfo)
@ -445,7 +445,7 @@ WCHAR* _glfwCreateWideStringFromUTF8Win32(const char* source)
return NULL;
}
target = _glfw_calloc(count, sizeof(WCHAR));
target = (WCHAR *)_glfw_calloc(count, sizeof(WCHAR));
if (!MultiByteToWideChar(CP_UTF8, 0, source, -1, target, count))
{
@ -473,7 +473,7 @@ char* _glfwCreateUTF8FromWideStringWin32(const WCHAR* source)
return NULL;
}
target = _glfw_calloc(size, 1);
target = (char*)_glfw_calloc(size, 1);
if (!WideCharToMultiByte(CP_UTF8, 0, source, -1, target, size, NULL, NULL))
{
@ -528,7 +528,8 @@ void _glfwUpdateKeyNamesWin32(void)
if (key >= GLFW_KEY_KP_0 && key <= GLFW_KEY_KP_ADD)
{
const UINT vks[] = {
const UINT vks[] =
{
VK_NUMPAD0, VK_NUMPAD1, VK_NUMPAD2, VK_NUMPAD3,
VK_NUMPAD4, VK_NUMPAD5, VK_NUMPAD6, VK_NUMPAD7,
VK_NUMPAD8, VK_NUMPAD9, VK_DECIMAL, VK_DIVIDE,

View File

@ -178,8 +178,8 @@ static const char* getDeviceDescription(const XINPUT_CAPABILITIES* xic)
//
static int compareJoystickObjects(const void* first, const void* second)
{
const _GLFWjoyobjectWin32* fo = first;
const _GLFWjoyobjectWin32* so = second;
const _GLFWjoyobjectWin32* fo = (const _GLFWjoyobjectWin32 *)first;
const _GLFWjoyobjectWin32* so = (const _GLFWjoyobjectWin32 *)second;
if (fo->type != so->type)
return fo->type - so->type;
@ -199,7 +199,7 @@ static GLFWbool supportsXInput(const GUID* guid)
if (GetRawInputDeviceList(NULL, &count, sizeof(RAWINPUTDEVICELIST)) != 0)
return GLFW_FALSE;
ridl = _glfw_calloc(count, sizeof(RAWINPUTDEVICELIST));
ridl = (RAWINPUTDEVICELIST *)_glfw_calloc(count, sizeof(RAWINPUTDEVICELIST));
if (GetRawInputDeviceList(ridl, &count, sizeof(RAWINPUTDEVICELIST)) == (UINT) -1)
{
@ -274,7 +274,7 @@ static void closeJoystick(_GLFWjoystick* js)
static BOOL CALLBACK deviceObjectCallback(const DIDEVICEOBJECTINSTANCEW* doi,
void* user)
{
_GLFWobjenumWin32* data = user;
_GLFWobjenumWin32* data = (_GLFWobjenumWin32 *)user;
_GLFWjoyobjectWin32* object = data->objects + data->objectCount;
if (DIDFT_GETTYPE(doi->dwType) & DIDFT_AXIS)
@ -416,7 +416,7 @@ static BOOL CALLBACK deviceCallback(const DIDEVICEINSTANCE* di, void* user)
memset(&data, 0, sizeof(data));
data.device = device;
data.objects = _glfw_calloc(dc.dwAxes + (size_t) dc.dwButtons + dc.dwPOVs,
data.objects = (_GLFWjoyobjectWin32 *)_glfw_calloc(dc.dwAxes + (size_t) dc.dwButtons + dc.dwPOVs,
sizeof(_GLFWjoyobjectWin32));
if (FAILED(IDirectInputDevice8_EnumObjects(device,

View File

@ -145,7 +145,7 @@ void _glfwPollMonitorsWin32(void)
disconnectedCount = _glfw.monitorCount;
if (disconnectedCount)
{
disconnected = _glfw_calloc(_glfw.monitorCount, sizeof(_GLFWmonitor*));
disconnected = (_GLFWmonitor**)_glfw_calloc(_glfw.monitorCount, sizeof(_GLFWmonitor*));
memcpy(disconnected,
_glfw.monitors,
_glfw.monitorCount * sizeof(_GLFWmonitor*));
@ -463,7 +463,7 @@ GLFWvidmode* _glfwGetVideoModesWin32(_GLFWmonitor* monitor, int* count)
if (!*count)
{
// HACK: Report the current mode if no valid modes were found
result = _glfw_calloc(1, sizeof(GLFWvidmode));
result = (GLFWvidmode*)_glfw_calloc(1, sizeof(GLFWvidmode));
_glfwGetVideoModeWin32(monitor, result);
*count = 1;
}

View File

@ -530,7 +530,7 @@ static void maximizeWindowManually(_GLFWwindow* window)
//
static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
_GLFWwindow* window = GetPropW(hWnd, L"GLFW");
_GLFWwindow* window = (_GLFWwindow*)GetPropW(hWnd, L"GLFW");
if (!window)
{
if (uMsg == WM_NCCREATE)
@ -538,7 +538,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
if (_glfwIsWindows10Version1607OrGreaterWin32())
{
const CREATESTRUCTW* cs = (const CREATESTRUCTW*) lParam;
const _GLFWwndconfig* wndconfig = cs->lpCreateParams;
const _GLFWwndconfig* wndconfig = (const _GLFWwndconfig*)cs->lpCreateParams;
// On per-monitor DPI aware V1 systems, only enable
// non-client scaling for windows that scale the client area
@ -910,7 +910,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
if (size > (UINT) _glfw.win32.rawInputSize)
{
_glfw_free(_glfw.win32.rawInput);
_glfw.win32.rawInput = _glfw_calloc(size, 1);
_glfw.win32.rawInput = (RAWINPUT *)_glfw_calloc(size, 1);
_glfw.win32.rawInputSize = size;
}
@ -1236,7 +1236,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
int i;
const int count = DragQueryFileW(drop, 0xffffffff, NULL, 0);
char** paths = _glfw_calloc(count, sizeof(char*));
char** paths = (char**)_glfw_calloc(count, sizeof(char*));
// Move the mouse to the position of the drop
DragQueryPoint(drop, &pt);
@ -1245,7 +1245,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
for (i = 0; i < count; i++)
{
const UINT length = DragQueryFileW(drop, i, NULL, 0);
WCHAR* buffer = _glfw_calloc((size_t) length + 1, sizeof(WCHAR));
WCHAR* buffer = (WCHAR*)_glfw_calloc((size_t) length + 1, sizeof(WCHAR));
DragQueryFileW(drop, i, buffer, length + 1);
paths[i] = _glfwCreateUTF8FromWideStringWin32(buffer);
@ -1291,13 +1291,13 @@ static int createNativeWindow(_GLFWwindow* window,
wc.lpszClassName = L"GLFW30";
#endif
// Load user-provided icon if available
wc.hIcon = LoadImageW(GetModuleHandleW(NULL),
wc.hIcon = (HICON)LoadImageW(GetModuleHandleW(NULL),
L"GLFW_ICON", IMAGE_ICON,
0, 0, LR_DEFAULTSIZE | LR_SHARED);
if (!wc.hIcon)
{
// No user-provided icon found, load default icon
wc.hIcon = LoadImageW(NULL,
wc.hIcon = (HICON)LoadImageW(NULL,
IDI_APPLICATION, IMAGE_ICON,
0, 0, LR_DEFAULTSIZE | LR_SHARED);
}
@ -1321,7 +1321,7 @@ static int createNativeWindow(_GLFWwindow* window,
const int cursorWidth = GetSystemMetrics(SM_CXCURSOR);
const int cursorHeight = GetSystemMetrics(SM_CYCURSOR);
unsigned char* cursorPixels = _glfw_calloc(cursorWidth * cursorHeight, 4);
unsigned char* cursorPixels = (unsigned char*)_glfw_calloc(cursorWidth * cursorHeight, 4);
if (!cursorPixels)
return GLFW_FALSE;
@ -1769,7 +1769,7 @@ void _glfwGetWindowContentScaleWin32(_GLFWwindow* window, float* xscale, float*
{
const HANDLE handle = MonitorFromWindow(window->win32.handle,
MONITOR_DEFAULTTONEAREST);
_glfwGetHMONITORContentScaleWin32(handle, xscale, yscale);
_glfwGetHMONITORContentScaleWin32((HMONITOR)handle, xscale, yscale);
}
void _glfwIconifyWindowWin32(_GLFWwindow* window)
@ -2124,7 +2124,7 @@ void _glfwPollEventsWin32(void)
handle = GetActiveWindow();
if (handle)
{
window = GetPropW(handle, L"GLFW");
window = (_GLFWwindow*)GetPropW(handle, L"GLFW");
if (window)
{
int i;
@ -2326,7 +2326,7 @@ GLFWbool _glfwCreateStandardCursorWin32(_GLFWcursor* cursor, int shape)
return GLFW_FALSE;
}
cursor->win32.handle = LoadImageW(NULL,
cursor->win32.handle = (HCURSOR)LoadImageW(NULL,
MAKEINTRESOURCEW(id), IMAGE_CURSOR, 0, 0,
LR_DEFAULTSIZE | LR_SHARED);
if (!cursor->win32.handle)
@ -2369,7 +2369,7 @@ void _glfwSetClipboardStringWin32(const char* string)
return;
}
buffer = GlobalLock(object);
buffer = (WCHAR *)GlobalLock(object);
if (!buffer)
{
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
@ -2432,7 +2432,7 @@ const char* _glfwGetClipboardStringWin32(void)
return NULL;
}
buffer = GlobalLock(object);
buffer = (WCHAR *)GlobalLock(object);
if (!buffer)
{
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
@ -2480,7 +2480,7 @@ EGLenum _glfwGetEGLPlatformWin32(EGLint** attribs)
if (type)
{
*attribs = _glfw_calloc(3, sizeof(EGLint));
*attribs = (EGLint *)_glfw_calloc(3, sizeof(EGLint));
(*attribs)[0] = EGL_PLATFORM_ANGLE_TYPE_ANGLE;
(*attribs)[1] = type;
(*attribs)[2] = EGL_NONE;

View File

@ -213,7 +213,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
if (!_glfwIsValidContextConfig(&ctxconfig))
return NULL;
window = _glfw_calloc(1, sizeof(_GLFWwindow));
window = (_GLFWwindow *)_glfw_calloc(1, sizeof(_GLFWwindow));
window->next = _glfw.windowListHead;
_glfw.windowListHead = window;

View File

@ -979,7 +979,8 @@ void _glfwTerminateWayland(void)
if (_glfw.wl.cursorTimerfd >= 0)
close(_glfw.wl.cursorTimerfd);
// Free modules only after all wayland termination functions are called
// Free modules only after all Wayland termination functions are called
if (_glfw.egl.handle)
{
_glfwPlatformFreeModule(_glfw.egl.handle);
@ -1003,6 +1004,7 @@ void _glfwTerminateWayland(void)
_glfwPlatformFreeModule(_glfw.wl.xkb.handle);
_glfw.wl.xkb.handle = NULL;
}
if (_glfw.wl.cursor.handle)
{
_glfwPlatformFreeModule(_glfw.wl.cursor.handle);

View File

@ -136,18 +136,22 @@ struct wl_output;
#define GLFW_WAYLAND_MONITOR_STATE _GLFWmonitorWayland wl;
#define GLFW_WAYLAND_CURSOR_STATE _GLFWcursorWayland wl;
struct wl_cursor_image {
struct wl_cursor_image
{
uint32_t width;
uint32_t height;
uint32_t hotspot_x;
uint32_t hotspot_y;
uint32_t delay;
};
struct wl_cursor {
struct wl_cursor
{
unsigned int image_count;
struct wl_cursor_image** images;
char* name;
};
typedef struct wl_cursor_theme* (* PFN_wl_cursor_theme_load)(const char*, int, struct wl_shm*);
typedef void (* PFN_wl_cursor_theme_destroy)(struct wl_cursor_theme*);
typedef struct wl_cursor* (* PFN_wl_cursor_theme_get_cursor)(struct wl_cursor_theme*, const char*);

View File

@ -1413,7 +1413,7 @@ static void handleEvents(double* timeout)
if (read(_glfw.wl.keyRepeatTimerfd, &repeats, sizeof(repeats)) == 8)
{
if(_glfw.wl.keyboardFocus)
if (_glfw.wl.keyboardFocus)
{
for (uint64_t i = 0; i < repeats; i++)
{
@ -1692,7 +1692,8 @@ static void keyboardHandleKeymap(void* userData,
}
mapStr = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);
if (mapStr == MAP_FAILED) {
if (mapStr == MAP_FAILED)
{
close(fd);
return;
}
@ -1838,7 +1839,9 @@ static void keyboardHandleKey(void* userData,
timer.it_value.tv_nsec = (_glfw.wl.keyRepeatDelay % 1000) * 1000000;
timerfd_settime(_glfw.wl.keyRepeatTimerfd, 0, &timer, NULL);
}
} else if (scancode == _glfw.wl.keyRepeatScancode) {
}
else if (scancode == _glfw.wl.keyRepeatScancode)
{
timerfd_settime(_glfw.wl.keyRepeatTimerfd, 0, &timer, NULL);
}
@ -2974,10 +2977,16 @@ static void lockPointer(_GLFWwindow* window)
if (!_glfw.wl.relativePointerManager)
{
_glfwInputError(GLFW_FEATURE_UNAVAILABLE,
"Wayland: The compositor does not support pointer locking");
"Wayland: The compositor does not support relative pointer motion");
return;
}
if (!_glfw.wl.pointerConstraints)
{
_glfwInputError(GLFW_FEATURE_UNAVAILABLE,
"Wayland: The compositor does not support locking the pointer");
}
window->wl.relativePointer =
zwp_relative_pointer_manager_v1_get_relative_pointer(
_glfw.wl.relativePointerManager,
@ -3025,6 +3034,12 @@ static const struct zwp_confined_pointer_v1_listener confinedPointerListener =
static void confinePointer(_GLFWwindow* window)
{
if (!_glfw.wl.pointerConstraints)
{
_glfwInputError(GLFW_FEATURE_UNAVAILABLE,
"Wayland: The compositor does not support confining the pointer");
}
window->wl.confinedPointer =
zwp_pointer_constraints_v1_confine_pointer(
_glfw.wl.pointerConstraints,

View File

@ -151,7 +151,8 @@ void _glfwPollMonitorsX11(void)
}
XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, oi->crtc);
if (!ci) {
if (!ci)
{
XRRFreeOutputInfo(oi);
continue;
}

View File

@ -2207,10 +2207,10 @@ void _glfwGetWindowSizeX11(_GLFWwindow* window, int* width, int* height)
void _glfwSetWindowSizeX11(_GLFWwindow* window, int width, int height)
{
// The dimensions must be nonzero, or a BadValue error results.
// The dimensions must be nonzero, or a BadValue error results
width = _glfw_max(1, width);
height = _glfw_max(1, height);
if (window->monitor)
{
if (window->monitor->window == window)