diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 75533ec3..bd5ed5b1 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -14,6 +14,7 @@ video tutorials. - Luca Bacci - Keith Bauer - John Bartholomew + - Garett Bass - Coşku Baş - Niklas Behrens - Andrew Belt diff --git a/README.md b/README.md index cebe62bc..80ecbc08 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,10 @@ available for all supported compilers. See the [compilation guide](https://www.glfw.org/docs/latest/compile.html) for more information about how to compile GLFW yourself. +Alternatively, you can `#include ` in exactly one compilation +unit of a C or C++ project to compile the entire implementation directly into +your application, avoiding the need to separately compile and link with GLFW. + ## Using GLFW diff --git a/include/GLFW/glfw3impl.h b/include/GLFW/glfw3impl.h new file mode 100644 index 00000000..a12417d9 --- /dev/null +++ b/include/GLFW/glfw3impl.h @@ -0,0 +1,101 @@ +/************************************************************************* + * GLFW 3.4 - www.glfw.org + * A library for OpenGL, window and input + *------------------------------------------------------------------------ + * Copyright (c) 2002-2006 Marcus Geelnard + * Copyright (c) 2006-2019 Camilla Löwy + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would + * be appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not + * be misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source + * distribution. + * + *************************************************************************/ + +#ifndef _glfw3impl_h_ +#define _glfw3impl_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_WIN32) + + #define _GLFW_WIN32 + // -D_CRT_SECURE_NO_WARNINGS + // -lgdi32 + // -lshell32 + // -luser32 + +#elif defined(__APPLE__) + + #define _GLFW_COCOA + // -framework Cocoa + // -framework IOKit + // -framework QuartzCore + // -x objective-c + // or + // -x objective-c++ + +#endif + +#include "../../src/cocoa_init.m" +#include "../../src/cocoa_joystick.m" +#include "../../src/cocoa_monitor.m" +#include "../../src/cocoa_time.c" +#include "../../src/cocoa_window.m" +#include "../../src/context.c" +#include "../../src/egl_context.c" +#include "../../src/glx_context.c" +#include "../../src/init.c" +#include "../../src/input.c" +#include "../../src/linux_joystick.c" +#include "../../src/monitor.c" +#include "../../src/nsgl_context.m" +#include "../../src/null_init.c" +#include "../../src/null_joystick.c" +#include "../../src/null_monitor.c" +#include "../../src/null_window.c" +#include "../../src/osmesa_context.c" +#include "../../src/platform.c" +#include "../../src/posix_module.c" +#include "../../src/posix_poll.c" +#include "../../src/posix_thread.c" +#include "../../src/posix_time.c" +#include "../../src/vulkan.c" +#include "../../src/wgl_context.c" +#include "../../src/win32_init.c" +#include "../../src/win32_joystick.c" +#include "../../src/win32_module.c" +#include "../../src/win32_monitor.c" +#include "../../src/win32_thread.c" +#include "../../src/win32_time.c" +#include "../../src/win32_window.c" +#include "../../src/window.c" +#include "../../src/wl_init.c" +#include "../../src/wl_monitor.c" +#include "../../src/wl_window.c" +#include "../../src/x11_init.c" +#include "../../src/x11_monitor.c" +#include "../../src/x11_window.c" +#include "../../src/xkb_unicode.c" + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif /* _glfw3impl_h_ */ diff --git a/src/cocoa_init.m b/src/cocoa_init.m index b3831df1..6608172b 100644 --- a/src/cocoa_init.m +++ b/src/cocoa_init.m @@ -37,7 +37,7 @@ // Change to our application bundle's resources directory, if present // -static void changeToResourcesDirectory(void) +static void _glfwChangeToResourcesDirectoryCocoa(void) { char resourcesPath[MAXPATHLEN]; @@ -76,7 +76,7 @@ static void changeToResourcesDirectory(void) // could go away at any moment, lots of stuff that really should be // localize(d|able), etc. Add a nib to save us this horror. // -static void createMenuBar(void) +static void _glfwCreateMenuBarCocoa(void) { NSString* appName = nil; NSDictionary* bundleInfo = [[NSBundle mainBundle] infoDictionary]; @@ -177,7 +177,7 @@ static void createMenuBar(void) // Create key code translation tables // -static void createKeyTables(void) +static void _glfwCreateKeyTablesCocoa(void) { memset(_glfw.ns.keycodes, -1, sizeof(_glfw.ns.keycodes)); memset(_glfw.ns.scancodes, -1, sizeof(_glfw.ns.scancodes)); @@ -307,7 +307,7 @@ static void createKeyTables(void) // Retrieve Unicode data for the current keyboard layout // -static GLFWbool updateUnicodeData(void) +static GLFWbool _glfwUpdateUnicodeDataCocoa(void) { if (_glfw.ns.inputSource) { @@ -325,7 +325,8 @@ static GLFWbool updateUnicodeData(void) } _glfw.ns.unicodeData = - TISGetInputSourceProperty(_glfw.ns.inputSource, + (id) + TISGetInputSourceProperty((TISInputSourceRef) _glfw.ns.inputSource, kTISPropertyUnicodeKeyLayoutData); if (!_glfw.ns.unicodeData) { @@ -339,7 +340,7 @@ static GLFWbool updateUnicodeData(void) // Load HIToolbox.framework and the TIS symbols we need from it // -static GLFWbool initializeTIS(void) +static GLFWbool _glfwInitializeTISCocoa(void) { // This works only because Cocoa has already loaded it properly _glfw.ns.tis.bundle = @@ -352,15 +353,19 @@ static GLFWbool initializeTIS(void) } CFStringRef* kPropertyUnicodeKeyLayoutData = + (CFStringRef*) CFBundleGetDataPointerForName(_glfw.ns.tis.bundle, CFSTR("kTISPropertyUnicodeKeyLayoutData")); _glfw.ns.tis.CopyCurrentKeyboardLayoutInputSource = + (PFN_TISCopyCurrentKeyboardLayoutInputSource) CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle, CFSTR("TISCopyCurrentKeyboardLayoutInputSource")); _glfw.ns.tis.GetInputSourceProperty = + (PFN_TISGetInputSourceProperty) CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle, CFSTR("TISGetInputSourceProperty")); _glfw.ns.tis.GetKbdType = + (PFN_LMGetKbdType) CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle, CFSTR("LMGetKbdType")); @@ -377,7 +382,7 @@ static GLFWbool initializeTIS(void) _glfw.ns.tis.kPropertyUnicodeKeyLayoutData = *kPropertyUnicodeKeyLayoutData; - return updateUnicodeData(); + return _glfwUpdateUnicodeDataCocoa(); } @interface GLFWHelper : NSObject @@ -387,7 +392,7 @@ static GLFWbool initializeTIS(void) - (void)selectedKeyboardInputSourceChanged:(NSObject* )object { - updateUnicodeData(); + _glfwUpdateUnicodeDataCocoa(); } - (void)doNothing:(id)object @@ -434,7 +439,7 @@ static GLFWbool initializeTIS(void) topLevelObjects:&_glfw.ns.nibObjects]; } else - createMenuBar(); + _glfwCreateMenuBarCocoa(); } } @@ -608,7 +613,7 @@ int _glfwInitCocoa(void) handler:block]; if (_glfw.hints.init.ns.chdir) - changeToResourcesDirectory(); + _glfwChangeToResourcesDirectoryCocoa(); // Press and Hold prevents some keys from emitting repeated characters NSDictionary* defaults = @{@"ApplePressAndHoldEnabled":@NO}; @@ -620,7 +625,7 @@ int _glfwInitCocoa(void) name:NSTextInputContextKeyboardSelectionDidChangeNotification object:nil]; - createKeyTables(); + _glfwCreateKeyTablesCocoa(); _glfw.ns.eventSource = CGEventSourceCreate(kCGEventSourceStateHIDSystemState); if (!_glfw.ns.eventSource) @@ -628,7 +633,7 @@ int _glfwInitCocoa(void) CGEventSourceSetLocalEventsSuppressionInterval(_glfw.ns.eventSource, 0.0); - if (!initializeTIS()) + if (!_glfwInitializeTISCocoa()) return GLFW_FALSE; _glfwPollMonitorsCocoa(); diff --git a/src/cocoa_joystick.m b/src/cocoa_joystick.m index caeb4725..bf41adbf 100644 --- a/src/cocoa_joystick.m +++ b/src/cocoa_joystick.m @@ -57,7 +57,7 @@ typedef struct _GLFWjoyelementNS // Returns the value of the specified element of the specified joystick // -static long getElementValue(_GLFWjoystick* js, _GLFWjoyelementNS* element) +static long _glfwGetElementValueCocoa(_GLFWjoystick* js, _GLFWjoyelementNS* element) { IOHIDValueRef valueRef; long value = 0; @@ -77,12 +77,12 @@ static long getElementValue(_GLFWjoystick* js, _GLFWjoyelementNS* element) // Comparison function for matching the SDL element order // -static CFComparisonResult compareElements(const void* fp, - const void* sp, - void* user) +static CFComparisonResult _glfwCompareElementsCocoa(const void* fp, + const void* sp, + void* user) { - const _GLFWjoyelementNS* fe = fp; - const _GLFWjoyelementNS* se = sp; + const _GLFWjoyelementNS* fe = (const _GLFWjoyelementNS*) fp; + const _GLFWjoyelementNS* se = (const _GLFWjoyelementNS*) sp; if (fe->usage < se->usage) return kCFCompareLessThan; if (fe->usage > se->usage) @@ -96,7 +96,7 @@ static CFComparisonResult compareElements(const void* fp, // Removes the specified joystick // -static void closeJoystick(_GLFWjoystick* js) +static void _glfwCloseJoystickCocoa(_GLFWjoystick* js) { _glfwInputJoystick(js, GLFW_DISCONNECTED); @@ -117,10 +117,10 @@ static void closeJoystick(_GLFWjoystick* js) // Callback for user-initiated joystick addition // -static void matchCallback(void* context, - IOReturn result, - void* sender, - IOHIDDeviceRef device) +static void _glfwMatchCallbackCocoa(void* context, + IOReturn result, + void* sender, + IOHIDDeviceRef device) { int jid; char name[256]; @@ -151,7 +151,7 @@ static void matchCallback(void* context, property = IOHIDDeviceGetProperty(device, CFSTR(kIOHIDProductKey)); if (property) { - CFStringGetCString(property, + CFStringGetCString((CFStringRef) property, name, sizeof(name), kCFStringEncodingUTF8); @@ -161,27 +161,27 @@ static void matchCallback(void* context, property = IOHIDDeviceGetProperty(device, CFSTR(kIOHIDVendorIDKey)); if (property) - CFNumberGetValue(property, kCFNumberSInt32Type, &vendor); + CFNumberGetValue((CFNumberRef) property, kCFNumberSInt32Type, &vendor); property = IOHIDDeviceGetProperty(device, CFSTR(kIOHIDProductIDKey)); if (property) - CFNumberGetValue(property, kCFNumberSInt32Type, &product); + CFNumberGetValue((CFNumberRef) property, kCFNumberSInt32Type, &product); property = IOHIDDeviceGetProperty(device, CFSTR(kIOHIDVersionNumberKey)); if (property) - CFNumberGetValue(property, kCFNumberSInt32Type, &version); + CFNumberGetValue((CFNumberRef) property, kCFNumberSInt32Type, &version); // Generate a joystick GUID that matches the SDL 2.0.5+ one if (vendor && product) { - sprintf(guid, "03000000%02x%02x0000%02x%02x0000%02x%02x0000", + snprintf(guid, sizeof(guid), "03000000%02x%02x0000%02x%02x0000%02x%02x0000", (uint8_t) vendor, (uint8_t) (vendor >> 8), (uint8_t) product, (uint8_t) (product >> 8), (uint8_t) version, (uint8_t) (version >> 8)); } else { - sprintf(guid, "05000000%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x00", + snprintf(guid, sizeof(guid), "05000000%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x00", name[0], name[1], name[2], name[3], name[4], name[5], name[6], name[7], name[8], name[9], name[10]); @@ -253,7 +253,7 @@ static void matchCallback(void* context, if (target) { - _GLFWjoyelementNS* element = _glfw_calloc(1, sizeof(_GLFWjoyelementNS)); + _GLFWjoyelementNS* element = (_GLFWjoyelementNS*) _glfw_calloc(1, sizeof(_GLFWjoyelementNS)); element->native = native; element->usage = usage; element->index = (int) CFArrayGetCount(target); @@ -266,11 +266,11 @@ static void matchCallback(void* context, CFRelease(elements); CFArraySortValues(axes, CFRangeMake(0, CFArrayGetCount(axes)), - compareElements, NULL); + _glfwCompareElementsCocoa, NULL); CFArraySortValues(buttons, CFRangeMake(0, CFArrayGetCount(buttons)), - compareElements, NULL); + _glfwCompareElementsCocoa, NULL); CFArraySortValues(hats, CFRangeMake(0, CFArrayGetCount(hats)), - compareElements, NULL); + _glfwCompareElementsCocoa, NULL); js = _glfwAllocJoystick(name, guid, (int) CFArrayGetCount(axes), @@ -287,16 +287,16 @@ static void matchCallback(void* context, // Callback for user-initiated joystick removal // -static void removeCallback(void* context, - IOReturn result, - void* sender, - IOHIDDeviceRef device) +static void _glfwRemoveCallbackCocoa(void* context, + IOReturn result, + void* sender, + IOHIDDeviceRef device) { for (int jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++) { if (_glfw.joysticks[jid].connected && _glfw.joysticks[jid].ns.device == device) { - closeJoystick(&_glfw.joysticks[jid]); + _glfwCloseJoystickCocoa(&_glfw.joysticks[jid]); break; } } @@ -370,9 +370,9 @@ GLFWbool _glfwInitJoysticksCocoa(void) CFRelease(matching); IOHIDManagerRegisterDeviceMatchingCallback(_glfw.ns.hidManager, - &matchCallback, NULL); + &_glfwMatchCallbackCocoa, NULL); IOHIDManagerRegisterDeviceRemovalCallback(_glfw.ns.hidManager, - &removeCallback, NULL); + &_glfwRemoveCallbackCocoa, NULL); IOHIDManagerScheduleWithRunLoop(_glfw.ns.hidManager, CFRunLoopGetMain(), kCFRunLoopDefaultMode); @@ -389,7 +389,7 @@ void _glfwTerminateJoysticksCocoa(void) for (int jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++) { if (_glfw.joysticks[jid].connected) - closeJoystick(&_glfw.joysticks[jid]); + _glfwCloseJoystickCocoa(&_glfw.joysticks[jid]); } if (_glfw.ns.hidManager) @@ -409,7 +409,7 @@ GLFWbool _glfwPollJoystickCocoa(_GLFWjoystick* js, int mode) _GLFWjoyelementNS* axis = (_GLFWjoyelementNS*) CFArrayGetValueAtIndex(js->ns.axes, i); - const long raw = getElementValue(js, axis); + const long raw = _glfwGetElementValueCocoa(js, axis); // Perform auto calibration if (raw < axis->minimum) axis->minimum = raw; @@ -433,7 +433,7 @@ GLFWbool _glfwPollJoystickCocoa(_GLFWjoystick* js, int mode) { _GLFWjoyelementNS* button = (_GLFWjoyelementNS*) CFArrayGetValueAtIndex(js->ns.buttons, i); - const char value = getElementValue(js, button) - button->minimum; + const char value = _glfwGetElementValueCocoa(js, button) - button->minimum; const int state = (value > 0) ? GLFW_PRESS : GLFW_RELEASE; _glfwInputJoystickButton(js, (int) i, state); } @@ -455,7 +455,7 @@ GLFWbool _glfwPollJoystickCocoa(_GLFWjoystick* js, int mode) _GLFWjoyelementNS* hat = (_GLFWjoyelementNS*) CFArrayGetValueAtIndex(js->ns.hats, i); - long state = getElementValue(js, hat) - hat->minimum; + long state = _glfwGetElementValueCocoa(js, hat) - hat->minimum; if (state < 0 || state > 8) state = 8; @@ -478,7 +478,7 @@ void _glfwUpdateGamepadGUIDCocoa(char* guid) { char original[33]; strncpy(original, guid, sizeof(original) - 1); - sprintf(guid, "03000000%.4s0000%.4s000000000000", + snprintf(guid, sizeof(guid), "03000000%.4s0000%.4s000000000000", original, original + 16); } } diff --git a/src/cocoa_monitor.m b/src/cocoa_monitor.m index 6c7315bd..a41af8a3 100644 --- a/src/cocoa_monitor.m +++ b/src/cocoa_monitor.m @@ -41,7 +41,7 @@ // Get the name of the specified display, or NULL // -static char* getMonitorName(CGDirectDisplayID displayID, NSScreen* screen) +static char* _glfwGetMonitorNameCocoa(CGDirectDisplayID displayID, NSScreen* screen) { // IOKit doesn't work on Apple Silicon anymore // Luckily, 10.15 introduced -[NSScreen localizedName]. @@ -74,8 +74,10 @@ static char* getMonitorName(CGDirectDisplayID displayID, NSScreen* screen) kIODisplayOnlyPreferredName); CFNumberRef vendorIDRef = + (CFNumberRef) CFDictionaryGetValue(info, CFSTR(kDisplayVendorID)); CFNumberRef productIDRef = + (CFNumberRef) CFDictionaryGetValue(info, CFSTR(kDisplayProductID)); if (!vendorIDRef || !productIDRef) { @@ -103,6 +105,7 @@ static char* getMonitorName(CGDirectDisplayID displayID, NSScreen* screen) return _glfw_strdup("Display"); CFDictionaryRef names = + (CFDictionaryRef) CFDictionaryGetValue(info, CFSTR(kDisplayProductName)); CFStringRef nameRef; @@ -118,7 +121,7 @@ static char* getMonitorName(CGDirectDisplayID displayID, NSScreen* screen) const CFIndex size = CFStringGetMaximumSizeForEncoding(CFStringGetLength(nameRef), kCFStringEncodingUTF8); - char* name = _glfw_calloc(size + 1, 1); + char* name = (char*) _glfw_calloc(size + 1, 1); CFStringGetCString(nameRef, name, size, kCFStringEncodingUTF8); CFRelease(info); @@ -127,7 +130,7 @@ static char* getMonitorName(CGDirectDisplayID displayID, NSScreen* screen) // Check whether the display mode should be included in enumeration // -static GLFWbool modeIsGood(CGDisplayModeRef mode) +static GLFWbool _glfwModeIsGoodCocoa(CGDisplayModeRef mode) { uint32_t flags = CGDisplayModeGetIOFlags(mode); @@ -154,7 +157,7 @@ static GLFWbool modeIsGood(CGDisplayModeRef mode) // Convert Core Graphics display mode to GLFW video mode // -static GLFWvidmode vidmodeFromCGDisplayMode(CGDisplayModeRef mode, +static GLFWvidmode _glfwVidmodeFromCGDisplayModeCocoa(CGDisplayModeRef mode, double fallbackRefreshRate) { GLFWvidmode result; @@ -189,7 +192,7 @@ static GLFWvidmode vidmodeFromCGDisplayMode(CGDisplayModeRef mode, // Starts reservation for display fading // -static CGDisplayFadeReservationToken beginFadeReservation(void) +static CGDisplayFadeReservationToken _glfwBeginFadeReservationCocoa(void) { CGDisplayFadeReservationToken token = kCGDisplayFadeReservationInvalidToken; @@ -207,7 +210,7 @@ static CGDisplayFadeReservationToken beginFadeReservation(void) // Ends reservation for display fading // -static void endFadeReservation(CGDisplayFadeReservationToken token) +static void _glfwEndFadeReservationCocoa(CGDisplayFadeReservationToken token) { if (token != kCGDisplayFadeReservationInvalidToken) { @@ -222,7 +225,7 @@ static void endFadeReservation(CGDisplayFadeReservationToken token) // Returns the display refresh rate queried from the I/O registry // -static double getFallbackRefreshRate(CGDirectDisplayID displayID) +static double _glfwGetFallbackRefreshRateCocoa(CGDirectDisplayID displayID) { double refreshRate = 60.0; @@ -239,6 +242,7 @@ static double getFallbackRefreshRate(CGDirectDisplayID displayID) while ((service = IOIteratorNext(it)) != 0) { const CFNumberRef indexRef = + (CFNumberRef) IORegistryEntryCreateCFProperty(service, CFSTR("IOFramebufferOpenGLIndex"), kCFAllocatorDefault, @@ -254,11 +258,13 @@ static double getFallbackRefreshRate(CGDirectDisplayID displayID) continue; const CFNumberRef clockRef = + (CFNumberRef) IORegistryEntryCreateCFProperty(service, CFSTR("IOFBCurrentPixelClock"), kCFAllocatorDefault, kNilOptions); const CFNumberRef countRef = + (CFNumberRef) IORegistryEntryCreateCFProperty(service, CFSTR("IOFBCurrentPixelCount"), kCFAllocatorDefault, @@ -299,7 +305,7 @@ void _glfwPollMonitorsCocoa(void) { uint32_t displayCount; CGGetOnlineDisplayList(0, NULL, &displayCount); - CGDirectDisplayID* displays = _glfw_calloc(displayCount, sizeof(CGDirectDisplayID)); + CGDirectDisplayID* displays = (CGDirectDisplayID*) _glfw_calloc(displayCount, sizeof(CGDirectDisplayID)); CGGetOnlineDisplayList(displayCount, displays, &displayCount); for (int i = 0; i < _glfw.monitorCount; i++) @@ -309,7 +315,7 @@ void _glfwPollMonitorsCocoa(void) uint32_t 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*)); @@ -352,7 +358,7 @@ void _glfwPollMonitorsCocoa(void) continue; const CGSize size = CGDisplayScreenSize(displays[i]); - char* name = getMonitorName(displays[i], screen); + char* name = _glfwGetMonitorNameCocoa(displays[i], screen); if (!name) continue; @@ -365,7 +371,7 @@ void _glfwPollMonitorsCocoa(void) CGDisplayModeRef mode = CGDisplayCopyDisplayMode(displays[i]); if (CGDisplayModeGetRefreshRate(mode) == 0.0) - monitor->ns.fallbackRefreshRate = getFallbackRefreshRate(displays[i]); + monitor->ns.fallbackRefreshRate = _glfwGetFallbackRefreshRateCocoa(displays[i]); CGDisplayModeRelease(mode); _glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_LAST); @@ -399,11 +405,11 @@ void _glfwSetVideoModeCocoa(_GLFWmonitor* monitor, const GLFWvidmode* desired) for (CFIndex i = 0; i < count; i++) { CGDisplayModeRef dm = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i); - if (!modeIsGood(dm)) + if (!_glfwModeIsGoodCocoa(dm)) continue; const GLFWvidmode mode = - vidmodeFromCGDisplayMode(dm, monitor->ns.fallbackRefreshRate); + _glfwVidmodeFromCGDisplayModeCocoa(dm, monitor->ns.fallbackRefreshRate); if (_glfwCompareVideoModes(best, &mode) == 0) { native = dm; @@ -416,9 +422,9 @@ void _glfwSetVideoModeCocoa(_GLFWmonitor* monitor, const GLFWvidmode* desired) if (monitor->ns.previousMode == NULL) monitor->ns.previousMode = CGDisplayCopyDisplayMode(monitor->ns.displayID); - CGDisplayFadeReservationToken token = beginFadeReservation(); + CGDisplayFadeReservationToken token = _glfwBeginFadeReservationCocoa(); CGDisplaySetDisplayMode(monitor->ns.displayID, native, NULL); - endFadeReservation(token); + _glfwEndFadeReservationCocoa(token); } CFRelease(modes); @@ -430,10 +436,10 @@ void _glfwRestoreVideoModeCocoa(_GLFWmonitor* monitor) { if (monitor->ns.previousMode) { - CGDisplayFadeReservationToken token = beginFadeReservation(); + CGDisplayFadeReservationToken token = _glfwBeginFadeReservationCocoa(); CGDisplaySetDisplayMode(monitor->ns.displayID, monitor->ns.previousMode, NULL); - endFadeReservation(token); + _glfwEndFadeReservationCocoa(token); CGDisplayModeRelease(monitor->ns.previousMode); monitor->ns.previousMode = NULL; @@ -519,16 +525,16 @@ GLFWvidmode* _glfwGetVideoModesCocoa(_GLFWmonitor* monitor, int* count) CFArrayRef modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL); const CFIndex found = CFArrayGetCount(modes); - GLFWvidmode* result = _glfw_calloc(found, sizeof(GLFWvidmode)); + GLFWvidmode* result = (GLFWvidmode*) _glfw_calloc(found, sizeof(GLFWvidmode)); for (CFIndex i = 0; i < found; i++) { CGDisplayModeRef dm = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i); - if (!modeIsGood(dm)) + if (!_glfwModeIsGoodCocoa(dm)) continue; const GLFWvidmode mode = - vidmodeFromCGDisplayMode(dm, monitor->ns.fallbackRefreshRate); + _glfwVidmodeFromCGDisplayModeCocoa(dm, monitor->ns.fallbackRefreshRate); CFIndex j; for (j = 0; j < *count; j++) @@ -556,7 +562,7 @@ void _glfwGetVideoModeCocoa(_GLFWmonitor* monitor, GLFWvidmode *mode) @autoreleasepool { CGDisplayModeRef native = CGDisplayCopyDisplayMode(monitor->ns.displayID); - *mode = vidmodeFromCGDisplayMode(native, monitor->ns.fallbackRefreshRate); + *mode = _glfwVidmodeFromCGDisplayModeCocoa(native, monitor->ns.fallbackRefreshRate); CGDisplayModeRelease(native); } // autoreleasepool @@ -567,7 +573,7 @@ GLFWbool _glfwGetGammaRampCocoa(_GLFWmonitor* monitor, GLFWgammaramp* ramp) @autoreleasepool { uint32_t size = CGDisplayGammaTableCapacity(monitor->ns.displayID); - CGGammaValue* values = _glfw_calloc(size * 3, sizeof(CGGammaValue)); + CGGammaValue* values = (CGGammaValue*) _glfw_calloc(size * 3, sizeof(CGGammaValue)); CGGetDisplayTransferByTable(monitor->ns.displayID, size, @@ -595,7 +601,7 @@ void _glfwSetGammaRampCocoa(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) { @autoreleasepool { - CGGammaValue* values = _glfw_calloc(ramp->size * 3, sizeof(CGGammaValue)); + CGGammaValue* values = (CGGammaValue*) _glfw_calloc(ramp->size * 3, sizeof(CGGammaValue)); for (unsigned int i = 0; i < ramp->size; i++) { diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h index 9f7d191d..7a6510f8 100644 --- a/src/cocoa_platform.h +++ b/src/cocoa_platform.h @@ -298,5 +298,4 @@ void _glfwTerminateNSGL(void); GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig); -void _glfwDestroyContextNSGL(_GLFWwindow* window); diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 9d794940..905af056 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -39,7 +39,7 @@ // Returns whether the cursor is in the content area of the specified window // -static GLFWbool cursorInContentArea(_GLFWwindow* window) +static GLFWbool _glfwCursorInContentAreaCocoa(_GLFWwindow* window) { const NSPoint pos = [window->ns.object mouseLocationOutsideOfEventStream]; return [window->ns.view mouse:pos inRect:[window->ns.view frame]]; @@ -47,7 +47,7 @@ static GLFWbool cursorInContentArea(_GLFWwindow* window) // Hides the cursor if not already hidden // -static void hideCursor(_GLFWwindow* window) +static void _glfwHideCursorCocoa(_GLFWwindow* window) { if (!_glfw.ns.cursorHidden) { @@ -58,7 +58,7 @@ static void hideCursor(_GLFWwindow* window) // Shows the cursor if not already shown // -static void showCursor(_GLFWwindow* window) +static void _glfwShowCursorCocoa(_GLFWwindow* window) { if (_glfw.ns.cursorHidden) { @@ -69,11 +69,11 @@ static void showCursor(_GLFWwindow* window) // Updates the cursor image according to its cursor mode // -static void updateCursorImage(_GLFWwindow* window) +static void _glfwUpdateCursorImageCocoa(_GLFWwindow* window) { if (window->cursorMode == GLFW_CURSOR_NORMAL) { - showCursor(window); + _glfwShowCursorCocoa(window); if (window->cursor) [(NSCursor*) window->cursor->ns.object set]; @@ -81,12 +81,12 @@ static void updateCursorImage(_GLFWwindow* window) [[NSCursor arrowCursor] set]; } else - hideCursor(window); + _glfwHideCursorCocoa(window); } // Apply chosen cursor mode to a focused window // -static void updateCursorMode(_GLFWwindow* window) +static void _glfwUpdateCursorModeCocoa(_GLFWwindow* window) { if (window->cursorMode == GLFW_CURSOR_DISABLED) { @@ -107,13 +107,13 @@ static void updateCursorMode(_GLFWwindow* window) // made in _glfwSetCursorPosCocoa as part of a workaround } - if (cursorInContentArea(window)) - updateCursorImage(window); + if (_glfwCursorInContentAreaCocoa(window)) + _glfwUpdateCursorImageCocoa(window); } // Make the specified window and its video mode active on its monitor // -static void acquireMonitor(_GLFWwindow* window) +static void _glfwAcquireMonitorCocoa(_GLFWwindow* window) { _glfwSetVideoModeCocoa(window->monitor, &window->videoMode); const CGRect bounds = CGDisplayBounds(window->monitor->ns.displayID); @@ -129,7 +129,7 @@ static void acquireMonitor(_GLFWwindow* window) // Remove the window and restore the original video mode // -static void releaseMonitor(_GLFWwindow* window) +static void _glfwReleaseMonitorCocoa(_GLFWwindow* window) { if (window->monitor->window != window) return; @@ -140,7 +140,7 @@ static void releaseMonitor(_GLFWwindow* window) // Translates macOS key modifiers into GLFW ones // -static int translateFlags(NSUInteger flags) +static int _glfwTranslateFlagsCocoa(NSUInteger flags) { int mods = 0; @@ -160,7 +160,7 @@ static int translateFlags(NSUInteger flags) // Translates a macOS keycode to a GLFW keycode // -static int translateKey(unsigned int key) +static int _glfwTranslateKeyCocoa(unsigned int key) { if (key >= sizeof(_glfw.ns.keycodes) / sizeof(_glfw.ns.keycodes[0])) return GLFW_KEY_UNKNOWN; @@ -170,7 +170,7 @@ static int translateKey(unsigned int key) // Translate a GLFW keycode to a Cocoa modifier flag // -static NSUInteger translateKeyToModifierFlag(int key) +static NSUInteger _glfwTranslateKeyToModifierFlagCocoa(int key) { switch (key) { @@ -195,7 +195,7 @@ static NSUInteger translateKeyToModifierFlag(int key) // Defines a constant for empty ranges in NSTextInputClient // -static const NSRange kEmptyRange = { NSNotFound, 0 }; +static const NSRange _glfwKEmptyRangeCocoa = { NSNotFound, 0 }; //------------------------------------------------------------------------ @@ -279,7 +279,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; - (void)windowDidMiniaturize:(NSNotification *)notification { if (window->monitor) - releaseMonitor(window); + _glfwReleaseMonitorCocoa(window); _glfwInputWindowIconify(window, GLFW_TRUE); } @@ -287,7 +287,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; - (void)windowDidDeminiaturize:(NSNotification *)notification { if (window->monitor) - acquireMonitor(window); + _glfwAcquireMonitorCocoa(window); _glfwInputWindowIconify(window, GLFW_FALSE); } @@ -298,7 +298,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; _glfwCenterCursorInContentArea(window); _glfwInputWindowFocus(window, GLFW_TRUE); - updateCursorMode(window); + _glfwUpdateCursorModeCocoa(window); } - (void)windowDidResignKey:(NSNotification *)notification @@ -395,7 +395,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; - (void)cursorUpdate:(NSEvent *)event { - updateCursorImage(window); + _glfwUpdateCursorImageCocoa(window); } - (BOOL)acceptsFirstMouse:(NSEvent *)event @@ -408,7 +408,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_LEFT, GLFW_PRESS, - translateFlags([event modifierFlags])); + _glfwTranslateFlagsCocoa([event modifierFlags])); } - (void)mouseDragged:(NSEvent *)event @@ -421,7 +421,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_LEFT, GLFW_RELEASE, - translateFlags([event modifierFlags])); + _glfwTranslateFlagsCocoa([event modifierFlags])); } - (void)mouseMoved:(NSEvent *)event @@ -453,7 +453,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_RIGHT, GLFW_PRESS, - translateFlags([event modifierFlags])); + _glfwTranslateFlagsCocoa([event modifierFlags])); } - (void)rightMouseDragged:(NSEvent *)event @@ -466,7 +466,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_RIGHT, GLFW_RELEASE, - translateFlags([event modifierFlags])); + _glfwTranslateFlagsCocoa([event modifierFlags])); } - (void)otherMouseDown:(NSEvent *)event @@ -474,7 +474,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; _glfwInputMouseClick(window, (int) [event buttonNumber], GLFW_PRESS, - translateFlags([event modifierFlags])); + _glfwTranslateFlagsCocoa([event modifierFlags])); } - (void)otherMouseDragged:(NSEvent *)event @@ -487,13 +487,13 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; _glfwInputMouseClick(window, (int) [event buttonNumber], GLFW_RELEASE, - translateFlags([event modifierFlags])); + _glfwTranslateFlagsCocoa([event modifierFlags])); } - (void)mouseExited:(NSEvent *)event { if (window->cursorMode == GLFW_CURSOR_HIDDEN) - showCursor(window); + _glfwShowCursorCocoa(window); _glfwInputCursorEnter(window, GLFW_FALSE); } @@ -501,7 +501,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; - (void)mouseEntered:(NSEvent *)event { if (window->cursorMode == GLFW_CURSOR_HIDDEN) - hideCursor(window); + _glfwHideCursorCocoa(window); _glfwInputCursorEnter(window, GLFW_TRUE); } @@ -563,8 +563,8 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; - (void)keyDown:(NSEvent *)event { - const int key = translateKey([event keyCode]); - const int mods = translateFlags([event modifierFlags]); + const int key = _glfwTranslateKeyCocoa([event keyCode]); + const int mods = _glfwTranslateFlagsCocoa([event modifierFlags]); _glfwInputKey(window, key, [event keyCode], GLFW_PRESS, mods); @@ -576,9 +576,9 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; int action; const unsigned int modifierFlags = [event modifierFlags] & NSEventModifierFlagDeviceIndependentFlagsMask; - const int key = translateKey([event keyCode]); - const int mods = translateFlags(modifierFlags); - const NSUInteger keyFlag = translateKeyToModifierFlag(key); + const int key = _glfwTranslateKeyCocoa([event keyCode]); + const int mods = _glfwTranslateFlagsCocoa(modifierFlags); + const NSUInteger keyFlag = _glfwTranslateKeyToModifierFlagCocoa(key); if (keyFlag & modifierFlags) { @@ -595,8 +595,8 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; - (void)keyUp:(NSEvent *)event { - const int key = translateKey([event keyCode]); - const int mods = translateFlags([event modifierFlags]); + const int key = _glfwTranslateKeyCocoa([event keyCode]); + const int mods = _glfwTranslateFlagsCocoa([event modifierFlags]); _glfwInputKey(window, key, [event keyCode], GLFW_RELEASE, mods); } @@ -636,7 +636,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; const NSUInteger count = [urls count]; if (count) { - char** paths = _glfw_calloc(count, sizeof(char*)); + char** paths = (char**) _glfw_calloc(count, sizeof(char*)); for (NSUInteger i = 0; i < count; i++) paths[i] = _glfw_strdup([urls[i] fileSystemRepresentation]); @@ -661,12 +661,12 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; if ([markedText length] > 0) return NSMakeRange(0, [markedText length] - 1); else - return kEmptyRange; + return _glfwKEmptyRangeCocoa; } - (NSRange)selectedRange { - return kEmptyRange; + return _glfwKEmptyRangeCocoa; } - (void)setMarkedText:(id)string @@ -712,7 +712,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; { NSString* characters; NSEvent* event = [NSApp currentEvent]; - const int mods = translateFlags([event modifierFlags]); + const int mods = _glfwTranslateFlagsCocoa([event modifierFlags]); const int plain = !(mods & GLFW_MOD_SUPER); if ([string isKindOfClass:[NSAttributedString class]]) @@ -773,9 +773,9 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; // Create the Cocoa window // -static GLFWbool createNativeWindow(_GLFWwindow* window, - const _GLFWwndconfig* wndconfig, - const _GLFWfbconfig* fbconfig) +static GLFWbool _glfwCreateNativeWindowCocoa(_GLFWwindow* window, + const _GLFWwndconfig* wndconfig, + const _GLFWfbconfig* fbconfig) { window->ns.delegate = [[GLFWWindowDelegate alloc] initWithGlfwWindow:window]; if (window->ns.delegate == nil) @@ -925,7 +925,7 @@ GLFWbool _glfwCreateWindowCocoa(_GLFWwindow* window, { @autoreleasepool { - if (!createNativeWindow(window, wndconfig, fbconfig)) + if (!_glfwCreateNativeWindowCocoa(window, wndconfig, fbconfig)) return GLFW_FALSE; if (ctxconfig->client != GLFW_NO_API) @@ -968,7 +968,7 @@ GLFWbool _glfwCreateWindowCocoa(_GLFWwindow* window, { _glfwShowWindowCocoa(window); _glfwFocusWindowCocoa(window); - acquireMonitor(window); + _glfwAcquireMonitorCocoa(window); if (wndconfig->centerCursor) _glfwCenterCursorInContentArea(window); @@ -998,7 +998,7 @@ void _glfwDestroyWindowCocoa(_GLFWwindow* window) [window->ns.object orderOut:nil]; if (window->monitor) - releaseMonitor(window); + _glfwReleaseMonitorCocoa(window); if (window->context.destroy) window->context.destroy(window); @@ -1085,7 +1085,7 @@ void _glfwSetWindowSizeCocoa(_GLFWwindow* window, int width, int height) if (window->monitor) { if (window->monitor->window == window) - acquireMonitor(window); + _glfwAcquireMonitorCocoa(window); } else { @@ -1254,7 +1254,7 @@ void _glfwSetWindowMonitorCocoa(_GLFWwindow* window, if (monitor) { if (monitor->window == window) - acquireMonitor(window); + _glfwAcquireMonitorCocoa(window); } else { @@ -1272,7 +1272,7 @@ void _glfwSetWindowMonitorCocoa(_GLFWwindow* window, } if (window->monitor) - releaseMonitor(window); + _glfwReleaseMonitorCocoa(window); _glfwInputWindowMonitor(window, monitor); @@ -1310,7 +1310,7 @@ void _glfwSetWindowMonitorCocoa(_GLFWwindow* window, [window->ns.object setLevel:NSMainMenuWindowLevel + 1]; [window->ns.object setHasShadow:NO]; - acquireMonitor(window); + _glfwAcquireMonitorCocoa(window); } else { @@ -1607,7 +1607,7 @@ void _glfwSetCursorPosCocoa(_GLFWwindow* window, double x, double y) { @autoreleasepool { - updateCursorImage(window); + _glfwUpdateCursorImageCocoa(window); const NSRect contentRect = [window->ns.view frame]; // NOTE: The returned location uses base 0,1 not 0,0 @@ -1650,7 +1650,7 @@ void _glfwSetCursorModeCocoa(_GLFWwindow* window, int mode) } if (_glfwWindowFocusedCocoa(window)) - updateCursorMode(window); + _glfwUpdateCursorModeCocoa(window); } // autoreleasepool } @@ -1672,7 +1672,8 @@ const char* _glfwGetScancodeNameCocoa(int scancode) UniChar characters[4]; UniCharCount characterCount = 0; - if (UCKeyTranslate([(NSData*) _glfw.ns.unicodeData bytes], + if (UCKeyTranslate((const UCKeyboardLayout *) + [(NSData*) _glfw.ns.unicodeData bytes], scancode, kUCKeyActionDisplay, 0, @@ -1838,8 +1839,8 @@ void _glfwDestroyCursorCocoa(_GLFWcursor* cursor) void _glfwSetCursorCocoa(_GLFWwindow* window, _GLFWcursor* cursor) { @autoreleasepool { - if (cursorInContentArea(window)) - updateCursorImage(window); + if (_glfwCursorInContentAreaCocoa(window)) + _glfwUpdateCursorImageCocoa(window); } // autoreleasepool } @@ -1901,7 +1902,7 @@ EGLenum _glfwGetEGLPlatformCocoa(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; @@ -1926,13 +1927,13 @@ void _glfwGetRequiredInstanceExtensionsCocoa(char** extensions) { if (_glfw.vk.KHR_surface && _glfw.vk.EXT_metal_surface) { - extensions[0] = "VK_KHR_surface"; - extensions[1] = "VK_EXT_metal_surface"; + extensions[0] = (char*) "VK_KHR_surface"; + extensions[1] = (char*) "VK_EXT_metal_surface"; } else if (_glfw.vk.KHR_surface && _glfw.vk.MVK_macos_surface) { - extensions[0] = "VK_KHR_surface"; - extensions[1] = "VK_MVK_macos_surface"; + extensions[0] = (char*) "VK_KHR_surface"; + extensions[1] = (char*) "VK_MVK_macos_surface"; } } diff --git a/src/context.c b/src/context.c index f8610e1e..1585c194 100644 --- a/src/context.c +++ b/src/context.c @@ -361,7 +361,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; @@ -622,7 +622,7 @@ GLFWAPI void glfwMakeContextCurrent(GLFWwindow* handle) _GLFW_REQUIRE_INIT(); - previous = _glfwPlatformGetTls(&_glfw.contextSlot); + previous = (_GLFWwindow*) _glfwPlatformGetTls(&_glfw.contextSlot); if (window && window->context.client == GLFW_NO_API) { @@ -644,7 +644,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) @@ -670,7 +670,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, @@ -688,7 +688,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, @@ -754,7 +754,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, diff --git a/src/egl_context.c b/src/egl_context.c index 6e997b11..14c33169 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -37,7 +37,7 @@ // Return a description of the specified EGL error // -static const char* getEGLErrorString(EGLint error) +static const char* _glfwGetErrorStringEGL(EGLint error) { switch (error) { @@ -78,7 +78,7 @@ static const char* getEGLErrorString(EGLint error) // Returns the specified attribute of the specified EGLConfig // -static int getEGLConfigAttrib(EGLConfig config, int attrib) +static int _glfwGetConfigAttribEGL(EGLConfig config, int attrib) { int value; eglGetConfigAttrib(_glfw.egl.display, config, attrib, &value); @@ -87,7 +87,7 @@ static int getEGLConfigAttrib(EGLConfig config, int attrib) // Return the EGLConfig most closely matching the specified hints // -static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig, +static GLFWbool _glfwChooseConfigEGL(const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig, EGLConfig* result) { @@ -120,10 +120,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++) @@ -132,11 +132,11 @@ static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig, _GLFWfbconfig* u = usableConfigs + usableCount; // Only consider RGB(A) EGLConfigs - if (getEGLConfigAttrib(n, EGL_COLOR_BUFFER_TYPE) != EGL_RGB_BUFFER) + if (_glfwGetConfigAttribEGL(n, EGL_COLOR_BUFFER_TYPE) != EGL_RGB_BUFFER) continue; // Only consider window EGLConfigs - if (!(getEGLConfigAttrib(n, EGL_SURFACE_TYPE) & EGL_WINDOW_BIT)) + if (!(_glfwGetConfigAttribEGL(n, EGL_SURFACE_TYPE) & EGL_WINDOW_BIT)) continue; #if defined(_GLFW_X11) @@ -145,7 +145,7 @@ static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig, XVisualInfo vi = {0}; // Only consider EGLConfigs with associated Visuals - vi.visualid = getEGLConfigAttrib(n, EGL_NATIVE_VISUAL_ID); + vi.visualid = _glfwGetConfigAttribEGL(n, EGL_NATIVE_VISUAL_ID); if (!vi.visualid) continue; @@ -163,19 +163,19 @@ static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig, } #endif // _GLFW_X11 - if (!(getEGLConfigAttrib(n, EGL_RENDERABLE_TYPE) & apiBit)) + if (!(_glfwGetConfigAttribEGL(n, EGL_RENDERABLE_TYPE) & apiBit)) { wrongApiAvailable = GLFW_TRUE; continue; } - u->redBits = getEGLConfigAttrib(n, EGL_RED_SIZE); - u->greenBits = getEGLConfigAttrib(n, EGL_GREEN_SIZE); - u->blueBits = getEGLConfigAttrib(n, EGL_BLUE_SIZE); + u->redBits = _glfwGetConfigAttribEGL(n, EGL_RED_SIZE); + u->greenBits = _glfwGetConfigAttribEGL(n, EGL_GREEN_SIZE); + u->blueBits = _glfwGetConfigAttribEGL(n, EGL_BLUE_SIZE); - u->alphaBits = getEGLConfigAttrib(n, EGL_ALPHA_SIZE); - u->depthBits = getEGLConfigAttrib(n, EGL_DEPTH_SIZE); - u->stencilBits = getEGLConfigAttrib(n, EGL_STENCIL_SIZE); + u->alphaBits = _glfwGetConfigAttribEGL(n, EGL_ALPHA_SIZE); + u->depthBits = _glfwGetConfigAttribEGL(n, EGL_DEPTH_SIZE); + u->stencilBits = _glfwGetConfigAttribEGL(n, EGL_STENCIL_SIZE); #if defined(_GLFW_WAYLAND) if (_glfw.platform.platformID == GLFW_PLATFORM_WAYLAND) @@ -192,7 +192,7 @@ static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig, } #endif // _GLFW_WAYLAND - u->samples = getEGLConfigAttrib(n, EGL_SAMPLES); + u->samples = _glfwGetConfigAttribEGL(n, EGL_SAMPLES); u->doublebuffer = fbconfig->doublebuffer; u->handle = (uintptr_t) n; @@ -238,7 +238,7 @@ static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig, return closest != NULL; } -static void makeContextCurrentEGL(_GLFWwindow* window) +static void _glfwMakeContextCurrentEGL(_GLFWwindow* window) { if (window) { @@ -249,7 +249,7 @@ static void makeContextCurrentEGL(_GLFWwindow* window) { _glfwInputError(GLFW_PLATFORM_ERROR, "EGL: Failed to make context current: %s", - getEGLErrorString(eglGetError())); + _glfwGetErrorStringEGL(eglGetError())); return; } } @@ -262,7 +262,7 @@ static void makeContextCurrentEGL(_GLFWwindow* window) { _glfwInputError(GLFW_PLATFORM_ERROR, "EGL: Failed to clear current context: %s", - getEGLErrorString(eglGetError())); + _glfwGetErrorStringEGL(eglGetError())); return; } } @@ -270,7 +270,7 @@ static void makeContextCurrentEGL(_GLFWwindow* window) _glfwPlatformSetTls(&_glfw.contextSlot, window); } -static void swapBuffersEGL(_GLFWwindow* window) +static void _glfwSwapBuffersEGL(_GLFWwindow* window) { if (window != _glfwPlatformGetTls(&_glfw.contextSlot)) { @@ -291,12 +291,12 @@ static void swapBuffersEGL(_GLFWwindow* window) eglSwapBuffers(_glfw.egl.display, window->context.egl.surface); } -static void swapIntervalEGL(int interval) +static void _glfwSwapIntervalEGL(int interval) { eglSwapInterval(_glfw.egl.display, interval); } -static int extensionSupportedEGL(const char* extension) +static int _glfwExtensionSupportedEGL(const char* extension) { const char* extensions = eglQueryString(_glfw.egl.display, EGL_EXTENSIONS); if (extensions) @@ -308,9 +308,9 @@ static int extensionSupportedEGL(const char* extension) return GLFW_FALSE; } -static GLFWglproc getProcAddressEGL(const char* procname) +static GLFWglproc _glfwGetProcAddressEGL(const char* procname) { - _GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot); + _GLFWwindow* window = (_GLFWwindow*) _glfwPlatformGetTls(&_glfw.contextSlot); assert(window != NULL); if (window->context.egl.client) @@ -324,7 +324,7 @@ static GLFWglproc getProcAddressEGL(const char* procname) return eglGetProcAddress(procname); } -static void destroyContextEGL(_GLFWwindow* window) +static void _glfwDestroyContextEGL(_GLFWwindow* window) { // NOTE: Do not unload libGL.so.1 while the X11 display is still open, // as it will make XCloseDisplay segfault @@ -506,7 +506,7 @@ GLFWbool _glfwInitEGL(void) { _glfwInputError(GLFW_API_UNAVAILABLE, "EGL: Failed to get EGL display: %s", - getEGLErrorString(eglGetError())); + _glfwGetErrorStringEGL(eglGetError())); _glfwTerminateEGL(); return GLFW_FALSE; @@ -516,24 +516,24 @@ GLFWbool _glfwInitEGL(void) { _glfwInputError(GLFW_API_UNAVAILABLE, "EGL: Failed to initialize EGL: %s", - getEGLErrorString(eglGetError())); + _glfwGetErrorStringEGL(eglGetError())); _glfwTerminateEGL(); return GLFW_FALSE; } _glfw.egl.KHR_create_context = - extensionSupportedEGL("EGL_KHR_create_context"); + _glfwExtensionSupportedEGL("EGL_KHR_create_context"); _glfw.egl.KHR_create_context_no_error = - extensionSupportedEGL("EGL_KHR_create_context_no_error"); + _glfwExtensionSupportedEGL("EGL_KHR_create_context_no_error"); _glfw.egl.KHR_gl_colorspace = - extensionSupportedEGL("EGL_KHR_gl_colorspace"); + _glfwExtensionSupportedEGL("EGL_KHR_gl_colorspace"); _glfw.egl.KHR_get_all_proc_addresses = - extensionSupportedEGL("EGL_KHR_get_all_proc_addresses"); + _glfwExtensionSupportedEGL("EGL_KHR_get_all_proc_addresses"); _glfw.egl.KHR_context_flush_control = - extensionSupportedEGL("EGL_KHR_context_flush_control"); + _glfwExtensionSupportedEGL("EGL_KHR_context_flush_control"); _glfw.egl.EXT_present_opaque = - extensionSupportedEGL("EGL_EXT_present_opaque"); + _glfwExtensionSupportedEGL("EGL_EXT_present_opaque"); return GLFW_TRUE; } @@ -583,7 +583,7 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window, if (ctxconfig->share) share = ctxconfig->share->context.egl.handle; - if (!chooseEGLConfig(ctxconfig, fbconfig, &config)) + if (!_glfwChooseConfigEGL(ctxconfig, fbconfig, &config)) return GLFW_FALSE; if (ctxconfig->client == GLFW_OPENGL_ES_API) @@ -592,7 +592,7 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window, { _glfwInputError(GLFW_API_UNAVAILABLE, "EGL: Failed to bind OpenGL ES: %s", - getEGLErrorString(eglGetError())); + _glfwGetErrorStringEGL(eglGetError())); return GLFW_FALSE; } } @@ -602,7 +602,7 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window, { _glfwInputError(GLFW_API_UNAVAILABLE, "EGL: Failed to bind OpenGL: %s", - getEGLErrorString(eglGetError())); + _glfwGetErrorStringEGL(eglGetError())); return GLFW_FALSE; } } @@ -688,7 +688,7 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window, { _glfwInputError(GLFW_VERSION_UNAVAILABLE, "EGL: Failed to create context: %s", - getEGLErrorString(eglGetError())); + _glfwGetErrorStringEGL(eglGetError())); return GLFW_FALSE; } @@ -730,7 +730,7 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window, { _glfwInputError(GLFW_PLATFORM_ERROR, "EGL: Failed to create window surface: %s", - getEGLErrorString(eglGetError())); + _glfwGetErrorStringEGL(eglGetError())); return GLFW_FALSE; } @@ -821,12 +821,12 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window, } } - window->context.makeCurrent = makeContextCurrentEGL; - window->context.swapBuffers = swapBuffersEGL; - window->context.swapInterval = swapIntervalEGL; - window->context.extensionSupported = extensionSupportedEGL; - window->context.getProcAddress = getProcAddressEGL; - window->context.destroy = destroyContextEGL; + window->context.makeCurrent = _glfwMakeContextCurrentEGL; + window->context.swapBuffers = _glfwSwapBuffersEGL; + window->context.swapInterval = _glfwSwapIntervalEGL; + window->context.extensionSupported = _glfwExtensionSupportedEGL; + window->context.getProcAddress = _glfwGetProcAddressEGL; + window->context.destroy = _glfwDestroyContextEGL; return GLFW_TRUE; } @@ -847,7 +847,7 @@ GLFWbool _glfwChooseVisualEGL(const _GLFWwndconfig* wndconfig, EGLint visualID = 0, count = 0; const long vimask = VisualScreenMask | VisualIDMask; - if (!chooseEGLConfig(ctxconfig, fbconfig, &native)) + if (!_glfwChooseConfigEGL(ctxconfig, fbconfig, &native)) return GLFW_FALSE; eglGetConfigAttrib(_glfw.egl.display, native, diff --git a/src/glx_context.c b/src/glx_context.c index f3f4b3ec..48bea695 100644 --- a/src/glx_context.c +++ b/src/glx_context.c @@ -42,7 +42,7 @@ // Returns the specified attribute of the specified GLXFBConfig // -static int getGLXFBConfigAttrib(GLXFBConfig fbconfig, int attrib) +static int _glfwGetConfigAttribGLX(GLXFBConfig fbconfig, int attrib) { int value; glXGetFBConfigAttrib(_glfw.x11.display, fbconfig, attrib, &value); @@ -51,7 +51,7 @@ static int getGLXFBConfigAttrib(GLXFBConfig fbconfig, int attrib) // Return the GLXFBConfig most closely matching the specified hints // -static GLFWbool chooseGLXFBConfig(const _GLFWfbconfig* desired, +static GLFWbool _glfwChooseConfigGLX(const _GLFWfbconfig* desired, GLXFBConfig* result) { GLXFBConfig* nativeConfigs; @@ -84,17 +84,17 @@ static GLFWbool chooseGLXFBConfig(const _GLFWfbconfig* desired, _GLFWfbconfig* u = usableConfigs + usableCount; // Only consider RGBA GLXFBConfigs - if (!(getGLXFBConfigAttrib(n, GLX_RENDER_TYPE) & GLX_RGBA_BIT)) + if (!(_glfwGetConfigAttribGLX(n, GLX_RENDER_TYPE) & GLX_RGBA_BIT)) continue; // Only consider window GLXFBConfigs - if (!(getGLXFBConfigAttrib(n, GLX_DRAWABLE_TYPE) & GLX_WINDOW_BIT)) + if (!(_glfwGetConfigAttribGLX(n, GLX_DRAWABLE_TYPE) & GLX_WINDOW_BIT)) { if (trustWindowBit) continue; } - if (getGLXFBConfigAttrib(n, GLX_DOUBLEBUFFER) != desired->doublebuffer) + if (_glfwGetConfigAttribGLX(n, GLX_DOUBLEBUFFER) != desired->doublebuffer) continue; if (desired->transparent) @@ -107,29 +107,29 @@ static GLFWbool chooseGLXFBConfig(const _GLFWfbconfig* desired, } } - u->redBits = getGLXFBConfigAttrib(n, GLX_RED_SIZE); - u->greenBits = getGLXFBConfigAttrib(n, GLX_GREEN_SIZE); - u->blueBits = getGLXFBConfigAttrib(n, GLX_BLUE_SIZE); + u->redBits = _glfwGetConfigAttribGLX(n, GLX_RED_SIZE); + u->greenBits = _glfwGetConfigAttribGLX(n, GLX_GREEN_SIZE); + u->blueBits = _glfwGetConfigAttribGLX(n, GLX_BLUE_SIZE); - u->alphaBits = getGLXFBConfigAttrib(n, GLX_ALPHA_SIZE); - u->depthBits = getGLXFBConfigAttrib(n, GLX_DEPTH_SIZE); - u->stencilBits = getGLXFBConfigAttrib(n, GLX_STENCIL_SIZE); + u->alphaBits = _glfwGetConfigAttribGLX(n, GLX_ALPHA_SIZE); + u->depthBits = _glfwGetConfigAttribGLX(n, GLX_DEPTH_SIZE); + u->stencilBits = _glfwGetConfigAttribGLX(n, GLX_STENCIL_SIZE); - u->accumRedBits = getGLXFBConfigAttrib(n, GLX_ACCUM_RED_SIZE); - u->accumGreenBits = getGLXFBConfigAttrib(n, GLX_ACCUM_GREEN_SIZE); - u->accumBlueBits = getGLXFBConfigAttrib(n, GLX_ACCUM_BLUE_SIZE); - u->accumAlphaBits = getGLXFBConfigAttrib(n, GLX_ACCUM_ALPHA_SIZE); + u->accumRedBits = _glfwGetConfigAttribGLX(n, GLX_ACCUM_RED_SIZE); + u->accumGreenBits = _glfwGetConfigAttribGLX(n, GLX_ACCUM_GREEN_SIZE); + u->accumBlueBits = _glfwGetConfigAttribGLX(n, GLX_ACCUM_BLUE_SIZE); + u->accumAlphaBits = _glfwGetConfigAttribGLX(n, GLX_ACCUM_ALPHA_SIZE); - u->auxBuffers = getGLXFBConfigAttrib(n, GLX_AUX_BUFFERS); + u->auxBuffers = _glfwGetConfigAttribGLX(n, GLX_AUX_BUFFERS); - if (getGLXFBConfigAttrib(n, GLX_STEREO)) + if (_glfwGetConfigAttribGLX(n, GLX_STEREO)) u->stereo = GLFW_TRUE; if (_glfw.glx.ARB_multisample) - u->samples = getGLXFBConfigAttrib(n, GLX_SAMPLES); + u->samples = _glfwGetConfigAttribGLX(n, GLX_SAMPLES); if (_glfw.glx.ARB_framebuffer_sRGB || _glfw.glx.EXT_framebuffer_sRGB) - u->sRGB = getGLXFBConfigAttrib(n, GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB); + u->sRGB = _glfwGetConfigAttribGLX(n, GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB); u->handle = (uintptr_t) n; usableCount++; @@ -147,7 +147,7 @@ static GLFWbool chooseGLXFBConfig(const _GLFWfbconfig* desired, // Create the OpenGL context using legacy API // -static GLXContext createLegacyContextGLX(_GLFWwindow* window, +static GLXContext _glfwCreateLegacyContextGLX(_GLFWwindow* window, GLXFBConfig fbconfig, GLXContext share) { @@ -158,7 +158,7 @@ static GLXContext createLegacyContextGLX(_GLFWwindow* window, True); } -static void makeContextCurrentGLX(_GLFWwindow* window) +static void _glfwMakeContextCurrentGLX(_GLFWwindow* window) { if (window) { @@ -184,12 +184,12 @@ static void makeContextCurrentGLX(_GLFWwindow* window) _glfwPlatformSetTls(&_glfw.contextSlot, window); } -static void swapBuffersGLX(_GLFWwindow* window) +static void _glfwSwapBuffersGLX(_GLFWwindow* window) { glXSwapBuffers(_glfw.x11.display, window->context.glx.window); } -static void swapIntervalGLX(int interval) +static void _glfwSwapIntervalGLX(int interval) { _GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot); assert(window != NULL); @@ -209,7 +209,7 @@ static void swapIntervalGLX(int interval) } } -static int extensionSupportedGLX(const char* extension) +static int _glfwExtensionSupportedGLX(const char* extension) { const char* extensions = glXQueryExtensionsString(_glfw.x11.display, _glfw.x11.screen); @@ -222,7 +222,7 @@ static int extensionSupportedGLX(const char* extension) return GLFW_FALSE; } -static GLFWglproc getProcAddressGLX(const char* procname) +static GLFWglproc _glfwGetProcAddressGLX(const char* procname) { if (_glfw.glx.GetProcAddress) return _glfw.glx.GetProcAddress((const GLubyte*) procname); @@ -235,7 +235,7 @@ static GLFWglproc getProcAddressGLX(const char* procname) } } -static void destroyContextGLX(_GLFWwindow* window) +static void _glfwDestroyContextGLX(_GLFWwindow* window) { if (window->context.glx.window) { @@ -365,64 +365,64 @@ GLFWbool _glfwInitGLX(void) return GLFW_FALSE; } - if (extensionSupportedGLX("GLX_EXT_swap_control")) + if (_glfwExtensionSupportedGLX("GLX_EXT_swap_control")) { _glfw.glx.SwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC) - getProcAddressGLX("glXSwapIntervalEXT"); + _glfwGetProcAddressGLX("glXSwapIntervalEXT"); if (_glfw.glx.SwapIntervalEXT) _glfw.glx.EXT_swap_control = GLFW_TRUE; } - if (extensionSupportedGLX("GLX_SGI_swap_control")) + if (_glfwExtensionSupportedGLX("GLX_SGI_swap_control")) { _glfw.glx.SwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC) - getProcAddressGLX("glXSwapIntervalSGI"); + _glfwGetProcAddressGLX("glXSwapIntervalSGI"); if (_glfw.glx.SwapIntervalSGI) _glfw.glx.SGI_swap_control = GLFW_TRUE; } - if (extensionSupportedGLX("GLX_MESA_swap_control")) + if (_glfwExtensionSupportedGLX("GLX_MESA_swap_control")) { _glfw.glx.SwapIntervalMESA = (PFNGLXSWAPINTERVALMESAPROC) - getProcAddressGLX("glXSwapIntervalMESA"); + _glfwGetProcAddressGLX("glXSwapIntervalMESA"); if (_glfw.glx.SwapIntervalMESA) _glfw.glx.MESA_swap_control = GLFW_TRUE; } - if (extensionSupportedGLX("GLX_ARB_multisample")) + if (_glfwExtensionSupportedGLX("GLX_ARB_multisample")) _glfw.glx.ARB_multisample = GLFW_TRUE; - if (extensionSupportedGLX("GLX_ARB_framebuffer_sRGB")) + if (_glfwExtensionSupportedGLX("GLX_ARB_framebuffer_sRGB")) _glfw.glx.ARB_framebuffer_sRGB = GLFW_TRUE; - if (extensionSupportedGLX("GLX_EXT_framebuffer_sRGB")) + if (_glfwExtensionSupportedGLX("GLX_EXT_framebuffer_sRGB")) _glfw.glx.EXT_framebuffer_sRGB = GLFW_TRUE; - if (extensionSupportedGLX("GLX_ARB_create_context")) + if (_glfwExtensionSupportedGLX("GLX_ARB_create_context")) { _glfw.glx.CreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC) - getProcAddressGLX("glXCreateContextAttribsARB"); + _glfwGetProcAddressGLX("glXCreateContextAttribsARB"); if (_glfw.glx.CreateContextAttribsARB) _glfw.glx.ARB_create_context = GLFW_TRUE; } - if (extensionSupportedGLX("GLX_ARB_create_context_robustness")) + if (_glfwExtensionSupportedGLX("GLX_ARB_create_context_robustness")) _glfw.glx.ARB_create_context_robustness = GLFW_TRUE; - if (extensionSupportedGLX("GLX_ARB_create_context_profile")) + if (_glfwExtensionSupportedGLX("GLX_ARB_create_context_profile")) _glfw.glx.ARB_create_context_profile = GLFW_TRUE; - if (extensionSupportedGLX("GLX_EXT_create_context_es2_profile")) + if (_glfwExtensionSupportedGLX("GLX_EXT_create_context_es2_profile")) _glfw.glx.EXT_create_context_es2_profile = GLFW_TRUE; - if (extensionSupportedGLX("GLX_ARB_create_context_no_error")) + if (_glfwExtensionSupportedGLX("GLX_ARB_create_context_no_error")) _glfw.glx.ARB_create_context_no_error = GLFW_TRUE; - if (extensionSupportedGLX("GLX_ARB_context_flush_control")) + if (_glfwExtensionSupportedGLX("GLX_ARB_context_flush_control")) _glfw.glx.ARB_context_flush_control = GLFW_TRUE; return GLFW_TRUE; @@ -462,7 +462,7 @@ GLFWbool _glfwCreateContextGLX(_GLFWwindow* window, if (ctxconfig->share) share = ctxconfig->share->context.glx.handle; - if (!chooseGLXFBConfig(fbconfig, &native)) + if (!_glfwChooseConfigGLX(fbconfig, &native)) { _glfwInputError(GLFW_FORMAT_UNAVAILABLE, "GLX: Failed to find a suitable GLXFBConfig"); @@ -602,14 +602,14 @@ GLFWbool _glfwCreateContextGLX(_GLFWwindow* window, ctxconfig->forward == GLFW_FALSE) { window->context.glx.handle = - createLegacyContextGLX(window, native, share); + _glfwCreateLegacyContextGLX(window, native, share); } } } else { window->context.glx.handle = - createLegacyContextGLX(window, native, share); + _glfwCreateLegacyContextGLX(window, native, share); } _glfwReleaseErrorHandlerX11(); @@ -628,12 +628,12 @@ GLFWbool _glfwCreateContextGLX(_GLFWwindow* window, return GLFW_FALSE; } - window->context.makeCurrent = makeContextCurrentGLX; - window->context.swapBuffers = swapBuffersGLX; - window->context.swapInterval = swapIntervalGLX; - window->context.extensionSupported = extensionSupportedGLX; - window->context.getProcAddress = getProcAddressGLX; - window->context.destroy = destroyContextGLX; + window->context.makeCurrent = _glfwMakeContextCurrentGLX; + window->context.swapBuffers = _glfwSwapBuffersGLX; + window->context.swapInterval = _glfwSwapIntervalGLX; + window->context.extensionSupported = _glfwExtensionSupportedGLX; + window->context.getProcAddress = _glfwGetProcAddressGLX; + window->context.destroy = _glfwDestroyContextGLX; return GLFW_TRUE; } @@ -650,7 +650,7 @@ GLFWbool _glfwChooseVisualGLX(const _GLFWwndconfig* wndconfig, GLXFBConfig native; XVisualInfo* result; - if (!chooseGLXFBConfig(fbconfig, &native)) + if (!_glfwChooseConfigGLX(fbconfig, &native)) { _glfwInputError(GLFW_FORMAT_UNAVAILABLE, "GLX: Failed to find a suitable GLXFBConfig"); diff --git a/src/init.c b/src/init.c index 06dbb3f2..806083cb 100644 --- a/src/init.c +++ b/src/init.c @@ -69,28 +69,28 @@ static _GLFWinitconfig _glfwInitHints = // The allocation function used when no custom allocator is set // -static void* defaultAllocate(size_t size, void* user) +static void* _glfwDefaultAllocate(size_t size, void* user) { return malloc(size); } // The deallocation function used when no custom allocator is set // -static void defaultDeallocate(void* block, void* user) +static void _glfwDefaultDeallocate(void* block, void* user) { free(block); } // The reallocation function used when no custom allocator is set // -static void* defaultReallocate(void* block, size_t size, void* user) +static void* _glfwDefaultReallocate(void* block, size_t size, void* user) { return realloc(block, size); } // Terminate the library // -static void terminate(void) +static void _glfwTerminate(void) { int i; @@ -204,8 +204,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) @@ -230,7 +230,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; } @@ -380,10 +380,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; @@ -417,9 +417,9 @@ GLFWAPI int glfwInit(void) _glfw.allocator = _glfwInitAllocator; if (!_glfw.allocator.allocate) { - _glfw.allocator.allocate = defaultAllocate; - _glfw.allocator.reallocate = defaultReallocate; - _glfw.allocator.deallocate = defaultDeallocate; + _glfw.allocator.allocate = _glfwDefaultAllocate; + _glfw.allocator.reallocate = _glfwDefaultReallocate; + _glfw.allocator.deallocate = _glfwDefaultDeallocate; } if (!_glfwSelectPlatform(_glfw.hints.init.platformID, &_glfw.platform)) @@ -427,7 +427,7 @@ GLFWAPI int glfwInit(void) if (!_glfw.platform.init()) { - terminate(); + _glfwTerminate(); return GLFW_FALSE; } @@ -435,7 +435,7 @@ GLFWAPI int glfwInit(void) !_glfwPlatformCreateTls(&_glfw.errorSlot) || !_glfwPlatformCreateTls(&_glfw.contextSlot)) { - terminate(); + _glfwTerminate(); return GLFW_FALSE; } @@ -457,7 +457,7 @@ GLFWAPI void glfwTerminate(void) if (!_glfw.initialized) return; - terminate(); + _glfwTerminate(); } GLFWAPI void glfwInitHint(int hint, int value) @@ -528,7 +528,7 @@ GLFWAPI int glfwGetError(const char** description) *description = NULL; if (_glfw.initialized) - error = _glfwPlatformGetTls(&_glfw.errorSlot); + error = (_GLFWerror*) _glfwPlatformGetTls(&_glfw.errorSlot); else error = &_glfwMainThreadError; diff --git a/src/input.c b/src/input.c index 8b7ef29c..fa8ccfa1 100644 --- a/src/input.c +++ b/src/input.c @@ -53,7 +53,7 @@ // Initializes the platform joystick API if it has not been already // -static GLFWbool initJoysticks(void) +static GLFWbool _glfwInitJoysticks(void) { if (!_glfw.joysticksInitialized) { @@ -69,7 +69,7 @@ static GLFWbool initJoysticks(void) // Finds a mapping based on joystick GUID // -static _GLFWmapping* findMapping(const char* guid) +static _GLFWmapping* _glfwFindMapping(const char* guid) { int i; @@ -84,8 +84,8 @@ static _GLFWmapping* findMapping(const char* guid) // Checks whether a gamepad mapping element is present in the hardware // -static GLFWbool isValidElementForJoystick(const _GLFWmapelement* e, - const _GLFWjoystick* js) +static GLFWbool _glfwIsValidElementForJoystick(const _GLFWmapelement* e, + const _GLFWjoystick* js) { if (e->type == _GLFW_JOYSTICK_HATBIT && (e->index >> 4) >= js->hatCount) return GLFW_FALSE; @@ -99,22 +99,22 @@ static GLFWbool isValidElementForJoystick(const _GLFWmapelement* e, // Finds a mapping based on joystick GUID and verifies element indices // -static _GLFWmapping* findValidMapping(const _GLFWjoystick* js) +static _GLFWmapping* _glfwFindValidMapping(const _GLFWjoystick* js) { - _GLFWmapping* mapping = findMapping(js->guid); + _GLFWmapping* mapping = _glfwFindMapping(js->guid); if (mapping) { int i; for (i = 0; i <= GLFW_GAMEPAD_BUTTON_LAST; i++) { - if (!isValidElementForJoystick(mapping->buttons + i, js)) + if (!_glfwIsValidElementForJoystick(mapping->buttons + i, js)) return NULL; } for (i = 0; i <= GLFW_GAMEPAD_AXIS_LAST; i++) { - if (!isValidElementForJoystick(mapping->axes + i, js)) + if (!_glfwIsValidElementForJoystick(mapping->axes + i, js)) return NULL; } } @@ -124,7 +124,7 @@ static _GLFWmapping* findValidMapping(const _GLFWjoystick* js) // Parses an SDL_GameControllerDB line and adds it to the mapping list // -static GLFWbool parseMapping(_GLFWmapping* mapping, const char* string) +static GLFWbool _glfwParseMapping(_GLFWmapping* mapping, const char* string) { const char* c = string; size_t i, length; @@ -489,11 +489,11 @@ 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++) { - if (parseMapping(&_glfw.mappings[_glfw.mappingCount], _glfwDefaultMappings[i])) + if (_glfwParseMapping(&_glfw.mappings[_glfw.mappingCount], _glfwDefaultMappings[i])) _glfw.mappingCount++; } } @@ -520,16 +520,16 @@ _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; strncpy(js->name, name, sizeof(js->name) - 1); strncpy(js->guid, guid, sizeof(js->guid) - 1); - js->mapping = findValidMapping(js); + js->mapping = _glfwFindValidMapping(js); return js; } @@ -850,7 +850,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; @@ -884,7 +884,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; @@ -1044,7 +1044,7 @@ GLFWAPI int glfwJoystickPresent(int jid) return GLFW_FALSE; } - if (!initJoysticks()) + if (!_glfwInitJoysticks()) return GLFW_FALSE; js = _glfw.joysticks + jid; @@ -1072,7 +1072,7 @@ GLFWAPI const float* glfwGetJoystickAxes(int jid, int* count) return NULL; } - if (!initJoysticks()) + if (!_glfwInitJoysticks()) return NULL; js = _glfw.joysticks + jid; @@ -1104,7 +1104,7 @@ GLFWAPI const unsigned char* glfwGetJoystickButtons(int jid, int* count) return NULL; } - if (!initJoysticks()) + if (!_glfwInitJoysticks()) return NULL; js = _glfw.joysticks + jid; @@ -1140,7 +1140,7 @@ GLFWAPI const unsigned char* glfwGetJoystickHats(int jid, int* count) return NULL; } - if (!initJoysticks()) + if (!_glfwInitJoysticks()) return NULL; js = _glfw.joysticks + jid; @@ -1169,7 +1169,7 @@ GLFWAPI const char* glfwGetJoystickName(int jid) return NULL; } - if (!initJoysticks()) + if (!_glfwInitJoysticks()) return NULL; js = _glfw.joysticks + jid; @@ -1197,7 +1197,7 @@ GLFWAPI const char* glfwGetJoystickGUID(int jid) return NULL; } - if (!initJoysticks()) + if (!_glfwInitJoysticks()) return NULL; js = _glfw.joysticks + jid; @@ -1246,7 +1246,7 @@ GLFWAPI GLFWjoystickfun glfwSetJoystickCallback(GLFWjoystickfun cbfun) { _GLFW_REQUIRE_INIT_OR_RETURN(NULL); - if (!initJoysticks()) + if (!_glfwInitJoysticks()) return NULL; _GLFW_SWAP(GLFWjoystickfun, _glfw.callbacks.joystick, cbfun); @@ -1278,15 +1278,16 @@ GLFWAPI int glfwUpdateGamepadMappings(const char* string) memcpy(line, c, length); line[length] = '\0'; - if (parseMapping(&mapping, line)) + if (_glfwParseMapping(&mapping, line)) { - _GLFWmapping* previous = findMapping(mapping.guid); + _GLFWmapping* previous = _glfwFindMapping(mapping.guid); if (previous) *previous = mapping; else { _glfw.mappingCount++; _glfw.mappings = + (_GLFWmapping*) _glfw_realloc(_glfw.mappings, sizeof(_GLFWmapping) * _glfw.mappingCount); _glfw.mappings[_glfw.mappingCount - 1] = mapping; @@ -1307,7 +1308,7 @@ GLFWAPI int glfwUpdateGamepadMappings(const char* string) { _GLFWjoystick* js = _glfw.joysticks + jid; if (js->connected) - js->mapping = findValidMapping(js); + js->mapping = _glfwFindValidMapping(js); } return GLFW_TRUE; @@ -1328,7 +1329,7 @@ GLFWAPI int glfwJoystickIsGamepad(int jid) return GLFW_FALSE; } - if (!initJoysticks()) + if (!_glfwInitJoysticks()) return GLFW_FALSE; js = _glfw.joysticks + jid; @@ -1356,7 +1357,7 @@ GLFWAPI const char* glfwGetGamepadName(int jid) return NULL; } - if (!initJoysticks()) + if (!_glfwInitJoysticks()) return NULL; js = _glfw.joysticks + jid; @@ -1391,7 +1392,7 @@ GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state) return GLFW_FALSE; } - if (!initJoysticks()) + if (!_glfwInitJoysticks()) return GLFW_FALSE; js = _glfw.joysticks + jid; diff --git a/src/linux_joystick.c b/src/linux_joystick.c index 78d867eb..91611217 100644 --- a/src/linux_joystick.c +++ b/src/linux_joystick.c @@ -49,7 +49,7 @@ // Apply an EV_KEY event to the specified joystick // -static void handleKeyEvent(_GLFWjoystick* js, int code, int value) +static void _glfwHandleKeyEventLinux(_GLFWjoystick* js, int code, int value) { _glfwInputJoystickButton(js, js->linjs.keyMap[code - BTN_MISC], @@ -58,7 +58,7 @@ static void handleKeyEvent(_GLFWjoystick* js, int code, int value) // Apply an EV_ABS event to the specified joystick // -static void handleAbsEvent(_GLFWjoystick* js, int code, int value) +static void _glfwHandleAbsEventLinux(_GLFWjoystick* js, int code, int value) { const int index = js->linjs.absMap[code]; @@ -106,7 +106,7 @@ static void handleAbsEvent(_GLFWjoystick* js, int code, int value) // Poll state of absolute axes // -static void pollAbsState(_GLFWjoystick* js) +static void _glfwPollAbsStateLinux(_GLFWjoystick* js) { for (int code = 0; code < ABS_CNT; code++) { @@ -118,15 +118,15 @@ static void pollAbsState(_GLFWjoystick* js) if (ioctl(js->linjs.fd, EVIOCGABS(code), info) < 0) continue; - handleAbsEvent(js, code, info->value); + _glfwHandleAbsEventLinux(js, code, info->value); } } -#define isBitSet(bit, arr) (arr[(bit) / 8] & (1 << ((bit) % 8))) +#define _glfwIsBitSet(bit, arr) (arr[(bit) / 8] & (1 << ((bit) % 8))) // Attempt to open the specified joystick device // -static GLFWbool openJoystickDevice(const char* path) +static GLFWbool _glfwOpenJoystickDeviceLinux(const char* path) { for (int jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++) { @@ -159,7 +159,7 @@ static GLFWbool openJoystickDevice(const char* path) } // Ensure this device supports the events expected of a joystick - if (!isBitSet(EV_ABS, evBits)) + if (!_glfwIsBitSet(EV_ABS, evBits)) { close(linjs.fd); return GLFW_FALSE; @@ -175,7 +175,7 @@ static GLFWbool openJoystickDevice(const char* path) // Generate a joystick GUID that matches the SDL 2.0.5+ one if (id.vendor && id.product && id.version) { - sprintf(guid, "%02x%02x0000%02x%02x0000%02x%02x0000%02x%02x0000", + snprintf(guid, sizeof(guid), "%02x%02x0000%02x%02x0000%02x%02x0000%02x%02x0000", id.bustype & 0xff, id.bustype >> 8, id.vendor & 0xff, id.vendor >> 8, id.product & 0xff, id.product >> 8, @@ -183,7 +183,7 @@ static GLFWbool openJoystickDevice(const char* path) } else { - sprintf(guid, "%02x%02x0000%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x00", + snprintf(guid, sizeof(guid), "%02x%02x0000%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x00", id.bustype & 0xff, id.bustype >> 8, name[0], name[1], name[2], name[3], name[4], name[5], name[6], name[7], @@ -194,7 +194,7 @@ static GLFWbool openJoystickDevice(const char* path) for (int code = BTN_MISC; code < KEY_CNT; code++) { - if (!isBitSet(code, keyBits)) + if (!_glfwIsBitSet(code, keyBits)) continue; linjs.keyMap[code - BTN_MISC] = buttonCount; @@ -204,7 +204,7 @@ static GLFWbool openJoystickDevice(const char* path) for (int code = 0; code < ABS_CNT; code++) { linjs.absMap[code] = -1; - if (!isBitSet(code, absBits)) + if (!_glfwIsBitSet(code, absBits)) continue; if (code >= ABS_HAT0X && code <= ABS_HAT3Y) @@ -235,17 +235,17 @@ static GLFWbool openJoystickDevice(const char* path) strncpy(linjs.path, path, sizeof(linjs.path) - 1); memcpy(&js->linjs, &linjs, sizeof(linjs)); - pollAbsState(js); + _glfwPollAbsStateLinux(js); _glfwInputJoystick(js, GLFW_CONNECTED); return GLFW_TRUE; } -#undef isBitSet +#undef _glfwIsBitSet // Frees all resources associated with the specified joystick // -static void closeJoystick(_GLFWjoystick* js) +static void _glfwCloseJoystickLinux(_GLFWjoystick* js) { _glfwInputJoystick(js, GLFW_DISCONNECTED); close(js->linjs.fd); @@ -254,7 +254,7 @@ static void closeJoystick(_GLFWjoystick* js) // Lexically compare joysticks by name; used by qsort // -static int compareJoysticks(const void* fp, const void* sp) +static int _glfwCompareJoysticksLinux(const void* fp, const void* sp) { const _GLFWjoystick* fj = fp; const _GLFWjoystick* sj = sp; @@ -289,14 +289,14 @@ void _glfwDetectJoystickConnectionLinux(void) snprintf(path, sizeof(path), "/dev/input/%s", e->name); if (e->mask & (IN_CREATE | IN_ATTRIB)) - openJoystickDevice(path); + _glfwOpenJoystickDeviceLinux(path); else if (e->mask & IN_DELETE) { for (int jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++) { if (strcmp(_glfw.joysticks[jid].linjs.path, path) == 0) { - closeJoystick(_glfw.joysticks + jid); + _glfwCloseJoystickLinux(_glfw.joysticks + jid); break; } } @@ -351,7 +351,7 @@ GLFWbool _glfwInitJoysticksLinux(void) snprintf(path, sizeof(path), "%s/%s", dirname, entry->d_name); - if (openJoystickDevice(path)) + if (_glfwOpenJoystickDeviceLinux(path)) count++; } @@ -360,7 +360,7 @@ GLFWbool _glfwInitJoysticksLinux(void) // Continue with no joysticks if enumeration fails - qsort(_glfw.joysticks, count, sizeof(_GLFWjoystick), compareJoysticks); + qsort(_glfw.joysticks, count, sizeof(_GLFWjoystick), _glfwCompareJoysticksLinux); return GLFW_TRUE; } @@ -370,7 +370,7 @@ void _glfwTerminateJoysticksLinux(void) { _GLFWjoystick* js = _glfw.joysticks + jid; if (js->connected) - closeJoystick(js); + _glfwCloseJoystickLinux(js); } if (_glfw.linjs.inotify > 0) @@ -397,7 +397,7 @@ GLFWbool _glfwPollJoystickLinux(_GLFWjoystick* js, int mode) { // Reset the joystick slot if the device was disconnected if (errno == ENODEV) - closeJoystick(js); + _glfwCloseJoystickLinux(js); break; } @@ -409,7 +409,7 @@ GLFWbool _glfwPollJoystickLinux(_GLFWjoystick* js, int mode) else if (e.code == SYN_REPORT) { _glfw.linjs.dropped = GLFW_FALSE; - pollAbsState(js); + _glfwPollAbsStateLinux(js); } } @@ -417,9 +417,9 @@ GLFWbool _glfwPollJoystickLinux(_GLFWjoystick* js, int mode) continue; if (e.type == EV_KEY) - handleKeyEvent(js, e.code, e.value); + _glfwHandleKeyEventLinux(js, e.code, e.value); else if (e.type == EV_ABS) - handleAbsEvent(js, e.code, e.value); + _glfwHandleAbsEventLinux(js, e.code, e.value); } return js->connected; diff --git a/src/monitor.c b/src/monitor.c index 6429493b..a50f5af8 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -39,10 +39,10 @@ // Lexically compare video modes, used by qsort // -static int compareVideoModes(const void* fp, const void* sp) +static int _glfwQsortCompareVideoModes(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; @@ -66,7 +66,7 @@ static int compareVideoModes(const void* fp, const void* sp) // Retrieves the available modes for the specified monitor // -static GLFWbool refreshVideoModes(_GLFWmonitor* monitor) +static GLFWbool _glfwRefreshVideoModes(_GLFWmonitor* monitor) { int modeCount; GLFWvidmode* modes; @@ -78,7 +78,7 @@ static GLFWbool refreshVideoModes(_GLFWmonitor* monitor) if (!modes) return GLFW_FALSE; - qsort(modes, modeCount, sizeof(GLFWvidmode), compareVideoModes); + qsort(modes, modeCount, sizeof(GLFWvidmode), _glfwQsortCompareVideoModes); _glfw_free(monitor->modes); monitor->modes = modes; @@ -104,6 +104,7 @@ void _glfwInputMonitor(_GLFWmonitor* monitor, int action, int placement) { _glfw.monitorCount++; _glfw.monitors = + (_GLFWmonitor**) _glfw_realloc(_glfw.monitors, sizeof(_GLFWmonitor*) * _glfw.monitorCount); @@ -172,7 +173,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; @@ -201,9 +202,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; } @@ -230,7 +231,7 @@ const GLFWvidmode* _glfwChooseVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* current; const GLFWvidmode* closest = NULL; - if (!refreshVideoModes(monitor)) + if (!_glfwRefreshVideoModes(monitor)) return NULL; for (i = 0; i < monitor->modeCount; i++) @@ -274,7 +275,7 @@ const GLFWvidmode* _glfwChooseVideoMode(_GLFWmonitor* monitor, // int _glfwCompareVideoModes(const GLFWvidmode* fm, const GLFWvidmode* sm) { - return compareVideoModes(fm, sm); + return _glfwQsortCompareVideoModes(fm, sm); } // Splits a color depth into red, green and blue bit depths @@ -438,7 +439,7 @@ GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* handle, int* count) _GLFW_REQUIRE_INIT_OR_RETURN(NULL); - if (!refreshVideoModes(monitor)) + if (!_glfwRefreshVideoModes(monitor)) return NULL; *count = monitor->modeCount; @@ -478,7 +479,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++) { diff --git a/src/nsgl_context.m b/src/nsgl_context.m index de89e421..7dee8c8b 100644 --- a/src/nsgl_context.m +++ b/src/nsgl_context.m @@ -33,7 +33,7 @@ #include #include -static void makeContextCurrentNSGL(_GLFWwindow* window) +static void _glfwMakeContextCurrentNSGL(_GLFWwindow* window) { @autoreleasepool { @@ -47,7 +47,7 @@ static void makeContextCurrentNSGL(_GLFWwindow* window) } // autoreleasepool } -static void swapBuffersNSGL(_GLFWwindow* window) +static void _glfwSwapBuffersNSGL(_GLFWwindow* window) { @autoreleasepool { @@ -78,11 +78,11 @@ static void swapBuffersNSGL(_GLFWwindow* window) } // autoreleasepool } -static void swapIntervalNSGL(int interval) +static void _glfwSwapIntervalNSGL(int interval) { @autoreleasepool { - _GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot); + _GLFWwindow* window = (_GLFWwindow*) _glfwPlatformGetTls(&_glfw.contextSlot); assert(window != NULL); [window->context.nsgl.object setValues:&interval @@ -91,19 +91,19 @@ static void swapIntervalNSGL(int interval) } // autoreleasepool } -static int extensionSupportedNSGL(const char* extension) +static int _glfwExtensionSupportedNSGL(const char* extension) { // There are no NSGL extensions return GLFW_FALSE; } -static GLFWglproc getProcAddressNSGL(const char* procname) +static GLFWglproc _glfwGetProcAddressNSGL(const char* procname) { CFStringRef symbolName = CFStringCreateWithCString(kCFAllocatorDefault, procname, kCFStringEncodingASCII); - GLFWglproc symbol = CFBundleGetFunctionPointerForName(_glfw.nsgl.framework, + GLFWglproc symbol = (GLFWglproc) CFBundleGetFunctionPointerForName(_glfw.nsgl.framework, symbolName); CFRelease(symbolName); @@ -111,7 +111,7 @@ static GLFWglproc getProcAddressNSGL(const char* procname) return symbol; } -static void destroyContextNSGL(_GLFWwindow* window) +static void _glfwDestroyContextNSGL(_GLFWwindow* window) { @autoreleasepool { @@ -339,12 +339,12 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window, [window->context.nsgl.object setView:window->ns.view]; - window->context.makeCurrent = makeContextCurrentNSGL; - window->context.swapBuffers = swapBuffersNSGL; - window->context.swapInterval = swapIntervalNSGL; - window->context.extensionSupported = extensionSupportedNSGL; - window->context.getProcAddress = getProcAddressNSGL; - window->context.destroy = destroyContextNSGL; + window->context.makeCurrent = _glfwMakeContextCurrentNSGL; + window->context.swapBuffers = _glfwSwapBuffersNSGL; + window->context.swapInterval = _glfwSwapIntervalNSGL; + window->context.extensionSupported = _glfwExtensionSupportedNSGL; + window->context.getProcAddress = _glfwGetProcAddressNSGL; + window->context.destroy = _glfwDestroyContextNSGL; return GLFW_TRUE; } diff --git a/src/null_monitor.c b/src/null_monitor.c index 63a1cd20..22b62388 100644 --- a/src/null_monitor.c +++ b/src/null_monitor.c @@ -35,7 +35,7 @@ // The the sole (fake) video mode of our (sole) fake monitor // -static GLFWvidmode getVideoMode(void) +static GLFWvidmode _glfwGetDefaultVideoModeNull(void) { GLFWvidmode mode; mode.width = 1920; @@ -54,7 +54,7 @@ static GLFWvidmode getVideoMode(void) void _glfwPollMonitorsNull(void) { const float dpi = 141.f; - const GLFWvidmode mode = getVideoMode(); + const GLFWvidmode mode = _glfwGetDefaultVideoModeNull(); _GLFWmonitor* monitor = _glfwAllocMonitor("Null SuperNoop 0", (int) (mode.width * 25.4f / dpi), (int) (mode.height * 25.4f / dpi)); @@ -91,7 +91,7 @@ void _glfwGetMonitorWorkareaNull(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height) { - const GLFWvidmode mode = getVideoMode(); + const GLFWvidmode mode = _glfwGetDefaultVideoModeNull(); if (xpos) *xpos = 0; @@ -105,15 +105,15 @@ void _glfwGetMonitorWorkareaNull(_GLFWmonitor* monitor, GLFWvidmode* _glfwGetVideoModesNull(_GLFWmonitor* monitor, int* found) { - GLFWvidmode* mode = _glfw_calloc(1, sizeof(GLFWvidmode)); - *mode = getVideoMode(); + GLFWvidmode* mode = (GLFWvidmode*) _glfw_calloc(1, sizeof(GLFWvidmode)); + *mode = _glfwGetDefaultVideoModeNull(); *found = 1; return mode; } void _glfwGetVideoModeNull(_GLFWmonitor* monitor, GLFWvidmode* mode) { - *mode = getVideoMode(); + *mode = _glfwGetDefaultVideoModeNull(); } GLFWbool _glfwGetGammaRampNull(_GLFWmonitor* monitor, GLFWgammaramp* ramp) diff --git a/src/null_window.c b/src/null_window.c index e0bbb3b6..2e06cb42 100644 --- a/src/null_window.c +++ b/src/null_window.c @@ -31,7 +31,7 @@ #include -static void applySizeLimits(_GLFWwindow* window, int* width, int* height) +static void _glfwApplySizeLimitsNull(_GLFWwindow* window, int* width, int* height) { if (window->numer != GLFW_DONT_CARE && window->denom != GLFW_DONT_CARE) { @@ -50,7 +50,7 @@ static void applySizeLimits(_GLFWwindow* window, int* width, int* height) *height = _glfw_max(*height, window->maxheight); } -static void fitToMonitor(_GLFWwindow* window) +static void _glfwFitToMonitorNull(_GLFWwindow* window) { GLFWvidmode mode; _glfwGetVideoModeNull(window->monitor, &mode); @@ -61,12 +61,12 @@ static void fitToMonitor(_GLFWwindow* window) window->null.height = mode.height; } -static void acquireMonitor(_GLFWwindow* window) +static void _glfwAcquireMonitorNull(_GLFWwindow* window) { _glfwInputMonitorWindow(window->monitor, window); } -static void releaseMonitor(_GLFWwindow* window) +static void _glfwReleaseMonitorNull(_GLFWwindow* window) { if (window->monitor->window != window) return; @@ -74,12 +74,12 @@ static void releaseMonitor(_GLFWwindow* window) _glfwInputMonitorWindow(window->monitor, NULL); } -static int createNativeWindow(_GLFWwindow* window, - const _GLFWwndconfig* wndconfig, - const _GLFWfbconfig* fbconfig) +static int _glfwCreateNativeWindowNull(_GLFWwindow* window, + const _GLFWwndconfig* wndconfig, + const _GLFWfbconfig* fbconfig) { if (window->monitor) - fitToMonitor(window); + _glfwFitToMonitorNull(window); else { if (wndconfig->xpos == GLFW_ANY_POSITION && wndconfig->ypos == GLFW_ANY_POSITION) @@ -117,7 +117,7 @@ GLFWbool _glfwCreateWindowNull(_GLFWwindow* window, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig) { - if (!createNativeWindow(window, wndconfig, fbconfig)) + if (!_glfwCreateNativeWindowNull(window, wndconfig, fbconfig)) return GLFW_FALSE; if (ctxconfig->client != GLFW_NO_API) @@ -149,7 +149,7 @@ GLFWbool _glfwCreateWindowNull(_GLFWwindow* window, { _glfwShowWindowNull(window); _glfwFocusWindowNull(window); - acquireMonitor(window); + _glfwAcquireMonitorNull(window); if (wndconfig->centerCursor) _glfwCenterCursorInContentArea(window); @@ -170,7 +170,7 @@ GLFWbool _glfwCreateWindowNull(_GLFWwindow* window, void _glfwDestroyWindowNull(_GLFWwindow* window) { if (window->monitor) - releaseMonitor(window); + _glfwReleaseMonitorNull(window); if (_glfw.null.focusedWindow == window) _glfw.null.focusedWindow = NULL; @@ -205,15 +205,15 @@ void _glfwSetWindowMonitorNull(_GLFWwindow* window, } if (window->monitor) - releaseMonitor(window); + _glfwReleaseMonitorNull(window); _glfwInputWindowMonitor(window, monitor); if (window->monitor) { window->null.visible = GLFW_TRUE; - acquireMonitor(window); - fitToMonitor(window); + _glfwAcquireMonitorNull(window); + _glfwFitToMonitorNull(window); } else { @@ -271,7 +271,7 @@ void _glfwSetWindowSizeLimitsNull(_GLFWwindow* window, { int width = window->null.width; int height = window->null.height; - applySizeLimits(window, &width, &height); + _glfwApplySizeLimitsNull(window, &width, &height); _glfwSetWindowSizeNull(window, width, height); } @@ -279,7 +279,7 @@ void _glfwSetWindowAspectRatioNull(_GLFWwindow* window, int n, int d) { int width = window->null.width; int height = window->null.height; - applySizeLimits(window, &width, &height); + _glfwApplySizeLimitsNull(window, &width, &height); _glfwSetWindowSizeNull(window, width, height); } @@ -341,7 +341,7 @@ void _glfwIconifyWindowNull(_GLFWwindow* window) _glfwInputWindowIconify(window, GLFW_TRUE); if (window->monitor) - releaseMonitor(window); + _glfwReleaseMonitorNull(window); } } @@ -353,7 +353,7 @@ void _glfwRestoreWindowNull(_GLFWwindow* window) _glfwInputWindowIconify(window, GLFW_FALSE); if (window->monitor) - acquireMonitor(window); + _glfwAcquireMonitorNull(window); } else if (window->null.maximized) { diff --git a/src/osmesa_context.c b/src/osmesa_context.c index 38adabbc..113de079 100644 --- a/src/osmesa_context.c +++ b/src/osmesa_context.c @@ -34,7 +34,7 @@ #include "internal.h" -static void makeContextCurrentOSMesa(_GLFWwindow* window) +static void _glfwMakeContextCurrentOSMesa(_GLFWwindow* window) { if (window) { @@ -68,12 +68,12 @@ static void makeContextCurrentOSMesa(_GLFWwindow* window) _glfwPlatformSetTls(&_glfw.contextSlot, window); } -static GLFWglproc getProcAddressOSMesa(const char* procname) +static GLFWglproc _glfwGetProcAddressOSMesa(const char* procname) { return (GLFWglproc) OSMesaGetProcAddress(procname); } -static void destroyContextOSMesa(_GLFWwindow* window) +static void _glfwDestroyContextOSMesa(_GLFWwindow* window) { if (window->context.osmesa.handle) { @@ -89,17 +89,17 @@ static void destroyContextOSMesa(_GLFWwindow* window) } } -static void swapBuffersOSMesa(_GLFWwindow* window) +static void _glfwSwapBuffersOSMesa(_GLFWwindow* window) { // No double buffering on OSMesa } -static void swapIntervalOSMesa(int interval) +static void _glfwSwapIntervalOSMesa(int interval) { // No swap interval on OSMesa } -static int extensionSupportedOSMesa(const char* extension) +static int _glfwExtensionSupportedOSMesa(const char* extension) { // OSMesa does not have extensions return GLFW_FALSE; @@ -277,12 +277,12 @@ GLFWbool _glfwCreateContextOSMesa(_GLFWwindow* window, return GLFW_FALSE; } - window->context.makeCurrent = makeContextCurrentOSMesa; - window->context.swapBuffers = swapBuffersOSMesa; - window->context.swapInterval = swapIntervalOSMesa; - window->context.extensionSupported = extensionSupportedOSMesa; - window->context.getProcAddress = getProcAddressOSMesa; - window->context.destroy = destroyContextOSMesa; + window->context.makeCurrent = _glfwMakeContextCurrentOSMesa; + window->context.swapBuffers = _glfwSwapBuffersOSMesa; + window->context.swapInterval = _glfwSwapIntervalOSMesa; + window->context.extensionSupported = _glfwExtensionSupportedOSMesa; + window->context.getProcAddress = _glfwGetProcAddressOSMesa; + window->context.destroy = _glfwDestroyContextOSMesa; return GLFW_TRUE; } diff --git a/src/posix_module.c b/src/posix_module.c index ba5024a3..9183c92b 100644 --- a/src/posix_module.c +++ b/src/posix_module.c @@ -48,7 +48,7 @@ void _glfwPlatformFreeModule(void* module) GLFWproc _glfwPlatformGetModuleSymbol(void* module, const char* name) { - return dlsym(module, name); + return (GLFWproc) dlsym(module, name); } #endif // GLFW_BUILD_POSIX_MODULE diff --git a/src/vulkan.c b/src/vulkan.c index 64a4650f..25a6d71f 100644 --- a/src/vulkan.c +++ b/src/vulkan.c @@ -114,7 +114,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) diff --git a/src/wgl_context.c b/src/wgl_context.c index 08c499ff..60e24856 100644 --- a/src/wgl_context.c +++ b/src/wgl_context.c @@ -36,10 +36,10 @@ // Return the value corresponding to the specified attribute // -static int findPixelFormatAttribValueWGL(const int* attribs, - int attribCount, - const int* values, - int attrib) +static int _glfwFindPixelFormatAttribValueWGL(const int* attribs, + int attribCount, + const int* values, + int attrib) { int i; @@ -54,17 +54,17 @@ static int findPixelFormatAttribValueWGL(const int* attribs, return 0; } -#define ADD_ATTRIB(a) \ +#define _GLFW_ADD_ATTRIB(a) \ { \ assert((size_t) attribCount < sizeof(attribs) / sizeof(attribs[0])); \ attribs[attribCount++] = a; \ } -#define FIND_ATTRIB_VALUE(a) \ - findPixelFormatAttribValueWGL(attribs, attribCount, values, a) +#define _GLFW_FIND_ATTRIB_VALUE(a) \ + _glfwFindPixelFormatAttribValueWGL(attribs, attribCount, values, a) // Return a list of available and usable framebuffer configs // -static int choosePixelFormatWGL(_GLFWwindow* window, +static int _glfwChoosePixelFormatWGL(_GLFWwindow* window, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig) { @@ -81,45 +81,45 @@ static int choosePixelFormatWGL(_GLFWwindow* window, if (_glfw.wgl.ARB_pixel_format) { - ADD_ATTRIB(WGL_SUPPORT_OPENGL_ARB); - ADD_ATTRIB(WGL_DRAW_TO_WINDOW_ARB); - ADD_ATTRIB(WGL_PIXEL_TYPE_ARB); - ADD_ATTRIB(WGL_ACCELERATION_ARB); - ADD_ATTRIB(WGL_RED_BITS_ARB); - ADD_ATTRIB(WGL_RED_SHIFT_ARB); - ADD_ATTRIB(WGL_GREEN_BITS_ARB); - ADD_ATTRIB(WGL_GREEN_SHIFT_ARB); - ADD_ATTRIB(WGL_BLUE_BITS_ARB); - ADD_ATTRIB(WGL_BLUE_SHIFT_ARB); - ADD_ATTRIB(WGL_ALPHA_BITS_ARB); - ADD_ATTRIB(WGL_ALPHA_SHIFT_ARB); - ADD_ATTRIB(WGL_DEPTH_BITS_ARB); - ADD_ATTRIB(WGL_STENCIL_BITS_ARB); - ADD_ATTRIB(WGL_ACCUM_BITS_ARB); - ADD_ATTRIB(WGL_ACCUM_RED_BITS_ARB); - ADD_ATTRIB(WGL_ACCUM_GREEN_BITS_ARB); - ADD_ATTRIB(WGL_ACCUM_BLUE_BITS_ARB); - ADD_ATTRIB(WGL_ACCUM_ALPHA_BITS_ARB); - ADD_ATTRIB(WGL_AUX_BUFFERS_ARB); - ADD_ATTRIB(WGL_STEREO_ARB); - ADD_ATTRIB(WGL_DOUBLE_BUFFER_ARB); + _GLFW_ADD_ATTRIB(WGL_SUPPORT_OPENGL_ARB); + _GLFW_ADD_ATTRIB(WGL_DRAW_TO_WINDOW_ARB); + _GLFW_ADD_ATTRIB(WGL_PIXEL_TYPE_ARB); + _GLFW_ADD_ATTRIB(WGL_ACCELERATION_ARB); + _GLFW_ADD_ATTRIB(WGL_RED_BITS_ARB); + _GLFW_ADD_ATTRIB(WGL_RED_SHIFT_ARB); + _GLFW_ADD_ATTRIB(WGL_GREEN_BITS_ARB); + _GLFW_ADD_ATTRIB(WGL_GREEN_SHIFT_ARB); + _GLFW_ADD_ATTRIB(WGL_BLUE_BITS_ARB); + _GLFW_ADD_ATTRIB(WGL_BLUE_SHIFT_ARB); + _GLFW_ADD_ATTRIB(WGL_ALPHA_BITS_ARB); + _GLFW_ADD_ATTRIB(WGL_ALPHA_SHIFT_ARB); + _GLFW_ADD_ATTRIB(WGL_DEPTH_BITS_ARB); + _GLFW_ADD_ATTRIB(WGL_STENCIL_BITS_ARB); + _GLFW_ADD_ATTRIB(WGL_ACCUM_BITS_ARB); + _GLFW_ADD_ATTRIB(WGL_ACCUM_RED_BITS_ARB); + _GLFW_ADD_ATTRIB(WGL_ACCUM_GREEN_BITS_ARB); + _GLFW_ADD_ATTRIB(WGL_ACCUM_BLUE_BITS_ARB); + _GLFW_ADD_ATTRIB(WGL_ACCUM_ALPHA_BITS_ARB); + _GLFW_ADD_ATTRIB(WGL_AUX_BUFFERS_ARB); + _GLFW_ADD_ATTRIB(WGL_STEREO_ARB); + _GLFW_ADD_ATTRIB(WGL_DOUBLE_BUFFER_ARB); if (_glfw.wgl.ARB_multisample) - ADD_ATTRIB(WGL_SAMPLES_ARB); + _GLFW_ADD_ATTRIB(WGL_SAMPLES_ARB); if (ctxconfig->client == GLFW_OPENGL_API) { if (_glfw.wgl.ARB_framebuffer_sRGB || _glfw.wgl.EXT_framebuffer_sRGB) - ADD_ATTRIB(WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB); + _GLFW_ADD_ATTRIB(WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB); } else { if (_glfw.wgl.EXT_colorspace) - ADD_ATTRIB(WGL_COLORSPACE_EXT); + _GLFW_ADD_ATTRIB(WGL_COLORSPACE_EXT); } } - usableConfigs = _glfw_calloc(nativeCount, sizeof(_GLFWfbconfig)); + usableConfigs = (_GLFWfbconfig*) _glfw_calloc(nativeCount, sizeof(_GLFWfbconfig)); for (i = 0; i < nativeCount; i++) { @@ -142,48 +142,48 @@ static int choosePixelFormatWGL(_GLFWwindow* window, return 0; } - if (!FIND_ATTRIB_VALUE(WGL_SUPPORT_OPENGL_ARB) || - !FIND_ATTRIB_VALUE(WGL_DRAW_TO_WINDOW_ARB)) + if (!_GLFW_FIND_ATTRIB_VALUE(WGL_SUPPORT_OPENGL_ARB) || + !_GLFW_FIND_ATTRIB_VALUE(WGL_DRAW_TO_WINDOW_ARB)) { continue; } - if (FIND_ATTRIB_VALUE(WGL_PIXEL_TYPE_ARB) != WGL_TYPE_RGBA_ARB) + if (_GLFW_FIND_ATTRIB_VALUE(WGL_PIXEL_TYPE_ARB) != WGL_TYPE_RGBA_ARB) continue; - if (FIND_ATTRIB_VALUE(WGL_ACCELERATION_ARB) == WGL_NO_ACCELERATION_ARB) + if (_GLFW_FIND_ATTRIB_VALUE(WGL_ACCELERATION_ARB) == WGL_NO_ACCELERATION_ARB) continue; - if (FIND_ATTRIB_VALUE(WGL_DOUBLE_BUFFER_ARB) != fbconfig->doublebuffer) + if (_GLFW_FIND_ATTRIB_VALUE(WGL_DOUBLE_BUFFER_ARB) != fbconfig->doublebuffer) continue; - u->redBits = FIND_ATTRIB_VALUE(WGL_RED_BITS_ARB); - u->greenBits = FIND_ATTRIB_VALUE(WGL_GREEN_BITS_ARB); - u->blueBits = FIND_ATTRIB_VALUE(WGL_BLUE_BITS_ARB); - u->alphaBits = FIND_ATTRIB_VALUE(WGL_ALPHA_BITS_ARB); + u->redBits = _GLFW_FIND_ATTRIB_VALUE(WGL_RED_BITS_ARB); + u->greenBits = _GLFW_FIND_ATTRIB_VALUE(WGL_GREEN_BITS_ARB); + u->blueBits = _GLFW_FIND_ATTRIB_VALUE(WGL_BLUE_BITS_ARB); + u->alphaBits = _GLFW_FIND_ATTRIB_VALUE(WGL_ALPHA_BITS_ARB); - u->depthBits = FIND_ATTRIB_VALUE(WGL_DEPTH_BITS_ARB); - u->stencilBits = FIND_ATTRIB_VALUE(WGL_STENCIL_BITS_ARB); + u->depthBits = _GLFW_FIND_ATTRIB_VALUE(WGL_DEPTH_BITS_ARB); + u->stencilBits = _GLFW_FIND_ATTRIB_VALUE(WGL_STENCIL_BITS_ARB); - u->accumRedBits = FIND_ATTRIB_VALUE(WGL_ACCUM_RED_BITS_ARB); - u->accumGreenBits = FIND_ATTRIB_VALUE(WGL_ACCUM_GREEN_BITS_ARB); - u->accumBlueBits = FIND_ATTRIB_VALUE(WGL_ACCUM_BLUE_BITS_ARB); - u->accumAlphaBits = FIND_ATTRIB_VALUE(WGL_ACCUM_ALPHA_BITS_ARB); + u->accumRedBits = _GLFW_FIND_ATTRIB_VALUE(WGL_ACCUM_RED_BITS_ARB); + u->accumGreenBits = _GLFW_FIND_ATTRIB_VALUE(WGL_ACCUM_GREEN_BITS_ARB); + u->accumBlueBits = _GLFW_FIND_ATTRIB_VALUE(WGL_ACCUM_BLUE_BITS_ARB); + u->accumAlphaBits = _GLFW_FIND_ATTRIB_VALUE(WGL_ACCUM_ALPHA_BITS_ARB); - u->auxBuffers = FIND_ATTRIB_VALUE(WGL_AUX_BUFFERS_ARB); + u->auxBuffers = _GLFW_FIND_ATTRIB_VALUE(WGL_AUX_BUFFERS_ARB); - if (FIND_ATTRIB_VALUE(WGL_STEREO_ARB)) + if (_GLFW_FIND_ATTRIB_VALUE(WGL_STEREO_ARB)) u->stereo = GLFW_TRUE; if (_glfw.wgl.ARB_multisample) - u->samples = FIND_ATTRIB_VALUE(WGL_SAMPLES_ARB); + u->samples = _GLFW_FIND_ATTRIB_VALUE(WGL_SAMPLES_ARB); if (ctxconfig->client == GLFW_OPENGL_API) { if (_glfw.wgl.ARB_framebuffer_sRGB || _glfw.wgl.EXT_framebuffer_sRGB) { - if (FIND_ATTRIB_VALUE(WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB)) + if (_GLFW_FIND_ATTRIB_VALUE(WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB)) u->sRGB = GLFW_TRUE; } } @@ -191,7 +191,7 @@ static int choosePixelFormatWGL(_GLFWwindow* window, { if (_glfw.wgl.EXT_colorspace) { - if (FIND_ATTRIB_VALUE(WGL_COLORSPACE_EXT) == WGL_COLORSPACE_SRGB_EXT) + if (_GLFW_FIND_ATTRIB_VALUE(WGL_COLORSPACE_EXT) == WGL_COLORSPACE_SRGB_EXT) u->sRGB = GLFW_TRUE; } } @@ -280,10 +280,10 @@ static int choosePixelFormatWGL(_GLFWwindow* window, return pixelFormat; } -#undef ADD_ATTRIB -#undef FIND_ATTRIB_VALUE +#undef _GLFW_ADD_ATTRIB +#undef _GLFW_FIND_ATTRIB_VALUE -static void makeContextCurrentWGL(_GLFWwindow* window) +static void _glfwMakeContextCurrentWGL(_GLFWwindow* window) { if (window) { @@ -308,7 +308,7 @@ static void makeContextCurrentWGL(_GLFWwindow* window) } } -static void swapBuffersWGL(_GLFWwindow* window) +static void _glfwSwapBuffersWGL(_GLFWwindow* window) { if (!window->monitor) { @@ -329,9 +329,9 @@ static void swapBuffersWGL(_GLFWwindow* window) SwapBuffers(window->context.wgl.dc); } -static void swapIntervalWGL(int interval) +static void _glfwSwapIntervalWGL(int interval) { - _GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot); + _GLFWwindow* window = (_GLFWwindow*) _glfwPlatformGetTls(&_glfw.contextSlot); assert(window != NULL); window->context.wgl.interval = interval; @@ -353,7 +353,7 @@ static void swapIntervalWGL(int interval) wglSwapIntervalEXT(interval); } -static int extensionSupportedWGL(const char* extension) +static int _glfwExtensionSupportedWGL(const char* extension) { const char* extensions = NULL; @@ -368,7 +368,7 @@ static int extensionSupportedWGL(const char* extension) return _glfwStringInExtensionString(extension, extensions); } -static GLFWglproc getProcAddressWGL(const char* procname) +static GLFWglproc _glfwGetProcAddressWGL(const char* procname) { const GLFWglproc proc = (GLFWglproc) wglGetProcAddress(procname); if (proc) @@ -377,7 +377,7 @@ static GLFWglproc getProcAddressWGL(const char* procname) return (GLFWglproc) _glfwPlatformGetModuleSymbol(_glfw.wgl.instance, procname); } -static void destroyContextWGL(_GLFWwindow* window) +static void _glfwDestroyContextWGL(_GLFWwindow* window) { if (window->context.wgl.handle) { @@ -397,7 +397,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, @@ -477,29 +477,29 @@ GLFWbool _glfwInitWGL(void) // NOTE: WGL_ARB_extensions_string and WGL_EXT_extensions_string are not // checked below as we are already using them _glfw.wgl.ARB_multisample = - extensionSupportedWGL("WGL_ARB_multisample"); + _glfwExtensionSupportedWGL("WGL_ARB_multisample"); _glfw.wgl.ARB_framebuffer_sRGB = - extensionSupportedWGL("WGL_ARB_framebuffer_sRGB"); + _glfwExtensionSupportedWGL("WGL_ARB_framebuffer_sRGB"); _glfw.wgl.EXT_framebuffer_sRGB = - extensionSupportedWGL("WGL_EXT_framebuffer_sRGB"); + _glfwExtensionSupportedWGL("WGL_EXT_framebuffer_sRGB"); _glfw.wgl.ARB_create_context = - extensionSupportedWGL("WGL_ARB_create_context"); + _glfwExtensionSupportedWGL("WGL_ARB_create_context"); _glfw.wgl.ARB_create_context_profile = - extensionSupportedWGL("WGL_ARB_create_context_profile"); + _glfwExtensionSupportedWGL("WGL_ARB_create_context_profile"); _glfw.wgl.EXT_create_context_es2_profile = - extensionSupportedWGL("WGL_EXT_create_context_es2_profile"); + _glfwExtensionSupportedWGL("WGL_EXT_create_context_es2_profile"); _glfw.wgl.ARB_create_context_robustness = - extensionSupportedWGL("WGL_ARB_create_context_robustness"); + _glfwExtensionSupportedWGL("WGL_ARB_create_context_robustness"); _glfw.wgl.ARB_create_context_no_error = - extensionSupportedWGL("WGL_ARB_create_context_no_error"); + _glfwExtensionSupportedWGL("WGL_ARB_create_context_no_error"); _glfw.wgl.EXT_swap_control = - extensionSupportedWGL("WGL_EXT_swap_control"); + _glfwExtensionSupportedWGL("WGL_EXT_swap_control"); _glfw.wgl.EXT_colorspace = - extensionSupportedWGL("WGL_EXT_colorspace"); + _glfwExtensionSupportedWGL("WGL_EXT_colorspace"); _glfw.wgl.ARB_pixel_format = - extensionSupportedWGL("WGL_ARB_pixel_format"); + _glfwExtensionSupportedWGL("WGL_ARB_pixel_format"); _glfw.wgl.ARB_context_flush_control = - extensionSupportedWGL("WGL_ARB_context_flush_control"); + _glfwExtensionSupportedWGL("WGL_ARB_context_flush_control"); wglMakeCurrent(pdc, prc); wglDeleteContext(rc); @@ -543,7 +543,7 @@ GLFWbool _glfwCreateContextWGL(_GLFWwindow* window, return GLFW_FALSE; } - pixelFormat = choosePixelFormatWGL(window, ctxconfig, fbconfig); + pixelFormat = _glfwChoosePixelFormatWGL(window, ctxconfig, fbconfig); if (!pixelFormat) return GLFW_FALSE; @@ -746,12 +746,12 @@ GLFWbool _glfwCreateContextWGL(_GLFWwindow* window, } } - window->context.makeCurrent = makeContextCurrentWGL; - window->context.swapBuffers = swapBuffersWGL; - window->context.swapInterval = swapIntervalWGL; - window->context.extensionSupported = extensionSupportedWGL; - window->context.getProcAddress = getProcAddressWGL; - window->context.destroy = destroyContextWGL; + window->context.makeCurrent = _glfwMakeContextCurrentWGL; + window->context.swapBuffers = _glfwSwapBuffersWGL; + window->context.swapInterval = _glfwSwapIntervalWGL; + window->context.extensionSupported = _glfwExtensionSupportedWGL; + window->context.getProcAddress = _glfwGetProcAddressWGL; + window->context.destroy = _glfwDestroyContextWGL; return GLFW_TRUE; } diff --git a/src/win32_init.c b/src/win32_init.c index ef2615f1..12996288 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -36,7 +36,7 @@ static const GUID _glfw_GUID_DEVINTERFACE_HID = {0x4d1e55b2,0xf16f,0x11cf,{0x88,0xcb,0x00,0x11,0x11,0x00,0x00,0x30}}; -#define GUID_DEVINTERFACE_HID _glfw_GUID_DEVINTERFACE_HID +#define _GLFW_GUID_DEVINTERFACE_HID _glfw_GUID_DEVINTERFACE_HID #if defined(_GLFW_USE_HYBRID_HPG) || defined(_GLFW_USE_OPTIMUS_HPG) @@ -71,7 +71,7 @@ BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved) // Load necessary libraries (DLLs) // -static GLFWbool loadLibraries(void) +static GLFWbool _glfwLoadLibrariesWin32(void) { if (!GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, @@ -83,7 +83,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, @@ -106,7 +106,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) @@ -127,7 +127,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) @@ -140,7 +140,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) @@ -153,7 +153,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) @@ -162,7 +162,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) @@ -174,7 +174,7 @@ static GLFWbool loadLibraries(void) // Unload used libraries (DLLs) // -static void freeLibraries(void) +static void _glfwFreeLibrariesWin32(void) { if (_glfw.win32.xinput.instance) _glfwPlatformFreeModule(_glfw.win32.xinput.instance); @@ -197,7 +197,7 @@ static void freeLibraries(void) // Create key code translation tables // -static void createKeyTables(void) +static void _glfwCreateKeyTablesWin32(void) { int scancode; @@ -335,7 +335,7 @@ static void createKeyTables(void) // Window procedure for the hidden helper window // -static LRESULT CALLBACK helperWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +static LRESULT CALLBACK _glfwHelperWindowProcWin32(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { @@ -370,13 +370,13 @@ static LRESULT CALLBACK helperWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LP // Creates a dummy window for behind-the-scenes work // -static GLFWbool createHelperWindow(void) +static GLFWbool _glfwCreateHelperWindowWin32(void) { MSG msg; WNDCLASSEXW wc = { sizeof(wc) }; wc.style = CS_OWNDC; - wc.lpfnWndProc = (WNDPROC) helperWindowProc; + wc.lpfnWndProc = (WNDPROC) _glfwHelperWindowProcWin32; wc.hInstance = _glfw.win32.instance; wc.lpszClassName = L"GLFW3 Helper"; @@ -415,7 +415,7 @@ static GLFWbool createHelperWindow(void) ZeroMemory(&dbi, sizeof(dbi)); dbi.dbcc_size = sizeof(dbi); dbi.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE; - dbi.dbcc_classguid = GUID_DEVINTERFACE_HID; + dbi.dbcc_classguid = _GLFW_GUID_DEVINTERFACE_HID; _glfw.win32.deviceNotificationHandle = RegisterDeviceNotificationW(_glfw.win32.helperWindowHandle, @@ -452,7 +452,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)) { @@ -480,7 +480,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)) { @@ -685,10 +685,10 @@ GLFWbool _glfwConnectWin32(int platformID, _GLFWplatform* platform) int _glfwInitWin32(void) { - if (!loadLibraries()) + if (!_glfwLoadLibrariesWin32()) return GLFW_FALSE; - createKeyTables(); + _glfwCreateKeyTablesWin32(); _glfwUpdateKeyNamesWin32(); if (_glfwIsWindows10Version1703OrGreaterWin32()) @@ -698,7 +698,7 @@ int _glfwInitWin32(void) else if (IsWindowsVistaOrGreater()) SetProcessDPIAware(); - if (!createHelperWindow()) + if (!_glfwCreateHelperWindowWin32()) return GLFW_FALSE; _glfwPollMonitorsWin32(); @@ -724,7 +724,7 @@ void _glfwTerminateWin32(void) _glfwTerminateEGL(); _glfwTerminateOSMesa(); - freeLibraries(); + _glfwFreeLibrariesWin32(); } #endif // _GLFW_WIN32 diff --git a/src/win32_joystick.c b/src/win32_joystick.c index eae44edf..612c1bb1 100644 --- a/src/win32_joystick.c +++ b/src/win32_joystick.c @@ -148,7 +148,7 @@ static const DIDATAFORMAT _glfwDataFormat = // Returns a description fitting the specified XInput capabilities // -static const char* getDeviceDescription(const XINPUT_CAPABILITIES* xic) +static const char* _glfwGetDeviceDescriptionWin32(const XINPUT_CAPABILITIES* xic) { switch (xic->SubType) { @@ -178,10 +178,10 @@ static const char* getDeviceDescription(const XINPUT_CAPABILITIES* xic) // Lexically compare device objects // -static int compareJoystickObjects(const void* first, const void* second) +static int _glfwCompareJoystickObjectsWin32(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; @@ -192,7 +192,7 @@ static int compareJoystickObjects(const void* first, const void* second) // Checks whether the specified device supports XInput // Technique from FDInputJoystickManager::IsXInputDeviceFast in ZDoom // -static GLFWbool supportsXInput(const GUID* guid) +static GLFWbool _glfwSupportsXInputWin32(const GUID* guid) { UINT i, count = 0; RAWINPUTDEVICELIST* ridl; @@ -201,7 +201,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) { @@ -256,7 +256,7 @@ static GLFWbool supportsXInput(const GUID* guid) // Frees all resources associated with the specified joystick // -static void closeJoystick(_GLFWjoystick* js) +static void _glfwCloseJoystickWin32(_GLFWjoystick* js) { _glfwInputJoystick(js, GLFW_DISCONNECTED); @@ -273,10 +273,10 @@ static void closeJoystick(_GLFWjoystick* js) // DirectInput device object enumeration callback // Insights gleaned from SDL // -static BOOL CALLBACK deviceObjectCallback(const DIDEVICEOBJECTINSTANCEW* doi, - void* user) +static BOOL CALLBACK _glfwDeviceObjectCallbackWin32(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) @@ -343,9 +343,19 @@ static BOOL CALLBACK deviceObjectCallback(const DIDEVICEOBJECTINSTANCEW* doi, return DIENUM_CONTINUE; } +#ifdef __cplusplus + + #define _glfwRef(p) *p + +#else + + #define _glfwRef(p) p + +#endif + // DirectInput device enumeration callback // -static BOOL CALLBACK deviceCallback(const DIDEVICEINSTANCE* di, void* user) +static BOOL CALLBACK _glfwDeviceCallbackWin32(const DIDEVICEINSTANCE* di, void* user) { int jid = 0; DIDEVCAPS dc; @@ -366,11 +376,11 @@ static BOOL CALLBACK deviceCallback(const DIDEVICEINSTANCE* di, void* user) } } - if (supportsXInput(&di->guidProduct)) + if (_glfwSupportsXInputWin32(&di->guidProduct)) return DIENUM_CONTINUE; if (FAILED(IDirectInput8_CreateDevice(_glfw.win32.dinput8.api, - &di->guidInstance, + _glfwRef(&di->guidInstance), &device, NULL))) { @@ -418,11 +428,13 @@ 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, - sizeof(_GLFWjoyobjectWin32)); + data.objects = + (_GLFWjoyobjectWin32*) + _glfw_calloc(dc.dwAxes + (size_t) dc.dwButtons + dc.dwPOVs, + sizeof(_GLFWjoyobjectWin32)); if (FAILED(IDirectInputDevice8_EnumObjects(device, - deviceObjectCallback, + _glfwDeviceObjectCallbackWin32, &data, DIDFT_AXIS | DIDFT_BUTTON | DIDFT_POV))) { @@ -436,7 +448,7 @@ static BOOL CALLBACK deviceCallback(const DIDEVICEINSTANCE* di, void* user) qsort(data.objects, data.objectCount, sizeof(_GLFWjoyobjectWin32), - compareJoystickObjects); + _glfwCompareJoystickObjectsWin32); if (!WideCharToMultiByte(CP_UTF8, 0, di->tszInstanceName, -1, @@ -528,7 +540,7 @@ void _glfwDetectJoystickConnectionWin32(void) sprintf(guid, "78696e707574%02x000000000000000000", xic.SubType & 0xff); - js = _glfwAllocJoystick(getDeviceDescription(&xic), guid, 6, 10, 1); + js = _glfwAllocJoystick(_glfwGetDeviceDescriptionWin32(&xic), guid, 6, 10, 1); if (!js) continue; @@ -542,7 +554,7 @@ void _glfwDetectJoystickConnectionWin32(void) { if (FAILED(IDirectInput8_EnumDevices(_glfw.win32.dinput8.api, DI8DEVCLASS_GAMECTRL, - deviceCallback, + _glfwDeviceCallbackWin32, NULL, DIEDFL_ALLDEVICES))) { @@ -578,7 +590,7 @@ GLFWbool _glfwInitJoysticksWin32(void) { if (FAILED(DirectInput8Create(_glfw.win32.instance, DIRECTINPUT_VERSION, - &IID_IDirectInput8W, + _glfwRef(&IID_IDirectInput8W), (void**) &_glfw.win32.dinput8.api, NULL))) { @@ -597,7 +609,7 @@ void _glfwTerminateJoysticksWin32(void) int jid; for (jid = GLFW_JOYSTICK_1; jid <= GLFW_JOYSTICK_LAST; jid++) - closeJoystick(_glfw.joysticks + jid); + _glfwCloseJoystickWin32(_glfw.joysticks + jid); if (_glfw.win32.dinput8.api) IDirectInput8_Release(_glfw.win32.dinput8.api); @@ -626,7 +638,7 @@ GLFWbool _glfwPollJoystickWin32(_GLFWjoystick* js, int mode) if (FAILED(result)) { - closeJoystick(js); + _glfwCloseJoystickWin32(js); return GLFW_FALSE; } @@ -706,7 +718,7 @@ GLFWbool _glfwPollJoystickWin32(_GLFWjoystick* js, int mode) if (result != ERROR_SUCCESS) { if (result == ERROR_DEVICE_NOT_CONNECTED) - closeJoystick(js); + _glfwCloseJoystickWin32(js); return GLFW_FALSE; } diff --git a/src/win32_monitor.c b/src/win32_monitor.c index 2935ac28..18c4fe07 100644 --- a/src/win32_monitor.c +++ b/src/win32_monitor.c @@ -37,12 +37,12 @@ #include -// Callback for EnumDisplayMonitors in createMonitor +// Callback for EnumDisplayMonitors in _glfwCreateMonitorWin32 // -static BOOL CALLBACK monitorCallback(HMONITOR handle, - HDC dc, - RECT* rect, - LPARAM data) +static BOOL CALLBACK _glfwMonitorCallbackWin32(HMONITOR handle, + HDC dc, + RECT* rect, + LPARAM data) { MONITORINFOEXW mi; ZeroMemory(&mi, sizeof(mi)); @@ -60,8 +60,8 @@ static BOOL CALLBACK monitorCallback(HMONITOR handle, // Create monitor from an adapter and (optionally) a display // -static _GLFWmonitor* createMonitor(DISPLAY_DEVICEW* adapter, - DISPLAY_DEVICEW* display) +static _GLFWmonitor* _glfwCreateMonitorWin32(DISPLAY_DEVICEW* adapter, + DISPLAY_DEVICEW* display) { _GLFWmonitor* monitor; int widthMM, heightMM; @@ -124,7 +124,7 @@ static _GLFWmonitor* createMonitor(DISPLAY_DEVICEW* adapter, rect.right = dm.dmPosition.x + dm.dmPelsWidth; rect.bottom = dm.dmPosition.y + dm.dmPelsHeight; - EnumDisplayMonitors(NULL, &rect, monitorCallback, (LPARAM) monitor); + EnumDisplayMonitors(NULL, &rect, _glfwMonitorCallbackWin32, (LPARAM) monitor); return monitor; } @@ -146,7 +146,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*)); @@ -187,7 +187,7 @@ void _glfwPollMonitorsWin32(void) { disconnected[i] = NULL; // handle may have changed, update - EnumDisplayMonitors(NULL, NULL, monitorCallback, (LPARAM) _glfw.monitors[i]); + EnumDisplayMonitors(NULL, NULL, _glfwMonitorCallbackWin32, (LPARAM) _glfw.monitors[i]); break; } } @@ -195,7 +195,7 @@ void _glfwPollMonitorsWin32(void) if (i < disconnectedCount) continue; - monitor = createMonitor(&adapter, &display); + monitor = _glfwCreateMonitorWin32(&adapter, &display); if (!monitor) { _glfw_free(disconnected); @@ -225,7 +225,7 @@ void _glfwPollMonitorsWin32(void) if (i < disconnectedCount) continue; - monitor = createMonitor(&adapter, NULL); + monitor = _glfwCreateMonitorWin32(&adapter, NULL); if (!monitor) { _glfw_free(disconnected); @@ -464,7 +464,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; } diff --git a/src/win32_window.c b/src/win32_window.c index a4a18171..2a2ce0ff 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -39,7 +39,7 @@ // Returns the window style for the specified window // -static DWORD getWindowStyle(const _GLFWwindow* window) +static DWORD _glfwGetWindowStyleWin32(const _GLFWwindow* window) { DWORD style = WS_CLIPSIBLINGS | WS_CLIPCHILDREN; @@ -65,7 +65,7 @@ static DWORD getWindowStyle(const _GLFWwindow* window) // Returns the extended window style for the specified window // -static DWORD getWindowExStyle(const _GLFWwindow* window) +static DWORD _glfwGetWindowExStyleWin32(const _GLFWwindow* window) { DWORD style = WS_EX_APPWINDOW; @@ -77,7 +77,7 @@ static DWORD getWindowExStyle(const _GLFWwindow* window) // Returns the image whose area most closely matches the desired one // -static const GLFWimage* chooseImage(int count, const GLFWimage* images, +static const GLFWimage* _glfwChooseImageWin32(int count, const GLFWimage* images, int width, int height) { int i, leastDiff = INT_MAX; @@ -99,7 +99,7 @@ static const GLFWimage* chooseImage(int count, const GLFWimage* images, // Creates an RGBA icon or cursor // -static HICON createIcon(const GLFWimage* image, int xhot, int yhot, GLFWbool icon) +static HICON _glfwCreateIconWin32(const GLFWimage* image, int xhot, int yhot, GLFWbool icon) { int i; HDC dc; @@ -188,12 +188,12 @@ static HICON createIcon(const GLFWimage* image, int xhot, int yhot, GLFWbool ico // Enforce the content area aspect ratio based on which edge is being dragged // -static void applyAspectRatio(_GLFWwindow* window, int edge, RECT* area) +static void _glfwApplyAspectRatioWin32(_GLFWwindow* window, int edge, RECT* area) { RECT frame = {0}; const float ratio = (float) window->numer / (float) window->denom; - const DWORD style = getWindowStyle(window); - const DWORD exStyle = getWindowExStyle(window); + const DWORD style = _glfwGetWindowStyleWin32(window); + const DWORD exStyle = _glfwGetWindowExStyleWin32(window); if (_glfwIsWindows10Version1607OrGreaterWin32()) { @@ -223,7 +223,7 @@ static void applyAspectRatio(_GLFWwindow* window, int edge, RECT* area) // Updates the cursor image according to its cursor mode // -static void updateCursorImage(_GLFWwindow* window) +static void _glfwUpdateCursorImageWin32(_GLFWwindow* window) { if (window->cursorMode == GLFW_CURSOR_NORMAL || window->cursorMode == GLFW_CURSOR_CAPTURED) @@ -239,7 +239,7 @@ static void updateCursorImage(_GLFWwindow* window) // Sets the cursor clip rect to the window content area // -static void captureCursor(_GLFWwindow* window) +static void _glfwCaptureCursorWin32(_GLFWwindow* window) { RECT clipRect; GetClientRect(window->win32.handle, &clipRect); @@ -251,7 +251,7 @@ static void captureCursor(_GLFWwindow* window) // Disabled clip cursor // -static void releaseCursor(void) +static void _glfwReleaseCursorWin32(void) { ClipCursor(NULL); _glfw.win32.capturedCursorWindow = NULL; @@ -259,7 +259,7 @@ static void releaseCursor(void) // Enables WM_INPUT messages for the mouse for the specified window // -static void enableRawMouseMotion(_GLFWwindow* window) +static void _glfwEnableRawMouseMotionWin32(_GLFWwindow* window) { const RAWINPUTDEVICE rid = { 0x01, 0x02, 0, window->win32.handle }; @@ -272,7 +272,7 @@ static void enableRawMouseMotion(_GLFWwindow* window) // Disables WM_INPUT messages for the mouse // -static void disableRawMouseMotion(_GLFWwindow* window) +static void _glfwDisableRawMouseMotionWin32(_GLFWwindow* window) { const RAWINPUTDEVICE rid = { 0x01, 0x02, RIDEV_REMOVE, NULL }; @@ -285,38 +285,38 @@ static void disableRawMouseMotion(_GLFWwindow* window) // Apply disabled cursor mode to a focused window // -static void disableCursor(_GLFWwindow* window) +static void _glfwDisableCursorWin32(_GLFWwindow* window) { _glfw.win32.disabledCursorWindow = window; _glfwGetCursorPosWin32(window, &_glfw.win32.restoreCursorPosX, &_glfw.win32.restoreCursorPosY); - updateCursorImage(window); + _glfwUpdateCursorImageWin32(window); _glfwCenterCursorInContentArea(window); - captureCursor(window); + _glfwCaptureCursorWin32(window); if (window->rawMouseMotion) - enableRawMouseMotion(window); + _glfwEnableRawMouseMotionWin32(window); } // Exit disabled cursor mode for the specified window // -static void enableCursor(_GLFWwindow* window) +static void _glfwEnableCursorWin32(_GLFWwindow* window) { if (window->rawMouseMotion) - disableRawMouseMotion(window); + _glfwDisableRawMouseMotionWin32(window); _glfw.win32.disabledCursorWindow = NULL; - releaseCursor(); + _glfwReleaseCursorWin32(); _glfwSetCursorPosWin32(window, _glfw.win32.restoreCursorPosX, _glfw.win32.restoreCursorPosY); - updateCursorImage(window); + _glfwUpdateCursorImageWin32(window); } // Returns whether the cursor is in the content area of the specified window // -static GLFWbool cursorInContentArea(_GLFWwindow* window) +static GLFWbool _glfwCursorInContentAreaWin32(_GLFWwindow* window) { RECT area; POINT pos; @@ -336,23 +336,23 @@ static GLFWbool cursorInContentArea(_GLFWwindow* window) // Update native window styles to match attributes // -static void updateWindowStyles(const _GLFWwindow* window) +static void _glfwUpdateWindowStylesWin32(const _GLFWwindow* window) { RECT rect; DWORD style = GetWindowLongW(window->win32.handle, GWL_STYLE); style &= ~(WS_OVERLAPPEDWINDOW | WS_POPUP); - style |= getWindowStyle(window); + style |= _glfwGetWindowStyleWin32(window); GetClientRect(window->win32.handle, &rect); if (_glfwIsWindows10Version1607OrGreaterWin32()) { AdjustWindowRectExForDpi(&rect, style, FALSE, - getWindowExStyle(window), + _glfwGetWindowExStyleWin32(window), GetDpiForWindow(window->win32.handle)); } else - AdjustWindowRectEx(&rect, style, FALSE, getWindowExStyle(window)); + AdjustWindowRectEx(&rect, style, FALSE, _glfwGetWindowExStyleWin32(window)); ClientToScreen(window->win32.handle, (POINT*) &rect.left); ClientToScreen(window->win32.handle, (POINT*) &rect.right); @@ -365,7 +365,7 @@ static void updateWindowStyles(const _GLFWwindow* window) // Update window framebuffer transparency // -static void updateFramebufferTransparency(const _GLFWwindow* window) +static void _glfwUpdateFramebufferTransparencyWin32(const _GLFWwindow* window) { BOOL composition, opaque; DWORD color; @@ -402,7 +402,7 @@ static void updateFramebufferTransparency(const _GLFWwindow* window) // Retrieves and translates modifier keys // -static int getKeyMods(void) +static int _glfwGetKeyModsWin32(void) { int mods = 0; @@ -422,7 +422,7 @@ static int getKeyMods(void) return mods; } -static void fitToMonitor(_GLFWwindow* window) +static void _glfwFitToMonitorWin32(_GLFWwindow* window) { MONITORINFO mi = { sizeof(mi) }; GetMonitorInfoW(window->monitor->win32.handle, &mi); @@ -436,7 +436,7 @@ static void fitToMonitor(_GLFWwindow* window) // Make the specified window and its video mode active on its monitor // -static void acquireMonitor(_GLFWwindow* window) +static void _glfwAcquireMonitorWin32(_GLFWwindow* window) { if (!_glfw.win32.acquiredMonitorCount) { @@ -457,7 +457,7 @@ static void acquireMonitor(_GLFWwindow* window) // Remove the window and restore the original video mode // -static void releaseMonitor(_GLFWwindow* window) +static void _glfwReleaseMonitorWin32(_GLFWwindow* window) { if (window->monitor->window != window) return; @@ -467,7 +467,7 @@ static void releaseMonitor(_GLFWwindow* window) { SetThreadExecutionState(ES_CONTINUOUS); - // HACK: Restore mouse trail length saved in acquireMonitor + // HACK: Restore mouse trail length saved in _glfwAcquireMonitorWin32 SystemParametersInfoW(SPI_SETMOUSETRAILS, _glfw.win32.mouseTrailSize, 0, 0); } @@ -477,7 +477,7 @@ static void releaseMonitor(_GLFWwindow* window) // Manually maximize the window, for when SW_MAXIMIZE cannot be used // -static void maximizeWindowManually(_GLFWwindow* window) +static void _glfwMaximizeWindowManuallyWin32(_GLFWwindow* window) { RECT rect; DWORD style; @@ -527,9 +527,9 @@ static void maximizeWindowManually(_GLFWwindow* window) // Window procedure for user-created windows // -static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +static LRESULT CALLBACK _glfwWindowProcWin32(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) @@ -537,7 +537,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 @@ -573,9 +573,9 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l if (lParam == 0 && window->win32.frameAction) { if (window->cursorMode == GLFW_CURSOR_DISABLED) - disableCursor(window); + _glfwDisableCursorWin32(window); else if (window->cursorMode == GLFW_CURSOR_CAPTURED) - captureCursor(window); + _glfwCaptureCursorWin32(window); window->win32.frameAction = GLFW_FALSE; } @@ -593,9 +593,9 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l break; if (window->cursorMode == GLFW_CURSOR_DISABLED) - disableCursor(window); + _glfwDisableCursorWin32(window); else if (window->cursorMode == GLFW_CURSOR_CAPTURED) - captureCursor(window); + _glfwCaptureCursorWin32(window); return 0; } @@ -603,9 +603,9 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l case WM_KILLFOCUS: { if (window->cursorMode == GLFW_CURSOR_DISABLED) - enableCursor(window); + _glfwEnableCursorWin32(window); else if (window->cursorMode == GLFW_CURSOR_CAPTURED) - releaseCursor(); + _glfwReleaseCursorWin32(); if (window->monitor && window->autoIconify) _glfwIconifyWindowWin32(window); @@ -677,7 +677,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l codepoint = (WCHAR) wParam; window->win32.highSurrogate = 0; - _glfwInputChar(window, codepoint, getKeyMods(), uMsg != WM_SYSCHAR); + _glfwInputChar(window, codepoint, _glfwGetKeyModsWin32(), uMsg != WM_SYSCHAR); } if (uMsg == WM_SYSCHAR && window->win32.keymenu) @@ -696,7 +696,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l return TRUE; } - _glfwInputChar(window, (uint32_t) wParam, getKeyMods(), GLFW_TRUE); + _glfwInputChar(window, (uint32_t) wParam, _glfwGetKeyModsWin32(), GLFW_TRUE); return 0; } @@ -707,7 +707,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l { int key, scancode; const int action = (HIWORD(lParam) & KF_UP) ? GLFW_RELEASE : GLFW_PRESS; - const int mods = getKeyMods(); + const int mods = _glfwGetKeyModsWin32(); scancode = (HIWORD(lParam) & (KF_EXTENDED | 0xff)); if (!scancode) @@ -835,7 +835,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l if (i > GLFW_MOUSE_BUTTON_LAST) SetCapture(hWnd); - _glfwInputMouseClick(window, button, action, getKeyMods()); + _glfwInputMouseClick(window, button, action, _glfwGetKeyModsWin32()); for (i = 0; i <= GLFW_MOUSE_BUTTON_LAST; i++) { @@ -909,7 +909,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; } @@ -974,9 +974,9 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l // HACK: Enable the cursor while the user is moving or // resizing the window or using the window menu if (window->cursorMode == GLFW_CURSOR_DISABLED) - enableCursor(window); + _glfwEnableCursorWin32(window); else if (window->cursorMode == GLFW_CURSOR_CAPTURED) - releaseCursor(); + _glfwReleaseCursorWin32(); break; } @@ -990,9 +990,9 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l // HACK: Disable the cursor once the user is done moving or // resizing the window or using the menu if (window->cursorMode == GLFW_CURSOR_DISABLED) - disableCursor(window); + _glfwDisableCursorWin32(window); else if (window->cursorMode == GLFW_CURSOR_CAPTURED) - captureCursor(window); + _glfwCaptureCursorWin32(window); break; } @@ -1007,7 +1007,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l wParam != SIZE_RESTORED); if (_glfw.win32.capturedCursorWindow == window) - captureCursor(window); + _glfwCaptureCursorWin32(window); if (window->win32.iconified != iconified) _glfwInputWindowIconify(window, iconified); @@ -1027,11 +1027,11 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l if (window->monitor && window->win32.iconified != iconified) { if (iconified) - releaseMonitor(window); + _glfwReleaseMonitorWin32(window); else { - acquireMonitor(window); - fitToMonitor(window); + _glfwAcquireMonitorWin32(window); + _glfwFitToMonitorWin32(window); } } @@ -1043,7 +1043,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l case WM_MOVE: { if (_glfw.win32.capturedCursorWindow == window) - captureCursor(window); + _glfwCaptureCursorWin32(window); // NOTE: This cannot use LOWORD/HIWORD recommended by MSDN, as // those macros do not handle negative window positions correctly @@ -1061,7 +1061,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l break; } - applyAspectRatio(window, (int) wParam, (RECT*) lParam); + _glfwApplyAspectRatioWin32(window, (int) wParam, (RECT*) lParam); return TRUE; } @@ -1069,8 +1069,8 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l { RECT frame = {0}; MINMAXINFO* mmi = (MINMAXINFO*) lParam; - const DWORD style = getWindowStyle(window); - const DWORD exStyle = getWindowExStyle(window); + const DWORD style = _glfwGetWindowStyleWin32(window); + const DWORD exStyle = _glfwGetWindowExStyleWin32(window); if (window->monitor) break; @@ -1142,7 +1142,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l case WM_DWMCOLORIZATIONCOLORCHANGED: { if (window->win32.transparent) - updateFramebufferTransparency(window); + _glfwUpdateFramebufferTransparencyWin32(window); return 0; } @@ -1157,11 +1157,11 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l RECT source = {0}, target = {0}; SIZE* size = (SIZE*) lParam; - AdjustWindowRectExForDpi(&source, getWindowStyle(window), - FALSE, getWindowExStyle(window), + AdjustWindowRectExForDpi(&source, _glfwGetWindowStyleWin32(window), + FALSE, _glfwGetWindowExStyleWin32(window), GetDpiForWindow(window->win32.handle)); - AdjustWindowRectExForDpi(&target, getWindowStyle(window), - FALSE, getWindowExStyle(window), + AdjustWindowRectExForDpi(&target, _glfwGetWindowStyleWin32(window), + FALSE, _glfwGetWindowExStyleWin32(window), LOWORD(wParam)); size->cx += (target.right - target.left) - @@ -1202,7 +1202,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l { if (LOWORD(lParam) == HTCLIENT) { - updateCursorImage(window); + _glfwUpdateCursorImageWin32(window); return TRUE; } @@ -1216,7 +1216,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); @@ -1225,7 +1225,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); @@ -1249,20 +1249,20 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l // Creates the GLFW window // -static int createNativeWindow(_GLFWwindow* window, - const _GLFWwndconfig* wndconfig, - const _GLFWfbconfig* fbconfig) +static int _glfwCreateNativeWindowWin32(_GLFWwindow* window, + const _GLFWwndconfig* wndconfig, + const _GLFWfbconfig* fbconfig) { int frameX, frameY, frameWidth, frameHeight; WCHAR* wideTitle; - DWORD style = getWindowStyle(window); - DWORD exStyle = getWindowExStyle(window); + DWORD style = _glfwGetWindowStyleWin32(window); + DWORD exStyle = _glfwGetWindowExStyleWin32(window); if (!_glfw.win32.mainWindowClass) { WNDCLASSEXW wc = { sizeof(wc) }; wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; - wc.lpfnWndProc = windowProc; + wc.lpfnWndProc = _glfwWindowProcWin32; wc.hInstance = _glfw.win32.instance; wc.hCursor = LoadCursorW(NULL, IDC_ARROW); #if defined(_GLFW_WNDCLASSNAME) @@ -1271,15 +1271,15 @@ static int createNativeWindow(_GLFWwindow* window, wc.lpszClassName = L"GLFW30"; #endif // Load user-provided icon if available - wc.hIcon = LoadImageW(GetModuleHandleW(NULL), - L"GLFW_ICON", IMAGE_ICON, - 0, 0, LR_DEFAULTSIZE | LR_SHARED); + 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, - IDI_APPLICATION, IMAGE_ICON, - 0, 0, LR_DEFAULTSIZE | LR_SHARED); + wc.hIcon = (HICON) LoadImageW(NULL, + IDI_APPLICATION, IMAGE_ICON, + 0, 0, LR_DEFAULTSIZE | LR_SHARED); } _glfw.win32.mainWindowClass = RegisterClassExW(&wc); @@ -1430,7 +1430,7 @@ static int createNativeWindow(_GLFWwindow* window, if (fbconfig->transparent) { - updateFramebufferTransparency(window); + _glfwUpdateFramebufferTransparencyWin32(window); window->win32.transparent = GLFW_TRUE; } @@ -1444,7 +1444,7 @@ GLFWbool _glfwCreateWindowWin32(_GLFWwindow* window, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig) { - if (!createNativeWindow(window, wndconfig, fbconfig)) + if (!_glfwCreateNativeWindowWin32(window, wndconfig, fbconfig)) return GLFW_FALSE; if (ctxconfig->client != GLFW_NO_API) @@ -1482,8 +1482,8 @@ GLFWbool _glfwCreateWindowWin32(_GLFWwindow* window, { _glfwShowWindowWin32(window); _glfwFocusWindowWin32(window); - acquireMonitor(window); - fitToMonitor(window); + _glfwAcquireMonitorWin32(window); + _glfwFitToMonitorWin32(window); if (wndconfig->centerCursor) _glfwCenterCursorInContentArea(window); @@ -1504,16 +1504,16 @@ GLFWbool _glfwCreateWindowWin32(_GLFWwindow* window, void _glfwDestroyWindowWin32(_GLFWwindow* window) { if (window->monitor) - releaseMonitor(window); + _glfwReleaseMonitorWin32(window); if (window->context.destroy) window->context.destroy(window); if (_glfw.win32.disabledCursorWindow == window) - enableCursor(window); + _glfwEnableCursorWin32(window); if (_glfw.win32.capturedCursorWindow == window) - releaseCursor(); + _glfwReleaseCursorWin32(); if (window->win32.handle) { @@ -1545,15 +1545,15 @@ void _glfwSetWindowIconWin32(_GLFWwindow* window, int count, const GLFWimage* im if (count) { - const GLFWimage* bigImage = chooseImage(count, images, + const GLFWimage* bigImage = _glfwChooseImageWin32(count, images, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON)); - const GLFWimage* smallImage = chooseImage(count, images, + const GLFWimage* smallImage = _glfwChooseImageWin32(count, images, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON)); - bigIcon = createIcon(bigImage, 0, 0, GLFW_TRUE); - smallIcon = createIcon(smallImage, 0, 0, GLFW_TRUE); + bigIcon = _glfwCreateIconWin32(bigImage, 0, 0, GLFW_TRUE); + smallIcon = _glfwCreateIconWin32(smallImage, 0, 0, GLFW_TRUE); } else { @@ -1594,14 +1594,14 @@ void _glfwSetWindowPosWin32(_GLFWwindow* window, int xpos, int ypos) if (_glfwIsWindows10Version1607OrGreaterWin32()) { - AdjustWindowRectExForDpi(&rect, getWindowStyle(window), - FALSE, getWindowExStyle(window), + AdjustWindowRectExForDpi(&rect, _glfwGetWindowStyleWin32(window), + FALSE, _glfwGetWindowExStyleWin32(window), GetDpiForWindow(window->win32.handle)); } else { - AdjustWindowRectEx(&rect, getWindowStyle(window), - FALSE, getWindowExStyle(window)); + AdjustWindowRectEx(&rect, _glfwGetWindowStyleWin32(window), + FALSE, _glfwGetWindowExStyleWin32(window)); } SetWindowPos(window->win32.handle, NULL, rect.left, rect.top, 0, 0, @@ -1625,8 +1625,8 @@ void _glfwSetWindowSizeWin32(_GLFWwindow* window, int width, int height) { if (window->monitor->window == window) { - acquireMonitor(window); - fitToMonitor(window); + _glfwAcquireMonitorWin32(window); + _glfwFitToMonitorWin32(window); } } else @@ -1635,14 +1635,14 @@ void _glfwSetWindowSizeWin32(_GLFWwindow* window, int width, int height) if (_glfwIsWindows10Version1607OrGreaterWin32()) { - AdjustWindowRectExForDpi(&rect, getWindowStyle(window), - FALSE, getWindowExStyle(window), + AdjustWindowRectExForDpi(&rect, _glfwGetWindowStyleWin32(window), + FALSE, _glfwGetWindowExStyleWin32(window), GetDpiForWindow(window->win32.handle)); } else { - AdjustWindowRectEx(&rect, getWindowStyle(window), - FALSE, getWindowExStyle(window)); + AdjustWindowRectEx(&rect, _glfwGetWindowStyleWin32(window), + FALSE, _glfwGetWindowExStyleWin32(window)); } SetWindowPos(window->win32.handle, HWND_TOP, @@ -1678,7 +1678,7 @@ void _glfwSetWindowAspectRatioWin32(_GLFWwindow* window, int numer, int denom) return; GetWindowRect(window->win32.handle, &area); - applyAspectRatio(window, WMSZ_BOTTOMRIGHT, &area); + _glfwApplyAspectRatioWin32(window, WMSZ_BOTTOMRIGHT, &area); MoveWindow(window->win32.handle, area.left, area.top, area.right - area.left, @@ -1702,14 +1702,14 @@ void _glfwGetWindowFrameSizeWin32(_GLFWwindow* window, if (_glfwIsWindows10Version1607OrGreaterWin32()) { - AdjustWindowRectExForDpi(&rect, getWindowStyle(window), - FALSE, getWindowExStyle(window), + AdjustWindowRectExForDpi(&rect, _glfwGetWindowStyleWin32(window), + FALSE, _glfwGetWindowExStyleWin32(window), GetDpiForWindow(window->win32.handle)); } else { - AdjustWindowRectEx(&rect, getWindowStyle(window), - FALSE, getWindowExStyle(window)); + AdjustWindowRectEx(&rect, _glfwGetWindowStyleWin32(window), + FALSE, _glfwGetWindowExStyleWin32(window)); } if (left) @@ -1726,7 +1726,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) @@ -1744,7 +1744,7 @@ void _glfwMaximizeWindowWin32(_GLFWwindow* window) if (IsWindowVisible(window->win32.handle)) ShowWindow(window->win32.handle, SW_MAXIMIZE); else - maximizeWindowManually(window); + _glfwMaximizeWindowManuallyWin32(window); } void _glfwShowWindowWin32(_GLFWwindow* window) @@ -1781,8 +1781,8 @@ void _glfwSetWindowMonitorWin32(_GLFWwindow* window, { if (monitor->window == window) { - acquireMonitor(window); - fitToMonitor(window); + _glfwAcquireMonitorWin32(window); + _glfwFitToMonitorWin32(window); } } else @@ -1791,14 +1791,14 @@ void _glfwSetWindowMonitorWin32(_GLFWwindow* window, if (_glfwIsWindows10Version1607OrGreaterWin32()) { - AdjustWindowRectExForDpi(&rect, getWindowStyle(window), - FALSE, getWindowExStyle(window), + AdjustWindowRectExForDpi(&rect, _glfwGetWindowStyleWin32(window), + FALSE, _glfwGetWindowExStyleWin32(window), GetDpiForWindow(window->win32.handle)); } else { - AdjustWindowRectEx(&rect, getWindowStyle(window), - FALSE, getWindowExStyle(window)); + AdjustWindowRectEx(&rect, _glfwGetWindowStyleWin32(window), + FALSE, _glfwGetWindowExStyleWin32(window)); } SetWindowPos(window->win32.handle, HWND_TOP, @@ -1811,7 +1811,7 @@ void _glfwSetWindowMonitorWin32(_GLFWwindow* window, } if (window->monitor) - releaseMonitor(window); + _glfwReleaseMonitorWin32(window); _glfwInputWindowMonitor(window, monitor); @@ -1824,12 +1824,12 @@ void _glfwSetWindowMonitorWin32(_GLFWwindow* window, { DWORD style = GetWindowLongW(window->win32.handle, GWL_STYLE); style &= ~WS_OVERLAPPEDWINDOW; - style |= getWindowStyle(window); + style |= _glfwGetWindowStyleWin32(window); SetWindowLongW(window->win32.handle, GWL_STYLE, style); flags |= SWP_FRAMECHANGED; } - acquireMonitor(window); + _glfwAcquireMonitorWin32(window); GetMonitorInfoW(window->monitor->win32.handle, &mi); SetWindowPos(window->win32.handle, HWND_TOPMOST, @@ -1849,7 +1849,7 @@ void _glfwSetWindowMonitorWin32(_GLFWwindow* window, if (window->decorated) { style &= ~WS_POPUP; - style |= getWindowStyle(window); + style |= _glfwGetWindowStyleWin32(window); SetWindowLongW(window->win32.handle, GWL_STYLE, style); flags |= SWP_FRAMECHANGED; @@ -1862,14 +1862,14 @@ void _glfwSetWindowMonitorWin32(_GLFWwindow* window, if (_glfwIsWindows10Version1607OrGreaterWin32()) { - AdjustWindowRectExForDpi(&rect, getWindowStyle(window), - FALSE, getWindowExStyle(window), + AdjustWindowRectExForDpi(&rect, _glfwGetWindowStyleWin32(window), + FALSE, _glfwGetWindowExStyleWin32(window), GetDpiForWindow(window->win32.handle)); } else { - AdjustWindowRectEx(&rect, getWindowStyle(window), - FALSE, getWindowExStyle(window)); + AdjustWindowRectEx(&rect, _glfwGetWindowStyleWin32(window), + FALSE, _glfwGetWindowExStyleWin32(window)); } SetWindowPos(window->win32.handle, after, @@ -1901,7 +1901,7 @@ GLFWbool _glfwWindowMaximizedWin32(_GLFWwindow* window) GLFWbool _glfwWindowHoveredWin32(_GLFWwindow* window) { - return cursorInContentArea(window); + return _glfwCursorInContentAreaWin32(window); } GLFWbool _glfwFramebufferTransparentWin32(_GLFWwindow* window) @@ -1933,12 +1933,12 @@ GLFWbool _glfwFramebufferTransparentWin32(_GLFWwindow* window) void _glfwSetWindowResizableWin32(_GLFWwindow* window, GLFWbool enabled) { - updateWindowStyles(window); + _glfwUpdateWindowStylesWin32(window); } void _glfwSetWindowDecoratedWin32(_GLFWwindow* window, GLFWbool enabled) { - updateWindowStyles(window); + _glfwUpdateWindowStylesWin32(window); } void _glfwSetWindowFloatingWin32(_GLFWwindow* window, GLFWbool enabled) @@ -2020,9 +2020,9 @@ void _glfwSetRawMouseMotionWin32(_GLFWwindow *window, GLFWbool enabled) return; if (enabled) - enableRawMouseMotion(window); + _glfwEnableRawMouseMotionWin32(window); else - disableRawMouseMotion(window); + _glfwDisableRawMouseMotionWin32(window); } GLFWbool _glfwRawMouseMotionSupportedWin32(void) @@ -2064,11 +2064,11 @@ void _glfwPollEventsWin32(void) // NOTE: Windows key is not reported as released by the Win+V hotkey // Other Win hotkeys are handled implicitly by _glfwInputWindowFocus // because they change the input focus - // NOTE: The other half of this is in the WM_*KEY* handler in windowProc + // NOTE: The other half of this is in the WM_*KEY* handler in _glfwWindowProcWin32 handle = GetActiveWindow(); if (handle) { - window = GetPropW(handle, L"GLFW"); + window = (_GLFWwindow*) GetPropW(handle, L"GLFW"); if (window) { int i; @@ -2091,7 +2091,7 @@ void _glfwPollEventsWin32(void) if (window->keys[key] != GLFW_PRESS) continue; - _glfwInputKey(window, key, scancode, GLFW_RELEASE, getKeyMods()); + _glfwInputKey(window, key, scancode, GLFW_RELEASE, _glfwGetKeyModsWin32()); } } } @@ -2169,18 +2169,18 @@ void _glfwSetCursorModeWin32(_GLFWwindow* window, int mode) &_glfw.win32.restoreCursorPosY); _glfwCenterCursorInContentArea(window); if (window->rawMouseMotion) - enableRawMouseMotion(window); + _glfwEnableRawMouseMotionWin32(window); } else if (_glfw.win32.disabledCursorWindow == window) { if (window->rawMouseMotion) - disableRawMouseMotion(window); + _glfwDisableRawMouseMotionWin32(window); } if (mode == GLFW_CURSOR_DISABLED || mode == GLFW_CURSOR_CAPTURED) - captureCursor(window); + _glfwCaptureCursorWin32(window); else - releaseCursor(); + _glfwReleaseCursorWin32(); if (mode == GLFW_CURSOR_DISABLED) _glfw.win32.disabledCursorWindow = window; @@ -2193,8 +2193,8 @@ void _glfwSetCursorModeWin32(_GLFWwindow* window, int mode) } } - if (cursorInContentArea(window)) - updateCursorImage(window); + if (_glfwCursorInContentAreaWin32(window)) + _glfwUpdateCursorImageWin32(window); } const char* _glfwGetScancodeNameWin32(int scancode) @@ -2218,7 +2218,7 @@ GLFWbool _glfwCreateCursorWin32(_GLFWcursor* cursor, const GLFWimage* image, int xhot, int yhot) { - cursor->win32.handle = (HCURSOR) createIcon(image, xhot, yhot, GLFW_FALSE); + cursor->win32.handle = (HCURSOR) _glfwCreateIconWin32(image, xhot, yhot, GLFW_FALSE); if (!cursor->win32.handle) return GLFW_FALSE; @@ -2266,9 +2266,9 @@ GLFWbool _glfwCreateStandardCursorWin32(_GLFWcursor* cursor, int shape) return GLFW_FALSE; } - cursor->win32.handle = LoadImageW(NULL, - MAKEINTRESOURCEW(id), IMAGE_CURSOR, 0, 0, - LR_DEFAULTSIZE | LR_SHARED); + cursor->win32.handle = (HCURSOR) LoadImageW(NULL, + MAKEINTRESOURCEW(id), IMAGE_CURSOR, 0, 0, + LR_DEFAULTSIZE | LR_SHARED); if (!cursor->win32.handle) { _glfwInputErrorWin32(GLFW_PLATFORM_ERROR, @@ -2287,8 +2287,8 @@ void _glfwDestroyCursorWin32(_GLFWcursor* cursor) void _glfwSetCursorWin32(_GLFWwindow* window, _GLFWcursor* cursor) { - if (cursorInContentArea(window)) - updateCursorImage(window); + if (_glfwCursorInContentAreaWin32(window)) + _glfwUpdateCursorImageWin32(window); } void _glfwSetClipboardStringWin32(const char* string) @@ -2309,7 +2309,7 @@ void _glfwSetClipboardStringWin32(const char* string) return; } - buffer = GlobalLock(object); + buffer = (WCHAR*) GlobalLock(object); if (!buffer) { _glfwInputErrorWin32(GLFW_PLATFORM_ERROR, @@ -2355,7 +2355,7 @@ const char* _glfwGetClipboardStringWin32(void) return NULL; } - buffer = GlobalLock(object); + buffer = (WCHAR*) GlobalLock(object); if (!buffer) { _glfwInputErrorWin32(GLFW_PLATFORM_ERROR, @@ -2403,7 +2403,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; @@ -2429,8 +2429,8 @@ void _glfwGetRequiredInstanceExtensionsWin32(char** extensions) if (!_glfw.vk.KHR_surface || !_glfw.vk.KHR_win32_surface) return; - extensions[0] = "VK_KHR_surface"; - extensions[1] = "VK_KHR_win32_surface"; + extensions[0] = (char*) "VK_KHR_surface"; + extensions[1] = (char*) "VK_KHR_win32_surface"; } GLFWbool _glfwGetPhysicalDevicePresentationSupportWin32(VkInstance instance, diff --git a/src/window.c b/src/window.c index 1c8519ff..890ff540 100644 --- a/src/window.c +++ b/src/window.c @@ -216,7 +216,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; diff --git a/src/wl_init.c b/src/wl_init.c index 0ec65900..a7c4d00e 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -83,23 +83,23 @@ #include "wayland-idle-inhibit-unstable-v1-client-protocol-code.h" #undef types -static void wmBaseHandlePing(void* userData, - struct xdg_wm_base* wmBase, - uint32_t serial) +static void _glfwWmBaseHandlePingWayland(void* userData, + struct xdg_wm_base* wmBase, + uint32_t serial) { xdg_wm_base_pong(wmBase, serial); } -static const struct xdg_wm_base_listener wmBaseListener = +static const struct xdg_wm_base_listener _glfwWmBaseListenerWayland = { - wmBaseHandlePing + _glfwWmBaseHandlePingWayland }; -static void registryHandleGlobal(void* userData, - struct wl_registry* registry, - uint32_t name, - const char* interface, - uint32_t version) +static void _glfwRegistryHandleGlobalWayland(void* userData, + struct wl_registry* registry, + uint32_t name, + const char* interface, + uint32_t version) { if (strcmp(interface, "wl_compositor") == 0) { @@ -144,7 +144,7 @@ static void registryHandleGlobal(void* userData, { _glfw.wl.wmBase = wl_registry_bind(registry, name, &xdg_wm_base_interface, 1); - xdg_wm_base_add_listener(_glfw.wl.wmBase, &wmBaseListener, NULL); + xdg_wm_base_add_listener(_glfw.wl.wmBase, &_glfwWmBaseListenerWayland, NULL); } else if (strcmp(interface, "zxdg_decoration_manager_v1") == 0) { @@ -181,9 +181,9 @@ static void registryHandleGlobal(void* userData, } } -static void registryHandleGlobalRemove(void* userData, - struct wl_registry* registry, - uint32_t name) +static void _glfwRegistryHandleGlobalRemoveWayland(void* userData, + struct wl_registry* registry, + uint32_t name) { for (int i = 0; i < _glfw.monitorCount; ++i) { @@ -197,29 +197,29 @@ static void registryHandleGlobalRemove(void* userData, } -static const struct wl_registry_listener registryListener = +static const struct wl_registry_listener _glfwRegistryListenerWayland = { - registryHandleGlobal, - registryHandleGlobalRemove + _glfwRegistryHandleGlobalWayland, + _glfwRegistryHandleGlobalRemoveWayland }; -void libdecorHandleError(struct libdecor* context, - enum libdecor_error error, - const char* message) +static void _glfwLibdecorHandleErrorWayland(struct libdecor* context, + enum libdecor_error error, + const char* message) { _glfwInputError(GLFW_PLATFORM_ERROR, "Wayland: libdecor error %u: %s", error, message); } -static const struct libdecor_interface libdecorInterface = +static const struct libdecor_interface _glfwLibdecorInterfaceWayland = { - libdecorHandleError + _glfwLibdecorHandleErrorWayland }; -static void libdecorReadyCallback(void* userData, - struct wl_callback* callback, - uint32_t time) +static void _glfwLibdecorReadyCallbackWayland(void* userData, + struct wl_callback* callback, + uint32_t time) { _glfw.wl.libdecor.ready = GLFW_TRUE; @@ -228,14 +228,14 @@ static void libdecorReadyCallback(void* userData, _glfw.wl.libdecor.callback = NULL; } -static const struct wl_callback_listener libdecorReadyListener = +static const struct wl_callback_listener _glfwLibdecorReadyListenerWayland = { - libdecorReadyCallback + _glfwLibdecorReadyCallbackWayland }; // Create key code translation tables // -static void createKeyTables(void) +static void _glfwCreateKeyTablesWayland(void) { memset(_glfw.wl.keycodes, -1, sizeof(_glfw.wl.keycodes)); memset(_glfw.wl.scancodes, -1, sizeof(_glfw.wl.scancodes)); @@ -366,7 +366,7 @@ static void createKeyTables(void) } } -static GLFWbool loadCursorTheme(void) +static GLFWbool _glfwLoadCursorThemeWayland(void) { int cursorSize = 16; @@ -771,9 +771,9 @@ int _glfwInitWayland(void) } _glfw.wl.registry = wl_display_get_registry(_glfw.wl.display); - wl_registry_add_listener(_glfw.wl.registry, ®istryListener, NULL); + wl_registry_add_listener(_glfw.wl.registry, &_glfwRegistryListenerWayland, NULL); - createKeyTables(); + _glfwCreateKeyTablesWayland(); _glfw.wl.xkb.context = xkb_context_new(0); if (!_glfw.wl.xkb.context) @@ -791,7 +791,7 @@ int _glfwInitWayland(void) if (_glfw.wl.libdecor.handle) { - _glfw.wl.libdecor.context = libdecor_new(_glfw.wl.display, &libdecorInterface); + _glfw.wl.libdecor.context = libdecor_new(_glfw.wl.display, &_glfwLibdecorInterfaceWayland); if (_glfw.wl.libdecor.context) { // Perform an initial dispatch and flush to get the init started @@ -800,7 +800,7 @@ int _glfwInitWayland(void) // Create sync point to "know" when libdecor is ready for use _glfw.wl.libdecor.callback = wl_display_sync(_glfw.wl.display); wl_callback_add_listener(_glfw.wl.libdecor.callback, - &libdecorReadyListener, + &_glfwLibdecorReadyListenerWayland, NULL); } } @@ -827,7 +827,7 @@ int _glfwInitWayland(void) return GLFW_FALSE; } - if (!loadCursorTheme()) + if (!_glfwLoadCursorThemeWayland()) return GLFW_FALSE; if (_glfw.wl.seat && _glfw.wl.dataDeviceManager) diff --git a/src/wl_monitor.c b/src/wl_monitor.c index 0b1a3d8d..f25c55ae 100644 --- a/src/wl_monitor.c +++ b/src/wl_monitor.c @@ -39,16 +39,16 @@ #include "wayland-client-protocol.h" -static void outputHandleGeometry(void* userData, - struct wl_output* output, - int32_t x, - int32_t y, - int32_t physicalWidth, - int32_t physicalHeight, - int32_t subpixel, - const char* make, - const char* model, - int32_t transform) +static void _glfwOutputHandleGeometryWayland(void* userData, + struct wl_output* output, + int32_t x, + int32_t y, + int32_t physicalWidth, + int32_t physicalHeight, + int32_t subpixel, + const char* make, + const char* model, + int32_t transform) { struct _GLFWmonitor* monitor = userData; @@ -61,12 +61,12 @@ static void outputHandleGeometry(void* userData, snprintf(monitor->name, sizeof(monitor->name), "%s %s", make, model); } -static void outputHandleMode(void* userData, - struct wl_output* output, - uint32_t flags, - int32_t width, - int32_t height, - int32_t refresh) +static void _glfwOutputHandleModeWayland(void* userData, + struct wl_output* output, + uint32_t flags, + int32_t width, + int32_t height, + int32_t refresh) { struct _GLFWmonitor* monitor = userData; GLFWvidmode mode; @@ -87,7 +87,7 @@ static void outputHandleMode(void* userData, monitor->wl.currentMode = monitor->modeCount - 1; } -static void outputHandleDone(void* userData, struct wl_output* output) +static void _glfwOutputHandleDoneWayland(void* userData, struct wl_output* output) { struct _GLFWmonitor* monitor = userData; @@ -108,9 +108,9 @@ static void outputHandleDone(void* userData, struct wl_output* output) _glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_LAST); } -static void outputHandleScale(void* userData, - struct wl_output* output, - int32_t factor) +static void _glfwOutputHandleScaleWayland(void* userData, + struct wl_output* output, + int32_t factor) { struct _GLFWmonitor* monitor = userData; @@ -132,30 +132,30 @@ static void outputHandleScale(void* userData, #ifdef WL_OUTPUT_NAME_SINCE_VERSION -void outputHandleName(void* userData, struct wl_output* wl_output, const char* name) +static void _glfwOutputHandleNameWayland(void* userData, struct wl_output* wl_output, const char* name) { struct _GLFWmonitor* monitor = userData; strncpy(monitor->name, name, sizeof(monitor->name) - 1); } -void outputHandleDescription(void* userData, - struct wl_output* wl_output, - const char* description) +static void _glfwOutputHandleDescriptionWayland(void* userData, + struct wl_output* wl_output, + const char* description) { } #endif // WL_OUTPUT_NAME_SINCE_VERSION -static const struct wl_output_listener outputListener = +static const struct wl_output_listener _glfwOutputListenerWayland = { - outputHandleGeometry, - outputHandleMode, - outputHandleDone, - outputHandleScale, + _glfwOutputHandleGeometryWayland, + _glfwOutputHandleModeWayland, + _glfwOutputHandleDoneWayland, + _glfwOutputHandleScaleWayland, #ifdef WL_OUTPUT_NAME_SINCE_VERSION - outputHandleName, - outputHandleDescription, + _glfwOutputHandleNameWayland, + _glfwOutputHandleDescriptionWayland, #endif }; @@ -193,7 +193,7 @@ void _glfwAddOutputWayland(uint32_t name, uint32_t version) monitor->wl.name = name; wl_proxy_set_tag((struct wl_proxy*) output, &_glfw.wl.tag); - wl_output_add_listener(output, &outputListener, monitor); + wl_output_add_listener(output, &_glfwOutputListenerWayland, monitor); } diff --git a/src/wl_window.c b/src/wl_window.c index 7c509896..ffca125f 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -54,7 +54,7 @@ #define GLFW_BORDER_SIZE 4 #define GLFW_CAPTION_HEIGHT 24 -static int createTmpfileCloexec(char* tmpname) +static int _glfwCreateTmpfileCloexecWayland(char* tmpname) { int fd; @@ -85,7 +85,7 @@ static int createTmpfileCloexec(char* tmpname) * is set to ENOSPC. If posix_fallocate() is not supported, program may * receive SIGBUS on accessing mmap()'ed file contents instead. */ -static int createAnonymousFile(off_t size) +static int _glfwCreateAnonymousFileWayland(off_t size) { static const char template[] = "/glfw-shared-XXXXXX"; const char* path; @@ -121,7 +121,7 @@ static int createAnonymousFile(off_t size) strcpy(name, path); strcat(name, template); - fd = createTmpfileCloexec(name); + fd = _glfwCreateTmpfileCloexecWayland(name); _glfw_free(name); if (fd < 0) return -1; @@ -142,12 +142,12 @@ static int createAnonymousFile(off_t size) return fd; } -static struct wl_buffer* createShmBuffer(const GLFWimage* image) +static struct wl_buffer* _glfwCreateShmBufferWayland(const GLFWimage* image) { const int stride = image->width * 4; const int length = image->width * image->height * 4; - const int fd = createAnonymousFile(length); + const int fd = _glfwCreateAnonymousFileWayland(length); if (fd < 0) { _glfwInputError(GLFW_PLATFORM_ERROR, @@ -192,12 +192,12 @@ static struct wl_buffer* createShmBuffer(const GLFWimage* image) return buffer; } -static void createFallbackDecoration(_GLFWwindow* window, - _GLFWdecorationWayland* decoration, - struct wl_surface* parent, - struct wl_buffer* buffer, - int x, int y, - int width, int height) +static void _glfwCreateFallbackDecorationWayland(_GLFWwindow* window, + _GLFWdecorationWayland* decoration, + struct wl_surface* parent, + struct wl_buffer* buffer, + int x, int y, + int width, int height) { decoration->surface = wl_compositor_create_surface(_glfw.wl.compositor); wl_surface_set_user_data(decoration->surface, window); @@ -227,29 +227,29 @@ static void createFallbackDecorations(_GLFWwindow* window) return; if (!window->wl.decorations.buffer) - window->wl.decorations.buffer = createShmBuffer(&image); + window->wl.decorations.buffer = _glfwCreateShmBufferWayland(&image); if (!window->wl.decorations.buffer) return; - createFallbackDecoration(window, &window->wl.decorations.top, window->wl.surface, - window->wl.decorations.buffer, - 0, -GLFW_CAPTION_HEIGHT, - window->wl.width, GLFW_CAPTION_HEIGHT); - createFallbackDecoration(window, &window->wl.decorations.left, window->wl.surface, - window->wl.decorations.buffer, - -GLFW_BORDER_SIZE, -GLFW_CAPTION_HEIGHT, - GLFW_BORDER_SIZE, window->wl.height + GLFW_CAPTION_HEIGHT); - createFallbackDecoration(window, &window->wl.decorations.right, window->wl.surface, - window->wl.decorations.buffer, - window->wl.width, -GLFW_CAPTION_HEIGHT, - GLFW_BORDER_SIZE, window->wl.height + GLFW_CAPTION_HEIGHT); - createFallbackDecoration(window, &window->wl.decorations.bottom, window->wl.surface, - window->wl.decorations.buffer, - -GLFW_BORDER_SIZE, window->wl.height, - window->wl.width + GLFW_BORDER_SIZE * 2, GLFW_BORDER_SIZE); + _glfwCreateFallbackDecorationWayland(window, &window->wl.decorations.top, window->wl.surface, + window->wl.decorations.buffer, + 0, -GLFW_CAPTION_HEIGHT, + window->wl.width, GLFW_CAPTION_HEIGHT); + _glfwCreateFallbackDecorationWayland(window, &window->wl.decorations.left, window->wl.surface, + window->wl.decorations.buffer, + -GLFW_BORDER_SIZE, -GLFW_CAPTION_HEIGHT, + GLFW_BORDER_SIZE, window->wl.height + GLFW_CAPTION_HEIGHT); + _glfwCreateFallbackDecorationWayland(window, &window->wl.decorations.right, window->wl.surface, + window->wl.decorations.buffer, + window->wl.width, -GLFW_CAPTION_HEIGHT, + GLFW_BORDER_SIZE, window->wl.height + GLFW_CAPTION_HEIGHT); + _glfwCreateFallbackDecorationWayland(window, &window->wl.decorations.bottom, window->wl.surface, + window->wl.decorations.buffer, + -GLFW_BORDER_SIZE, window->wl.height, + window->wl.width + GLFW_BORDER_SIZE * 2, GLFW_BORDER_SIZE); } -static void destroyFallbackDecoration(_GLFWdecorationWayland* decoration) +static void _glfwDestroyFallbackDecorationWayland(_GLFWdecorationWayland* decoration) { if (decoration->subsurface) wl_subsurface_destroy(decoration->subsurface); @@ -262,17 +262,17 @@ static void destroyFallbackDecoration(_GLFWdecorationWayland* decoration) decoration->viewport = NULL; } -static void destroyFallbackDecorations(_GLFWwindow* window) +static void _glfwDestroyFallbackDecorationsWayland(_GLFWwindow* window) { - destroyFallbackDecoration(&window->wl.decorations.top); - destroyFallbackDecoration(&window->wl.decorations.left); - destroyFallbackDecoration(&window->wl.decorations.right); - destroyFallbackDecoration(&window->wl.decorations.bottom); + _glfwDestroyFallbackDecorationWayland(&window->wl.decorations.top); + _glfwDestroyFallbackDecorationWayland(&window->wl.decorations.left); + _glfwDestroyFallbackDecorationWayland(&window->wl.decorations.right); + _glfwDestroyFallbackDecorationWayland(&window->wl.decorations.bottom); } -static void xdgDecorationHandleConfigure(void* userData, - struct zxdg_toplevel_decoration_v1* decoration, - uint32_t mode) +static void _glfwXdgDecorationHandleConfigureWayland(void* userData, + struct zxdg_toplevel_decoration_v1* decoration, + uint32_t mode) { _GLFWwindow* window = userData; @@ -284,16 +284,16 @@ static void xdgDecorationHandleConfigure(void* userData, createFallbackDecorations(window); } else - destroyFallbackDecorations(window); + _glfwDestroyFallbackDecorationsWayland(window); } -static const struct zxdg_toplevel_decoration_v1_listener xdgDecorationListener = +static const struct zxdg_toplevel_decoration_v1_listener _glfwXdgDecorationListenerWayland = { - xdgDecorationHandleConfigure, + _glfwXdgDecorationHandleConfigureWayland, }; // Makes the surface considered as XRGB instead of ARGB. -static void setContentAreaOpaque(_GLFWwindow* window) +static void _glfwSetContentAreaOpaqueWayland(_GLFWwindow* window) { struct wl_region* region; @@ -307,7 +307,7 @@ static void setContentAreaOpaque(_GLFWwindow* window) } -static void resizeWindow(_GLFWwindow* window) +static void _glfwResizeWindowWayland(_GLFWwindow* window) { int scale = window->wl.contentScale; int scaledWidth = window->wl.width * scale; @@ -316,7 +316,7 @@ static void resizeWindow(_GLFWwindow* window) if (window->wl.egl.window) wl_egl_window_resize(window->wl.egl.window, scaledWidth, scaledHeight, 0, 0); if (!window->wl.transparent) - setContentAreaOpaque(window); + _glfwSetContentAreaOpaqueWayland(window); _glfwInputFramebufferSize(window, scaledWidth, scaledHeight); if (!window->wl.decorations.top.surface) @@ -363,16 +363,16 @@ void _glfwUpdateContentScaleWayland(_GLFWwindow* window) window->wl.contentScale = maxScale; wl_surface_set_buffer_scale(window->wl.surface, maxScale); _glfwInputWindowContentScale(window, maxScale, maxScale); - resizeWindow(window); + _glfwResizeWindowWayland(window); if (window->wl.visible) _glfwInputWindowDamage(window); } } -static void surfaceHandleEnter(void* userData, - struct wl_surface* surface, - struct wl_output* output) +static void _glfwSurfaceHandleEnterWayland(void* userData, + struct wl_surface* surface, + struct wl_output* output) { if (wl_proxy_get_tag((struct wl_proxy*) output) != &_glfw.wl.tag) return; @@ -397,9 +397,9 @@ static void surfaceHandleEnter(void* userData, _glfwUpdateContentScaleWayland(window); } -static void surfaceHandleLeave(void* userData, - struct wl_surface* surface, - struct wl_output* output) +static void _glfwSurfaceHandleLeaveWayland(void* userData, + struct wl_surface* surface, + struct wl_output* output) { if (wl_proxy_get_tag((struct wl_proxy*) output) != &_glfw.wl.tag) return; @@ -421,11 +421,11 @@ static void surfaceHandleLeave(void* userData, static const struct wl_surface_listener surfaceListener = { - surfaceHandleEnter, - surfaceHandleLeave + _glfwSurfaceHandleEnterWayland, + _glfwSurfaceHandleLeaveWayland }; -static void setIdleInhibitor(_GLFWwindow* window, GLFWbool enable) +static void _glfwSetIdleInhibitorWayland(_GLFWwindow* window, GLFWbool enable) { if (enable && !window->wl.idleInhibitor && _glfw.wl.idleInhibitManager) { @@ -445,7 +445,7 @@ static void setIdleInhibitor(_GLFWwindow* window, GLFWbool enable) // Make the specified window and its video mode active on its monitor // -static void acquireMonitor(_GLFWwindow* window) +static void _glfwAcquireMonitorWayland(_GLFWwindow* window) { if (window->wl.libdecor.frame) { @@ -458,22 +458,22 @@ static void acquireMonitor(_GLFWwindow* window) window->monitor->wl.output); } - setIdleInhibitor(window, GLFW_TRUE); + _glfwSetIdleInhibitorWayland(window, GLFW_TRUE); if (window->wl.decorations.top.surface) - destroyFallbackDecorations(window); + _glfwDestroyFallbackDecorationsWayland(window); } // Remove the window and restore the original video mode // -static void releaseMonitor(_GLFWwindow* window) +static void _glfwReleaseMonitorWayland(_GLFWwindow* window) { if (window->wl.libdecor.frame) libdecor_frame_unset_fullscreen(window->wl.libdecor.frame); else if (window->wl.xdg.toplevel) xdg_toplevel_unset_fullscreen(window->wl.xdg.toplevel); - setIdleInhibitor(window, GLFW_FALSE); + _glfwSetIdleInhibitorWayland(window, GLFW_FALSE); if (!window->wl.libdecor.frame && window->wl.xdg.decorationMode != ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE) @@ -483,11 +483,11 @@ static void releaseMonitor(_GLFWwindow* window) } } -static void xdgToplevelHandleConfigure(void* userData, - struct xdg_toplevel* toplevel, - int32_t width, - int32_t height, - struct wl_array* states) +static void _glfwXdgToplevelHandleConfigureWayland(void* userData, + struct xdg_toplevel* toplevel, + int32_t width, + int32_t height, + struct wl_array* states) { _GLFWwindow* window = userData; uint32_t* state; @@ -535,7 +535,7 @@ static void xdgToplevelHandleConfigure(void* userData, } } -static void xdgToplevelHandleClose(void* userData, +static void _glfwXdgToplevelHandleCloseWayland(void* userData, struct xdg_toplevel* toplevel) { _GLFWwindow* window = userData; @@ -544,13 +544,13 @@ static void xdgToplevelHandleClose(void* userData, static const struct xdg_toplevel_listener xdgToplevelListener = { - xdgToplevelHandleConfigure, - xdgToplevelHandleClose + _glfwXdgToplevelHandleConfigureWayland, + _glfwXdgToplevelHandleCloseWayland }; -static void xdgSurfaceHandleConfigure(void* userData, - struct xdg_surface* surface, - uint32_t serial) +static void _glfwXdgSurfaceHandleConfigureWayland(void* userData, + struct xdg_surface* surface, + uint32_t serial) { _GLFWwindow* window = userData; @@ -594,7 +594,7 @@ static void xdgSurfaceHandleConfigure(void* userData, { window->wl.width = width; window->wl.height = height; - resizeWindow(window); + _glfwResizeWindowWayland(window); _glfwInputWindowSize(window, width, height); @@ -614,14 +614,14 @@ static void xdgSurfaceHandleConfigure(void* userData, } } -static const struct xdg_surface_listener xdgSurfaceListener = +static const struct xdg_surface_listener _glfwXdgSurfaceListenerWayland = { - xdgSurfaceHandleConfigure + _glfwXdgSurfaceHandleConfigureWayland }; -void libdecorFrameHandleConfigure(struct libdecor_frame* frame, - struct libdecor_configuration* config, - void* userData) +void _glfwLibdecorFrameHandleConfigureWayland(struct libdecor_frame* frame, + struct libdecor_configuration* config, + void* userData) { _GLFWwindow* window = userData; int width, height; @@ -695,7 +695,7 @@ void libdecorFrameHandleConfigure(struct libdecor_frame* frame, { window->wl.width = width; window->wl.height = height; - resizeWindow(window); + _glfwResizeWindowWayland(window); _glfwInputWindowSize(window, width, height); damaged = GLFW_TRUE; @@ -707,33 +707,33 @@ void libdecorFrameHandleConfigure(struct libdecor_frame* frame, wl_surface_commit(window->wl.surface); } -void libdecorFrameHandleClose(struct libdecor_frame* frame, void* userData) +void _glfwLibdecorFrameHandleCloseWayland(struct libdecor_frame* frame, void* userData) { _GLFWwindow* window = userData; _glfwInputWindowCloseRequest(window); } -void libdecorFrameHandleCommit(struct libdecor_frame* frame, void* userData) +void _glfwLibdecorFrameHandleCommitWayland(struct libdecor_frame* frame, void* userData) { _GLFWwindow* window = userData; wl_surface_commit(window->wl.surface); } -void libdecorFrameHandleDismissPopup(struct libdecor_frame* frame, - const char* seatName, - void* userData) +void _glfwLibdecorFrameHandleDismissPopupWayland(struct libdecor_frame* frame, + const char* seatName, + void* userData) { } -static const struct libdecor_frame_interface libdecorFrameInterface = +static const struct libdecor_frame_interface _glfwLibdecorFrameInterfaceWayland = { - libdecorFrameHandleConfigure, - libdecorFrameHandleClose, - libdecorFrameHandleCommit, - libdecorFrameHandleDismissPopup + _glfwLibdecorFrameHandleConfigureWayland, + _glfwLibdecorFrameHandleCloseWayland, + _glfwLibdecorFrameHandleCommitWayland, + _glfwLibdecorFrameHandleDismissPopupWayland }; -static GLFWbool createLibdecorFrame(_GLFWwindow* window) +static GLFWbool _glfwCreateLibdecorFrameWayland(_GLFWwindow* window) { // Allow libdecor to finish initialization of itself and its plugin while (!_glfw.wl.libdecor.ready) @@ -741,7 +741,7 @@ static GLFWbool createLibdecorFrame(_GLFWwindow* window) window->wl.libdecor.frame = libdecor_decorate(_glfw.wl.libdecor.context, window->wl.surface, - &libdecorFrameInterface, + &_glfwLibdecorFrameInterfaceWayland, window); if (!window->wl.libdecor.frame) { @@ -787,7 +787,7 @@ static GLFWbool createLibdecorFrame(_GLFWwindow* window) { libdecor_frame_set_fullscreen(window->wl.libdecor.frame, window->monitor->wl.output); - setIdleInhibitor(window, GLFW_TRUE); + _glfwSetIdleInhibitorWayland(window, GLFW_TRUE); } else { @@ -797,7 +797,7 @@ static GLFWbool createLibdecorFrame(_GLFWwindow* window) if (!window->decorated) libdecor_frame_set_visibility(window->wl.libdecor.frame, false); - setIdleInhibitor(window, GLFW_FALSE); + _glfwSetIdleInhibitorWayland(window, GLFW_FALSE); } libdecor_frame_map(window->wl.libdecor.frame); @@ -805,7 +805,7 @@ static GLFWbool createLibdecorFrame(_GLFWwindow* window) return GLFW_TRUE; } -static GLFWbool createXdgShellObjects(_GLFWwindow* window) +static GLFWbool _glfwCreateXdgShellObjectsWayland(_GLFWwindow* window) { window->wl.xdg.surface = xdg_wm_base_get_xdg_surface(_glfw.wl.wmBase, window->wl.surface); @@ -816,7 +816,7 @@ static GLFWbool createXdgShellObjects(_GLFWwindow* window) return GLFW_FALSE; } - xdg_surface_add_listener(window->wl.xdg.surface, &xdgSurfaceListener, window); + xdg_surface_add_listener(window->wl.xdg.surface, &_glfwXdgSurfaceListenerWayland, window); window->wl.xdg.toplevel = xdg_surface_get_toplevel(window->wl.xdg.surface); if (!window->wl.xdg.toplevel) @@ -837,14 +837,14 @@ static GLFWbool createXdgShellObjects(_GLFWwindow* window) if (window->monitor) { xdg_toplevel_set_fullscreen(window->wl.xdg.toplevel, window->monitor->wl.output); - setIdleInhibitor(window, GLFW_TRUE); + _glfwSetIdleInhibitorWayland(window, GLFW_TRUE); } else { if (window->wl.maximized) xdg_toplevel_set_maximized(window->wl.xdg.toplevel); - setIdleInhibitor(window, GLFW_FALSE); + _glfwSetIdleInhibitorWayland(window, GLFW_FALSE); } if (_glfw.wl.decorationManager) @@ -853,7 +853,7 @@ static GLFWbool createXdgShellObjects(_GLFWwindow* window) zxdg_decoration_manager_v1_get_toplevel_decoration( _glfw.wl.decorationManager, window->wl.xdg.toplevel); zxdg_toplevel_decoration_v1_add_listener(window->wl.xdg.decoration, - &xdgDecorationListener, + &_glfwXdgDecorationListenerWayland, window); uint32_t mode; @@ -904,20 +904,20 @@ static GLFWbool createXdgShellObjects(_GLFWwindow* window) return GLFW_TRUE; } -static GLFWbool createShellObjects(_GLFWwindow* window) +static GLFWbool _glfwCreateShellObjectsWayland(_GLFWwindow* window) { if (_glfw.wl.libdecor.context) { - if (createLibdecorFrame(window)) + if (_glfwCreateLibdecorFrameWayland(window)) return GLFW_TRUE; } - return createXdgShellObjects(window); + return _glfwCreateXdgShellObjectsWayland(window); } -static void destroyShellObjects(_GLFWwindow* window) +static void _glfwDestroyShellObjectsWayland(_GLFWwindow* window) { - destroyFallbackDecorations(window); + _glfwDestroyFallbackDecorationsWayland(window); if (window->wl.libdecor.frame) libdecor_frame_unref(window->wl.libdecor.frame); @@ -938,9 +938,9 @@ static void destroyShellObjects(_GLFWwindow* window) window->wl.xdg.surface = NULL; } -static GLFWbool createNativeSurface(_GLFWwindow* window, - const _GLFWwndconfig* wndconfig, - const _GLFWfbconfig* fbconfig) +static GLFWbool _glfwCreateNativeSurfaceWayland(_GLFWwindow* window, + const _GLFWwndconfig* wndconfig, + const _GLFWfbconfig* fbconfig) { window->wl.surface = wl_compositor_create_surface(_glfw.wl.compositor); if (!window->wl.surface) @@ -964,13 +964,13 @@ static GLFWbool createNativeSurface(_GLFWwindow* window, window->wl.transparent = fbconfig->transparent; if (!window->wl.transparent) - setContentAreaOpaque(window); + _glfwSetContentAreaOpaqueWayland(window); return GLFW_TRUE; } -static void setCursorImage(_GLFWwindow* window, - _GLFWcursorWayland* cursorWayland) +static void _glfwSetCursorImageWayland(_GLFWwindow* window, + _GLFWcursorWayland* cursorWayland) { struct itimerspec timer = {0}; struct wl_cursor* wlCursor = cursorWayland->cursor; @@ -1015,7 +1015,7 @@ static void setCursorImage(_GLFWwindow* window, wl_surface_commit(surface); } -static void incrementCursorImage(_GLFWwindow* window) +static void _glfwIncrementCursorImageWayland(_GLFWwindow* window) { _GLFWcursor* cursor; @@ -1027,11 +1027,11 @@ static void incrementCursorImage(_GLFWwindow* window) { cursor->wl.currentImage += 1; cursor->wl.currentImage %= cursor->wl.cursor->image_count; - setCursorImage(window, &cursor->wl); + _glfwSetCursorImageWayland(window, &cursor->wl); } } -static GLFWbool flushDisplay(void) +static GLFWbool _glfwFlushDisplayWayland(void) { while (wl_display_flush(_glfw.wl.display) == -1) { @@ -1050,7 +1050,7 @@ static GLFWbool flushDisplay(void) return GLFW_TRUE; } -static int translateKey(uint32_t scancode) +static int _glfwTranslateKeyWayland(uint32_t scancode) { if (scancode < sizeof(_glfw.wl.keycodes) / sizeof(_glfw.wl.keycodes[0])) return _glfw.wl.keycodes[scancode]; @@ -1058,7 +1058,7 @@ static int translateKey(uint32_t scancode) return GLFW_KEY_UNKNOWN; } -static xkb_keysym_t composeSymbol(xkb_keysym_t sym) +static xkb_keysym_t _glfwComposeSymbolWayland(xkb_keysym_t sym) { if (sym == XKB_KEY_NoSymbol || !_glfw.wl.xkb.composeState) return sym; @@ -1078,14 +1078,14 @@ static xkb_keysym_t composeSymbol(xkb_keysym_t sym) } } -static void inputText(_GLFWwindow* window, uint32_t scancode) +static void _glfwInputTextWayland(_GLFWwindow* window, uint32_t scancode) { const xkb_keysym_t* keysyms; const xkb_keycode_t keycode = scancode + 8; if (xkb_state_key_get_syms(_glfw.wl.xkb.state, keycode, &keysyms) == 1) { - const xkb_keysym_t keysym = composeSymbol(keysyms[0]); + const xkb_keysym_t keysym = _glfwComposeSymbolWayland(keysyms[0]); const uint32_t codepoint = _glfwKeySym2Unicode(keysym); if (codepoint != GLFW_INVALID_CODEPOINT) { @@ -1096,7 +1096,7 @@ static void inputText(_GLFWwindow* window, uint32_t scancode) } } -static void handleEvents(double* timeout) +static void _glfwHandleEventsWayland(double* timeout) { #if defined(GLFW_BUILD_LINUX_JOYSTICK) if (_glfw.joysticksInitialized) @@ -1125,7 +1125,7 @@ static void handleEvents(double* timeout) // If an error other than EAGAIN happens, we have likely been disconnected // from the Wayland session; try to handle that the best we can. - if (!flushDisplay()) + if (!_glfwFlushDisplayWayland()) { wl_display_cancel_read(_glfw.wl.display); @@ -1163,11 +1163,11 @@ static void handleEvents(double* timeout) for (uint64_t i = 0; i < repeats; i++) { _glfwInputKey(_glfw.wl.keyboardFocus, - translateKey(_glfw.wl.keyRepeatScancode), + _glfwTranslateKeyWayland(_glfw.wl.keyRepeatScancode), _glfw.wl.keyRepeatScancode, GLFW_PRESS, _glfw.wl.xkb.modifiers); - inputText(_glfw.wl.keyboardFocus, _glfw.wl.keyRepeatScancode); + _glfwInputTextWayland(_glfw.wl.keyboardFocus, _glfw.wl.keyRepeatScancode); } event = GLFW_TRUE; @@ -1179,7 +1179,7 @@ static void handleEvents(double* timeout) uint64_t repeats; if (read(_glfw.wl.cursorTimerfd, &repeats, sizeof(repeats)) == 8) - incrementCursorImage(_glfw.wl.pointerFocus); + _glfwIncrementCursorImageWayland(_glfw.wl.pointerFocus); } if (fds[3].revents & POLLIN) @@ -1192,7 +1192,7 @@ static void handleEvents(double* timeout) // Reads the specified data offer as the specified MIME type // -static char* readDataOfferAsString(struct wl_data_offer* offer, const char* mimeType) +static char* _glfwReadDataOfferAsStringWayland(struct wl_data_offer* offer, const char* mimeType) { int fds[2]; @@ -1205,7 +1205,7 @@ static char* readDataOfferAsString(struct wl_data_offer* offer, const char* mime } wl_data_offer_receive(offer, mimeType, fds[1]); - flushDisplay(); + _glfwFlushDisplayWayland(); close(fds[1]); char* string = NULL; @@ -1254,12 +1254,12 @@ static char* readDataOfferAsString(struct wl_data_offer* offer, const char* mime return string; } -static void pointerHandleEnter(void* userData, - struct wl_pointer* pointer, - uint32_t serial, - struct wl_surface* surface, - wl_fixed_t sx, - wl_fixed_t sy) +static void _glfwPointerHandleEnterWayland(void* userData, + struct wl_pointer* pointer, + uint32_t serial, + struct wl_surface* surface, + wl_fixed_t sx, + wl_fixed_t sy) { // Happens in the case we just destroyed the surface. if (!surface) @@ -1291,10 +1291,10 @@ static void pointerHandleEnter(void* userData, _glfwInputCursorEnter(window, GLFW_TRUE); } -static void pointerHandleLeave(void* userData, - struct wl_pointer* pointer, - uint32_t serial, - struct wl_surface* surface) +static void _glfwPointerHandleLeaveWayland(void* userData, + struct wl_pointer* pointer, + uint32_t serial, + struct wl_surface* surface) { if (!surface) return; @@ -1314,11 +1314,11 @@ static void pointerHandleLeave(void* userData, _glfwInputCursorEnter(window, GLFW_FALSE); } -static void pointerHandleMotion(void* userData, - struct wl_pointer* pointer, - uint32_t time, - wl_fixed_t sx, - wl_fixed_t sy) +static void _glfwPointerHandleMotionWayland(void* userData, + struct wl_pointer* pointer, + uint32_t time, + wl_fixed_t sx, + wl_fixed_t sy) { _GLFWwindow* window = _glfw.wl.pointerFocus; if (!window) @@ -1410,12 +1410,12 @@ static void pointerHandleMotion(void* userData, } } -static void pointerHandleButton(void* userData, - struct wl_pointer* pointer, - uint32_t serial, - uint32_t time, - uint32_t button, - uint32_t state) +static void _glfwPointerHandleButtonWayland(void* userData, + struct wl_pointer* pointer, + uint32_t serial, + uint32_t time, + uint32_t button, + uint32_t state) { _GLFWwindow* window = _glfw.wl.pointerFocus; int glfwButton; @@ -1496,11 +1496,11 @@ static void pointerHandleButton(void* userData, _glfw.wl.xkb.modifiers); } -static void pointerHandleAxis(void* userData, - struct wl_pointer* pointer, - uint32_t time, - uint32_t axis, - wl_fixed_t value) +static void _glfwPointerHandleAxisWayland(void* userData, + struct wl_pointer* pointer, + uint32_t time, + uint32_t axis, + wl_fixed_t value) { _GLFWwindow* window = _glfw.wl.pointerFocus; double x = 0.0, y = 0.0; @@ -1523,20 +1523,20 @@ static void pointerHandleAxis(void* userData, _glfwInputScroll(window, x, y); } -static const struct wl_pointer_listener pointerListener = +static const struct wl_pointer_listener _glfwPointerListenerWayland = { - pointerHandleEnter, - pointerHandleLeave, - pointerHandleMotion, - pointerHandleButton, - pointerHandleAxis, + _glfwPointerHandleEnterWayland, + _glfwPointerHandleLeaveWayland, + _glfwPointerHandleMotionWayland, + _glfwPointerHandleButtonWayland, + _glfwPointerHandleAxisWayland, }; -static void keyboardHandleKeymap(void* userData, - struct wl_keyboard* keyboard, - uint32_t format, - int fd, - uint32_t size) +static void _glfwKeyboardHandleKeymapWayland(void* userData, + struct wl_keyboard* keyboard, + uint32_t format, + int fd, + uint32_t size) { struct xkb_keymap* keymap; struct xkb_state* state; @@ -1623,11 +1623,11 @@ static void keyboardHandleKeymap(void* userData, _glfw.wl.xkb.numLockIndex = xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Mod2"); } -static void keyboardHandleEnter(void* userData, - struct wl_keyboard* keyboard, - uint32_t serial, - struct wl_surface* surface, - struct wl_array* keys) +static void _glfwKeyboardHandleEnterWayland(void* userData, + struct wl_keyboard* keyboard, + uint32_t serial, + struct wl_surface* surface, + struct wl_array* keys) { // Happens in the case we just destroyed the surface. if (!surface) @@ -1645,10 +1645,10 @@ static void keyboardHandleEnter(void* userData, _glfwInputWindowFocus(window, GLFW_TRUE); } -static void keyboardHandleLeave(void* userData, - struct wl_keyboard* keyboard, - uint32_t serial, - struct wl_surface* surface) +static void _glfwKeyboardHandleLeaveWayland(void* userData, + struct wl_keyboard* keyboard, + uint32_t serial, + struct wl_surface* surface) { _GLFWwindow* window = _glfw.wl.keyboardFocus; @@ -1663,18 +1663,18 @@ static void keyboardHandleLeave(void* userData, _glfwInputWindowFocus(window, GLFW_FALSE); } -static void keyboardHandleKey(void* userData, - struct wl_keyboard* keyboard, - uint32_t serial, - uint32_t time, - uint32_t scancode, - uint32_t state) +static void _glfwKeyboardHandleKeyWayland(void* userData, + struct wl_keyboard* keyboard, + uint32_t serial, + uint32_t time, + uint32_t scancode, + uint32_t state) { _GLFWwindow* window = _glfw.wl.keyboardFocus; if (!window) return; - const int key = translateKey(scancode); + const int key = _glfwTranslateKeyWayland(scancode); const int action = state == WL_KEYBOARD_KEY_STATE_PRESSED ? GLFW_PRESS : GLFW_RELEASE; @@ -1705,16 +1705,16 @@ static void keyboardHandleKey(void* userData, _glfwInputKey(window, key, scancode, action, _glfw.wl.xkb.modifiers); if (action == GLFW_PRESS) - inputText(window, scancode); + _glfwInputTextWayland(window, scancode); } -static void keyboardHandleModifiers(void* userData, - struct wl_keyboard* keyboard, - uint32_t serial, - uint32_t modsDepressed, - uint32_t modsLatched, - uint32_t modsLocked, - uint32_t group) +static void _glfwKeyboardHandleModifiersWayland(void* userData, + struct wl_keyboard* keyboard, + uint32_t serial, + uint32_t modsDepressed, + uint32_t modsLatched, + uint32_t modsLocked, + uint32_t group) { _glfw.wl.serial = serial; @@ -1757,7 +1757,7 @@ static void keyboardHandleModifiers(void* userData, } #ifdef WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION -static void keyboardHandleRepeatInfo(void* userData, +static void _glfwKeyboardHandleRepeatInfoWayland(void* userData, struct wl_keyboard* keyboard, int32_t rate, int32_t delay) @@ -1772,24 +1772,24 @@ static void keyboardHandleRepeatInfo(void* userData, static const struct wl_keyboard_listener keyboardListener = { - keyboardHandleKeymap, - keyboardHandleEnter, - keyboardHandleLeave, - keyboardHandleKey, - keyboardHandleModifiers, + _glfwKeyboardHandleKeymapWayland, + _glfwKeyboardHandleEnterWayland, + _glfwKeyboardHandleLeaveWayland, + _glfwKeyboardHandleKeyWayland, + _glfwKeyboardHandleModifiersWayland, #ifdef WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION - keyboardHandleRepeatInfo, + _glfwKeyboardHandleRepeatInfoWayland, #endif }; -static void seatHandleCapabilities(void* userData, - struct wl_seat* seat, - enum wl_seat_capability caps) +static void _glfwSeatHandleCapabilitiesWayland(void* userData, + struct wl_seat* seat, + enum wl_seat_capability caps) { if ((caps & WL_SEAT_CAPABILITY_POINTER) && !_glfw.wl.pointer) { _glfw.wl.pointer = wl_seat_get_pointer(seat); - wl_pointer_add_listener(_glfw.wl.pointer, &pointerListener, NULL); + wl_pointer_add_listener(_glfw.wl.pointer, &_glfwPointerListenerWayland, NULL); } else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && _glfw.wl.pointer) { @@ -1809,19 +1809,19 @@ static void seatHandleCapabilities(void* userData, } } -static void seatHandleName(void* userData, - struct wl_seat* seat, - const char* name) +static void _glfwSeatHandleNameWayland(void* userData, + struct wl_seat* seat, + const char* name) { } -static const struct wl_seat_listener seatListener = +static const struct wl_seat_listener _glfwSeatListenerWayland = { - seatHandleCapabilities, - seatHandleName, + _glfwSeatHandleCapabilitiesWayland, + _glfwSeatHandleNameWayland, }; -static void dataOfferHandleOffer(void* userData, +static void _glfwDataOfferHandleOfferWayland(void* userData, struct wl_data_offer* offer, const char* mimeType) { @@ -1839,9 +1839,9 @@ static void dataOfferHandleOffer(void* userData, } } -static const struct wl_data_offer_listener dataOfferListener = +static const struct wl_data_offer_listener _glfwDataOfferListenerWayland = { - dataOfferHandleOffer + _glfwDataOfferHandleOfferWayland }; static void dataDeviceHandleDataOffer(void* userData, @@ -1861,16 +1861,16 @@ static void dataDeviceHandleDataOffer(void* userData, _glfw.wl.offerCount++; _glfw.wl.offers[_glfw.wl.offerCount - 1] = (_GLFWofferWayland) { offer }; - wl_data_offer_add_listener(offer, &dataOfferListener, NULL); + wl_data_offer_add_listener(offer, &_glfwDataOfferListenerWayland, NULL); } -static void dataDeviceHandleEnter(void* userData, - struct wl_data_device* device, - uint32_t serial, - struct wl_surface* surface, - wl_fixed_t x, - wl_fixed_t y, - struct wl_data_offer* offer) +static void _glfwDataDeviceHandleEnterWayland(void* userData, + struct wl_data_device* device, + uint32_t serial, + struct wl_surface* surface, + wl_fixed_t x, + wl_fixed_t y, + struct wl_data_offer* offer) { if (_glfw.wl.dragOffer) { @@ -1916,8 +1916,8 @@ static void dataDeviceHandleEnter(void* userData, } } -static void dataDeviceHandleLeave(void* userData, - struct wl_data_device* device) +static void _glfwDataDeviceHandleLeaveWayland(void* userData, + struct wl_data_device* device) { if (_glfw.wl.dragOffer) { @@ -1927,21 +1927,21 @@ static void dataDeviceHandleLeave(void* userData, } } -static void dataDeviceHandleMotion(void* userData, - struct wl_data_device* device, - uint32_t time, - wl_fixed_t x, - wl_fixed_t y) +static void _glfwDataDeviceHandleMotionWayland(void* userData, + struct wl_data_device* device, + uint32_t time, + wl_fixed_t x, + wl_fixed_t y) { } -static void dataDeviceHandleDrop(void* userData, - struct wl_data_device* device) +static void _glfwDataDeviceHandleDropWayland(void* userData, + struct wl_data_device* device) { if (!_glfw.wl.dragOffer) return; - char* string = readDataOfferAsString(_glfw.wl.dragOffer, "text/uri-list"); + char* string = _glfwReadDataOfferAsStringWayland(_glfw.wl.dragOffer, "text/uri-list"); if (string) { int count; @@ -1958,9 +1958,9 @@ static void dataDeviceHandleDrop(void* userData, _glfw_free(string); } -static void dataDeviceHandleSelection(void* userData, - struct wl_data_device* device, - struct wl_data_offer* offer) +static void _glfwDataDeviceHandleSelectionWayland(void* userData, + struct wl_data_device* device, + struct wl_data_offer* offer) { if (_glfw.wl.selectionOffer) { @@ -1984,24 +1984,24 @@ static void dataDeviceHandleSelection(void* userData, } } -const struct wl_data_device_listener dataDeviceListener = +const struct wl_data_device_listener _glfwDataDeviceListenerWayland = { dataDeviceHandleDataOffer, - dataDeviceHandleEnter, - dataDeviceHandleLeave, - dataDeviceHandleMotion, - dataDeviceHandleDrop, - dataDeviceHandleSelection, + _glfwDataDeviceHandleEnterWayland, + _glfwDataDeviceHandleLeaveWayland, + _glfwDataDeviceHandleMotionWayland, + _glfwDataDeviceHandleDropWayland, + _glfwDataDeviceHandleSelectionWayland, }; void _glfwAddSeatListenerWayland(struct wl_seat* seat) { - wl_seat_add_listener(seat, &seatListener, NULL); + wl_seat_add_listener(seat, &_glfwSeatListenerWayland, NULL); } void _glfwAddDataDeviceListenerWayland(struct wl_data_device* device) { - wl_data_device_add_listener(device, &dataDeviceListener, NULL); + wl_data_device_add_listener(device, &_glfwDataDeviceListenerWayland, NULL); } @@ -2014,7 +2014,7 @@ GLFWbool _glfwCreateWindowWayland(_GLFWwindow* window, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig) { - if (!createNativeSurface(window, wndconfig, fbconfig)) + if (!_glfwCreateNativeSurfaceWayland(window, wndconfig, fbconfig)) return GLFW_FALSE; if (ctxconfig->client != GLFW_NO_API) @@ -2054,7 +2054,7 @@ GLFWbool _glfwCreateWindowWayland(_GLFWwindow* window, if (window->monitor || wndconfig->visible) { - if (!createShellObjects(window)) + if (!_glfwCreateShellObjectsWayland(window)) return GLFW_FALSE; } @@ -2084,7 +2084,7 @@ void _glfwDestroyWindowWayland(_GLFWwindow* window) if (window->context.destroy) window->context.destroy(window); - destroyShellObjects(window); + _glfwDestroyShellObjectsWayland(window); if (window->wl.decorations.buffer) wl_buffer_destroy(window->wl.decorations.buffer); @@ -2154,7 +2154,7 @@ void _glfwSetWindowSizeWayland(_GLFWwindow* window, int width, int height) { window->wl.width = width; window->wl.height = height; - resizeWindow(window); + _glfwResizeWindowWayland(window); if (window->wl.libdecor.frame) { @@ -2236,7 +2236,7 @@ void _glfwSetWindowAspectRatioWayland(_GLFWwindow* window, int numer, int denom) { window->wl.width = width; window->wl.height = height; - resizeWindow(window); + _glfwResizeWindowWayland(window); if (window->wl.libdecor.frame) { @@ -2334,7 +2334,7 @@ void _glfwShowWindowWayland(_GLFWwindow* window) { // 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 - createShellObjects(window); + _glfwCreateShellObjectsWayland(window); } } @@ -2343,7 +2343,7 @@ void _glfwHideWindowWayland(_GLFWwindow* window) if (window->wl.visible) { window->wl.visible = GLFW_FALSE; - destroyShellObjects(window); + _glfwDestroyShellObjectsWayland(window); wl_surface_attach(window->wl.surface, NULL, 0, 0); wl_surface_commit(window->wl.surface); @@ -2378,12 +2378,12 @@ void _glfwSetWindowMonitorWayland(_GLFWwindow* window, } if (window->monitor) - releaseMonitor(window); + _glfwReleaseMonitorWayland(window); _glfwInputWindowMonitor(window, monitor); if (window->monitor) - acquireMonitor(window); + _glfwAcquireMonitorWayland(window); else _glfwSetWindowSizeWayland(window, width, height); } @@ -2465,7 +2465,7 @@ void _glfwSetWindowDecoratedWayland(_GLFWwindow* window, GLFWbool enabled) if (enabled) createFallbackDecorations(window); else - destroyFallbackDecorations(window); + _glfwDestroyFallbackDecorationsWayland(window); } } @@ -2500,7 +2500,7 @@ void _glfwSetWindowOpacityWayland(_GLFWwindow* window, float opacity) void _glfwSetRawMouseMotionWayland(_GLFWwindow* window, GLFWbool enabled) { - // This is handled in relativePointerHandleRelativeMotion + // This is handled in _glfwRelativePointerHandleRelativeMotionWayland } GLFWbool _glfwRawMouseMotionSupportedWayland(void) @@ -2511,23 +2511,23 @@ GLFWbool _glfwRawMouseMotionSupportedWayland(void) void _glfwPollEventsWayland(void) { double timeout = 0.0; - handleEvents(&timeout); + _glfwHandleEventsWayland(&timeout); } void _glfwWaitEventsWayland(void) { - handleEvents(NULL); + _glfwHandleEventsWayland(NULL); } void _glfwWaitEventsTimeoutWayland(double timeout) { - handleEvents(&timeout); + _glfwHandleEventsWayland(&timeout); } void _glfwPostEmptyEventWayland(void) { wl_display_sync(_glfw.wl.display); - flushDisplay(); + _glfwFlushDisplayWayland(); } void _glfwGetCursorPosWayland(_GLFWwindow* window, double* xpos, double* ypos) @@ -2613,7 +2613,7 @@ GLFWbool _glfwCreateCursorWayland(_GLFWcursor* cursor, const GLFWimage* image, int xhot, int yhot) { - cursor->wl.buffer = createShmBuffer(image); + cursor->wl.buffer = _glfwCreateShmBufferWayland(image); if (!cursor->wl.buffer) return GLFW_FALSE; @@ -2735,14 +2735,14 @@ void _glfwDestroyCursorWayland(_GLFWcursor* cursor) wl_buffer_destroy(cursor->wl.buffer); } -static void relativePointerHandleRelativeMotion(void* userData, - struct zwp_relative_pointer_v1* pointer, - uint32_t timeHi, - uint32_t timeLo, - wl_fixed_t dx, - wl_fixed_t dy, - wl_fixed_t dxUnaccel, - wl_fixed_t dyUnaccel) +static void _glfwRelativePointerHandleRelativeMotionWayland(void* userData, + struct zwp_relative_pointer_v1* pointer, + uint32_t timeHi, + uint32_t timeLo, + wl_fixed_t dx, + wl_fixed_t dy, + wl_fixed_t dxUnaccel, + wl_fixed_t dyUnaccel) { _GLFWwindow* window = userData; double xpos = window->virtualCursorPosX; @@ -2765,28 +2765,28 @@ static void relativePointerHandleRelativeMotion(void* userData, _glfwInputCursorPos(window, xpos, ypos); } -static const struct zwp_relative_pointer_v1_listener relativePointerListener = +static const struct zwp_relative_pointer_v1_listener _glfwRelativePointerListenerWayland = { - relativePointerHandleRelativeMotion + _glfwRelativePointerHandleRelativeMotionWayland }; -static void lockedPointerHandleLocked(void* userData, - struct zwp_locked_pointer_v1* lockedPointer) +static void _glfwLockedPointerHandleLockedWayland(void* userData, + struct zwp_locked_pointer_v1* lockedPointer) { } -static void lockedPointerHandleUnlocked(void* userData, - struct zwp_locked_pointer_v1* lockedPointer) +static void _glfwLockedPointerHandleUnlockedWayland(void* userData, + struct zwp_locked_pointer_v1* lockedPointer) { } -static const struct zwp_locked_pointer_v1_listener lockedPointerListener = +static const struct zwp_locked_pointer_v1_listener _glfwLockedPointerListenerWayland = { - lockedPointerHandleLocked, - lockedPointerHandleUnlocked + _glfwLockedPointerHandleLockedWayland, + _glfwLockedPointerHandleUnlockedWayland }; -static void lockPointer(_GLFWwindow* window) +static void _glfwLockPointerWayland(_GLFWwindow* window) { if (!_glfw.wl.relativePointerManager) { @@ -2800,7 +2800,7 @@ static void lockPointer(_GLFWwindow* window) _glfw.wl.relativePointerManager, _glfw.wl.pointer); zwp_relative_pointer_v1_add_listener(window->wl.relativePointer, - &relativePointerListener, + &_glfwRelativePointerListenerWayland, window); window->wl.lockedPointer = @@ -2811,11 +2811,11 @@ static void lockPointer(_GLFWwindow* window) NULL, ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_PERSISTENT); zwp_locked_pointer_v1_add_listener(window->wl.lockedPointer, - &lockedPointerListener, + &_glfwLockedPointerListenerWayland, window); } -static void unlockPointer(_GLFWwindow* window) +static void _glfwUnlockPointerWayland(_GLFWwindow* window) { zwp_relative_pointer_v1_destroy(window->wl.relativePointer); window->wl.relativePointer = NULL; @@ -2824,23 +2824,23 @@ static void unlockPointer(_GLFWwindow* window) window->wl.lockedPointer = NULL; } -static void confinedPointerHandleConfined(void* userData, +static void _glfwConfinedPointerHandleConfinedWayland(void* userData, struct zwp_confined_pointer_v1* confinedPointer) { } -static void confinedPointerHandleUnconfined(void* userData, +static void _glfwConfinedPointerHandleUnconfinedWayland(void* userData, struct zwp_confined_pointer_v1* confinedPointer) { } -static const struct zwp_confined_pointer_v1_listener confinedPointerListener = +static const struct zwp_confined_pointer_v1_listener _glfwConfinedPointerListenerWayland = { - confinedPointerHandleConfined, - confinedPointerHandleUnconfined + _glfwConfinedPointerHandleConfinedWayland, + _glfwConfinedPointerHandleUnconfinedWayland }; -static void confinePointer(_GLFWwindow* window) +static void _glfwConfinePointerWayland(_GLFWwindow* window) { window->wl.confinedPointer = zwp_pointer_constraints_v1_confine_pointer( @@ -2851,11 +2851,11 @@ static void confinePointer(_GLFWwindow* window) ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_PERSISTENT); zwp_confined_pointer_v1_add_listener(window->wl.confinedPointer, - &confinedPointerListener, + &_glfwConfinedPointerListenerWayland, window); } -static void unconfinePointer(_GLFWwindow* window) +static void _glfwUnconfinePointerWayland(_GLFWwindow* window) { zwp_confined_pointer_v1_destroy(window->wl.confinedPointer); window->wl.confinedPointer = NULL; @@ -2880,31 +2880,31 @@ void _glfwSetCursorWayland(_GLFWwindow* window, _GLFWcursor* cursor) if (window->cursorMode == GLFW_CURSOR_DISABLED) { if (window->wl.confinedPointer) - unconfinePointer(window); + _glfwUnconfinePointerWayland(window); if (!window->wl.lockedPointer) - lockPointer(window); + _glfwLockPointerWayland(window); } else if (window->cursorMode == GLFW_CURSOR_CAPTURED) { if (window->wl.lockedPointer) - unlockPointer(window); + _glfwUnlockPointerWayland(window); if (!window->wl.confinedPointer) - confinePointer(window); + _glfwConfinePointerWayland(window); } else if (window->cursorMode == GLFW_CURSOR_NORMAL || window->cursorMode == GLFW_CURSOR_HIDDEN) { if (window->wl.lockedPointer) - unlockPointer(window); + _glfwUnlockPointerWayland(window); else if (window->wl.confinedPointer) - unconfinePointer(window); + _glfwUnconfinePointerWayland(window); } if (window->cursorMode == GLFW_CURSOR_NORMAL || window->cursorMode == GLFW_CURSOR_CAPTURED) { if (cursor) - setCursorImage(window, &cursor->wl); + _glfwSetCursorImageWayland(window, &cursor->wl); else { struct wl_cursor* defaultCursor = @@ -2933,7 +2933,7 @@ void _glfwSetCursorWayland(_GLFWwindow* window, _GLFWcursor* cursor) 0 }; - setCursorImage(window, &cursorWayland); + _glfwSetCursorImageWayland(window, &cursorWayland); } } else if (window->cursorMode == GLFW_CURSOR_HIDDEN || @@ -2943,9 +2943,9 @@ void _glfwSetCursorWayland(_GLFWwindow* window, _GLFWcursor* cursor) } } -static void dataSourceHandleTarget(void* userData, - struct wl_data_source* source, - const char* mimeType) +static void _glfwDataSourceHandleTargetWayland(void* userData, + struct wl_data_source* source, + const char* mimeType) { if (_glfw.wl.selectionSource != source) { @@ -2955,10 +2955,10 @@ static void dataSourceHandleTarget(void* userData, } } -static void dataSourceHandleSend(void* userData, - struct wl_data_source* source, - const char* mimeType, - int fd) +static void _glfwDataSourceHandleSendWayland(void* userData, + struct wl_data_source* source, + const char* mimeType, + int fd) { // Ignore it if this is an outdated or invalid request if (_glfw.wl.selectionSource != source || @@ -2992,8 +2992,8 @@ static void dataSourceHandleSend(void* userData, close(fd); } -static void dataSourceHandleCancelled(void* userData, - struct wl_data_source* source) +static void _glfwDataSourceHandleCancelledWayland(void* userData, + struct wl_data_source* source) { wl_data_source_destroy(source); @@ -3003,11 +3003,11 @@ static void dataSourceHandleCancelled(void* userData, _glfw.wl.selectionSource = NULL; } -static const struct wl_data_source_listener dataSourceListener = +static const struct wl_data_source_listener _glfwDataSourceListenerWayland = { - dataSourceHandleTarget, - dataSourceHandleSend, - dataSourceHandleCancelled, + _glfwDataSourceHandleTargetWayland, + _glfwDataSourceHandleSendWayland, + _glfwDataSourceHandleCancelledWayland, }; void _glfwSetClipboardStringWayland(const char* string) @@ -3037,7 +3037,7 @@ void _glfwSetClipboardStringWayland(const char* string) return; } wl_data_source_add_listener(_glfw.wl.selectionSource, - &dataSourceListener, + &_glfwDataSourceListenerWayland, NULL); wl_data_source_offer(_glfw.wl.selectionSource, "text/plain;charset=utf-8"); wl_data_device_set_selection(_glfw.wl.dataDevice, @@ -3059,7 +3059,7 @@ const char* _glfwGetClipboardStringWayland(void) _glfw_free(_glfw.wl.clipboardString); _glfw.wl.clipboardString = - readDataOfferAsString(_glfw.wl.selectionOffer, "text/plain;charset=utf-8"); + _glfwReadDataOfferAsStringWayland(_glfw.wl.selectionOffer, "text/plain;charset=utf-8"); return _glfw.wl.clipboardString; } @@ -3086,8 +3086,8 @@ void _glfwGetRequiredInstanceExtensionsWayland(char** extensions) if (!_glfw.vk.KHR_surface || !_glfw.vk.KHR_wayland_surface) return; - extensions[0] = "VK_KHR_surface"; - extensions[1] = "VK_KHR_wayland_surface"; + extensions[0] = (char*) "VK_KHR_surface"; + extensions[1] = (char*) "VK_KHR_wayland_surface"; } GLFWbool _glfwGetPhysicalDevicePresentationSupportWayland(VkInstance instance, diff --git a/src/x11_init.c b/src/x11_init.c index a0100f2f..f45a3fd9 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -46,7 +46,7 @@ // NOTE: This is only used as a fallback, in case the XKB method fails // It is layout-dependent and will fail partially on most non-US layouts // -static int translateKeySyms(const KeySym* keysyms, int width) +static int _glfwTranslateKeySymsX11(const KeySym* keysyms, int width) { if (width > 1) { @@ -212,7 +212,7 @@ static int translateKeySyms(const KeySym* keysyms, int width) // Create key code translation tables // -static void createKeyTables(void) +static void _glfwCreateKeyTablesX11(void) { int scancodeMin, scancodeMax; @@ -426,7 +426,7 @@ static void createKeyTables(void) if (_glfw.x11.keycodes[scancode] < 0) { const size_t base = (scancode - scancodeMin) * width; - _glfw.x11.keycodes[scancode] = translateKeySyms(&keysyms[base], width); + _glfw.x11.keycodes[scancode] = _glfwTranslateKeySymsX11(&keysyms[base], width); } // Store the reverse translation for faster key name lookup @@ -439,7 +439,7 @@ static void createKeyTables(void) // Check whether the IM has a usable style // -static GLFWbool hasUsableInputMethodStyle(void) +static GLFWbool _glfwHasUsableInputMethodStyleX11(void) { GLFWbool found = GLFW_FALSE; XIMStyles* styles = NULL; @@ -460,14 +460,14 @@ static GLFWbool hasUsableInputMethodStyle(void) return found; } -static void inputMethodDestroyCallback(XIM im, XPointer clientData, XPointer callData) +static void _glfwInputMethodDestroyCallbackX11(XIM im, XPointer clientData, XPointer callData) { _glfw.x11.im = NULL; } -static void inputMethodInstantiateCallback(Display* display, - XPointer clientData, - XPointer callData) +static void _glfwInputMethodInstantiateCallbackX11(Display* display, + XPointer clientData, + XPointer callData) { if (_glfw.x11.im) return; @@ -475,7 +475,7 @@ static void inputMethodInstantiateCallback(Display* display, _glfw.x11.im = XOpenIM(_glfw.x11.display, 0, NULL, NULL); if (_glfw.x11.im) { - if (!hasUsableInputMethodStyle()) + if (!_glfwHasUsableInputMethodStyleX11()) { XCloseIM(_glfw.x11.im); _glfw.x11.im = NULL; @@ -485,7 +485,7 @@ static void inputMethodInstantiateCallback(Display* display, if (_glfw.x11.im) { XIMCallback callback; - callback.callback = (XIMProc) inputMethodDestroyCallback; + callback.callback = (XIMProc) _glfwInputMethodDestroyCallbackX11; callback.client_data = NULL; XSetIMValues(_glfw.x11.im, XNDestroyCallback, &callback, NULL); @@ -496,7 +496,7 @@ static void inputMethodInstantiateCallback(Display* display, // Return the atom ID only if it is listed in the specified array // -static Atom getAtomIfSupported(Atom* supportedAtoms, +static Atom _glfwGetAtomIfSupportedX11(Atom* supportedAtoms, unsigned long atomCount, const char* atomName) { @@ -513,7 +513,7 @@ static Atom getAtomIfSupported(Atom* supportedAtoms, // Check whether the running window manager is EWMH-compliant // -static void detectEWMH(void) +static void _glfwdetectEWMHX11(void) { // First we read the _NET_SUPPORTING_WM_CHECK property on the root window @@ -570,33 +570,33 @@ static void detectEWMH(void) // See which of the atoms we support that are supported by the WM _glfw.x11.NET_WM_STATE = - getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE"); + _glfwGetAtomIfSupportedX11(supportedAtoms, atomCount, "_NET_WM_STATE"); _glfw.x11.NET_WM_STATE_ABOVE = - getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_ABOVE"); + _glfwGetAtomIfSupportedX11(supportedAtoms, atomCount, "_NET_WM_STATE_ABOVE"); _glfw.x11.NET_WM_STATE_FULLSCREEN = - getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_FULLSCREEN"); + _glfwGetAtomIfSupportedX11(supportedAtoms, atomCount, "_NET_WM_STATE_FULLSCREEN"); _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT = - getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_MAXIMIZED_VERT"); + _glfwGetAtomIfSupportedX11(supportedAtoms, atomCount, "_NET_WM_STATE_MAXIMIZED_VERT"); _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ = - getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_MAXIMIZED_HORZ"); + _glfwGetAtomIfSupportedX11(supportedAtoms, atomCount, "_NET_WM_STATE_MAXIMIZED_HORZ"); _glfw.x11.NET_WM_STATE_DEMANDS_ATTENTION = - getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_DEMANDS_ATTENTION"); + _glfwGetAtomIfSupportedX11(supportedAtoms, atomCount, "_NET_WM_STATE_DEMANDS_ATTENTION"); _glfw.x11.NET_WM_FULLSCREEN_MONITORS = - getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_FULLSCREEN_MONITORS"); + _glfwGetAtomIfSupportedX11(supportedAtoms, atomCount, "_NET_WM_FULLSCREEN_MONITORS"); _glfw.x11.NET_WM_WINDOW_TYPE = - getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_WINDOW_TYPE"); + _glfwGetAtomIfSupportedX11(supportedAtoms, atomCount, "_NET_WM_WINDOW_TYPE"); _glfw.x11.NET_WM_WINDOW_TYPE_NORMAL = - getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_WINDOW_TYPE_NORMAL"); + _glfwGetAtomIfSupportedX11(supportedAtoms, atomCount, "_NET_WM_WINDOW_TYPE_NORMAL"); _glfw.x11.NET_WORKAREA = - getAtomIfSupported(supportedAtoms, atomCount, "_NET_WORKAREA"); + _glfwGetAtomIfSupportedX11(supportedAtoms, atomCount, "_NET_WORKAREA"); _glfw.x11.NET_CURRENT_DESKTOP = - getAtomIfSupported(supportedAtoms, atomCount, "_NET_CURRENT_DESKTOP"); + _glfwGetAtomIfSupportedX11(supportedAtoms, atomCount, "_NET_CURRENT_DESKTOP"); _glfw.x11.NET_ACTIVE_WINDOW = - getAtomIfSupported(supportedAtoms, atomCount, "_NET_ACTIVE_WINDOW"); + _glfwGetAtomIfSupportedX11(supportedAtoms, atomCount, "_NET_ACTIVE_WINDOW"); _glfw.x11.NET_FRAME_EXTENTS = - getAtomIfSupported(supportedAtoms, atomCount, "_NET_FRAME_EXTENTS"); + _glfwGetAtomIfSupportedX11(supportedAtoms, atomCount, "_NET_FRAME_EXTENTS"); _glfw.x11.NET_REQUEST_FRAME_EXTENTS = - getAtomIfSupported(supportedAtoms, atomCount, "_NET_REQUEST_FRAME_EXTENTS"); + _glfwGetAtomIfSupportedX11(supportedAtoms, atomCount, "_NET_REQUEST_FRAME_EXTENTS"); if (supportedAtoms) XFree(supportedAtoms); @@ -604,7 +604,7 @@ static void detectEWMH(void) // Look for and initialize supported X11 extensions // -static GLFWbool initExtensions(void) +static GLFWbool _glfwInitExtensionsX11(void) { #if defined(__OpenBSD__) || defined(__NetBSD__) _glfw.x11.vidmode.handle = _glfwPlatformLoadModule("libXxf86vm.so"); @@ -910,7 +910,7 @@ static GLFWbool initExtensions(void) // Update the key code LUT // FIXME: We should listen to XkbMapNotify events to track changes to // the keyboard mapping. - createKeyTables(); + _glfwCreateKeyTablesX11(); // String format atoms _glfw.x11.NULL_ = XInternAtom(_glfw.x11.display, "NULL", False); @@ -948,7 +948,7 @@ static GLFWbool initExtensions(void) // ICCCM, EWMH and Motif window property atoms // These can be set safely even without WM support - // The EWMH atoms that require WM support are handled in detectEWMH + // The EWMH atoms that require WM support are handled in _glfwdetectEWMHX11 _glfw.x11.WM_PROTOCOLS = XInternAtom(_glfw.x11.display, "WM_PROTOCOLS", False); _glfw.x11.WM_STATE = @@ -984,14 +984,14 @@ static GLFWbool initExtensions(void) } // Detect whether an EWMH-conformant window manager is running - detectEWMH(); + _glfwdetectEWMHX11(); return GLFW_TRUE; } // Retrieve system content scale via folklore heuristics // -static void getSystemContentScale(float* xscale, float* yscale) +static void _glfwGetSystemContentScaleX11(float* xscale, float* yscale) { // Start by assuming the default X11 DPI // NOTE: Some desktop environments (KDE) may remove the Xft.dpi field when it @@ -1026,7 +1026,7 @@ static void getSystemContentScale(float* xscale, float* yscale) // Create a blank cursor for hidden and disabled cursor modes // -static Cursor createHiddenCursor(void) +static Cursor _glfwCreateHiddenCursorX11(void) { unsigned char pixels[16 * 16 * 4] = { 0 }; GLFWimage image = { 16, 16, pixels }; @@ -1035,7 +1035,7 @@ static Cursor createHiddenCursor(void) // Create a helper window for IPC // -static Window createHelperWindow(void) +static Window _glfwCreateHelperWindowX11(void) { XSetWindowAttributes wa; wa.event_mask = PropertyChangeMask; @@ -1049,7 +1049,7 @@ static Window createHelperWindow(void) // Create the pipe for empty events without assumuing the OS has pipe2(2) // -static GLFWbool createEmptyEventPipe(void) +static GLFWbool _glfwCreateEmptyEventPipeX11(void) { if (pipe(_glfw.x11.emptyEventPipe) != 0) { @@ -1080,7 +1080,7 @@ static GLFWbool createEmptyEventPipe(void) // X error handler // -static int errorHandler(Display *display, XErrorEvent* event) +static int _glfwErrorHandlerX11(Display *display, XErrorEvent* event) { if (_glfw.x11.display != display) return 0; @@ -1100,7 +1100,7 @@ void _glfwGrabErrorHandlerX11(void) { assert(_glfw.x11.errorHandler == NULL); _glfw.x11.errorCode = Success; - _glfw.x11.errorHandler = XSetErrorHandler(errorHandler); + _glfw.x11.errorHandler = XSetErrorHandler(_glfwErrorHandlerX11); } // Clears the X error handler callback @@ -1527,16 +1527,16 @@ int _glfwInitX11(void) _glfw.x11.root = RootWindow(_glfw.x11.display, _glfw.x11.screen); _glfw.x11.context = XUniqueContext(); - getSystemContentScale(&_glfw.x11.contentScaleX, &_glfw.x11.contentScaleY); + _glfwGetSystemContentScaleX11(&_glfw.x11.contentScaleX, &_glfw.x11.contentScaleY); - if (!createEmptyEventPipe()) + if (!_glfwCreateEmptyEventPipeX11()) return GLFW_FALSE; - if (!initExtensions()) + if (!_glfwInitExtensionsX11()) return GLFW_FALSE; - _glfw.x11.helperWindowHandle = createHelperWindow(); - _glfw.x11.hiddenCursorHandle = createHiddenCursor(); + _glfw.x11.helperWindowHandle = _glfwCreateHelperWindowX11(); + _glfw.x11.hiddenCursorHandle = _glfwCreateHiddenCursorX11(); if (XSupportsLocale() && _glfw.x11.xlib.utf8) { @@ -1545,7 +1545,7 @@ int _glfwInitX11(void) // If an IM is already present our callback will be called right away XRegisterIMInstantiateCallback(_glfw.x11.display, NULL, NULL, NULL, - inputMethodInstantiateCallback, + _glfwInputMethodInstantiateCallbackX11, NULL); } @@ -1578,7 +1578,7 @@ void _glfwTerminateX11(void) XUnregisterIMInstantiateCallback(_glfw.x11.display, NULL, NULL, NULL, - inputMethodInstantiateCallback, + _glfwInputMethodInstantiateCallbackX11, NULL); if (_glfw.x11.im) diff --git a/src/x11_monitor.c b/src/x11_monitor.c index 3183630b..fbf6a608 100644 --- a/src/x11_monitor.c +++ b/src/x11_monitor.c @@ -39,14 +39,14 @@ // Check whether the display mode should be included in enumeration // -static GLFWbool modeIsGood(const XRRModeInfo* mi) +static GLFWbool _glfwModeIsGoodX11(const XRRModeInfo* mi) { return (mi->modeFlags & RR_Interlace) == 0; } // Calculates the refresh rate, in Hz, from the specified RandR mode info // -static int calculateRefreshRate(const XRRModeInfo* mi) +static int _glfwCalculateRefreshRateX11(const XRRModeInfo* mi) { if (mi->hTotal && mi->vTotal) return (int) round((double) mi->dotClock / ((double) mi->hTotal * (double) mi->vTotal)); @@ -56,7 +56,7 @@ static int calculateRefreshRate(const XRRModeInfo* mi) // Returns the mode info for a RandR mode XID // -static const XRRModeInfo* getModeInfo(const XRRScreenResources* sr, RRMode id) +static const XRRModeInfo* _glfwGetModeInfoX11(const XRRScreenResources* sr, RRMode id) { for (int i = 0; i < sr->nmode; i++) { @@ -69,8 +69,8 @@ static const XRRModeInfo* getModeInfo(const XRRScreenResources* sr, RRMode id) // Convert RandR mode info to GLFW video mode // -static GLFWvidmode vidmodeFromModeInfo(const XRRModeInfo* mi, - const XRRCrtcInfo* ci) +static GLFWvidmode _glfwVidmodeFromModeInfoX11(const XRRModeInfo* mi, + const XRRCrtcInfo* ci) { GLFWvidmode mode; @@ -85,7 +85,7 @@ static GLFWvidmode vidmodeFromModeInfo(const XRRModeInfo* mi, mode.height = mi->height; } - mode.refreshRate = calculateRefreshRate(mi); + mode.refreshRate = _glfwCalculateRefreshRateX11(mi); _glfwSplitBPP(DefaultDepth(_glfw.x11.display, _glfw.x11.screen), &mode.redBits, &mode.greenBits, &mode.blueBits); @@ -245,11 +245,11 @@ void _glfwSetVideoModeX11(_GLFWmonitor* monitor, const GLFWvidmode* desired) for (int i = 0; i < oi->nmode; i++) { - const XRRModeInfo* mi = getModeInfo(sr, oi->modes[i]); - if (!modeIsGood(mi)) + const XRRModeInfo* mi = _glfwGetModeInfoX11(sr, oi->modes[i]); + if (!_glfwModeIsGoodX11(mi)) continue; - const GLFWvidmode mode = vidmodeFromModeInfo(mi, ci); + const GLFWvidmode mode = _glfwVidmodeFromModeInfoX11(mi, ci); if (_glfwCompareVideoModes(best, &mode) == 0) { native = mi->id; @@ -362,7 +362,7 @@ void _glfwGetMonitorWorkareaX11(_GLFWmonitor* monitor, areaX = ci->x; areaY = ci->y; - const XRRModeInfo* mi = getModeInfo(sr, ci->mode); + const XRRModeInfo* mi = _glfwGetModeInfoX11(sr, ci->mode); if (ci->rotation == RR_Rotate_90 || ci->rotation == RR_Rotate_270) { @@ -458,11 +458,11 @@ GLFWvidmode* _glfwGetVideoModesX11(_GLFWmonitor* monitor, int* count) for (int i = 0; i < oi->nmode; i++) { - const XRRModeInfo* mi = getModeInfo(sr, oi->modes[i]); - if (!modeIsGood(mi)) + const XRRModeInfo* mi = _glfwGetModeInfoX11(sr, oi->modes[i]); + if (!_glfwModeIsGoodX11(mi)) continue; - const GLFWvidmode mode = vidmodeFromModeInfo(mi, ci); + const GLFWvidmode mode = _glfwVidmodeFromModeInfoX11(mi, ci); int j; for (j = 0; j < *count; j++) @@ -503,9 +503,9 @@ void _glfwGetVideoModeX11(_GLFWmonitor* monitor, GLFWvidmode* mode) if (ci) { - const XRRModeInfo* mi = getModeInfo(sr, ci->mode); + const XRRModeInfo* mi = _glfwGetModeInfoX11(sr, ci->mode); if (mi) // mi can be NULL if the monitor has been disconnected - *mode = vidmodeFromModeInfo(mi, ci); + *mode = _glfwVidmodeFromModeInfoX11(mi, ci); XRRFreeCrtcInfo(ci); } diff --git a/src/x11_platform.h b/src/x11_platform.h index cdea3957..80920366 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -996,7 +996,6 @@ void _glfwTerminateGLX(void); GLFWbool _glfwCreateContextGLX(_GLFWwindow* window, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig); -void _glfwDestroyContextGLX(_GLFWwindow* window); GLFWbool _glfwChooseVisualGLX(const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig, diff --git a/src/x11_window.c b/src/x11_window.c index 7da9b965..761f899a 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -62,7 +62,7 @@ // This avoids blocking other threads via the per-display Xlib lock that also // covers GLX functions // -static GLFWbool waitForX11Event(double* timeout) +static GLFWbool _glfwWaitForEventX11(double* timeout) { struct pollfd fd = { ConnectionNumber(_glfw.x11.display), POLLIN }; @@ -79,7 +79,7 @@ static GLFWbool waitForX11Event(double* timeout) // This avoids blocking other threads via the per-display Xlib lock that also // covers GLX functions // -static GLFWbool waitForAnyEvent(double* timeout) +static GLFWbool _glfwWaitForAnyEventX11(double* timeout) { nfds_t count = 2; struct pollfd fds[3] = @@ -110,7 +110,7 @@ static GLFWbool waitForAnyEvent(double* timeout) // Writes a byte to the empty event pipe // -static void writeEmptyEvent(void) +static void _glfwWriteEmptyEventX11(void) { for (;;) { @@ -123,7 +123,7 @@ static void writeEmptyEvent(void) // Drains available data from the empty event pipe // -static void drainEmptyEvents(void) +static void _glfwDrainEmptyEventsX11(void) { for (;;) { @@ -137,7 +137,7 @@ static void drainEmptyEvents(void) // Waits until a VisibilityNotify event arrives for the specified window or the // timeout period elapses (ICCCM section 4.2.2) // -static GLFWbool waitForVisibilityNotify(_GLFWwindow* window) +static GLFWbool _glfwWaitForVisibilityNotifyX11(_GLFWwindow* window) { XEvent dummy; double timeout = 0.1; @@ -147,7 +147,7 @@ static GLFWbool waitForVisibilityNotify(_GLFWwindow* window) VisibilityNotify, &dummy)) { - if (!waitForX11Event(&timeout)) + if (!_glfwWaitForEventX11(&timeout)) return GLFW_FALSE; } @@ -156,7 +156,7 @@ static GLFWbool waitForVisibilityNotify(_GLFWwindow* window) // Returns whether the window is iconified // -static int getWindowState(_GLFWwindow* window) +static int _glfwGetWindowStateX11(_GLFWwindow* window) { int result = WithdrawnState; struct { @@ -180,7 +180,7 @@ static int getWindowState(_GLFWwindow* window) // Returns whether the event is a selection event // -static Bool isSelectionEvent(Display* display, XEvent* event, XPointer pointer) +static Bool _glfwIsSelectionEventX11(Display* display, XEvent* event, XPointer pointer) { if (event->xany.window != _glfw.x11.helperWindowHandle) return False; @@ -192,7 +192,7 @@ static Bool isSelectionEvent(Display* display, XEvent* event, XPointer pointer) // Returns whether it is a _NET_FRAME_EXTENTS event for the specified window // -static Bool isFrameExtentsEvent(Display* display, XEvent* event, XPointer pointer) +static Bool _glfwIsFrameExtentsEventX11(Display* display, XEvent* event, XPointer pointer) { _GLFWwindow* window = (_GLFWwindow*) pointer; return event->type == PropertyNotify && @@ -203,7 +203,7 @@ static Bool isFrameExtentsEvent(Display* display, XEvent* event, XPointer pointe // Returns whether it is a property event for the specified selection transfer // -static Bool isSelPropNewValueNotify(Display* display, XEvent* event, XPointer pointer) +static Bool _glfwIsSelPropNewValueNotifyX11(Display* display, XEvent* event, XPointer pointer) { XEvent* notification = (XEvent*) pointer; return event->type == PropertyNotify && @@ -214,7 +214,7 @@ static Bool isSelPropNewValueNotify(Display* display, XEvent* event, XPointer po // Translates an X event modifier state mask // -static int translateState(int state) +static int _glfwTranslateStateX11(int state) { int mods = 0; @@ -236,7 +236,7 @@ static int translateState(int state) // Translates an X11 key code to a GLFW key token // -static int translateKey(int scancode) +static int _glfwTranslateKeyX11(int scancode) { // Use the pre-filled LUT (see createKeyTables() in x11_init.c) if (scancode < 0 || scancode > 255) @@ -247,7 +247,7 @@ static int translateKey(int scancode) // Sends an EWMH or ICCCM event to the window manager // -static void sendEventToWM(_GLFWwindow* window, Atom type, +static void _glfwSendEventToWMX11(_GLFWwindow* window, Atom type, long a, long b, long c, long d, long e) { XEvent event = { ClientMessage }; @@ -268,7 +268,7 @@ static void sendEventToWM(_GLFWwindow* window, Atom type, // Updates the normal hints according to the window settings // -static void updateNormalHints(_GLFWwindow* window, int width, int height) +static void _glfwUpdateNormalHintsX11(_GLFWwindow* window, int width, int height) { XSizeHints* hints = XAllocSizeHints(); @@ -319,14 +319,14 @@ static void updateNormalHints(_GLFWwindow* window, int width, int height) // Updates the full screen status of the window // -static void updateWindowMode(_GLFWwindow* window) +static void _glfwUpdateWindowModeX11(_GLFWwindow* window) { if (window->monitor) { if (_glfw.x11.xinerama.available && _glfw.x11.NET_WM_FULLSCREEN_MONITORS) { - sendEventToWM(window, + _glfwSendEventToWMX11(window, _glfw.x11.NET_WM_FULLSCREEN_MONITORS, window->monitor->x11.index, window->monitor->x11.index, @@ -337,7 +337,7 @@ static void updateWindowMode(_GLFWwindow* window) if (_glfw.x11.NET_WM_STATE && _glfw.x11.NET_WM_STATE_FULLSCREEN) { - sendEventToWM(window, + _glfwSendEventToWMX11(window, _glfw.x11.NET_WM_STATE, _NET_WM_STATE_ADD, _glfw.x11.NET_WM_STATE_FULLSCREEN, @@ -384,7 +384,7 @@ static void updateWindowMode(_GLFWwindow* window) if (_glfw.x11.NET_WM_STATE && _glfw.x11.NET_WM_STATE_FULLSCREEN) { - sendEventToWM(window, + _glfwSendEventToWMX11(window, _glfw.x11.NET_WM_STATE, _NET_WM_STATE_REMOVE, _glfw.x11.NET_WM_STATE_FULLSCREEN, @@ -414,7 +414,7 @@ static void updateWindowMode(_GLFWwindow* window) // Decode a Unicode code point from a UTF-8 stream // Based on cutef8 by Jeff Bezanson (Public Domain) // -static uint32_t decodeUTF8(const char** s) +static uint32_t _glfwDecodeUTF8X11(const char** s) { uint32_t codepoint = 0, count = 0; static const uint32_t offsets[] = @@ -436,7 +436,7 @@ static uint32_t decodeUTF8(const char** s) // Convert the specified Latin-1 string to UTF-8 // -static char* convertLatin1toUTF8(const char* source) +static char* _glfwConvertLatin1toUTF8X11(const char* source) { size_t size = 1; const char* sp; @@ -455,7 +455,7 @@ static char* convertLatin1toUTF8(const char* source) // Updates the cursor image according to its cursor mode // -static void updateCursorImage(_GLFWwindow* window) +static void _glfwUpdateCursorImageX11(_GLFWwindow* window) { if (window->cursorMode == GLFW_CURSOR_NORMAL || window->cursorMode == GLFW_CURSOR_CAPTURED) @@ -477,7 +477,7 @@ static void updateCursorImage(_GLFWwindow* window) // Grabs the cursor and confines it to the window // -static void captureCursor(_GLFWwindow* window) +static void _glfwCaptureCursorX11(_GLFWwindow* window) { XGrabPointer(_glfw.x11.display, window->x11.handle, True, ButtonPressMask | ButtonReleaseMask | PointerMotionMask, @@ -489,14 +489,14 @@ static void captureCursor(_GLFWwindow* window) // Ungrabs the cursor // -static void releaseCursor(void) +static void _glfwReleaseCursorX11(void) { XUngrabPointer(_glfw.x11.display, CurrentTime); } // Enable XI2 raw mouse motion events // -static void enableRawMouseMotion(_GLFWwindow* window) +static void _glfwEnableRawMouseMotionX11(_GLFWwindow* window) { XIEventMask em; unsigned char mask[XIMaskLen(XI_RawMotion)] = { 0 }; @@ -511,7 +511,7 @@ static void enableRawMouseMotion(_GLFWwindow* window) // Disable XI2 raw mouse motion events // -static void disableRawMouseMotion(_GLFWwindow* window) +static void _glfwDisableRawMouseMotionX11(_GLFWwindow* window) { XIEventMask em; unsigned char mask[] = { 0 }; @@ -525,38 +525,38 @@ static void disableRawMouseMotion(_GLFWwindow* window) // Apply disabled cursor mode to a focused window // -static void disableCursor(_GLFWwindow* window) +static void _glfwDisableCursorX11(_GLFWwindow* window) { if (window->rawMouseMotion) - enableRawMouseMotion(window); + _glfwEnableRawMouseMotionX11(window); _glfw.x11.disabledCursorWindow = window; _glfwGetCursorPosX11(window, &_glfw.x11.restoreCursorPosX, &_glfw.x11.restoreCursorPosY); - updateCursorImage(window); + _glfwUpdateCursorImageX11(window); _glfwCenterCursorInContentArea(window); - captureCursor(window); + _glfwCaptureCursorX11(window); } // Exit disabled cursor mode for the specified window // -static void enableCursor(_GLFWwindow* window) +static void _glfwEnableCursorX11(_GLFWwindow* window) { if (window->rawMouseMotion) - disableRawMouseMotion(window); + _glfwDisableRawMouseMotionX11(window); _glfw.x11.disabledCursorWindow = NULL; - releaseCursor(); + _glfwReleaseCursorX11(); _glfwSetCursorPosX11(window, _glfw.x11.restoreCursorPosX, _glfw.x11.restoreCursorPosY); - updateCursorImage(window); + _glfwUpdateCursorImageX11(window); } // Clear its handle when the input context has been destroyed // -static void inputContextDestroyCallback(XIC ic, XPointer clientData, XPointer callData) +static void _glfwInputContextDestroyCallbackX11(XIC ic, XPointer clientData, XPointer callData) { _GLFWwindow* window = (_GLFWwindow*) clientData; window->x11.ic = NULL; @@ -564,9 +564,9 @@ static void inputContextDestroyCallback(XIC ic, XPointer clientData, XPointer ca // Create the X11 window (and its colormap) // -static GLFWbool createNativeWindow(_GLFWwindow* window, - const _GLFWwndconfig* wndconfig, - Visual* visual, int depth) +static GLFWbool _glfwCreateNativeWindowX11(_GLFWwindow* window, + const _GLFWwndconfig* wndconfig, + Visual* visual, int depth) { int width = wndconfig->width; int height = wndconfig->height; @@ -790,7 +790,7 @@ static GLFWbool createNativeWindow(_GLFWwindow* window, // Set the specified property to the selection converted to the requested target // -static Atom writeTargetToProperty(const XSelectionRequestEvent* request) +static Atom _glfwWriteTargetToPropertyX11(const XSelectionRequestEvent* request) { char* selectionString = NULL; const Atom formats[] = { _glfw.x11.UTF8_STRING, XA_STRING }; @@ -922,12 +922,12 @@ static Atom writeTargetToProperty(const XSelectionRequestEvent* request) return None; } -static void handleSelectionRequest(XEvent* event) +static void _glfwHandleSelectionRequestX11(XEvent* event) { const XSelectionRequestEvent* request = &event->xselectionrequest; XEvent reply = { SelectionNotify }; - reply.xselection.property = writeTargetToProperty(request); + reply.xselection.property = _glfwWriteTargetToPropertyX11(request); reply.xselection.display = request->display; reply.xselection.requestor = request->requestor; reply.xselection.selection = request->selection; @@ -937,7 +937,7 @@ static void handleSelectionRequest(XEvent* event) XSendEvent(_glfw.x11.display, request->requestor, False, 0, &reply); } -static const char* getSelectionString(Atom selection) +static const char* _glfwGetSelectionStringX11(Atom selection) { char** selectionString = NULL; const Atom targets[] = { _glfw.x11.UTF8_STRING, XA_STRING }; @@ -979,7 +979,7 @@ static const char* getSelectionString(Atom selection) SelectionNotify, ¬ification)) { - waitForX11Event(NULL); + _glfwWaitForEventX11(NULL); } if (notification.xselection.property == None) @@ -987,7 +987,7 @@ static const char* getSelectionString(Atom selection) XCheckIfEvent(_glfw.x11.display, &dummy, - isSelPropNewValueNotify, + _glfwIsSelPropNewValueNotifyX11, (XPointer) ¬ification); XGetWindowProperty(_glfw.x11.display, @@ -1012,10 +1012,10 @@ static const char* getSelectionString(Atom selection) { while (!XCheckIfEvent(_glfw.x11.display, &dummy, - isSelPropNewValueNotify, + _glfwIsSelPropNewValueNotifyX11, (XPointer) ¬ification)) { - waitForX11Event(NULL); + _glfwWaitForEventX11(NULL); } XFree(data); @@ -1046,7 +1046,7 @@ static const char* getSelectionString(Atom selection) { if (targets[i] == XA_STRING) { - *selectionString = convertLatin1toUTF8(string); + *selectionString = _glfwConvertLatin1toUTF8X11(string); _glfw_free(string); } else @@ -1060,7 +1060,7 @@ static const char* getSelectionString(Atom selection) else if (actualType == targets[i]) { if (targets[i] == XA_STRING) - *selectionString = convertLatin1toUTF8(data); + *selectionString = _glfwConvertLatin1toUTF8X11(data); else *selectionString = _glfw_strdup(data); } @@ -1082,7 +1082,7 @@ static const char* getSelectionString(Atom selection) // Make the specified window and its video mode active on its monitor // -static void acquireMonitor(_GLFWwindow* window) +static void _glfwAcquireMonitorX11(_GLFWwindow* window) { if (_glfw.x11.saver.count == 0) { @@ -1121,7 +1121,7 @@ static void acquireMonitor(_GLFWwindow* window) // Remove the window and restore the original video mode // -static void releaseMonitor(_GLFWwindow* window) +static void _glfwReleaseMonitorX11(_GLFWwindow* window) { if (window->monitor->window != window) return; @@ -1144,7 +1144,7 @@ static void releaseMonitor(_GLFWwindow* window) // Process the specified X event // -static void processEvent(XEvent *event) +static void _glfwProcessEventX11(XEvent *event) { int keycode = 0; Bool filtered = False; @@ -1219,7 +1219,7 @@ static void processEvent(XEvent *event) if (event->type == SelectionRequest) { - handleSelectionRequest(event); + _glfwHandleSelectionRequestX11(event); return; } @@ -1243,8 +1243,8 @@ static void processEvent(XEvent *event) case KeyPress: { - const int key = translateKey(keycode); - const int mods = translateState(event->xkey.state); + const int key = _glfwTranslateKeyX11(keycode); + const int mods = _glfwTranslateStateX11(event->xkey.state); const int plain = !(mods & (GLFW_MOD_CONTROL | GLFW_MOD_ALT)); if (window->x11.ic) @@ -1291,7 +1291,7 @@ static void processEvent(XEvent *event) const char* c = chars; chars[count] = '\0'; while (c - chars < count) - _glfwInputChar(window, decodeUTF8(&c), mods, plain); + _glfwInputChar(window, _glfwDecodeUTF8X11(&c), mods, plain); } if (chars != buffer) @@ -1315,8 +1315,8 @@ static void processEvent(XEvent *event) case KeyRelease: { - const int key = translateKey(keycode); - const int mods = translateState(event->xkey.state); + const int key = _glfwTranslateKeyX11(keycode); + const int mods = _glfwTranslateStateX11(event->xkey.state); if (!_glfw.x11.xkb.detectable) { @@ -1356,7 +1356,7 @@ static void processEvent(XEvent *event) case ButtonPress: { - const int mods = translateState(event->xbutton.state); + const int mods = _glfwTranslateStateX11(event->xbutton.state); if (event->xbutton.button == Button1) _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_LEFT, GLFW_PRESS, mods); @@ -1390,7 +1390,7 @@ static void processEvent(XEvent *event) case ButtonRelease: { - const int mods = translateState(event->xbutton.state); + const int mods = _glfwTranslateStateX11(event->xbutton.state); if (event->xbutton.button == Button1) { @@ -1435,7 +1435,7 @@ static void processEvent(XEvent *event) // HACK: This is a workaround for WMs (KWM, Fluxbox) that otherwise // ignore the defined cursor for hidden cursor mode if (window->cursorMode == GLFW_CURSOR_HIDDEN) - updateCursorImage(window); + _glfwUpdateCursorImageX11(window); _glfwInputCursorEnter(window, GLFW_TRUE); _glfwInputCursorPos(window, x, y); @@ -1747,9 +1747,9 @@ static void processEvent(XEvent *event) } if (window->cursorMode == GLFW_CURSOR_DISABLED) - disableCursor(window); + _glfwDisableCursorX11(window); else if (window->cursorMode == GLFW_CURSOR_CAPTURED) - captureCursor(window); + _glfwCaptureCursorX11(window); if (window->x11.ic) XSetICFocus(window->x11.ic); @@ -1769,9 +1769,9 @@ static void processEvent(XEvent *event) } if (window->cursorMode == GLFW_CURSOR_DISABLED) - enableCursor(window); + _glfwEnableCursorX11(window); else if (window->cursorMode == GLFW_CURSOR_CAPTURED) - releaseCursor(); + _glfwReleaseCursorX11(); if (window->x11.ic) XUnsetICFocus(window->x11.ic); @@ -1796,7 +1796,7 @@ static void processEvent(XEvent *event) if (event->xproperty.atom == _glfw.x11.WM_STATE) { - const int state = getWindowState(window); + const int state = _glfwGetWindowStateX11(window); if (state != IconicState && state != NormalState) return; @@ -1806,9 +1806,9 @@ static void processEvent(XEvent *event) if (window->monitor) { if (iconified) - releaseMonitor(window); + _glfwReleaseMonitorX11(window); else - acquireMonitor(window); + _glfwAcquireMonitorX11(window); } window->x11.iconified = iconified; @@ -1890,12 +1890,12 @@ void _glfwPushSelectionToManagerX11(void) { XEvent event; - while (XCheckIfEvent(_glfw.x11.display, &event, isSelectionEvent, NULL)) + while (XCheckIfEvent(_glfw.x11.display, &event, _glfwIsSelectionEventX11, NULL)) { switch (event.type) { case SelectionRequest: - handleSelectionRequest(&event); + _glfwHandleSelectionRequestX11(&event); break; case SelectionNotify: @@ -1915,14 +1915,14 @@ void _glfwPushSelectionToManagerX11(void) } } - waitForX11Event(NULL); + _glfwWaitForEventX11(NULL); } } void _glfwCreateInputContextX11(_GLFWwindow* window) { XIMCallback callback; - callback.callback = (XIMProc) inputContextDestroyCallback; + callback.callback = (XIMProc) _glfwInputContextDestroyCallbackX11; callback.client_data = (XPointer) window; window->x11.ic = XCreateIC(_glfw.x11.im, @@ -1993,7 +1993,7 @@ GLFWbool _glfwCreateWindowX11(_GLFWwindow* window, depth = DefaultDepth(_glfw.x11.display, _glfw.x11.screen); } - if (!createNativeWindow(window, wndconfig, visual, depth)) + if (!_glfwCreateNativeWindowX11(window, wndconfig, visual, depth)) return GLFW_FALSE; if (ctxconfig->client != GLFW_NO_API) @@ -2024,8 +2024,8 @@ GLFWbool _glfwCreateWindowX11(_GLFWwindow* window, if (window->monitor) { _glfwShowWindowX11(window); - updateWindowMode(window); - acquireMonitor(window); + _glfwUpdateWindowModeX11(window); + _glfwAcquireMonitorX11(window); if (wndconfig->centerCursor) _glfwCenterCursorInContentArea(window); @@ -2047,10 +2047,10 @@ GLFWbool _glfwCreateWindowX11(_GLFWwindow* window, void _glfwDestroyWindowX11(_GLFWwindow* window) { if (_glfw.x11.disabledCursorWindow == window) - enableCursor(window); + _glfwEnableCursorX11(window); if (window->monitor) - releaseMonitor(window); + _glfwReleaseMonitorX11(window); if (window->x11.ic) { @@ -2206,12 +2206,12 @@ void _glfwSetWindowSizeX11(_GLFWwindow* window, int width, int height) if (window->monitor) { if (window->monitor->window == window) - acquireMonitor(window); + _glfwAcquireMonitorX11(window); } else { if (!window->resizable) - updateNormalHints(window, width, height); + _glfwUpdateNormalHintsX11(window, width, height); XResizeWindow(_glfw.x11.display, window->x11.handle, width, height); } @@ -2225,7 +2225,7 @@ void _glfwSetWindowSizeLimitsX11(_GLFWwindow* window, { int width, height; _glfwGetWindowSizeX11(window, &width, &height); - updateNormalHints(window, width, height); + _glfwUpdateNormalHintsX11(window, width, height); XFlush(_glfw.x11.display); } @@ -2233,7 +2233,7 @@ void _glfwSetWindowAspectRatioX11(_GLFWwindow* window, int numer, int denom) { int width, height; _glfwGetWindowSizeX11(window, &width, &height); - updateNormalHints(window, width, height); + _glfwUpdateNormalHintsX11(window, width, height); XFlush(_glfw.x11.display); } @@ -2262,7 +2262,7 @@ void _glfwGetWindowFrameSizeX11(_GLFWwindow* window, // Ensure _NET_FRAME_EXTENTS is set, allowing glfwGetWindowFrameSize to // function before the window is mapped - sendEventToWM(window, _glfw.x11.NET_REQUEST_FRAME_EXTENTS, + _glfwSendEventToWMX11(window, _glfw.x11.NET_REQUEST_FRAME_EXTENTS, 0, 0, 0, 0, 0); // HACK: Use a timeout because earlier versions of some window managers @@ -2272,10 +2272,10 @@ void _glfwGetWindowFrameSizeX11(_GLFWwindow* window, // listed above, PLEASE report it to their and our issue trackers while (!XCheckIfEvent(_glfw.x11.display, &event, - isFrameExtentsEvent, + _glfwIsFrameExtentsEventX11, (XPointer) window)) { - if (!waitForX11Event(&timeout)) + if (!_glfwWaitForEventX11(&timeout)) { _glfwInputError(GLFW_PLATFORM_ERROR, "X11: The window manager has a broken _NET_REQUEST_FRAME_EXTENTS implementation; please report this issue"); @@ -2340,7 +2340,7 @@ void _glfwRestoreWindowX11(_GLFWwindow* window) if (_glfwWindowIconifiedX11(window)) { XMapWindow(_glfw.x11.display, window->x11.handle); - waitForVisibilityNotify(window); + _glfwWaitForVisibilityNotifyX11(window); } else if (_glfwWindowVisibleX11(window)) { @@ -2348,7 +2348,7 @@ void _glfwRestoreWindowX11(_GLFWwindow* window) _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT && _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ) { - sendEventToWM(window, + _glfwSendEventToWMX11(window, _glfw.x11.NET_WM_STATE, _NET_WM_STATE_REMOVE, _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT, @@ -2371,7 +2371,7 @@ void _glfwMaximizeWindowX11(_GLFWwindow* window) if (_glfwWindowVisibleX11(window)) { - sendEventToWM(window, + _glfwSendEventToWMX11(window, _glfw.x11.NET_WM_STATE, _NET_WM_STATE_ADD, _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT, @@ -2431,7 +2431,7 @@ void _glfwShowWindowX11(_GLFWwindow* window) return; XMapWindow(_glfw.x11.display, window->x11.handle); - waitForVisibilityNotify(window); + _glfwWaitForVisibilityNotifyX11(window); } void _glfwHideWindowX11(_GLFWwindow* window) @@ -2445,7 +2445,7 @@ void _glfwRequestWindowAttentionX11(_GLFWwindow* window) if (!_glfw.x11.NET_WM_STATE || !_glfw.x11.NET_WM_STATE_DEMANDS_ATTENTION) return; - sendEventToWM(window, + _glfwSendEventToWMX11(window, _glfw.x11.NET_WM_STATE, _NET_WM_STATE_ADD, _glfw.x11.NET_WM_STATE_DEMANDS_ATTENTION, @@ -2455,7 +2455,7 @@ void _glfwRequestWindowAttentionX11(_GLFWwindow* window) void _glfwFocusWindowX11(_GLFWwindow* window) { if (_glfw.x11.NET_ACTIVE_WINDOW) - sendEventToWM(window, _glfw.x11.NET_ACTIVE_WINDOW, 1, 0, 0, 0, 0); + _glfwSendEventToWMX11(window, _glfw.x11.NET_ACTIVE_WINDOW, 1, 0, 0, 0, 0); else if (_glfwWindowVisibleX11(window)) { XRaiseWindow(_glfw.x11.display, window->x11.handle); @@ -2477,12 +2477,12 @@ void _glfwSetWindowMonitorX11(_GLFWwindow* window, if (monitor) { if (monitor->window == window) - acquireMonitor(window); + _glfwAcquireMonitorX11(window); } else { if (!window->resizable) - updateNormalHints(window, width, height); + _glfwUpdateNormalHintsX11(window, width, height); XMoveResizeWindow(_glfw.x11.display, window->x11.handle, xpos, ypos, width, height); @@ -2496,26 +2496,26 @@ void _glfwSetWindowMonitorX11(_GLFWwindow* window, { _glfwSetWindowDecoratedX11(window, window->decorated); _glfwSetWindowFloatingX11(window, window->floating); - releaseMonitor(window); + _glfwReleaseMonitorX11(window); } _glfwInputWindowMonitor(window, monitor); - updateNormalHints(window, width, height); + _glfwUpdateNormalHintsX11(window, width, height); if (window->monitor) { if (!_glfwWindowVisibleX11(window)) { XMapRaised(_glfw.x11.display, window->x11.handle); - waitForVisibilityNotify(window); + _glfwWaitForVisibilityNotifyX11(window); } - updateWindowMode(window); - acquireMonitor(window); + _glfwUpdateWindowModeX11(window); + _glfwAcquireMonitorX11(window); } else { - updateWindowMode(window); + _glfwUpdateWindowModeX11(window); XMoveResizeWindow(_glfw.x11.display, window->x11.handle, xpos, ypos, width, height); } @@ -2534,7 +2534,7 @@ GLFWbool _glfwWindowFocusedX11(_GLFWwindow* window) GLFWbool _glfwWindowIconifiedX11(_GLFWwindow* window) { - return getWindowState(window) == IconicState; + return _glfwGetWindowStateX11(window) == IconicState; } GLFWbool _glfwWindowVisibleX11(_GLFWwindow* window) @@ -2618,7 +2618,7 @@ void _glfwSetWindowResizableX11(_GLFWwindow* window, GLFWbool enabled) { int width, height; _glfwGetWindowSizeX11(window, &width, &height); - updateNormalHints(window, width, height); + _glfwUpdateNormalHintsX11(window, width, height); } void _glfwSetWindowDecoratedX11(_GLFWwindow* window, GLFWbool enabled) @@ -2651,7 +2651,7 @@ void _glfwSetWindowFloatingX11(_GLFWwindow* window, GLFWbool enabled) if (_glfwWindowVisibleX11(window)) { const long action = enabled ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE; - sendEventToWM(window, + _glfwSendEventToWMX11(window, _glfw.x11.NET_WM_STATE, action, _glfw.x11.NET_WM_STATE_ABOVE, @@ -2769,9 +2769,9 @@ void _glfwSetRawMouseMotionX11(_GLFWwindow *window, GLFWbool enabled) return; if (enabled) - enableRawMouseMotion(window); + _glfwEnableRawMouseMotionX11(window); else - disableRawMouseMotion(window); + _glfwDisableRawMouseMotionX11(window); } GLFWbool _glfwRawMouseMotionSupportedX11(void) @@ -2781,7 +2781,7 @@ GLFWbool _glfwRawMouseMotionSupportedX11(void) void _glfwPollEventsX11(void) { - drainEmptyEvents(); + _glfwDrainEmptyEventsX11(); #if defined(GLFW_BUILD_LINUX_JOYSTICK) if (_glfw.joysticksInitialized) @@ -2793,7 +2793,7 @@ void _glfwPollEventsX11(void) { XEvent event; XNextEvent(_glfw.x11.display, &event); - processEvent(&event); + _glfwProcessEventX11(&event); } _GLFWwindow* window = _glfw.x11.disabledCursorWindow; @@ -2816,19 +2816,19 @@ void _glfwPollEventsX11(void) void _glfwWaitEventsX11(void) { - waitForAnyEvent(NULL); + _glfwWaitForAnyEventX11(NULL); _glfwPollEventsX11(); } void _glfwWaitEventsTimeoutX11(double timeout) { - waitForAnyEvent(&timeout); + _glfwWaitForAnyEventX11(&timeout); _glfwPollEventsX11(); } void _glfwPostEmptyEventX11(void) { - writeEmptyEvent(); + _glfwWriteEmptyEventX11(); } void _glfwGetCursorPosX11(_GLFWwindow* window, double* xpos, double* ypos) @@ -2870,18 +2870,18 @@ void _glfwSetCursorModeX11(_GLFWwindow* window, int mode) &_glfw.x11.restoreCursorPosY); _glfwCenterCursorInContentArea(window); if (window->rawMouseMotion) - enableRawMouseMotion(window); + _glfwEnableRawMouseMotionX11(window); } else if (_glfw.x11.disabledCursorWindow == window) { if (window->rawMouseMotion) - disableRawMouseMotion(window); + _glfwDisableRawMouseMotionX11(window); } if (mode == GLFW_CURSOR_DISABLED || mode == GLFW_CURSOR_CAPTURED) - captureCursor(window); + _glfwCaptureCursorX11(window); else - releaseCursor(); + _glfwReleaseCursorX11(); if (mode == GLFW_CURSOR_DISABLED) _glfw.x11.disabledCursorWindow = window; @@ -2894,7 +2894,7 @@ void _glfwSetCursorModeX11(_GLFWwindow* window, int mode) } } - updateCursorImage(window); + _glfwUpdateCursorImageX11(window); XFlush(_glfw.x11.display); } @@ -3053,7 +3053,7 @@ void _glfwSetCursorX11(_GLFWwindow* window, _GLFWcursor* cursor) if (window->cursorMode == GLFW_CURSOR_NORMAL || window->cursorMode == GLFW_CURSOR_CAPTURED) { - updateCursorImage(window); + _glfwUpdateCursorImageX11(window); XFlush(_glfw.x11.display); } } @@ -3079,7 +3079,7 @@ void _glfwSetClipboardStringX11(const char* string) const char* _glfwGetClipboardStringX11(void) { - return getSelectionString(_glfw.x11.CLIPBOARD); + return _glfwGetSelectionStringX11(_glfw.x11.CLIPBOARD); } EGLenum _glfwGetEGLPlatformX11(EGLint** attribs) @@ -3142,14 +3142,14 @@ void _glfwGetRequiredInstanceExtensionsX11(char** extensions) return; } - extensions[0] = "VK_KHR_surface"; + extensions[0] = (char*) "VK_KHR_surface"; // NOTE: VK_KHR_xcb_surface is preferred due to some early ICDs exposing but // not correctly implementing VK_KHR_xlib_surface if (_glfw.vk.KHR_xcb_surface && _glfw.x11.x11xcb.handle) - extensions[1] = "VK_KHR_xcb_surface"; + extensions[1] = (char*) "VK_KHR_xcb_surface"; else - extensions[1] = "VK_KHR_xlib_surface"; + extensions[1] = (char*) "VK_KHR_xlib_surface"; } GLFWbool _glfwGetPhysicalDevicePresentationSupportX11(VkInstance instance, @@ -3348,7 +3348,7 @@ GLFWAPI const char* glfwGetX11SelectionString(void) return NULL; } - return getSelectionString(_glfw.x11.PRIMARY); + return _glfwGetSelectionStringX11(_glfw.x11.PRIMARY); } #endif // _GLFW_X11 diff --git a/src/xkb_unicode.c b/src/xkb_unicode.c index a516af00..cc341a51 100644 --- a/src/xkb_unicode.c +++ b/src/xkb_unicode.c @@ -67,7 +67,7 @@ //**** KeySym to Unicode mapping table **** //************************************************************************ -static const struct codepair { +static const struct _glfwCodepair { unsigned short keysym; unsigned short ucs; } keysymtab[] = { @@ -911,7 +911,7 @@ static const struct codepair { uint32_t _glfwKeySym2Unicode(unsigned int keysym) { int min = 0; - int max = sizeof(keysymtab) / sizeof(struct codepair) - 1; + int max = sizeof(keysymtab) / sizeof(struct _glfwCodepair) - 1; int mid; // First check for Latin-1 characters (1:1 mapping)