diff --git a/glfw/backend_utils.c b/glfw/backend_utils.c index 508cdea62..afae54c38 100644 --- a/glfw/backend_utils.c +++ b/glfw/backend_utils.c @@ -220,7 +220,7 @@ dispatchTimers(EventLoopData *eld) { } static void -drain_wakeup_fd(int fd, int events, void* data) { +drain_wakeup_fd(int fd, int events UNUSED, void* data UNUSED) { static char drain_buf[64]; while(read(fd, drain_buf, sizeof(drain_buf)) < 0 && errno == EINTR); } diff --git a/glfw/cocoa_init.m b/glfw/cocoa_init.m index d2537a40b..e39559ecb 100644 --- a/glfw/cocoa_init.m +++ b/glfw/cocoa_init.m @@ -247,13 +247,13 @@ static bool initializeTIS(void) CFStringRef* kPropertyUnicodeKeyLayoutData = CFBundleGetDataPointerForName(_glfw.ns.tis.bundle, CFSTR("kTISPropertyUnicodeKeyLayoutData")); - _glfw.ns.tis.CopyCurrentKeyboardLayoutInputSource = + *(void **)&_glfw.ns.tis.CopyCurrentKeyboardLayoutInputSource = CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle, CFSTR("TISCopyCurrentKeyboardLayoutInputSource")); - _glfw.ns.tis.GetInputSourceProperty = + *(void **)&_glfw.ns.tis.GetInputSourceProperty = CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle, CFSTR("TISGetInputSourceProperty")); - _glfw.ns.tis.GetKbdType = + *(void **)&_glfw.ns.tis.GetKbdType = CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle, CFSTR("LMGetKbdType")); @@ -280,11 +280,13 @@ static bool initializeTIS(void) - (void)selectedKeyboardInputSourceChanged:(NSObject* )object { + (void)object; updateUnicodeDataNS(); } - (void)doNothing:(id)object { + (void)object; } @end // GLFWHelper diff --git a/glfw/cocoa_joystick.m b/glfw/cocoa_joystick.m index d27bca3d9..4a6b8fe9c 100644 --- a/glfw/cocoa_joystick.m +++ b/glfw/cocoa_joystick.m @@ -75,7 +75,7 @@ static long getElementValue(_GLFWjoystick* js, _GLFWjoyelementNS* element) // static CFComparisonResult compareElements(const void* fp, const void* sp, - void* user) + void* user UNUSED) { const _GLFWjoyelementNS* fe = fp; const _GLFWjoyelementNS* se = sp; @@ -117,9 +117,9 @@ static void closeJoystick(_GLFWjoystick* js) // Callback for user-initiated joystick addition // -static void matchCallback(void* context, - IOReturn result, - void* sender, +static void matchCallback(void* context UNUSED, + IOReturn result UNUSED, + void* sender UNUSED, IOHIDDeviceRef device) { int jid; @@ -270,9 +270,9 @@ static void matchCallback(void* context, // Callback for user-initiated joystick removal // -static void removeCallback(void* context, - IOReturn result, - void* sender, +static void removeCallback(void* context UNUSED, + IOReturn result UNUSED, + void* sender UNUSED, IOHIDDeviceRef device) { int jid; @@ -316,7 +316,7 @@ void _glfwInitJoysticksNS(void) return; } - for (int i = 0; i < sizeof(usages) / sizeof(long); i++) + for (size_t i = 0; i < sizeof(usages) / sizeof(long); i++) { const long page = kHIDPage_GenericDesktop; diff --git a/glfw/cocoa_monitor.m b/glfw/cocoa_monitor.m index 7dca4129d..3ddde7002 100644 --- a/glfw/cocoa_monitor.m +++ b/glfw/cocoa_monitor.m @@ -256,9 +256,9 @@ void _glfwClearDisplayLinks() { } static CVReturn displayLinkCallback( - CVDisplayLinkRef displayLink, - const CVTimeStamp* now, const CVTimeStamp* outputTime, - CVOptionFlags flagsIn, CVOptionFlags* flagsOut, void* userInfo) + CVDisplayLinkRef displayLink UNUSED, + const CVTimeStamp* now UNUSED, const CVTimeStamp* outputTime UNUSED, + CVOptionFlags flagsIn UNUSED, CVOptionFlags* flagsOut UNUSED, void* userInfo) { CGDirectDisplayID displayID = (CGDirectDisplayID)userInfo; [_glfw.ns.displayLinks.lock lock]; @@ -306,7 +306,7 @@ void _glfwPollMonitorsNS(void) CGGetOnlineDisplayList(displayCount, displays, &displayCount); _glfwClearDisplayLinks(); - for (uint32_t i = 0; i < _glfw.monitorCount; i++) + for (int i = 0; i < _glfw.monitorCount; i++) _glfw.monitors[i]->ns.screen = nil; _GLFWmonitor** disconnected = NULL; @@ -430,7 +430,7 @@ void _glfwRestoreVideoModeNS(_GLFWmonitor* monitor) ////// GLFW platform API ////// ////////////////////////////////////////////////////////////////////////// -void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor) +void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor UNUSED) { } @@ -559,7 +559,7 @@ void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) { CGGammaValue* values = calloc(ramp->size * 3, sizeof(CGGammaValue)); - for (int i = 0; i < ramp->size; i++) + for (unsigned int i = 0; i < ramp->size; i++) { values[i] = ramp->red[i] / 65535.f; values[i + ramp->size] = ramp->green[i] / 65535.f; diff --git a/glfw/cocoa_window.m b/glfw/cocoa_window.m index c6c214942..26756e5b3 100644 --- a/glfw/cocoa_window.m +++ b/glfw/cocoa_window.m @@ -66,7 +66,7 @@ static unsigned long long display_link_shutdown_timer = 0; #define DISPLAY_LINK_SHUTDOWN_CHECK_INTERVAL 30 void -_glfwShutdownCVDisplayLink(unsigned long long timer_id, void *user_data) { +_glfwShutdownCVDisplayLink(unsigned long long timer_id UNUSED, void *user_data UNUSED) { [_glfw.ns.displayLinks.lock lock]; display_link_shutdown_timer = 0; for (size_t i = 0; i < _glfw.ns.displayLinks.count; i++) { @@ -125,7 +125,7 @@ static bool cursorInContentArea(_GLFWwindow* window) // Hides the cursor if not already hidden // -static void hideCursor(_GLFWwindow* window) +static void hideCursor(_GLFWwindow* window UNUSED) { if (!_glfw.ns.cursorHidden) { @@ -136,7 +136,7 @@ static void hideCursor(_GLFWwindow* window) // Shows the cursor if not already shown // -static void showCursor(_GLFWwindow* window) +static void showCursor(_GLFWwindow* window UNUSED) { if (_glfw.ns.cursorHidden) { @@ -350,9 +350,8 @@ static int translateKey(unsigned int key, bool apply_keymap) } static void -display_reconfigured(CGDirectDisplayID display, CGDisplayChangeSummaryFlags flags, void *userInfo) +display_reconfigured(CGDirectDisplayID display UNUSED, CGDisplayChangeSummaryFlags flags, void *userInfo UNUSED) { - (void)(userInfo); (void)(display); (void)(flags); if (flags & kCGDisplayBeginConfigurationFlag) { return; } @@ -417,12 +416,14 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; - (BOOL)windowShouldClose:(id)sender { + (void)sender; _glfwInputWindowCloseRequest(window); return NO; } - (void)windowDidResize:(NSNotification *)notification { + (void)notification; if (window->context.client != GLFW_NO_API) [window->context.nsgl.object update]; @@ -458,6 +459,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; - (void)windowDidMove:(NSNotification *)notification { + (void)notification; if (window->context.client != GLFW_NO_API) [window->context.nsgl.object update]; @@ -471,11 +473,13 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; - (void)windowDidChangeOcclusionState:(NSNotification *)notification { + (void)notification; _glfwInputWindowOcclusion(window, !([window->ns.object occlusionState] & NSWindowOcclusionStateVisible)); } - (void)windowDidMiniaturize:(NSNotification *)notification { + (void)notification; if (window->monitor) releaseMonitor(window); @@ -484,6 +488,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; - (void)windowDidDeminiaturize:(NSNotification *)notification { + (void)notification; if (window->monitor) acquireMonitor(window); @@ -492,6 +497,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; - (void)windowDidBecomeKey:(NSNotification *)notification { + (void)notification; if (_glfw.ns.disabledCursorWindow == window) _glfwCenterCursorInContentArea(window); @@ -508,6 +514,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; - (void)windowDidResignKey:(NSNotification *)notification { + (void)notification; if (window->monitor && window->autoIconify) _glfwPlatformIconifyWindow(window); showCursor(window); @@ -517,6 +524,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; - (void)windowDidChangeScreen:(NSNotification *)notification { + (void)notification; if (window->ns.renderFrameRequested && window->ns.renderFrameCallback) { // Ensure that if the window changed its monitor, CVDisplayLink // is running for the new monitor @@ -539,6 +547,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender { + (void)sender; _GLFWwindow* window; for (window = _glfw.windowListHead; window; window = window->next) @@ -551,6 +560,7 @@ static GLFWapplicationshouldhandlereopenfun handle_reopen_callback = NULL; - (BOOL)applicationShouldHandleReopen:(NSApplication *)sender hasVisibleWindows:(BOOL)flag { + (void)sender; if (!handle_reopen_callback) return YES; if (handle_reopen_callback(flag)) return YES; return NO; @@ -558,6 +568,7 @@ static GLFWapplicationshouldhandlereopenfun handle_reopen_callback = NULL; - (void)applicationDidChangeScreenParameters:(NSNotification *) notification { + (void)notification; _GLFWwindow* window; for (window = _glfw.windowListHead; window; window = window->next) @@ -571,6 +582,7 @@ static GLFWapplicationshouldhandlereopenfun handle_reopen_callback = NULL; - (void)applicationDidFinishLaunching:(NSNotification *)notification { + (void)notification; [NSApp stop:nil]; CGDisplayRegisterReconfigurationCallback(display_reconfigured, NULL); @@ -579,11 +591,13 @@ static GLFWapplicationshouldhandlereopenfun handle_reopen_callback = NULL; - (void)applicationWillTerminate:(NSNotification *)aNotification { + (void)aNotification; CGDisplayRemoveReconfigurationCallback(display_reconfigured, NULL); } - (void)applicationDidHide:(NSNotification *)notification { + (void)notification; int i; for (i = 0; i < _glfw.monitorCount; i++) @@ -686,11 +700,13 @@ static GLFWapplicationshouldhandlereopenfun handle_reopen_callback = NULL; - (void)cursorUpdate:(NSEvent *)event { + (void)event; updateCursorImage(window); } - (BOOL)acceptsFirstMouse:(NSEvent *)event { + (void)event; return NO; // changed by Kovid, to follow cocoa platform conventions } @@ -783,11 +799,13 @@ static GLFWapplicationshouldhandlereopenfun handle_reopen_callback = NULL; - (void)mouseExited:(NSEvent *)event { + (void)event; _glfwInputCursorEnter(window, false); } - (void)mouseEntered:(NSEvent *)event { + (void)event; _glfwInputCursorEnter(window, true); } @@ -820,6 +838,7 @@ static GLFWapplicationshouldhandlereopenfun handle_reopen_callback = NULL; - (void)drawRect:(NSRect)rect { + (void)rect; _glfwInputWindowDamage(window); } @@ -1026,6 +1045,7 @@ is_ascii_control_char(char x) { - (NSDragOperation)draggingEntered:(id )sender { + (void)sender; // HACK: We don't know what to say here because we don't know what the // application wants to do with the paths return NSDragOperationGeneric; @@ -1083,6 +1103,7 @@ is_ascii_control_char(char x) { selectedRange:(NSRange)selectedRange replacementRange:(NSRange)replacementRange { + (void)selectedRange; (void)replacementRange; [markedText release]; if ([string isKindOfClass:[NSAttributedString class]]) markedText = [[NSMutableAttributedString alloc] initWithAttributedString:string]; @@ -1105,6 +1126,7 @@ void _glfwPlatformUpdateIMEState(_GLFWwindow *w, int which, int a, int b, int c, cellWidth:(CGFloat)cellWidth cellHeight:(CGFloat)cellHeight { + (void) which; left /= window->ns.xscale; top /= window->ns.yscale; cellWidth /= window->ns.xscale; @@ -1125,22 +1147,26 @@ void _glfwPlatformUpdateIMEState(_GLFWwindow *w, int which, int a, int b, int c, - (NSAttributedString*)attributedSubstringForProposedRange:(NSRange)range actualRange:(NSRangePointer)actualRange { + (void)range; (void)actualRange; return nil; } - (NSUInteger)characterIndexForPoint:(NSPoint)point { + (void)point; return 0; } - (NSRect)firstRectForCharacterRange:(NSRange)range actualRange:(NSRangePointer)actualRange { + (void)range; (void)actualRange; return markedRect; } - (void)insertText:(id)string replacementRange:(NSRange)replacementRange { + (void)replacementRange; NSString* characters; if ([string isKindOfClass:[NSAttributedString class]]) characters = [string string]; @@ -1154,6 +1180,7 @@ void _glfwPlatformUpdateIMEState(_GLFWwindow *w, int which, int a, int b, int c, - (void)doCommandBySelector:(SEL)selector { + (void)selector; } @end @@ -1510,7 +1537,7 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window) window->ns.object = nil; } -void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char *title) +void _glfwPlatformSetWindowTitle(_GLFWwindow* window UNUSED, const char *title) { NSString* string = @(title); [window->ns.object setTitle:string]; @@ -1519,8 +1546,8 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char *title) [window->ns.object setMiniwindowTitle:string]; } -void _glfwPlatformSetWindowIcon(_GLFWwindow* window, - int count, const GLFWimage* images) +void _glfwPlatformSetWindowIcon(_GLFWwindow* window UNUSED, + int count UNUSED, const GLFWimage* images UNUSED) { // Regular windows do not have icons } @@ -1630,7 +1657,7 @@ void _glfwPlatformGetWindowContentScale(_GLFWwindow* window, *yscale = (float) (pixels.size.height / points.size.height); } -double _glfwPlatformGetDoubleClickInterval(_GLFWwindow* window) +double _glfwPlatformGetDoubleClickInterval(_GLFWwindow* window UNUSED) { return [NSEvent doubleClickInterval]; } @@ -1664,12 +1691,12 @@ void _glfwPlatformHideWindow(_GLFWwindow* window) [window->ns.object orderOut:nil]; } -void _glfwPlatformRequestWindowAttention(_GLFWwindow* window) +void _glfwPlatformRequestWindowAttention(_GLFWwindow* window UNUSED) { [NSApp requestUserAttention:NSInformationalRequest]; } -int _glfwPlatformWindowBell(_GLFWwindow* window) +int _glfwPlatformWindowBell(_GLFWwindow* window UNUSED) { NSBeep(); return true; @@ -1689,7 +1716,7 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, - int refreshRate) + int refreshRate UNUSED) { if (window->monitor == monitor) { @@ -1814,12 +1841,12 @@ int _glfwPlatformFramebufferTransparent(_GLFWwindow* window) return ![window->ns.object isOpaque] && ![window->ns.view isOpaque]; } -void _glfwPlatformSetWindowResizable(_GLFWwindow* window, bool enabled) +void _glfwPlatformSetWindowResizable(_GLFWwindow* window, bool enabled UNUSED) { [window->ns.object setStyleMask:getStyleMask(window)]; } -void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, bool enabled) +void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, bool enabled UNUSED) { [window->ns.object setStyleMask:getStyleMask(window)]; [window->ns.object makeFirstResponder:window->ns.view]; @@ -1917,7 +1944,7 @@ void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y) } } -void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode) +void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode UNUSED) { if (_glfwPlatformWindowFocused(window)) updateCursorMode(window); @@ -2035,7 +2062,7 @@ void _glfwPlatformDestroyCursor(_GLFWcursor* cursor) [(NSCursor*) cursor->ns.object release]; } -void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor) +void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor UNUSED) { if (cursorInContentArea(window)) updateCursorImage(window); @@ -2105,9 +2132,9 @@ void _glfwPlatformGetRequiredInstanceExtensions(char** extensions) extensions[1] = "VK_MVK_macos_surface"; } -int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance, - VkPhysicalDevice device, - uint32_t queuefamily) +int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance UNUSED, + VkPhysicalDevice device UNUSED, + uint32_t queuefamily UNUSED) { return true; } @@ -2227,6 +2254,7 @@ GLFWAPI void glfwGetCocoaKeyEquivalent(int glfw_key, int glfw_mods, unsigned sho if (glfw_mods & GLFW_MOD_CAPS_LOCK) *cocoa_mods |= NSEventModifierFlagCapsLock; +START_ALLOW_CASE_RANGE switch(glfw_key) { #define K(ch, name) case GLFW_KEY_##name: *cocoa_key = ch; break; K('a', A); @@ -2304,6 +2332,7 @@ GLFWAPI void glfwGetCocoaKeyEquivalent(int glfw_key, int glfw_mods, unsigned sho K((unichar)(0x4E|NSEventModifierFlagNumericPad), KP_SUBTRACT); K((unichar)(0x51|NSEventModifierFlagNumericPad), KP_EQUAL); #undef K +END_ALLOW_CASE_RANGE } } diff --git a/glfw/dbus_glfw.c b/glfw/dbus_glfw.c index ce5718be3..367f89d7a 100644 --- a/glfw/dbus_glfw.c +++ b/glfw/dbus_glfw.c @@ -53,7 +53,7 @@ glfw_dbus_init(_GLFWDBUSData *dbus, EventLoopData *eld) { } static void -on_dbus_watch_ready(int fd, int events, void *data) { +on_dbus_watch_ready(int fd UNUSED, int events, void *data) { DBusWatch *watch = (DBusWatch*)data; unsigned int flags = 0; if (events & POLLERR) flags |= DBUS_WATCH_ERROR; @@ -84,19 +84,19 @@ add_dbus_watch(DBusWatch *watch, void *data) { } static void -remove_dbus_watch(DBusWatch *watch, void *data) { +remove_dbus_watch(DBusWatch *watch, void *data UNUSED) { id_type *idp = dbus_watch_get_data(watch); if (idp) removeWatch(dbus_data->eld, *idp); } static void -toggle_dbus_watch(DBusWatch *watch, void *data) { +toggle_dbus_watch(DBusWatch *watch, void *data UNUSED) { id_type *idp = dbus_watch_get_data(watch); if (idp) toggleWatch(dbus_data->eld, *idp, dbus_watch_get_enabled(watch)); } static void -on_dbus_timer_ready(id_type timer_id, void *data) { +on_dbus_timer_ready(id_type timer_id UNUSED, void *data) { if (data) { DBusTimeout *t = (DBusTimeout*)data; dbus_timeout_handle(t); @@ -123,13 +123,13 @@ add_dbus_timeout(DBusTimeout *timeout, void *data) { } static void -remove_dbus_timeout(DBusTimeout *timeout, void *data) { +remove_dbus_timeout(DBusTimeout *timeout, void *data UNUSED) { id_type *idp = dbus_timeout_get_data(timeout); if (idp) removeTimer(dbus_data->eld, *idp); } static void -toggle_dbus_timeout(DBusTimeout *timeout, void *data) { +toggle_dbus_timeout(DBusTimeout *timeout, void *data UNUSED) { id_type *idp = dbus_timeout_get_data(timeout); if (idp) toggleTimer(dbus_data->eld, *idp, dbus_timeout_get_enabled(timeout)); } @@ -178,7 +178,7 @@ glfw_dbus_session_bus_dispatch() { } void -glfw_dbus_terminate(_GLFWDBUSData *dbus) { +glfw_dbus_terminate(_GLFWDBUSData *dbus UNUSED) { if (dbus_data) { dbus_data->eld = NULL; dbus_data = NULL; diff --git a/glfw/egl_context.c b/glfw/egl_context.c index 360516e80..c8eef34f9 100644 --- a/glfw/egl_context.c +++ b/glfw/egl_context.c @@ -253,8 +253,8 @@ static GLFWglproc getProcAddressEGL(const char* procname) if (window->context.egl.client) { - GLFWglproc proc = (GLFWglproc) _glfw_dlsym(window->context.egl.client, - procname); + GLFWglproc proc = NULL; + glfw_dlsym(proc, window->context.egl.client, procname); if (proc) return proc; } @@ -335,38 +335,22 @@ bool _glfwInitEGL(void) _glfw.egl.prefix = (strncmp(sonames[i], "lib", 3) == 0); - _glfw.egl.GetConfigAttrib = (PFN_eglGetConfigAttrib) - _glfw_dlsym(_glfw.egl.handle, "eglGetConfigAttrib"); - _glfw.egl.GetConfigs = (PFN_eglGetConfigs) - _glfw_dlsym(_glfw.egl.handle, "eglGetConfigs"); - _glfw.egl.GetDisplay = (PFN_eglGetDisplay) - _glfw_dlsym(_glfw.egl.handle, "eglGetDisplay"); - _glfw.egl.GetError = (PFN_eglGetError) - _glfw_dlsym(_glfw.egl.handle, "eglGetError"); - _glfw.egl.Initialize = (PFN_eglInitialize) - _glfw_dlsym(_glfw.egl.handle, "eglInitialize"); - _glfw.egl.Terminate = (PFN_eglTerminate) - _glfw_dlsym(_glfw.egl.handle, "eglTerminate"); - _glfw.egl.BindAPI = (PFN_eglBindAPI) - _glfw_dlsym(_glfw.egl.handle, "eglBindAPI"); - _glfw.egl.CreateContext = (PFN_eglCreateContext) - _glfw_dlsym(_glfw.egl.handle, "eglCreateContext"); - _glfw.egl.DestroySurface = (PFN_eglDestroySurface) - _glfw_dlsym(_glfw.egl.handle, "eglDestroySurface"); - _glfw.egl.DestroyContext = (PFN_eglDestroyContext) - _glfw_dlsym(_glfw.egl.handle, "eglDestroyContext"); - _glfw.egl.CreateWindowSurface = (PFN_eglCreateWindowSurface) - _glfw_dlsym(_glfw.egl.handle, "eglCreateWindowSurface"); - _glfw.egl.MakeCurrent = (PFN_eglMakeCurrent) - _glfw_dlsym(_glfw.egl.handle, "eglMakeCurrent"); - _glfw.egl.SwapBuffers = (PFN_eglSwapBuffers) - _glfw_dlsym(_glfw.egl.handle, "eglSwapBuffers"); - _glfw.egl.SwapInterval = (PFN_eglSwapInterval) - _glfw_dlsym(_glfw.egl.handle, "eglSwapInterval"); - _glfw.egl.QueryString = (PFN_eglQueryString) - _glfw_dlsym(_glfw.egl.handle, "eglQueryString"); - _glfw.egl.GetProcAddress = (PFN_eglGetProcAddress) - _glfw_dlsym(_glfw.egl.handle, "eglGetProcAddress"); + glfw_dlsym(_glfw.egl.GetConfigAttrib, _glfw.egl.handle, "eglGetConfigAttrib"); + glfw_dlsym(_glfw.egl.GetConfigs, _glfw.egl.handle, "eglGetConfigs"); + glfw_dlsym(_glfw.egl.GetDisplay, _glfw.egl.handle, "eglGetDisplay"); + glfw_dlsym(_glfw.egl.GetError, _glfw.egl.handle, "eglGetError"); + glfw_dlsym(_glfw.egl.Initialize, _glfw.egl.handle, "eglInitialize"); + glfw_dlsym(_glfw.egl.Terminate, _glfw.egl.handle, "eglTerminate"); + glfw_dlsym(_glfw.egl.BindAPI, _glfw.egl.handle, "eglBindAPI"); + glfw_dlsym(_glfw.egl.CreateContext, _glfw.egl.handle, "eglCreateContext"); + glfw_dlsym(_glfw.egl.DestroySurface, _glfw.egl.handle, "eglDestroySurface"); + glfw_dlsym(_glfw.egl.DestroyContext, _glfw.egl.handle, "eglDestroyContext"); + glfw_dlsym(_glfw.egl.CreateWindowSurface, _glfw.egl.handle, "eglCreateWindowSurface"); + glfw_dlsym(_glfw.egl.MakeCurrent, _glfw.egl.handle, "eglMakeCurrent"); + glfw_dlsym(_glfw.egl.SwapBuffers, _glfw.egl.handle, "eglSwapBuffers"); + glfw_dlsym(_glfw.egl.SwapInterval, _glfw.egl.handle, "eglSwapInterval"); + glfw_dlsym(_glfw.egl.QueryString, _glfw.egl.handle, "eglQueryString"); + glfw_dlsym(_glfw.egl.GetProcAddress, _glfw.egl.handle, "eglGetProcAddress"); if (!_glfw.egl.GetConfigAttrib || !_glfw.egl.GetConfigs || @@ -714,7 +698,7 @@ bool _glfwCreateContextEGL(_GLFWwindow* window, // Returns the Visual and depth of the chosen EGLConfig // #if defined(_GLFW_X11) -bool _glfwChooseVisualEGL(const _GLFWwndconfig* wndconfig, +bool _glfwChooseVisualEGL(const _GLFWwndconfig* wndconfig UNUSED, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig, Visual** visual, int* depth) diff --git a/glfw/glfw.py b/glfw/glfw.py index ed1d42585..73a11b6a3 100755 --- a/glfw/glfw.py +++ b/glfw/glfw.py @@ -23,10 +23,7 @@ def wayland_protocol_file_name(base, ext='c'): def init_env(env, pkg_config, at_least_version, test_compile, module='x11'): ans = env.copy() - ans.cflags = [ - x for x in ans.cflags - if x not in '-Wpedantic -Wextra -pedantic-errors'.split() - ] + ans.cflags = list(ans.cflags) if not is_macos: ans.cflags.append('-pthread') ans.ldpaths.append('-pthread') diff --git a/glfw/glx_context.c b/glfw/glx_context.c index 77e90085a..d3851e17c 100644 --- a/glfw/glx_context.c +++ b/glfw/glx_context.c @@ -142,7 +142,7 @@ static bool chooseGLXFBConfig(const _GLFWfbconfig* desired, // Create the OpenGL context using legacy API // -static GLXContext createLegacyContextGLX(_GLFWwindow* window, +static GLXContext createLegacyContextGLX(_GLFWwindow* window UNUSED, GLXFBConfig fbconfig, GLXContext share) { @@ -222,8 +222,11 @@ static GLFWglproc getProcAddressGLX(const char* procname) return _glfw.glx.GetProcAddress((const GLubyte*) procname); else if (_glfw.glx.GetProcAddressARB) return _glfw.glx.GetProcAddressARB((const GLubyte*) procname); - else - return _glfw_dlsym(_glfw.glx.handle, procname); + else { + GLFWglproc ans = NULL; + glfw_dlsym(ans, _glfw.glx.handle, procname); + return ans; + } } static void destroyContextGLX(_GLFWwindow* window) @@ -280,36 +283,21 @@ bool _glfwInitGLX(void) return false; } - _glfw.glx.GetFBConfigs = - _glfw_dlsym(_glfw.glx.handle, "glXGetFBConfigs"); - _glfw.glx.GetFBConfigAttrib = - _glfw_dlsym(_glfw.glx.handle, "glXGetFBConfigAttrib"); - _glfw.glx.GetClientString = - _glfw_dlsym(_glfw.glx.handle, "glXGetClientString"); - _glfw.glx.QueryExtension = - _glfw_dlsym(_glfw.glx.handle, "glXQueryExtension"); - _glfw.glx.QueryVersion = - _glfw_dlsym(_glfw.glx.handle, "glXQueryVersion"); - _glfw.glx.DestroyContext = - _glfw_dlsym(_glfw.glx.handle, "glXDestroyContext"); - _glfw.glx.MakeCurrent = - _glfw_dlsym(_glfw.glx.handle, "glXMakeCurrent"); - _glfw.glx.SwapBuffers = - _glfw_dlsym(_glfw.glx.handle, "glXSwapBuffers"); - _glfw.glx.QueryExtensionsString = - _glfw_dlsym(_glfw.glx.handle, "glXQueryExtensionsString"); - _glfw.glx.CreateNewContext = - _glfw_dlsym(_glfw.glx.handle, "glXCreateNewContext"); - _glfw.glx.CreateWindow = - _glfw_dlsym(_glfw.glx.handle, "glXCreateWindow"); - _glfw.glx.DestroyWindow = - _glfw_dlsym(_glfw.glx.handle, "glXDestroyWindow"); - _glfw.glx.GetProcAddress = - _glfw_dlsym(_glfw.glx.handle, "glXGetProcAddress"); - _glfw.glx.GetProcAddressARB = - _glfw_dlsym(_glfw.glx.handle, "glXGetProcAddressARB"); - _glfw.glx.GetVisualFromFBConfig = - _glfw_dlsym(_glfw.glx.handle, "glXGetVisualFromFBConfig"); + glfw_dlsym(_glfw.glx.GetFBConfigs, _glfw.glx.handle, "glXGetFBConfigs"); + glfw_dlsym(_glfw.glx.GetFBConfigAttrib, _glfw.glx.handle, "glXGetFBConfigAttrib"); + glfw_dlsym(_glfw.glx.GetClientString, _glfw.glx.handle, "glXGetClientString"); + glfw_dlsym(_glfw.glx.QueryExtension, _glfw.glx.handle, "glXQueryExtension"); + glfw_dlsym(_glfw.glx.QueryVersion, _glfw.glx.handle, "glXQueryVersion"); + glfw_dlsym(_glfw.glx.DestroyContext, _glfw.glx.handle, "glXDestroyContext"); + glfw_dlsym(_glfw.glx.MakeCurrent, _glfw.glx.handle, "glXMakeCurrent"); + glfw_dlsym(_glfw.glx.SwapBuffers, _glfw.glx.handle, "glXSwapBuffers"); + glfw_dlsym(_glfw.glx.QueryExtensionsString, _glfw.glx.handle, "glXQueryExtensionsString"); + glfw_dlsym(_glfw.glx.CreateNewContext, _glfw.glx.handle, "glXCreateNewContext"); + glfw_dlsym(_glfw.glx.CreateWindow, _glfw.glx.handle, "glXCreateWindow"); + glfw_dlsym(_glfw.glx.DestroyWindow, _glfw.glx.handle, "glXDestroyWindow"); + glfw_dlsym(_glfw.glx.GetProcAddress, _glfw.glx.handle, "glXGetProcAddress"); + glfw_dlsym(_glfw.glx.GetProcAddressARB, _glfw.glx.handle, "glXGetProcAddressARB"); + glfw_dlsym(_glfw.glx.GetVisualFromFBConfig, _glfw.glx.handle, "glXGetVisualFromFBConfig"); if (!_glfw.glx.GetFBConfigs || !_glfw.glx.GetFBConfigAttrib || @@ -631,8 +619,8 @@ bool _glfwCreateContextGLX(_GLFWwindow* window, // Returns the Visual and depth of the chosen GLXFBConfig // -bool _glfwChooseVisualGLX(const _GLFWwndconfig* wndconfig, - const _GLFWctxconfig* ctxconfig, +bool _glfwChooseVisualGLX(const _GLFWwndconfig* wndconfig UNUSED, + const _GLFWctxconfig* ctxconfig UNUSED, const _GLFWfbconfig* fbconfig, Visual** visual, int* depth) { diff --git a/glfw/glx_context.h b/glfw/glx_context.h index 6abdb2b6c..d2572d033 100644 --- a/glfw/glx_context.h +++ b/glfw/glx_context.h @@ -107,8 +107,8 @@ typedef GLXContext (*PFNGLXCREATECONTEXTATTRIBSARBPROC)(Display*,GLXFBConfig,GLX #define glXCreateWindow _glfw.glx.CreateWindow #define glXDestroyWindow _glfw.glx.DestroyWindow -#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextGLX glx -#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryGLX glx +#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextGLX glx; +#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryGLX glx; // GLX-specific per-context data @@ -178,4 +178,3 @@ bool _glfwChooseVisualGLX(const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig, Visual** visual, int* depth); - diff --git a/glfw/ibus_glfw.c b/glfw/ibus_glfw.c index a21b3a5c3..d32d0cb01 100644 --- a/glfw/ibus_glfw.c +++ b/glfw/ibus_glfw.c @@ -117,7 +117,7 @@ send_text(const char *text, int state) { // Connection handling {{{ static DBusHandlerResult -message_handler(DBusConnection *conn, DBusMessage *msg, void *user_data) { +message_handler(DBusConnection *conn UNUSED, DBusMessage *msg, void *user_data) { // To monitor signals from IBUS, use //  dbus-monitor --address `ibus address` "type='signal',interface='org.freedesktop.IBus.InputContext'" _GLFWIBUSData *ibus = (_GLFWIBUSData*)user_data; diff --git a/glfw/input.c b/glfw/input.c index db899cc2a..ed1ecf567 100644 --- a/glfw/input.c +++ b/glfw/input.c @@ -1371,7 +1371,7 @@ GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state) return true; } -GLFWAPI void glfwSetClipboardString(GLFWwindow* handle, const char* string) +GLFWAPI void glfwSetClipboardString(GLFWwindow* handle UNUSED, const char* string) { assert(string != NULL); @@ -1379,14 +1379,14 @@ GLFWAPI void glfwSetClipboardString(GLFWwindow* handle, const char* string) _glfwPlatformSetClipboardString(string); } -GLFWAPI const char* glfwGetClipboardString(GLFWwindow* handle) +GLFWAPI const char* glfwGetClipboardString(GLFWwindow* handle UNUSED) { _GLFW_REQUIRE_INIT_OR_RETURN(NULL); return _glfwPlatformGetClipboardString(); } #if defined(_GLFW_X11) || defined(_GLFW_WAYLAND) -GLFWAPI void glfwSetPrimarySelectionString(GLFWwindow* handle, const char* string) +GLFWAPI void glfwSetPrimarySelectionString(GLFWwindow* handle UNUSED, const char* string) { assert(string != NULL); @@ -1394,7 +1394,7 @@ GLFWAPI void glfwSetPrimarySelectionString(GLFWwindow* handle, const char* strin _glfwPlatformSetPrimarySelectionString(string); } -GLFWAPI const char* glfwGetPrimarySelectionString(GLFWwindow* handle) +GLFWAPI const char* glfwGetPrimarySelectionString(GLFWwindow* handle UNUSED) { _GLFW_REQUIRE_INIT_OR_RETURN(NULL); return _glfwPlatformGetPrimarySelectionString(); diff --git a/glfw/internal.h b/glfw/internal.h index b08ed3988..22e870d05 100644 --- a/glfw/internal.h +++ b/glfw/internal.h @@ -225,12 +225,32 @@ typedef void (APIENTRY * PFN_vkVoidFunction)(void); // Swaps the provided pointers #define _GLFW_SWAP_POINTERS(x, y) \ - { \ - void* t; \ + do{ \ + __typeof__(x) t; \ t = x; \ x = y; \ y = t; \ - } + }while(0) + + +// Suppress some pedantic warnings +#ifdef __clang__ +#define START_ALLOW_CASE_RANGE _Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wpedantic\"") +#define END_ALLOW_CASE_RANGE _Pragma("clang diagnostic pop") +#define ALLOW_UNUSED_RESULT _Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wunused-result\"") +#define END_ALLOW_UNUSED_RESULT _Pragma("clang diagnostic pop") +#else +#define START_ALLOW_CASE_RANGE _Pragma("GCC diagnostic ignored \"-Wpedantic\"") +#define END_ALLOW_CASE_RANGE _Pragma("GCC diagnostic pop") +#define ALLOW_UNUSED_RESULT _Pragma("GCC diagnostic ignored \"-Wunused-result\"") +#define END_ALLOW_UNUSED_RESULT _Pragma("GCC diagnostic pop") +#endif + +// dlsym that works with -Wpedantic +#define glfw_dlsym(dest, handle, name) do {*(void **)&(handle) = _glfw_dlsym(handle, name);}while (0) + +// Mark function arguments as unused +#define UNUSED __attribute__ ((unused)) // Per-thread error structure // @@ -367,7 +387,7 @@ struct _GLFWcontext _GLFWdestroycontextfun destroy; // This is defined in the context API's context.h - _GLFW_PLATFORM_CONTEXT_STATE; + _GLFW_PLATFORM_CONTEXT_STATE // This is defined in egl_context.h _GLFW_EGL_CONTEXT_STATE; // This is defined in osmesa_context.h @@ -587,9 +607,9 @@ struct _GLFWlibrary // This is defined in the window API's platform.h _GLFW_PLATFORM_LIBRARY_WINDOW_STATE; // This is defined in the context API's context.h - _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE; + _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE // This is defined in the platform's joystick.h - _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE; + _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE // This is defined in egl_context.h _GLFW_EGL_LIBRARY_CONTEXT_STATE; // This is defined in osmesa_context.h diff --git a/glfw/linux_joystick.c b/glfw/linux_joystick.c index 908605d2e..479753fa0 100644 --- a/glfw/linux_joystick.c +++ b/glfw/linux_joystick.c @@ -385,7 +385,7 @@ void _glfwDetectJoystickConnectionLinux(void) ////// GLFW platform API ////// ////////////////////////////////////////////////////////////////////////// -int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode) +int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode UNUSED) { // Read all queued events (non-blocking) for (;;) @@ -425,6 +425,6 @@ int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode) return js->present; } -void _glfwPlatformUpdateGamepadGUID(char* guid) +void _glfwPlatformUpdateGamepadGUID(char* guid UNUSED) { } diff --git a/glfw/linux_joystick.h b/glfw/linux_joystick.h index 82593e448..242ace5fd 100644 --- a/glfw/linux_joystick.h +++ b/glfw/linux_joystick.h @@ -29,7 +29,7 @@ #include #define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickLinux linjs -#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE _GLFWlibraryLinux linjs +#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE _GLFWlibraryLinux linjs; #define _GLFW_PLATFORM_MAPPING_NAME "Linux" @@ -59,4 +59,3 @@ typedef struct _GLFWlibraryLinux bool _glfwInitJoysticksLinux(void); void _glfwTerminateJoysticksLinux(void); void _glfwDetectJoystickConnectionLinux(void); - diff --git a/glfw/linux_notify.c b/glfw/linux_notify.c index e608cae39..b0691cfd7 100644 --- a/glfw/linux_notify.c +++ b/glfw/linux_notify.c @@ -43,8 +43,7 @@ notification_created(DBusMessage *msg, const char* errmsg, void *data) { } static DBusHandlerResult -message_handler(DBusConnection *conn, DBusMessage *msg, void *user_data) { - (void)(user_data); +message_handler(DBusConnection *conn UNUSED, DBusMessage *msg, void *user_data UNUSED) { /* printf("session_bus message_handler invoked interface: %s member: %s\n", dbus_message_get_interface(msg), dbus_message_get_member(msg)); */ if (dbus_message_is_signal(msg, NOTIFICATIONS_IFACE, "ActionInvoked")) { uint32_t notification_id; diff --git a/glfw/nsgl_context.h b/glfw/nsgl_context.h index 961e01286..85977b90e 100644 --- a/glfw/nsgl_context.h +++ b/glfw/nsgl_context.h @@ -24,8 +24,8 @@ // //======================================================================== -#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextNSGL nsgl -#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryNSGL nsgl +#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextNSGL nsgl; +#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryNSGL nsgl; // NSGL-specific per-context data @@ -53,4 +53,3 @@ bool _glfwCreateContextNSGL(_GLFWwindow* window, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig); void _glfwDestroyContextNSGL(_GLFWwindow* window); - diff --git a/glfw/nsgl_context.m b/glfw/nsgl_context.m index 6ef0d1050..33905c2e3 100644 --- a/glfw/nsgl_context.m +++ b/glfw/nsgl_context.m @@ -43,15 +43,14 @@ static void swapBuffersNSGL(_GLFWwindow* window) [window->context.nsgl.object flushBuffer]; } -static void swapIntervalNSGL(int interval) +static void swapIntervalNSGL(int interval UNUSED) { // As of Mojave this does not work so we use CVDisplayLink instead - (void)(interval); _glfwInputError(GLFW_API_UNAVAILABLE, "NSGL: Swap intervals do not work on macOS"); } -static int extensionSupportedNSGL(const char* extension) +static int extensionSupportedNSGL(const char* extension UNUSED) { // There are no NSGL extensions return false; @@ -63,8 +62,9 @@ static GLFWglproc getProcAddressNSGL(const char* procname) procname, kCFStringEncodingASCII); - GLFWglproc symbol = CFBundleGetFunctionPointerForName(_glfw.nsgl.framework, - symbolName); + GLFWglproc symbol; + *(void **) &symbol = CFBundleGetFunctionPointerForName(_glfw.nsgl.framework, + symbolName); CFRelease(symbolName); diff --git a/glfw/null_joystick.h b/glfw/null_joystick.h index 3075815d0..d52acb602 100644 --- a/glfw/null_joystick.h +++ b/glfw/null_joystick.h @@ -25,7 +25,6 @@ //======================================================================== #define _GLFW_PLATFORM_JOYSTICK_STATE int nulljs -#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE int nulljs +#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE int nulljs; #define _GLFW_PLATFORM_MAPPING_NAME "" - diff --git a/glfw/osmesa_context.c b/glfw/osmesa_context.c index a6fa4e5c9..286822143 100644 --- a/glfw/osmesa_context.c +++ b/glfw/osmesa_context.c @@ -87,17 +87,17 @@ static void destroyContextOSMesa(_GLFWwindow* window) } } -static void swapBuffersOSMesa(_GLFWwindow* window) +static void swapBuffersOSMesa(_GLFWwindow* window UNUSED) { // No double buffering on OSMesa } -static void swapIntervalOSMesa(int interval) +static void swapIntervalOSMesa(int interval UNUSED) { // No swap interval on OSMesa } -static int extensionSupportedOSMesa(const char* extension) +static int extensionSupportedOSMesa(const char* extension UNUSED) { // OSMesa does not have extensions return false; @@ -145,20 +145,13 @@ bool _glfwInitOSMesa(void) return false; } - _glfw.osmesa.CreateContextExt = (PFN_OSMesaCreateContextExt) - _glfw_dlsym(_glfw.osmesa.handle, "OSMesaCreateContextExt"); - _glfw.osmesa.CreateContextAttribs = (PFN_OSMesaCreateContextAttribs) - _glfw_dlsym(_glfw.osmesa.handle, "OSMesaCreateContextAttribs"); - _glfw.osmesa.DestroyContext = (PFN_OSMesaDestroyContext) - _glfw_dlsym(_glfw.osmesa.handle, "OSMesaDestroyContext"); - _glfw.osmesa.MakeCurrent = (PFN_OSMesaMakeCurrent) - _glfw_dlsym(_glfw.osmesa.handle, "OSMesaMakeCurrent"); - _glfw.osmesa.GetColorBuffer = (PFN_OSMesaGetColorBuffer) - _glfw_dlsym(_glfw.osmesa.handle, "OSMesaGetColorBuffer"); - _glfw.osmesa.GetDepthBuffer = (PFN_OSMesaGetDepthBuffer) - _glfw_dlsym(_glfw.osmesa.handle, "OSMesaGetDepthBuffer"); - _glfw.osmesa.GetProcAddress = (PFN_OSMesaGetProcAddress) - _glfw_dlsym(_glfw.osmesa.handle, "OSMesaGetProcAddress"); + glfw_dlsym(_glfw.osmesa.CreateContextExt, _glfw.osmesa.handle, "OSMesaCreateContextExt"); + glfw_dlsym(_glfw.osmesa.CreateContextAttribs, _glfw.osmesa.handle, "OSMesaCreateContextAttribs"); + glfw_dlsym(_glfw.osmesa.DestroyContext, _glfw.osmesa.handle, "OSMesaDestroyContext"); + glfw_dlsym(_glfw.osmesa.MakeCurrent, _glfw.osmesa.handle, "OSMesaMakeCurrent"); + glfw_dlsym(_glfw.osmesa.GetColorBuffer, _glfw.osmesa.handle, "OSMesaGetColorBuffer"); + glfw_dlsym(_glfw.osmesa.GetDepthBuffer, _glfw.osmesa.handle, "OSMesaGetDepthBuffer"); + glfw_dlsym(_glfw.osmesa.GetProcAddress, _glfw.osmesa.handle, "OSMesaGetProcAddress"); if (!_glfw.osmesa.CreateContextExt || !_glfw.osmesa.DestroyContext || diff --git a/glfw/vulkan.c b/glfw/vulkan.c index f7f3b4267..7d62e29b2 100644 --- a/glfw/vulkan.c +++ b/glfw/vulkan.c @@ -66,7 +66,7 @@ bool _glfwInitVulkan(int mode) return false; } - _glfw.vk.GetInstanceProcAddr = (PFN_vkGetInstanceProcAddr) + *(void **) &_glfw.vk.GetInstanceProcAddr = _glfw_dlsym(_glfw.vk.handle, "vkGetInstanceProcAddr"); if (!_glfw.vk.GetInstanceProcAddr) { @@ -260,7 +260,7 @@ GLFWAPI GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance, } #else if (!proc) - proc = (GLFWvkproc) _glfw_dlsym(_glfw.vk.handle, procname); + *(void **) &proc = _glfw_dlsym(_glfw.vk.handle, procname); #endif return proc; diff --git a/glfw/wgl_context.h b/glfw/wgl_context.h index 3b5dce13f..8f86d60a0 100644 --- a/glfw/wgl_context.h +++ b/glfw/wgl_context.h @@ -103,8 +103,8 @@ typedef BOOL (WINAPI * PFN_wglShareLists)(HGLRC,HGLRC); #define _GLFW_RECREATION_REQUIRED 1 #define _GLFW_RECREATION_IMPOSSIBLE 2 -#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextWGL wgl -#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryWGL wgl +#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextWGL wgl; +#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryWGL wgl; // WGL-specific per-context data @@ -156,4 +156,3 @@ void _glfwTerminateWGL(void); bool _glfwCreateContextWGL(_GLFWwindow* window, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig); - diff --git a/glfw/window.c b/glfw/window.c index 1baf56c82..560bc3969 100644 --- a/glfw/window.c +++ b/glfw/window.c @@ -82,7 +82,7 @@ _GLFWwindow* _glfwFocusedWindow() { _GLFWwindow* _glfwWindowForId(GLFWid id) { _GLFWwindow *w = _glfw.windowListHead; while (w) { - if (w->id == _glfw.focusedWindowId) return w; + if (w->id == id) return w; w = w->next; } return NULL; diff --git a/glfw/wl_init.c b/glfw/wl_init.c index ef4d57b00..9559eedd2 100644 --- a/glfw/wl_init.c +++ b/glfw/wl_init.c @@ -79,12 +79,12 @@ static _GLFWwindow* findWindowFromDecorationSurface(struct wl_surface* surface, return window; } -static void pointerHandleEnter(void* data, - struct wl_pointer* pointer, +static void pointerHandleEnter(void* data UNUSED, + struct wl_pointer* pointer UNUSED, uint32_t serial, struct wl_surface* surface, - wl_fixed_t sx, - wl_fixed_t sy) + wl_fixed_t sx UNUSED, + wl_fixed_t sy UNUSED) { // Happens in the case we just destroyed the surface. if (!surface) @@ -109,10 +109,10 @@ static void pointerHandleEnter(void* data, _glfwInputCursorEnter(window, true); } -static void pointerHandleLeave(void* data, - struct wl_pointer* pointer, +static void pointerHandleLeave(void* data UNUSED, + struct wl_pointer* pointer UNUSED, uint32_t serial, - struct wl_surface* surface) + struct wl_surface* surface UNUSED) { _GLFWwindow* window = _glfw.wl.pointerFocus; @@ -154,9 +154,9 @@ static void setCursor(GLFWCursorShape shape) wl_surface_commit(surface); } -static void pointerHandleMotion(void* data, - struct wl_pointer* pointer, - uint32_t time, +static void pointerHandleMotion(void* data UNUSED, + struct wl_pointer* pointer UNUSED, + uint32_t time UNUSED, wl_fixed_t sx, wl_fixed_t sy) { @@ -209,10 +209,10 @@ static void pointerHandleMotion(void* data, setCursor(cursorShape); } -static void pointerHandleButton(void* data, - struct wl_pointer* pointer, +static void pointerHandleButton(void* data UNUSED, + struct wl_pointer* pointer UNUSED, uint32_t serial, - uint32_t time, + uint32_t time UNUSED, uint32_t button, uint32_t state) { @@ -296,9 +296,9 @@ static void pointerHandleButton(void* data, _glfw.wl.xkb.states.modifiers); } -static void pointerHandleAxis(void* data, - struct wl_pointer* pointer, - uint32_t time, +static void pointerHandleAxis(void* data UNUSED, + struct wl_pointer* pointer UNUSED, + uint32_t time UNUSED, uint32_t axis, wl_fixed_t value) { @@ -326,8 +326,8 @@ static const struct wl_pointer_listener pointerListener = { pointerHandleAxis, }; -static void keyboardHandleKeymap(void* data, - struct wl_keyboard* keyboard, +static void keyboardHandleKeymap(void* data UNUSED, + struct wl_keyboard* keyboard UNUSED, uint32_t format, int fd, uint32_t size) @@ -351,11 +351,11 @@ static void keyboardHandleKeymap(void* data, } -static void keyboardHandleEnter(void* data, - struct wl_keyboard* keyboard, - uint32_t serial, +static void keyboardHandleEnter(void* data UNUSED, + struct wl_keyboard* keyboard UNUSED, + uint32_t serial UNUSED, struct wl_surface* surface, - struct wl_array* keys) + struct wl_array* keys UNUSED) { // Happens in the case we just destroyed the surface. if (!surface) @@ -373,10 +373,10 @@ static void keyboardHandleEnter(void* data, _glfwInputWindowFocus(window, true); } -static void keyboardHandleLeave(void* data, - struct wl_keyboard* keyboard, - uint32_t serial, - struct wl_surface* surface) +static void keyboardHandleLeave(void* data UNUSED, + struct wl_keyboard* keyboard UNUSED, + uint32_t serial UNUSED, + struct wl_surface* surface UNUSED) { _GLFWwindow* window = _glfw.wl.keyboardFocus; @@ -388,7 +388,7 @@ static void keyboardHandleLeave(void* data, } static void -dispatchPendingKeyRepeats(id_type timer_id, void *data) { +dispatchPendingKeyRepeats(id_type timer_id UNUSED, void *data UNUSED) { if (_glfw.wl.keyRepeatInfo.keyboardFocus != _glfw.wl.keyboardFocus || _glfw.wl.keyboardRepeatRate == 0) return; glfw_xkb_handle_key_event(_glfw.wl.keyRepeatInfo.keyboardFocus, &_glfw.wl.xkb, _glfw.wl.keyRepeatInfo.key, GLFW_REPEAT); changeTimerInterval(&_glfw.wl.eventLoopData, _glfw.wl.keyRepeatInfo.keyRepeatTimer, (1.0 / (double)_glfw.wl.keyboardRepeatRate)); @@ -396,10 +396,10 @@ dispatchPendingKeyRepeats(id_type timer_id, void *data) { } -static void keyboardHandleKey(void* data, - struct wl_keyboard* keyboard, - uint32_t serial, - uint32_t time, +static void keyboardHandleKey(void* data UNUSED, + struct wl_keyboard* keyboard UNUSED, + uint32_t serial UNUSED, + uint32_t time UNUSED, uint32_t key, uint32_t state) { @@ -422,9 +422,9 @@ static void keyboardHandleKey(void* data, toggleTimer(&_glfw.wl.eventLoopData, _glfw.wl.keyRepeatInfo.keyRepeatTimer, repeatable ? 1 : 0); } -static void keyboardHandleModifiers(void* data, - struct wl_keyboard* keyboard, - uint32_t serial, +static void keyboardHandleModifiers(void* data UNUSED, + struct wl_keyboard* keyboard UNUSED, + uint32_t serial UNUSED, uint32_t modsDepressed, uint32_t modsLatched, uint32_t modsLocked, @@ -433,7 +433,7 @@ static void keyboardHandleModifiers(void* data, glfw_xkb_update_modifiers(&_glfw.wl.xkb, modsDepressed, modsLatched, modsLocked, 0, 0, group); } -static void keyboardHandleRepeatInfo(void* data, +static void keyboardHandleRepeatInfo(void* data UNUSED, struct wl_keyboard* keyboard, int32_t rate, int32_t delay) @@ -454,7 +454,7 @@ static const struct wl_keyboard_listener keyboardListener = { keyboardHandleRepeatInfo, }; -static void seatHandleCapabilities(void* data, +static void seatHandleCapabilities(void* data UNUSED, struct wl_seat* seat, enum wl_seat_capability caps) { @@ -481,9 +481,9 @@ static void seatHandleCapabilities(void* data, } } -static void seatHandleName(void* data, - struct wl_seat* seat, - const char* name) +static void seatHandleName(void* data UNUSED, + struct wl_seat* seat UNUSED, + const char* name UNUSED) { } @@ -492,7 +492,7 @@ static const struct wl_seat_listener seatListener = { seatHandleName, }; -static void wmBaseHandlePing(void* data, +static void wmBaseHandlePing(void* data UNUSED, struct xdg_wm_base* wmBase, uint32_t serial) { @@ -503,7 +503,7 @@ static const struct xdg_wm_base_listener wmBaseListener = { wmBaseHandlePing }; -static void registryHandleGlobal(void* data, +static void registryHandleGlobal(void* data UNUSED, struct wl_registry* registry, uint32_t name, const char* interface, @@ -609,8 +609,8 @@ static void registryHandleGlobal(void* data, } -static void registryHandleGlobalRemove(void *data, - struct wl_registry *registry, +static void registryHandleGlobalRemove(void *data UNUSED, + struct wl_registry *registry UNUSED, uint32_t name) { _GLFWmonitor* monitor; @@ -642,19 +642,19 @@ static const struct wl_registry_listener registryListener = { static void registry_handle_global(void* data, - struct wl_registry* registry, - uint32_t name, + struct wl_registry* registry UNUSED, + uint32_t name UNUSED, const char* interface, - uint32_t version) { + uint32_t version UNUSED) { if (strcmp(interface, "zxdg_decoration_manager_v1") == 0) { bool *has_ssd = (bool*)data; if (has_ssd) *has_ssd = true; } } -static void registry_handle_global_remove(void *data, - struct wl_registry *registry, - uint32_t name) {} +static void registry_handle_global_remove(void *data UNUSED, + struct wl_registry *registry UNUSED, + uint32_t name UNUSED) {} GLFWAPI const char* glfwWaylandCheckForServerSideDecorations(void) { struct wl_display *display = wl_display_connect(NULL); @@ -694,14 +694,10 @@ int _glfwPlatformInit(void) return false; } - _glfw.wl.cursor.theme_load = (PFN_wl_cursor_theme_load) - _glfw_dlsym(_glfw.wl.cursor.handle, "wl_cursor_theme_load"); - _glfw.wl.cursor.theme_destroy = (PFN_wl_cursor_theme_destroy) - _glfw_dlsym(_glfw.wl.cursor.handle, "wl_cursor_theme_destroy"); - _glfw.wl.cursor.theme_get_cursor = (PFN_wl_cursor_theme_get_cursor) - _glfw_dlsym(_glfw.wl.cursor.handle, "wl_cursor_theme_get_cursor"); - _glfw.wl.cursor.image_get_buffer = (PFN_wl_cursor_image_get_buffer) - _glfw_dlsym(_glfw.wl.cursor.handle, "wl_cursor_image_get_buffer"); + glfw_dlsym(_glfw.wl.cursor.theme_load, _glfw.wl.cursor.handle, "wl_cursor_theme_load"); + glfw_dlsym(_glfw.wl.cursor.theme_destroy, _glfw.wl.cursor.handle, "wl_cursor_theme_destroy"); + glfw_dlsym(_glfw.wl.cursor.theme_get_cursor, _glfw.wl.cursor.handle, "wl_cursor_theme_get_cursor"); + glfw_dlsym(_glfw.wl.cursor.image_get_buffer, _glfw.wl.cursor.handle, "wl_cursor_image_get_buffer"); _glfw.wl.egl.handle = _glfw_dlopen("libwayland-egl.so.1"); if (!_glfw.wl.egl.handle) @@ -711,12 +707,9 @@ int _glfwPlatformInit(void) return false; } - _glfw.wl.egl.window_create = (PFN_wl_egl_window_create) - _glfw_dlsym(_glfw.wl.egl.handle, "wl_egl_window_create"); - _glfw.wl.egl.window_destroy = (PFN_wl_egl_window_destroy) - _glfw_dlsym(_glfw.wl.egl.handle, "wl_egl_window_destroy"); - _glfw.wl.egl.window_resize = (PFN_wl_egl_window_resize) - _glfw_dlsym(_glfw.wl.egl.handle, "wl_egl_window_resize"); + glfw_dlsym(_glfw.wl.egl.window_create, _glfw.wl.egl.handle, "wl_egl_window_create"); + glfw_dlsym(_glfw.wl.egl.window_destroy, _glfw.wl.egl.handle, "wl_egl_window_destroy"); + glfw_dlsym(_glfw.wl.egl.window_resize, _glfw.wl.egl.handle, "wl_egl_window_resize"); _glfw.wl.display = wl_display_connect(NULL); if (!_glfw.wl.display) diff --git a/glfw/wl_monitor.c b/glfw/wl_monitor.c index c8c6bbf7f..4f358c353 100644 --- a/glfw/wl_monitor.c +++ b/glfw/wl_monitor.c @@ -34,15 +34,15 @@ static void outputHandleGeometry(void* data, - struct wl_output* output, + struct wl_output* output UNUSED, int32_t x, int32_t y, int32_t physicalWidth, int32_t physicalHeight, - int32_t subpixel, + int32_t subpixel UNUSED, const char* make, const char* model, - int32_t transform) + int32_t transform UNUSED) { struct _GLFWmonitor *monitor = data; char name[1024]; @@ -57,7 +57,7 @@ static void outputHandleGeometry(void* data, } static void outputHandleMode(void* data, - struct wl_output* output, + struct wl_output* output UNUSED, uint32_t flags, int32_t width, int32_t height, @@ -82,7 +82,7 @@ static void outputHandleMode(void* data, monitor->wl.currentMode = monitor->modeCount - 1; } -static void outputHandleDone(void* data, struct wl_output* output) +static void outputHandleDone(void* data, struct wl_output* output UNUSED) { struct _GLFWmonitor *monitor = data; for (int i = 0; i < _glfw.monitorCount; i++) { @@ -93,7 +93,7 @@ static void outputHandleDone(void* data, struct wl_output* output) } static void outputHandleScale(void* data, - struct wl_output* output, + struct wl_output* output UNUSED, int32_t factor) { struct _GLFWmonitor *monitor = data; @@ -198,15 +198,15 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode) *mode = monitor->modes[monitor->wl.currentMode]; } -bool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp) +bool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor UNUSED, GLFWgammaramp* ramp UNUSED) { _glfwInputError(GLFW_PLATFORM_ERROR, "Wayland: Gamma ramp access is not available"); return false; } -void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, - const GLFWgammaramp* ramp) +void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor UNUSED, + const GLFWgammaramp* ramp UNUSED) { _glfwInputError(GLFW_PLATFORM_ERROR, "Wayland: Gamma ramp access is not available"); @@ -223,4 +223,3 @@ GLFWAPI struct wl_output* glfwGetWaylandMonitor(GLFWmonitor* handle) _GLFW_REQUIRE_INIT_OR_RETURN(NULL); return monitor->wl.output; } - diff --git a/glfw/wl_platform.h b/glfw/wl_platform.h index 4c41d199c..66e38bbd5 100644 --- a/glfw/wl_platform.h +++ b/glfw/wl_platform.h @@ -295,7 +295,7 @@ typedef struct _GLFWlibraryWayland typedef struct _GLFWmonitorWayland { struct wl_output* output; - int name; + uint32_t name; int currentMode; int x; @@ -321,4 +321,3 @@ void _glfwSetupWaylandDataDevice(void); void _glfwSetupWaylandPrimarySelectionDevice(void); void animateCursorImage(id_type timer_id, void *data); struct wl_cursor* _glfwLoadCursor(GLFWCursorShape); - diff --git a/glfw/wl_window.c b/glfw/wl_window.c index 83ae8fa86..f997f409c 100644 --- a/glfw/wl_window.c +++ b/glfw/wl_window.c @@ -239,7 +239,7 @@ static struct wl_buffer* createShmBuffer(const GLFWimage* image) if (fd < 0) { _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: Creating a buffer file for %d B failed: %m", + "Wayland: Creating a buffer file for %d B failed: %%m", length); return NULL; } @@ -248,7 +248,7 @@ static struct wl_buffer* createShmBuffer(const GLFWimage* image) if (data == MAP_FAILED) { _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: mmap failed: %m"); + "Wayland: mmap failed: %%m"); close(fd); return NULL; } @@ -363,7 +363,7 @@ static void destroyDecorations(_GLFWwindow* window) } static void xdgDecorationHandleConfigure(void* data, - struct zxdg_toplevel_decoration_v1* decoration, + struct zxdg_toplevel_decoration_v1* decoration UNUSED, uint32_t mode) { _GLFWwindow* window = data; @@ -377,7 +377,7 @@ static const struct zxdg_toplevel_decoration_v1_listener xdgDecorationListener = }; static void handleEnter(void *data, - struct wl_surface *surface, + struct wl_surface *surface UNUSED, struct wl_output *output) { _GLFWwindow* window = data; @@ -400,7 +400,7 @@ static void handleEnter(void *data, } static void handleLeave(void *data, - struct wl_surface *surface, + struct wl_surface *surface UNUSED, struct wl_output *output) { _GLFWwindow* window = data; @@ -496,15 +496,14 @@ setFullscreen(_GLFWwindow* window, _GLFWmonitor* monitor, bool on) } bool -_glfwPlatformToggleFullscreen(_GLFWwindow *window, unsigned int flags) { - (void) flags; +_glfwPlatformToggleFullscreen(_GLFWwindow *window, unsigned int flags UNUSED) { bool already_fullscreen = window->wl.fullscreened; setFullscreen(window, NULL, !already_fullscreen); return !already_fullscreen; } static void xdgToplevelHandleConfigure(void* data, - struct xdg_toplevel* toplevel, + struct xdg_toplevel* toplevel UNUSED, int32_t width, int32_t height, struct wl_array* states) @@ -562,7 +561,7 @@ static void xdgToplevelHandleConfigure(void* data, } static void xdgToplevelHandleClose(void* data, - struct xdg_toplevel* toplevel) + struct xdg_toplevel* toplevel UNUSED) { _GLFWwindow* window = data; _glfwInputWindowCloseRequest(window); @@ -573,7 +572,7 @@ static const struct xdg_toplevel_listener xdgToplevelListener = { xdgToplevelHandleClose }; -static void xdgSurfaceHandleConfigure(void* data, +static void xdgSurfaceHandleConfigure(void* data UNUSED, struct xdg_surface* surface, uint32_t serial) { @@ -726,7 +725,7 @@ incrementCursorImage(_GLFWwindow* window) } void -animateCursorImage(id_type timer_id, void *data) { +animateCursorImage(id_type timer_id UNUSED, void *data UNUSED) { incrementCursorImage(_glfw.wl.pointerFocus); } @@ -945,14 +944,14 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title) xdg_toplevel_set_title(window->wl.xdg.toplevel, title); } -void _glfwPlatformSetWindowIcon(_GLFWwindow* window, - int count, const GLFWimage* images) +void _glfwPlatformSetWindowIcon(_GLFWwindow* window UNUSED, + int count UNUSED, const GLFWimage* images UNUSED) { _glfwInputError(GLFW_PLATFORM_ERROR, "Wayland: Setting window icon not supported"); } -void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos) +void _glfwPlatformGetWindowPos(_GLFWwindow* window UNUSED, int* xpos UNUSED, int* ypos UNUSED) { // A Wayland client is not aware of its position, so just warn and leave it // as (0, 0) @@ -961,7 +960,7 @@ void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos) "Wayland: Window position retrieval not supported"); } -void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos) +void _glfwPlatformSetWindowPos(_GLFWwindow* window UNUSED, int xpos UNUSED, int ypos UNUSED) { // A Wayland client can not set its position, so just warn @@ -1002,8 +1001,8 @@ void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window, } } -void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, - int numer, int denom) +void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window UNUSED, + int numer UNUSED, int denom UNUSED) { // TODO: find out how to trigger a resize. // The actual limits are checked in the xdg_toplevel::configure handler. @@ -1043,7 +1042,7 @@ void _glfwPlatformGetWindowContentScale(_GLFWwindow* window, *yscale = (float) window->wl.scale; } -double _glfwPlatformGetDoubleClickInterval(_GLFWwindow* window) +double _glfwPlatformGetDoubleClickInterval(_GLFWwindow* window UNUSED) { return 0.5; } @@ -1099,7 +1098,7 @@ void _glfwPlatformHideWindow(_GLFWwindow* window) window->wl.visible = false; } -void _glfwPlatformRequestWindowAttention(_GLFWwindow* window) +void _glfwPlatformRequestWindowAttention(_GLFWwindow* window UNUSED) { // TODO static bool notified = false; @@ -1110,7 +1109,7 @@ void _glfwPlatformRequestWindowAttention(_GLFWwindow* window) } } -int _glfwPlatformWindowBell(_GLFWwindow* window) +int _glfwPlatformWindowBell(_GLFWwindow* window UNUSED) { // TODO: Use an actual Wayland API to implement this when one becomes available static char tty[L_ctermid + 1]; @@ -1123,7 +1122,7 @@ int _glfwPlatformWindowBell(_GLFWwindow* window) return false; } -void _glfwPlatformFocusWindow(_GLFWwindow* window) +void _glfwPlatformFocusWindow(_GLFWwindow* window UNUSED) { _glfwInputError(GLFW_PLATFORM_ERROR, "Wayland: Focusing a window requires user interaction"); @@ -1131,9 +1130,9 @@ void _glfwPlatformFocusWindow(_GLFWwindow* window) void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, _GLFWmonitor* monitor, - int xpos, int ypos, - int width, int height, - int refreshRate) + int xpos UNUSED, int ypos UNUSED, + int width UNUSED, int height UNUSED, + int refreshRate UNUSED) { setFullscreen(window, monitor, monitor != NULL); _glfwInputWindowMonitor(window, monitor); @@ -1144,12 +1143,12 @@ int _glfwPlatformWindowFocused(_GLFWwindow* window) return _glfw.wl.keyboardFocus == window; } -int _glfwPlatformWindowOccluded(_GLFWwindow* window) +int _glfwPlatformWindowOccluded(_GLFWwindow* window UNUSED) { return false; } -int _glfwPlatformWindowIconified(_GLFWwindow* window) +int _glfwPlatformWindowIconified(_GLFWwindow* window UNUSED) { // xdg-shell doesn’t give any way to request whether a surface is // iconified. @@ -1176,7 +1175,7 @@ int _glfwPlatformFramebufferTransparent(_GLFWwindow* window) return window->wl.transparent; } -void _glfwPlatformSetWindowResizable(_GLFWwindow* window, bool enabled) +void _glfwPlatformSetWindowResizable(_GLFWwindow* window UNUSED, bool enabled UNUSED) { // TODO _glfwInputError(GLFW_PLATFORM_ERROR, @@ -1194,19 +1193,19 @@ void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, bool enabled) } } -void _glfwPlatformSetWindowFloating(_GLFWwindow* window, bool enabled) +void _glfwPlatformSetWindowFloating(_GLFWwindow* window UNUSED, bool enabled UNUSED) { // TODO _glfwInputError(GLFW_PLATFORM_ERROR, "Wayland: Window attribute setting not implemented yet"); } -float _glfwPlatformGetWindowOpacity(_GLFWwindow* window) +float _glfwPlatformGetWindowOpacity(_GLFWwindow* window UNUSED) { return 1.f; } -void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity) +void _glfwPlatformSetWindowOpacity(_GLFWwindow* window UNUSED, float opacity UNUSED) { } @@ -1254,7 +1253,7 @@ void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y) } } -void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode) +void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode UNUSED) { _glfwPlatformSetCursor(window, window->wl.currentCursor); } @@ -1271,7 +1270,7 @@ int _glfwPlatformGetKeyScancode(int key) int _glfwPlatformCreateCursor(_GLFWcursor* cursor, const GLFWimage* image, - int xhot, int yhot, int count) + int xhot, int yhot, int count UNUSED) { cursor->wl.buffer = createShmBuffer(image); if (!cursor->wl.buffer) @@ -1305,11 +1304,11 @@ void _glfwPlatformDestroyCursor(_GLFWcursor* cursor) } static void handleRelativeMotion(void* data, - struct zwp_relative_pointer_v1* pointer, - uint32_t timeHi, - uint32_t timeLo, - wl_fixed_t dx, - wl_fixed_t dy, + struct zwp_relative_pointer_v1* pointer UNUSED, + uint32_t timeHi UNUSED, + uint32_t timeLo UNUSED, + wl_fixed_t dx UNUSED, + wl_fixed_t dy UNUSED, wl_fixed_t dxUnaccel, wl_fixed_t dyUnaccel) { @@ -1327,8 +1326,8 @@ static const struct zwp_relative_pointer_v1_listener relativePointerListener = { handleRelativeMotion }; -static void handleLocked(void* data, - struct zwp_locked_pointer_v1* lockedPointer) +static void handleLocked(void* data UNUSED, + struct zwp_locked_pointer_v1* lockedPointer UNUSED) { } @@ -1346,10 +1345,10 @@ static void unlockPointer(_GLFWwindow* window) window->wl.pointerLock.lockedPointer = NULL; } -static void lockPointer(_GLFWwindow* window); +static void lockPointer(_GLFWwindow* window UNUSED); -static void handleUnlocked(void* data, - struct zwp_locked_pointer_v1* lockedPointer) +static void handleUnlocked(void* data UNUSED, + struct zwp_locked_pointer_v1* lockedPointer UNUSED) { } @@ -1471,12 +1470,12 @@ static void send_text(char *text, int fd) close(fd); } -static void _glfwSendClipboardText(void *data, struct wl_data_source *data_source, const char *mime_type, int fd) { +static void _glfwSendClipboardText(void *data UNUSED, struct wl_data_source *data_source UNUSED, const char *mime_type UNUSED, int fd) { send_text(_glfw.wl.clipboardString, fd); } -static void _glfwSendPrimarySelectionText(void *data, struct zwp_primary_selection_source_v1 *primary_selection_source, - const char *mime_type, int fd) { +static void _glfwSendPrimarySelectionText(void *data UNUSED, struct zwp_primary_selection_source_v1 *primary_selection_source UNUSED, + const char *mime_type UNUSED, int fd) { send_text(_glfw.wl.primarySelectionString, fd); } @@ -1541,28 +1540,28 @@ static char* read_data_offer(struct wl_data_offer *data_offer, const char *mime) return read_offer_string(pipefd[0]); } -static void data_source_canceled(void *data, struct wl_data_source *wl_data_source) { +static void data_source_canceled(void *data UNUSED, struct wl_data_source *wl_data_source) { if (_glfw.wl.dataSourceForClipboard == wl_data_source) _glfw.wl.dataSourceForClipboard = NULL; wl_data_source_destroy(wl_data_source); } -static void primary_selection_source_canceled(void *data, struct zwp_primary_selection_source_v1 *primary_selection_source) { +static void primary_selection_source_canceled(void *data UNUSED, struct zwp_primary_selection_source_v1 *primary_selection_source) { if (_glfw.wl.dataSourceForPrimarySelection == primary_selection_source) _glfw.wl.dataSourceForPrimarySelection = NULL; zwp_primary_selection_source_v1_destroy(primary_selection_source); } -static void data_source_target(void *data, struct wl_data_source *wl_data_source, const char* mime) { +static void data_source_target(void *data UNUSED, struct wl_data_source *wl_data_source UNUSED, const char* mime UNUSED) { } -const static struct wl_data_source_listener data_source_listener = { +static const struct wl_data_source_listener data_source_listener = { .send = _glfwSendClipboardText, .cancelled = data_source_canceled, .target = data_source_target, }; -const static struct zwp_primary_selection_source_v1_listener primary_selection_source_listener = { +static const struct zwp_primary_selection_source_v1_listener primary_selection_source_listener = { .send = _glfwSendPrimarySelectionText, .cancelled = primary_selection_source_canceled, }; @@ -1585,7 +1584,7 @@ static void prune_unclaimed_primary_selection_offers(void) { } } -static void mark_selection_offer(void *data, struct wl_data_device *data_device, struct wl_data_offer *data_offer) +static void mark_selection_offer(void *data UNUSED, struct wl_data_device *data_device UNUSED, struct wl_data_offer *data_offer) { for (size_t i = 0; i < arraysz(_glfw.wl.dataOffers); i++) { if (_glfw.wl.dataOffers[i].id == data_offer) { @@ -1597,7 +1596,7 @@ static void mark_selection_offer(void *data, struct wl_data_device *data_device, prune_unclaimed_data_offers(); } -static void mark_primary_selection_offer(void *data, struct zwp_primary_selection_device_v1* primary_selection_device, +static void mark_primary_selection_offer(void *data UNUSED, struct zwp_primary_selection_device_v1* primary_selection_device UNUSED, struct zwp_primary_selection_offer_v1 *primary_selection_offer) { for (size_t i = 0; i < arraysz(_glfw.wl.primarySelectionOffers); i++) { if (_glfw.wl.primarySelectionOffers[i].id == primary_selection_offer) { @@ -1620,7 +1619,7 @@ static void set_offer_mimetype(struct _GLFWWaylandDataOffer* offer, const char* offer->has_uri_list = 1; } -static void handle_offer_mimetype(void *data, struct wl_data_offer* id, const char *mime) { +static void handle_offer_mimetype(void *data UNUSED, struct wl_data_offer* id, const char *mime) { for (size_t i = 0; i < arraysz(_glfw.wl.dataOffers); i++) { if (_glfw.wl.dataOffers[i].id == id) { set_offer_mimetype(&_glfw.wl.dataOffers[i], mime); @@ -1629,7 +1628,7 @@ static void handle_offer_mimetype(void *data, struct wl_data_offer* id, const ch } } -static void handle_primary_selection_offer_mimetype(void *data, struct zwp_primary_selection_offer_v1* id, const char *mime) { +static void handle_primary_selection_offer_mimetype(void *data UNUSED, struct zwp_primary_selection_offer_v1* id, const char *mime) { for (size_t i = 0; i < arraysz(_glfw.wl.primarySelectionOffers); i++) { if (_glfw.wl.primarySelectionOffers[i].id == id) { set_offer_mimetype((struct _GLFWWaylandDataOffer*)&_glfw.wl.primarySelectionOffers[i], mime); @@ -1638,7 +1637,7 @@ static void handle_primary_selection_offer_mimetype(void *data, struct zwp_prima } } -static void data_offer_source_actions(void *data, struct wl_data_offer* id, uint32_t actions) { +static void data_offer_source_actions(void *data UNUSED, struct wl_data_offer* id, uint32_t actions) { for (size_t i = 0; i < arraysz(_glfw.wl.dataOffers); i++) { if (_glfw.wl.dataOffers[i].id == id) { _glfw.wl.dataOffers[i].source_actions = actions; @@ -1647,7 +1646,7 @@ static void data_offer_source_actions(void *data, struct wl_data_offer* id, uint } } -static void data_offer_action(void *data, struct wl_data_offer* id, uint32_t action) { +static void data_offer_action(void *data UNUSED, struct wl_data_offer* id, uint32_t action) { for (size_t i = 0; i < arraysz(_glfw.wl.dataOffers); i++) { if (_glfw.wl.dataOffers[i].id == id) { _glfw.wl.dataOffers[i].dnd_action = action; @@ -1667,7 +1666,7 @@ static const struct zwp_primary_selection_offer_v1_listener primary_selection_of .offer = handle_primary_selection_offer_mimetype, }; -static void handle_data_offer(void *data, struct wl_data_device *wl_data_device, struct wl_data_offer *id) { +static void handle_data_offer(void *data UNUSED, struct wl_data_device *wl_data_device UNUSED, struct wl_data_offer *id) { size_t smallest_idx = SIZE_MAX, pos = 0; for (size_t i = 0; i < arraysz(_glfw.wl.dataOffers); i++) { if (_glfw.wl.dataOffers[i].idx && _glfw.wl.dataOffers[i].idx < smallest_idx) { @@ -1688,7 +1687,7 @@ end: wl_data_offer_add_listener(id, &data_offer_listener, NULL); } -static void handle_primary_selection_offer(void *data, struct zwp_primary_selection_device_v1 *zwp_primary_selection_device_v1, struct zwp_primary_selection_offer_v1 *id) { +static void handle_primary_selection_offer(void *data UNUSED, struct zwp_primary_selection_device_v1 *zwp_primary_selection_device_v1 UNUSED, struct zwp_primary_selection_offer_v1 *id) { size_t smallest_idx = SIZE_MAX, pos = 0; for (size_t i = 0; i < arraysz(_glfw.wl.primarySelectionOffers); i++) { if (_glfw.wl.primarySelectionOffers[i].idx && _glfw.wl.primarySelectionOffers[i].idx < smallest_idx) { @@ -1709,7 +1708,7 @@ end: zwp_primary_selection_offer_v1_add_listener(id, &primary_selection_offer_listener, NULL); } -static void drag_enter(void *data, struct wl_data_device *wl_data_device, uint32_t serial, struct wl_surface *surface, wl_fixed_t x, wl_fixed_t y, struct wl_data_offer *id) { +static void drag_enter(void *data UNUSED, struct wl_data_device *wl_data_device UNUSED, uint32_t serial, struct wl_surface *surface, wl_fixed_t x UNUSED, wl_fixed_t y UNUSED, struct wl_data_offer *id) { for (size_t i = 0; i < arraysz(_glfw.wl.dataOffers); i++) { if (_glfw.wl.dataOffers[i].id == id) { _glfw.wl.dataOffers[i].offer_type = DRAG_AND_DROP; @@ -1723,7 +1722,7 @@ static void drag_enter(void *data, struct wl_data_device *wl_data_device, uint32 prune_unclaimed_data_offers(); } -static void drag_leave(void *data, struct wl_data_device *wl_data_device) { +static void drag_leave(void *data UNUSED, struct wl_data_device *wl_data_device UNUSED) { for (size_t i = 0; i < arraysz(_glfw.wl.dataOffers); i++) { if (_glfw.wl.dataOffers[i].offer_type == DRAG_AND_DROP) { wl_data_offer_destroy(_glfw.wl.dataOffers[i].id); @@ -1732,7 +1731,7 @@ static void drag_leave(void *data, struct wl_data_device *wl_data_device) { } } -static void drop(void *data, struct wl_data_device *wl_data_device) { +static void drop(void *data, struct wl_data_device *wl_data_device UNUSED) { for (size_t i = 0; i < arraysz(_glfw.wl.dataOffers); i++) { if (_glfw.wl.dataOffers[i].offer_type == DRAG_AND_DROP) { char *uri_list = read_data_offer(_glfw.wl.dataOffers[i].id, URI_LIST_MIME); @@ -1764,10 +1763,10 @@ static void drop(void *data, struct wl_data_device *wl_data_device) { } } -static void motion(void *data, struct wl_data_device *wl_data_device, uint32_t time, wl_fixed_t x, wl_fixed_t y) { +static void motion(void *data UNUSED, struct wl_data_device *wl_data_device UNUSED, uint32_t time UNUSED, wl_fixed_t x UNUSED, wl_fixed_t y UNUSED) { } -const static struct wl_data_device_listener data_device_listener = { +static const struct wl_data_device_listener data_device_listener = { .data_offer = handle_data_offer, .selection = mark_selection_offer, .enter = drag_enter, @@ -1776,7 +1775,7 @@ const static struct wl_data_device_listener data_device_listener = { .leave = drag_leave, }; -const static struct zwp_primary_selection_device_v1_listener primary_selection_device_listener = { +static const struct zwp_primary_selection_device_v1_listener primary_selection_device_listener = { .data_offer = handle_primary_selection_offer, .selection = mark_primary_selection_offer, }; @@ -1856,7 +1855,7 @@ void _glfwPlatformSetClipboardString(const char* string) wl_data_source_offer(_glfw.wl.dataSourceForClipboard, "STRING"); wl_data_source_offer(_glfw.wl.dataSourceForClipboard, "UTF8_STRING"); struct wl_callback *callback = wl_display_sync(_glfw.wl.display); - const static struct wl_callback_listener clipboard_copy_callback_listener = {.done = clipboard_copy_callback_done}; + static const struct wl_callback_listener clipboard_copy_callback_listener = {.done = clipboard_copy_callback_done}; wl_callback_add_listener(callback, &clipboard_copy_callback_listener, _glfw.wl.dataSourceForClipboard); } @@ -1905,7 +1904,7 @@ void _glfwPlatformSetPrimarySelectionString(const char* string) zwp_primary_selection_source_v1_offer(_glfw.wl.dataSourceForPrimarySelection, "STRING"); zwp_primary_selection_source_v1_offer(_glfw.wl.dataSourceForPrimarySelection, "UTF8_STRING"); struct wl_callback *callback = wl_display_sync(_glfw.wl.display); - const static struct wl_callback_listener primary_selection_copy_callback_listener = {.done = primary_selection_copy_callback_done}; + static const struct wl_callback_listener primary_selection_copy_callback_listener = {.done = primary_selection_copy_callback_done}; wl_callback_add_listener(callback, &primary_selection_copy_callback_listener, _glfw.wl.dataSourceForPrimarySelection); } @@ -1995,7 +1994,7 @@ _glfwPlatformUpdateIMEState(_GLFWwindow *w, int which, int a, int b, int c, int } static void -frame_handle_redraw(void *data, struct wl_callback *callback, uint32_t time) { +frame_handle_redraw(void *data, struct wl_callback *callback, uint32_t time UNUSED) { _GLFWwindow* window = (_GLFWwindow*) data; if (callback == window->wl.frameCallbackData.current_wl_callback) { window->wl.frameCallbackData.callback(window->wl.frameCallbackData.id); @@ -2046,4 +2045,3 @@ GLFWAPI unsigned long long glfwDBusUserNotify(const char *app_name, const char* GLFWAPI void glfwDBusSetUserNotificationHandler(GLFWDBusnotificationactivatedfun handler) { glfw_dbus_set_user_notification_activated_handler(handler); } - diff --git a/glfw/x11_init.c b/glfw/x11_init.c index 7d056a73c..bbb5c8b76 100644 --- a/glfw/x11_init.c +++ b/glfw/x11_init.c @@ -155,14 +155,10 @@ static bool initExtensions(void) _glfw.x11.vidmode.handle = _glfw_dlopen("libXxf86vm.so.1"); if (_glfw.x11.vidmode.handle) { - _glfw.x11.vidmode.QueryExtension = (PFN_XF86VidModeQueryExtension) - _glfw_dlsym(_glfw.x11.vidmode.handle, "XF86VidModeQueryExtension"); - _glfw.x11.vidmode.GetGammaRamp = (PFN_XF86VidModeGetGammaRamp) - _glfw_dlsym(_glfw.x11.vidmode.handle, "XF86VidModeGetGammaRamp"); - _glfw.x11.vidmode.SetGammaRamp = (PFN_XF86VidModeSetGammaRamp) - _glfw_dlsym(_glfw.x11.vidmode.handle, "XF86VidModeSetGammaRamp"); - _glfw.x11.vidmode.GetGammaRampSize = (PFN_XF86VidModeGetGammaRampSize) - _glfw_dlsym(_glfw.x11.vidmode.handle, "XF86VidModeGetGammaRampSize"); + glfw_dlsym(_glfw.x11.vidmode.QueryExtension, _glfw.x11.vidmode.handle, "XF86VidModeQueryExtension"); + glfw_dlsym(_glfw.x11.vidmode.GetGammaRamp, _glfw.x11.vidmode.handle, "XF86VidModeGetGammaRamp"); + glfw_dlsym(_glfw.x11.vidmode.SetGammaRamp, _glfw.x11.vidmode.handle, "XF86VidModeSetGammaRamp"); + glfw_dlsym(_glfw.x11.vidmode.GetGammaRampSize, _glfw.x11.vidmode.handle, "XF86VidModeGetGammaRampSize"); _glfw.x11.vidmode.available = XF86VidModeQueryExtension(_glfw.x11.display, @@ -177,10 +173,8 @@ static bool initExtensions(void) #endif if (_glfw.x11.xi.handle) { - _glfw.x11.xi.QueryVersion = (PFN_XIQueryVersion) - _glfw_dlsym(_glfw.x11.xi.handle, "XIQueryVersion"); - _glfw.x11.xi.SelectEvents = (PFN_XISelectEvents) - _glfw_dlsym(_glfw.x11.xi.handle, "XISelectEvents"); + glfw_dlsym(_glfw.x11.xi.QueryVersion, _glfw.x11.xi.handle, "XIQueryVersion"); + glfw_dlsym(_glfw.x11.xi.SelectEvents, _glfw.x11.xi.handle, "XISelectEvents"); if (XQueryExtension(_glfw.x11.display, "XInputExtension", @@ -207,42 +201,24 @@ static bool initExtensions(void) #endif if (_glfw.x11.randr.handle) { - _glfw.x11.randr.AllocGamma = (PFN_XRRAllocGamma) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRAllocGamma"); - _glfw.x11.randr.FreeGamma = (PFN_XRRFreeGamma) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRFreeGamma"); - _glfw.x11.randr.FreeCrtcInfo = (PFN_XRRFreeCrtcInfo) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRFreeCrtcInfo"); - _glfw.x11.randr.FreeGamma = (PFN_XRRFreeGamma) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRFreeGamma"); - _glfw.x11.randr.FreeOutputInfo = (PFN_XRRFreeOutputInfo) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRFreeOutputInfo"); - _glfw.x11.randr.FreeScreenResources = (PFN_XRRFreeScreenResources) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRFreeScreenResources"); - _glfw.x11.randr.GetCrtcGamma = (PFN_XRRGetCrtcGamma) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRGetCrtcGamma"); - _glfw.x11.randr.GetCrtcGammaSize = (PFN_XRRGetCrtcGammaSize) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRGetCrtcGammaSize"); - _glfw.x11.randr.GetCrtcInfo = (PFN_XRRGetCrtcInfo) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRGetCrtcInfo"); - _glfw.x11.randr.GetOutputInfo = (PFN_XRRGetOutputInfo) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRGetOutputInfo"); - _glfw.x11.randr.GetOutputPrimary = (PFN_XRRGetOutputPrimary) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRGetOutputPrimary"); - _glfw.x11.randr.GetScreenResourcesCurrent = (PFN_XRRGetScreenResourcesCurrent) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRGetScreenResourcesCurrent"); - _glfw.x11.randr.QueryExtension = (PFN_XRRQueryExtension) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRQueryExtension"); - _glfw.x11.randr.QueryVersion = (PFN_XRRQueryVersion) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRQueryVersion"); - _glfw.x11.randr.SelectInput = (PFN_XRRSelectInput) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRSelectInput"); - _glfw.x11.randr.SetCrtcConfig = (PFN_XRRSetCrtcConfig) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRSetCrtcConfig"); - _glfw.x11.randr.SetCrtcGamma = (PFN_XRRSetCrtcGamma) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRSetCrtcGamma"); - _glfw.x11.randr.UpdateConfiguration = (PFN_XRRUpdateConfiguration) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRUpdateConfiguration"); + glfw_dlsym(_glfw.x11.randr.AllocGamma, _glfw.x11.randr.handle, "XRRAllocGamma"); + glfw_dlsym(_glfw.x11.randr.FreeGamma, _glfw.x11.randr.handle, "XRRFreeGamma"); + glfw_dlsym(_glfw.x11.randr.FreeCrtcInfo, _glfw.x11.randr.handle, "XRRFreeCrtcInfo"); + glfw_dlsym(_glfw.x11.randr.FreeGamma, _glfw.x11.randr.handle, "XRRFreeGamma"); + glfw_dlsym(_glfw.x11.randr.FreeOutputInfo, _glfw.x11.randr.handle, "XRRFreeOutputInfo"); + glfw_dlsym(_glfw.x11.randr.FreeScreenResources, _glfw.x11.randr.handle, "XRRFreeScreenResources"); + glfw_dlsym(_glfw.x11.randr.GetCrtcGamma, _glfw.x11.randr.handle, "XRRGetCrtcGamma"); + glfw_dlsym(_glfw.x11.randr.GetCrtcGammaSize, _glfw.x11.randr.handle, "XRRGetCrtcGammaSize"); + glfw_dlsym(_glfw.x11.randr.GetCrtcInfo, _glfw.x11.randr.handle, "XRRGetCrtcInfo"); + glfw_dlsym(_glfw.x11.randr.GetOutputInfo, _glfw.x11.randr.handle, "XRRGetOutputInfo"); + glfw_dlsym(_glfw.x11.randr.GetOutputPrimary, _glfw.x11.randr.handle, "XRRGetOutputPrimary"); + glfw_dlsym(_glfw.x11.randr.GetScreenResourcesCurrent, _glfw.x11.randr.handle, "XRRGetScreenResourcesCurrent"); + glfw_dlsym(_glfw.x11.randr.QueryExtension, _glfw.x11.randr.handle, "XRRQueryExtension"); + glfw_dlsym(_glfw.x11.randr.QueryVersion, _glfw.x11.randr.handle, "XRRQueryVersion"); + glfw_dlsym(_glfw.x11.randr.SelectInput, _glfw.x11.randr.handle, "XRRSelectInput"); + glfw_dlsym(_glfw.x11.randr.SetCrtcConfig, _glfw.x11.randr.handle, "XRRSetCrtcConfig"); + glfw_dlsym(_glfw.x11.randr.SetCrtcGamma, _glfw.x11.randr.handle, "XRRSetCrtcGamma"); + glfw_dlsym(_glfw.x11.randr.UpdateConfiguration, _glfw.x11.randr.handle, "XRRUpdateConfiguration"); if (XRRQueryExtension(_glfw.x11.display, &_glfw.x11.randr.eventBase, @@ -299,12 +275,9 @@ static bool initExtensions(void) #endif if (_glfw.x11.xcursor.handle) { - _glfw.x11.xcursor.ImageCreate = (PFN_XcursorImageCreate) - _glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorImageCreate"); - _glfw.x11.xcursor.ImageDestroy = (PFN_XcursorImageDestroy) - _glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorImageDestroy"); - _glfw.x11.xcursor.ImageLoadCursor = (PFN_XcursorImageLoadCursor) - _glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorImageLoadCursor"); + glfw_dlsym(_glfw.x11.xcursor.ImageCreate, _glfw.x11.xcursor.handle, "XcursorImageCreate"); + glfw_dlsym(_glfw.x11.xcursor.ImageDestroy, _glfw.x11.xcursor.handle, "XcursorImageDestroy"); + glfw_dlsym(_glfw.x11.xcursor.ImageLoadCursor, _glfw.x11.xcursor.handle, "XcursorImageLoadCursor"); } #if defined(__CYGWIN__) @@ -314,12 +287,9 @@ static bool initExtensions(void) #endif if (_glfw.x11.xinerama.handle) { - _glfw.x11.xinerama.IsActive = (PFN_XineramaIsActive) - _glfw_dlsym(_glfw.x11.xinerama.handle, "XineramaIsActive"); - _glfw.x11.xinerama.QueryExtension = (PFN_XineramaQueryExtension) - _glfw_dlsym(_glfw.x11.xinerama.handle, "XineramaQueryExtension"); - _glfw.x11.xinerama.QueryScreens = (PFN_XineramaQueryScreens) - _glfw_dlsym(_glfw.x11.xinerama.handle, "XineramaQueryScreens"); + glfw_dlsym(_glfw.x11.xinerama.IsActive, _glfw.x11.xinerama.handle, "XineramaIsActive"); + glfw_dlsym(_glfw.x11.xinerama.QueryExtension, _glfw.x11.xinerama.handle, "XineramaQueryExtension"); + glfw_dlsym(_glfw.x11.xinerama.QueryScreens, _glfw.x11.xinerama.handle, "XineramaQueryScreens"); if (XineramaQueryExtension(_glfw.x11.display, &_glfw.x11.xinerama.major, @@ -337,12 +307,9 @@ static bool initExtensions(void) #endif if (_glfw.x11.xrender.handle) { - _glfw.x11.xrender.QueryExtension = (PFN_XRenderQueryExtension) - _glfw_dlsym(_glfw.x11.xrender.handle, "XRenderQueryExtension"); - _glfw.x11.xrender.QueryVersion = (PFN_XRenderQueryVersion) - _glfw_dlsym(_glfw.x11.xrender.handle, "XRenderQueryVersion"); - _glfw.x11.xrender.FindVisualFormat = (PFN_XRenderFindVisualFormat) - _glfw_dlsym(_glfw.x11.xrender.handle, "XRenderFindVisualFormat"); + glfw_dlsym(_glfw.x11.xrender.QueryExtension, _glfw.x11.xrender.handle, "XRenderQueryExtension"); + glfw_dlsym(_glfw.x11.xrender.QueryVersion, _glfw.x11.xrender.handle, "XRenderQueryVersion"); + glfw_dlsym(_glfw.x11.xrender.FindVisualFormat, _glfw.x11.xrender.handle, "XRenderFindVisualFormat"); if (XRenderQueryExtension(_glfw.x11.display, &_glfw.x11.xrender.errorBase, @@ -536,7 +503,7 @@ static Window createHelperWindow(void) // X error handler // -static int errorHandler(Display *display, XErrorEvent* event) +static int errorHandler(Display *display UNUSED, XErrorEvent* event) { _glfw.x11.errorCode = event->error_code; return 0; diff --git a/glfw/x11_monitor.c b/glfw/x11_monitor.c index 55e37c489..b247b23a6 100644 --- a/glfw/x11_monitor.c +++ b/glfw/x11_monitor.c @@ -172,8 +172,8 @@ void _glfwPollMonitorsX11(void) { if (screens[j].x_org == ci->x && screens[j].y_org == ci->y && - screens[j].width == ci->width && - screens[j].height == ci->height) + screens[j].width == (short int)ci->width && + screens[j].height == (short int)ci->height) { monitor->x11.index = j; break; @@ -301,7 +301,7 @@ void _glfwRestoreVideoModeX11(_GLFWmonitor* monitor) ////// GLFW platform API ////// ////////////////////////////////////////////////////////////////////////// -void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor) +void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor UNUSED) { } @@ -325,7 +325,7 @@ void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos) } } -void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor, +void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor UNUSED, float* xscale, float* yscale) { if (xscale) @@ -547,7 +547,7 @@ void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) { if (_glfw.x11.randr.available && !_glfw.x11.randr.gammaBroken) { - if (XRRGetCrtcGammaSize(_glfw.x11.display, monitor->x11.crtc) != ramp->size) + if (XRRGetCrtcGammaSize(_glfw.x11.display, monitor->x11.crtc) != (int)ramp->size) { _glfwInputError(GLFW_PLATFORM_ERROR, "X11: Gamma ramp size must match current ramp size"); diff --git a/glfw/x11_window.c b/glfw/x11_window.c index 9e046122a..6415141fa 100644 --- a/glfw/x11_window.c +++ b/glfw/x11_window.c @@ -139,7 +139,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 isSelectionEvent(Display* display UNUSED, XEvent* event, XPointer pointer UNUSED) { if (event->xany.window != _glfw.x11.helperWindowHandle) return False; @@ -151,7 +151,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 isFrameExtentsEvent(Display* display UNUSED, XEvent* event, XPointer pointer) { _GLFWwindow* window = (_GLFWwindow*) pointer; return event->type == PropertyNotify && @@ -162,7 +162,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 isSelPropNewValueNotify(Display* display UNUSED, XEvent* event, XPointer pointer) { XEvent* notification = (XEvent*) pointer; return event->type == PropertyNotify && @@ -326,8 +326,7 @@ set_fullscreen(_GLFWwindow *window, bool on) { } bool -_glfwPlatformToggleFullscreen(_GLFWwindow *window, unsigned int flags) { - (void) flags; +_glfwPlatformToggleFullscreen(_GLFWwindow *window, unsigned int flags UNUSED) { bool already_fullscreen = is_window_fullscreen(window); set_fullscreen(window, !already_fullscreen); return !already_fullscreen; @@ -2010,8 +2009,8 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height) } void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window, - int minwidth, int minheight, - int maxwidth, int maxheight) + int minwidth UNUSED, int minheight UNUSED, + int maxwidth UNUSED, int maxheight UNUSED) { int width, height; _glfwPlatformGetWindowSize(window, &width, &height); @@ -2019,7 +2018,7 @@ void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window, XFlush(_glfw.x11.display); } -void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int numer, int denom) +void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int numer UNUSED, int denom UNUSED) { int width, height; _glfwPlatformGetWindowSize(window, &width, &height); @@ -2092,7 +2091,7 @@ void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window, XFree(extents); } -void _glfwPlatformGetWindowContentScale(_GLFWwindow* window, +void _glfwPlatformGetWindowContentScale(_GLFWwindow* window UNUSED, float* xscale, float* yscale) { if (xscale) @@ -2101,7 +2100,7 @@ void _glfwPlatformGetWindowContentScale(_GLFWwindow* window, *yscale = _glfw.x11.contentScaleY; } -double _glfwPlatformGetDoubleClickInterval(_GLFWwindow* window) +double _glfwPlatformGetDoubleClickInterval(_GLFWwindow* window UNUSED) { return 0.5; } @@ -2200,7 +2199,7 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, - int refreshRate) + int refreshRate UNUSED) { if (window->monitor == monitor) { @@ -2258,7 +2257,7 @@ int _glfwPlatformWindowFocused(_GLFWwindow* window) return window->x11.handle == focused; } -int _glfwPlatformWindowOccluded(_GLFWwindow* window) +int _glfwPlatformWindowOccluded(_GLFWwindow* window UNUSED) { return false; } @@ -2339,7 +2338,7 @@ int _glfwPlatformFramebufferTransparent(_GLFWwindow* window) return XGetSelectionOwner(_glfw.x11.display, _glfw.x11.NET_WM_CM_Sx) != None; } -void _glfwPlatformSetWindowResizable(_GLFWwindow* window, bool enabled) +void _glfwPlatformSetWindowResizable(_GLFWwindow* window, bool enabled UNUSED) { int width, height; _glfwPlatformGetWindowSize(window, &width, &height); @@ -2597,7 +2596,7 @@ int _glfwPlatformGetKeyScancode(int key) int _glfwPlatformCreateCursor(_GLFWcursor* cursor, const GLFWimage* image, - int xhot, int yhot, int count) + int xhot, int yhot, int count UNUSED) { cursor->x11.handle = _glfwCreateCursorX11(image, xhot, yhot); if (!cursor->x11.handle) @@ -2643,7 +2642,7 @@ void _glfwPlatformDestroyCursor(_GLFWcursor* cursor) XFreeCursor(_glfw.x11.display, cursor->x11.handle); } -void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor) +void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor UNUSED) { if (window->cursorMode == GLFW_CURSOR_NORMAL) { diff --git a/glfw/xkb_glfw.c b/glfw/xkb_glfw.c index 386668be7..19626f090 100644 --- a/glfw/xkb_glfw.c +++ b/glfw/xkb_glfw.c @@ -29,6 +29,7 @@ #include #include "internal.h" #include "xkb_glfw.h" +START_ALLOW_CASE_RANGE #define debug(...) if (_glfw.hints.init.debugKeyboard) printf(__VA_ARGS__); @@ -101,7 +102,7 @@ glfw_key_for_sym(xkb_keysym_t key) { #define S(f, t) case XKB_KEY_##f: return GLFW_KEY_##t #define F(f, t) S(f, t) #define R(s, e, gs, ...) case XKB_KEY_##s ... XKB_KEY_##e: return GLFW_KEY_##gs + key - XKB_KEY_##s -#define D(s, e, gs, ...) R(s, e, gs) +#define D(s, e, gs, ...) R(s, e, gs, __VA_ARGS__) map_key(key) S(KP_Up, UP); S(KP_Down, DOWN); @@ -115,7 +116,7 @@ glfw_key_for_sym(xkb_keysym_t key) { #undef D #undef R #undef S -}; +} xkb_keysym_t glfw_xkb_sym_for_key(int key) { @@ -133,6 +134,7 @@ glfw_xkb_sym_for_key(int key) { #undef R #undef S } +END_ALLOW_CASE_RANGE #ifdef _GLFW_X11 @@ -167,7 +169,7 @@ glfw_xkb_update_x11_keyboard_id(_GLFWXKBData *xkb) { if (conn) keymap = xkb_x11_keymap_new_from_device(xkb->context, conn, xkb->keyboard_device_id, XKB_KEYMAP_COMPILE_NO_FLAGS); \ } -#define xkb_glfw_load_state(keymap, state, ...) {\ +#define xkb_glfw_load_state(keymap, state) {\ xcb_connection_t* conn = XGetXCBConnection(_glfw.x11.display); \ if (conn) state = xkb_x11_state_new_from_device(keymap, conn, xkb->keyboard_device_id); \ } @@ -175,7 +177,7 @@ glfw_xkb_update_x11_keyboard_id(_GLFWXKBData *xkb) { #else #define xkb_glfw_load_keymap(keymap, map_str) keymap = xkb_keymap_new_from_string(xkb->context, map_str, XKB_KEYMAP_FORMAT_TEXT_V1, 0); -#define xkb_glfw_load_state(keymap, state, ...) state = xkb_state_new(keymap); +#define xkb_glfw_load_state(keymap, state) state = xkb_state_new(keymap); #endif @@ -335,7 +337,7 @@ glfw_xkb_should_repeat(_GLFWXKBData *xkb, xkb_keycode_t scancode) { } -static KeyEvent key_event = {}; +static KeyEvent key_event = {0}; static inline xkb_keysym_t compose_symbol(struct xkb_compose_state *composeState, xkb_keysym_t sym, int *compose_completed) {