Build glfw with all warnings enabled

This commit is contained in:
Kovid Goyal 2019-07-01 10:42:07 +05:30
parent 9bc288cd8e
commit 841c907efc
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
31 changed files with 370 additions and 406 deletions

View File

@ -220,7 +220,7 @@ dispatchTimers(EventLoopData *eld) {
} }
static void 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]; static char drain_buf[64];
while(read(fd, drain_buf, sizeof(drain_buf)) < 0 && errno == EINTR); while(read(fd, drain_buf, sizeof(drain_buf)) < 0 && errno == EINTR);
} }

View File

@ -247,13 +247,13 @@ static bool initializeTIS(void)
CFStringRef* kPropertyUnicodeKeyLayoutData = CFStringRef* kPropertyUnicodeKeyLayoutData =
CFBundleGetDataPointerForName(_glfw.ns.tis.bundle, CFBundleGetDataPointerForName(_glfw.ns.tis.bundle,
CFSTR("kTISPropertyUnicodeKeyLayoutData")); CFSTR("kTISPropertyUnicodeKeyLayoutData"));
_glfw.ns.tis.CopyCurrentKeyboardLayoutInputSource = *(void **)&_glfw.ns.tis.CopyCurrentKeyboardLayoutInputSource =
CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle, CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle,
CFSTR("TISCopyCurrentKeyboardLayoutInputSource")); CFSTR("TISCopyCurrentKeyboardLayoutInputSource"));
_glfw.ns.tis.GetInputSourceProperty = *(void **)&_glfw.ns.tis.GetInputSourceProperty =
CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle, CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle,
CFSTR("TISGetInputSourceProperty")); CFSTR("TISGetInputSourceProperty"));
_glfw.ns.tis.GetKbdType = *(void **)&_glfw.ns.tis.GetKbdType =
CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle, CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle,
CFSTR("LMGetKbdType")); CFSTR("LMGetKbdType"));
@ -280,11 +280,13 @@ static bool initializeTIS(void)
- (void)selectedKeyboardInputSourceChanged:(NSObject* )object - (void)selectedKeyboardInputSourceChanged:(NSObject* )object
{ {
(void)object;
updateUnicodeDataNS(); updateUnicodeDataNS();
} }
- (void)doNothing:(id)object - (void)doNothing:(id)object
{ {
(void)object;
} }
@end // GLFWHelper @end // GLFWHelper

View File

@ -75,7 +75,7 @@ static long getElementValue(_GLFWjoystick* js, _GLFWjoyelementNS* element)
// //
static CFComparisonResult compareElements(const void* fp, static CFComparisonResult compareElements(const void* fp,
const void* sp, const void* sp,
void* user) void* user UNUSED)
{ {
const _GLFWjoyelementNS* fe = fp; const _GLFWjoyelementNS* fe = fp;
const _GLFWjoyelementNS* se = sp; const _GLFWjoyelementNS* se = sp;
@ -117,9 +117,9 @@ static void closeJoystick(_GLFWjoystick* js)
// Callback for user-initiated joystick addition // Callback for user-initiated joystick addition
// //
static void matchCallback(void* context, static void matchCallback(void* context UNUSED,
IOReturn result, IOReturn result UNUSED,
void* sender, void* sender UNUSED,
IOHIDDeviceRef device) IOHIDDeviceRef device)
{ {
int jid; int jid;
@ -270,9 +270,9 @@ static void matchCallback(void* context,
// Callback for user-initiated joystick removal // Callback for user-initiated joystick removal
// //
static void removeCallback(void* context, static void removeCallback(void* context UNUSED,
IOReturn result, IOReturn result UNUSED,
void* sender, void* sender UNUSED,
IOHIDDeviceRef device) IOHIDDeviceRef device)
{ {
int jid; int jid;
@ -316,7 +316,7 @@ void _glfwInitJoysticksNS(void)
return; 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; const long page = kHIDPage_GenericDesktop;

View File

@ -256,9 +256,9 @@ void _glfwClearDisplayLinks() {
} }
static CVReturn displayLinkCallback( static CVReturn displayLinkCallback(
CVDisplayLinkRef displayLink, CVDisplayLinkRef displayLink UNUSED,
const CVTimeStamp* now, const CVTimeStamp* outputTime, const CVTimeStamp* now UNUSED, const CVTimeStamp* outputTime UNUSED,
CVOptionFlags flagsIn, CVOptionFlags* flagsOut, void* userInfo) CVOptionFlags flagsIn UNUSED, CVOptionFlags* flagsOut UNUSED, void* userInfo)
{ {
CGDirectDisplayID displayID = (CGDirectDisplayID)userInfo; CGDirectDisplayID displayID = (CGDirectDisplayID)userInfo;
[_glfw.ns.displayLinks.lock lock]; [_glfw.ns.displayLinks.lock lock];
@ -306,7 +306,7 @@ void _glfwPollMonitorsNS(void)
CGGetOnlineDisplayList(displayCount, displays, &displayCount); CGGetOnlineDisplayList(displayCount, displays, &displayCount);
_glfwClearDisplayLinks(); _glfwClearDisplayLinks();
for (uint32_t i = 0; i < _glfw.monitorCount; i++) for (int i = 0; i < _glfw.monitorCount; i++)
_glfw.monitors[i]->ns.screen = nil; _glfw.monitors[i]->ns.screen = nil;
_GLFWmonitor** disconnected = NULL; _GLFWmonitor** disconnected = NULL;
@ -430,7 +430,7 @@ void _glfwRestoreVideoModeNS(_GLFWmonitor* monitor)
////// GLFW platform API ////// ////// 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)); 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->red[i] / 65535.f;
values[i + ramp->size] = ramp->green[i] / 65535.f; values[i + ramp->size] = ramp->green[i] / 65535.f;

View File

@ -66,7 +66,7 @@ static unsigned long long display_link_shutdown_timer = 0;
#define DISPLAY_LINK_SHUTDOWN_CHECK_INTERVAL 30 #define DISPLAY_LINK_SHUTDOWN_CHECK_INTERVAL 30
void 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]; [_glfw.ns.displayLinks.lock lock];
display_link_shutdown_timer = 0; display_link_shutdown_timer = 0;
for (size_t i = 0; i < _glfw.ns.displayLinks.count; i++) { 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 // Hides the cursor if not already hidden
// //
static void hideCursor(_GLFWwindow* window) static void hideCursor(_GLFWwindow* window UNUSED)
{ {
if (!_glfw.ns.cursorHidden) if (!_glfw.ns.cursorHidden)
{ {
@ -136,7 +136,7 @@ static void hideCursor(_GLFWwindow* window)
// Shows the cursor if not already shown // Shows the cursor if not already shown
// //
static void showCursor(_GLFWwindow* window) static void showCursor(_GLFWwindow* window UNUSED)
{ {
if (_glfw.ns.cursorHidden) if (_glfw.ns.cursorHidden)
{ {
@ -350,9 +350,8 @@ static int translateKey(unsigned int key, bool apply_keymap)
} }
static void 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) { if (flags & kCGDisplayBeginConfigurationFlag) {
return; return;
} }
@ -417,12 +416,14 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
- (BOOL)windowShouldClose:(id)sender - (BOOL)windowShouldClose:(id)sender
{ {
(void)sender;
_glfwInputWindowCloseRequest(window); _glfwInputWindowCloseRequest(window);
return NO; return NO;
} }
- (void)windowDidResize:(NSNotification *)notification - (void)windowDidResize:(NSNotification *)notification
{ {
(void)notification;
if (window->context.client != GLFW_NO_API) if (window->context.client != GLFW_NO_API)
[window->context.nsgl.object update]; [window->context.nsgl.object update];
@ -458,6 +459,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
- (void)windowDidMove:(NSNotification *)notification - (void)windowDidMove:(NSNotification *)notification
{ {
(void)notification;
if (window->context.client != GLFW_NO_API) if (window->context.client != GLFW_NO_API)
[window->context.nsgl.object update]; [window->context.nsgl.object update];
@ -471,11 +473,13 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
- (void)windowDidChangeOcclusionState:(NSNotification *)notification - (void)windowDidChangeOcclusionState:(NSNotification *)notification
{ {
(void)notification;
_glfwInputWindowOcclusion(window, !([window->ns.object occlusionState] & NSWindowOcclusionStateVisible)); _glfwInputWindowOcclusion(window, !([window->ns.object occlusionState] & NSWindowOcclusionStateVisible));
} }
- (void)windowDidMiniaturize:(NSNotification *)notification - (void)windowDidMiniaturize:(NSNotification *)notification
{ {
(void)notification;
if (window->monitor) if (window->monitor)
releaseMonitor(window); releaseMonitor(window);
@ -484,6 +488,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
- (void)windowDidDeminiaturize:(NSNotification *)notification - (void)windowDidDeminiaturize:(NSNotification *)notification
{ {
(void)notification;
if (window->monitor) if (window->monitor)
acquireMonitor(window); acquireMonitor(window);
@ -492,6 +497,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
- (void)windowDidBecomeKey:(NSNotification *)notification - (void)windowDidBecomeKey:(NSNotification *)notification
{ {
(void)notification;
if (_glfw.ns.disabledCursorWindow == window) if (_glfw.ns.disabledCursorWindow == window)
_glfwCenterCursorInContentArea(window); _glfwCenterCursorInContentArea(window);
@ -508,6 +514,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
- (void)windowDidResignKey:(NSNotification *)notification - (void)windowDidResignKey:(NSNotification *)notification
{ {
(void)notification;
if (window->monitor && window->autoIconify) if (window->monitor && window->autoIconify)
_glfwPlatformIconifyWindow(window); _glfwPlatformIconifyWindow(window);
showCursor(window); showCursor(window);
@ -517,6 +524,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
- (void)windowDidChangeScreen:(NSNotification *)notification - (void)windowDidChangeScreen:(NSNotification *)notification
{ {
(void)notification;
if (window->ns.renderFrameRequested && window->ns.renderFrameCallback) { if (window->ns.renderFrameRequested && window->ns.renderFrameCallback) {
// Ensure that if the window changed its monitor, CVDisplayLink // Ensure that if the window changed its monitor, CVDisplayLink
// is running for the new monitor // is running for the new monitor
@ -539,6 +547,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
{ {
(void)sender;
_GLFWwindow* window; _GLFWwindow* window;
for (window = _glfw.windowListHead; window; window = window->next) 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 - (BOOL)applicationShouldHandleReopen:(NSApplication *)sender hasVisibleWindows:(BOOL)flag
{ {
(void)sender;
if (!handle_reopen_callback) return YES; if (!handle_reopen_callback) return YES;
if (handle_reopen_callback(flag)) return YES; if (handle_reopen_callback(flag)) return YES;
return NO; return NO;
@ -558,6 +568,7 @@ static GLFWapplicationshouldhandlereopenfun handle_reopen_callback = NULL;
- (void)applicationDidChangeScreenParameters:(NSNotification *) notification - (void)applicationDidChangeScreenParameters:(NSNotification *) notification
{ {
(void)notification;
_GLFWwindow* window; _GLFWwindow* window;
for (window = _glfw.windowListHead; window; window = window->next) for (window = _glfw.windowListHead; window; window = window->next)
@ -571,6 +582,7 @@ static GLFWapplicationshouldhandlereopenfun handle_reopen_callback = NULL;
- (void)applicationDidFinishLaunching:(NSNotification *)notification - (void)applicationDidFinishLaunching:(NSNotification *)notification
{ {
(void)notification;
[NSApp stop:nil]; [NSApp stop:nil];
CGDisplayRegisterReconfigurationCallback(display_reconfigured, NULL); CGDisplayRegisterReconfigurationCallback(display_reconfigured, NULL);
@ -579,11 +591,13 @@ static GLFWapplicationshouldhandlereopenfun handle_reopen_callback = NULL;
- (void)applicationWillTerminate:(NSNotification *)aNotification - (void)applicationWillTerminate:(NSNotification *)aNotification
{ {
(void)aNotification;
CGDisplayRemoveReconfigurationCallback(display_reconfigured, NULL); CGDisplayRemoveReconfigurationCallback(display_reconfigured, NULL);
} }
- (void)applicationDidHide:(NSNotification *)notification - (void)applicationDidHide:(NSNotification *)notification
{ {
(void)notification;
int i; int i;
for (i = 0; i < _glfw.monitorCount; i++) for (i = 0; i < _glfw.monitorCount; i++)
@ -686,11 +700,13 @@ static GLFWapplicationshouldhandlereopenfun handle_reopen_callback = NULL;
- (void)cursorUpdate:(NSEvent *)event - (void)cursorUpdate:(NSEvent *)event
{ {
(void)event;
updateCursorImage(window); updateCursorImage(window);
} }
- (BOOL)acceptsFirstMouse:(NSEvent *)event - (BOOL)acceptsFirstMouse:(NSEvent *)event
{ {
(void)event;
return NO; // changed by Kovid, to follow cocoa platform conventions 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)mouseExited:(NSEvent *)event
{ {
(void)event;
_glfwInputCursorEnter(window, false); _glfwInputCursorEnter(window, false);
} }
- (void)mouseEntered:(NSEvent *)event - (void)mouseEntered:(NSEvent *)event
{ {
(void)event;
_glfwInputCursorEnter(window, true); _glfwInputCursorEnter(window, true);
} }
@ -820,6 +838,7 @@ static GLFWapplicationshouldhandlereopenfun handle_reopen_callback = NULL;
- (void)drawRect:(NSRect)rect - (void)drawRect:(NSRect)rect
{ {
(void)rect;
_glfwInputWindowDamage(window); _glfwInputWindowDamage(window);
} }
@ -1026,6 +1045,7 @@ is_ascii_control_char(char x) {
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender - (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
{ {
(void)sender;
// HACK: We don't know what to say here because we don't know what the // HACK: We don't know what to say here because we don't know what the
// application wants to do with the paths // application wants to do with the paths
return NSDragOperationGeneric; return NSDragOperationGeneric;
@ -1083,6 +1103,7 @@ is_ascii_control_char(char x) {
selectedRange:(NSRange)selectedRange selectedRange:(NSRange)selectedRange
replacementRange:(NSRange)replacementRange replacementRange:(NSRange)replacementRange
{ {
(void)selectedRange; (void)replacementRange;
[markedText release]; [markedText release];
if ([string isKindOfClass:[NSAttributedString class]]) if ([string isKindOfClass:[NSAttributedString class]])
markedText = [[NSMutableAttributedString alloc] initWithAttributedString:string]; markedText = [[NSMutableAttributedString alloc] initWithAttributedString:string];
@ -1105,6 +1126,7 @@ void _glfwPlatformUpdateIMEState(_GLFWwindow *w, int which, int a, int b, int c,
cellWidth:(CGFloat)cellWidth cellWidth:(CGFloat)cellWidth
cellHeight:(CGFloat)cellHeight cellHeight:(CGFloat)cellHeight
{ {
(void) which;
left /= window->ns.xscale; left /= window->ns.xscale;
top /= window->ns.yscale; top /= window->ns.yscale;
cellWidth /= window->ns.xscale; cellWidth /= window->ns.xscale;
@ -1125,22 +1147,26 @@ void _glfwPlatformUpdateIMEState(_GLFWwindow *w, int which, int a, int b, int c,
- (NSAttributedString*)attributedSubstringForProposedRange:(NSRange)range - (NSAttributedString*)attributedSubstringForProposedRange:(NSRange)range
actualRange:(NSRangePointer)actualRange actualRange:(NSRangePointer)actualRange
{ {
(void)range; (void)actualRange;
return nil; return nil;
} }
- (NSUInteger)characterIndexForPoint:(NSPoint)point - (NSUInteger)characterIndexForPoint:(NSPoint)point
{ {
(void)point;
return 0; return 0;
} }
- (NSRect)firstRectForCharacterRange:(NSRange)range - (NSRect)firstRectForCharacterRange:(NSRange)range
actualRange:(NSRangePointer)actualRange actualRange:(NSRangePointer)actualRange
{ {
(void)range; (void)actualRange;
return markedRect; return markedRect;
} }
- (void)insertText:(id)string replacementRange:(NSRange)replacementRange - (void)insertText:(id)string replacementRange:(NSRange)replacementRange
{ {
(void)replacementRange;
NSString* characters; NSString* characters;
if ([string isKindOfClass:[NSAttributedString class]]) if ([string isKindOfClass:[NSAttributedString class]])
characters = [string string]; characters = [string string];
@ -1154,6 +1180,7 @@ void _glfwPlatformUpdateIMEState(_GLFWwindow *w, int which, int a, int b, int c,
- (void)doCommandBySelector:(SEL)selector - (void)doCommandBySelector:(SEL)selector
{ {
(void)selector;
} }
@end @end
@ -1510,7 +1537,7 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
window->ns.object = nil; window->ns.object = nil;
} }
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char *title) void _glfwPlatformSetWindowTitle(_GLFWwindow* window UNUSED, const char *title)
{ {
NSString* string = @(title); NSString* string = @(title);
[window->ns.object setTitle:string]; [window->ns.object setTitle:string];
@ -1519,8 +1546,8 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char *title)
[window->ns.object setMiniwindowTitle:string]; [window->ns.object setMiniwindowTitle:string];
} }
void _glfwPlatformSetWindowIcon(_GLFWwindow* window, void _glfwPlatformSetWindowIcon(_GLFWwindow* window UNUSED,
int count, const GLFWimage* images) int count UNUSED, const GLFWimage* images UNUSED)
{ {
// Regular windows do not have icons // Regular windows do not have icons
} }
@ -1630,7 +1657,7 @@ void _glfwPlatformGetWindowContentScale(_GLFWwindow* window,
*yscale = (float) (pixels.size.height / points.size.height); *yscale = (float) (pixels.size.height / points.size.height);
} }
double _glfwPlatformGetDoubleClickInterval(_GLFWwindow* window) double _glfwPlatformGetDoubleClickInterval(_GLFWwindow* window UNUSED)
{ {
return [NSEvent doubleClickInterval]; return [NSEvent doubleClickInterval];
} }
@ -1664,12 +1691,12 @@ void _glfwPlatformHideWindow(_GLFWwindow* window)
[window->ns.object orderOut:nil]; [window->ns.object orderOut:nil];
} }
void _glfwPlatformRequestWindowAttention(_GLFWwindow* window) void _glfwPlatformRequestWindowAttention(_GLFWwindow* window UNUSED)
{ {
[NSApp requestUserAttention:NSInformationalRequest]; [NSApp requestUserAttention:NSInformationalRequest];
} }
int _glfwPlatformWindowBell(_GLFWwindow* window) int _glfwPlatformWindowBell(_GLFWwindow* window UNUSED)
{ {
NSBeep(); NSBeep();
return true; return true;
@ -1689,7 +1716,7 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
_GLFWmonitor* monitor, _GLFWmonitor* monitor,
int xpos, int ypos, int xpos, int ypos,
int width, int height, int width, int height,
int refreshRate) int refreshRate UNUSED)
{ {
if (window->monitor == monitor) if (window->monitor == monitor)
{ {
@ -1814,12 +1841,12 @@ int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
return ![window->ns.object isOpaque] && ![window->ns.view isOpaque]; 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)]; [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 setStyleMask:getStyleMask(window)];
[window->ns.object makeFirstResponder:window->ns.view]; [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)) if (_glfwPlatformWindowFocused(window))
updateCursorMode(window); updateCursorMode(window);
@ -2035,7 +2062,7 @@ void _glfwPlatformDestroyCursor(_GLFWcursor* cursor)
[(NSCursor*) cursor->ns.object release]; [(NSCursor*) cursor->ns.object release];
} }
void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor) void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor UNUSED)
{ {
if (cursorInContentArea(window)) if (cursorInContentArea(window))
updateCursorImage(window); updateCursorImage(window);
@ -2105,9 +2132,9 @@ void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
extensions[1] = "VK_MVK_macos_surface"; extensions[1] = "VK_MVK_macos_surface";
} }
int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance, int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance UNUSED,
VkPhysicalDevice device, VkPhysicalDevice device UNUSED,
uint32_t queuefamily) uint32_t queuefamily UNUSED)
{ {
return true; return true;
} }
@ -2227,6 +2254,7 @@ GLFWAPI void glfwGetCocoaKeyEquivalent(int glfw_key, int glfw_mods, unsigned sho
if (glfw_mods & GLFW_MOD_CAPS_LOCK) if (glfw_mods & GLFW_MOD_CAPS_LOCK)
*cocoa_mods |= NSEventModifierFlagCapsLock; *cocoa_mods |= NSEventModifierFlagCapsLock;
START_ALLOW_CASE_RANGE
switch(glfw_key) { switch(glfw_key) {
#define K(ch, name) case GLFW_KEY_##name: *cocoa_key = ch; break; #define K(ch, name) case GLFW_KEY_##name: *cocoa_key = ch; break;
K('a', A); 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)(0x4E|NSEventModifierFlagNumericPad), KP_SUBTRACT);
K((unichar)(0x51|NSEventModifierFlagNumericPad), KP_EQUAL); K((unichar)(0x51|NSEventModifierFlagNumericPad), KP_EQUAL);
#undef K #undef K
END_ALLOW_CASE_RANGE
} }
} }

14
glfw/dbus_glfw.c vendored
View File

@ -53,7 +53,7 @@ glfw_dbus_init(_GLFWDBUSData *dbus, EventLoopData *eld) {
} }
static void 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; DBusWatch *watch = (DBusWatch*)data;
unsigned int flags = 0; unsigned int flags = 0;
if (events & POLLERR) flags |= DBUS_WATCH_ERROR; if (events & POLLERR) flags |= DBUS_WATCH_ERROR;
@ -84,19 +84,19 @@ add_dbus_watch(DBusWatch *watch, void *data) {
} }
static void 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); id_type *idp = dbus_watch_get_data(watch);
if (idp) removeWatch(dbus_data->eld, *idp); if (idp) removeWatch(dbus_data->eld, *idp);
} }
static void 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); id_type *idp = dbus_watch_get_data(watch);
if (idp) toggleWatch(dbus_data->eld, *idp, dbus_watch_get_enabled(watch)); if (idp) toggleWatch(dbus_data->eld, *idp, dbus_watch_get_enabled(watch));
} }
static void 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) { if (data) {
DBusTimeout *t = (DBusTimeout*)data; DBusTimeout *t = (DBusTimeout*)data;
dbus_timeout_handle(t); dbus_timeout_handle(t);
@ -123,13 +123,13 @@ add_dbus_timeout(DBusTimeout *timeout, void *data) {
} }
static void 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); id_type *idp = dbus_timeout_get_data(timeout);
if (idp) removeTimer(dbus_data->eld, *idp); if (idp) removeTimer(dbus_data->eld, *idp);
} }
static void 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); id_type *idp = dbus_timeout_get_data(timeout);
if (idp) toggleTimer(dbus_data->eld, *idp, dbus_timeout_get_enabled(timeout)); if (idp) toggleTimer(dbus_data->eld, *idp, dbus_timeout_get_enabled(timeout));
} }
@ -178,7 +178,7 @@ glfw_dbus_session_bus_dispatch() {
} }
void void
glfw_dbus_terminate(_GLFWDBUSData *dbus) { glfw_dbus_terminate(_GLFWDBUSData *dbus UNUSED) {
if (dbus_data) { if (dbus_data) {
dbus_data->eld = NULL; dbus_data->eld = NULL;
dbus_data = NULL; dbus_data = NULL;

54
glfw/egl_context.c vendored
View File

@ -253,8 +253,8 @@ static GLFWglproc getProcAddressEGL(const char* procname)
if (window->context.egl.client) if (window->context.egl.client)
{ {
GLFWglproc proc = (GLFWglproc) _glfw_dlsym(window->context.egl.client, GLFWglproc proc = NULL;
procname); glfw_dlsym(proc, window->context.egl.client, procname);
if (proc) if (proc)
return proc; return proc;
} }
@ -335,38 +335,22 @@ bool _glfwInitEGL(void)
_glfw.egl.prefix = (strncmp(sonames[i], "lib", 3) == 0); _glfw.egl.prefix = (strncmp(sonames[i], "lib", 3) == 0);
_glfw.egl.GetConfigAttrib = (PFN_eglGetConfigAttrib) glfw_dlsym(_glfw.egl.GetConfigAttrib, _glfw.egl.handle, "eglGetConfigAttrib");
_glfw_dlsym(_glfw.egl.handle, "eglGetConfigAttrib"); glfw_dlsym(_glfw.egl.GetConfigs, _glfw.egl.handle, "eglGetConfigs");
_glfw.egl.GetConfigs = (PFN_eglGetConfigs) glfw_dlsym(_glfw.egl.GetDisplay, _glfw.egl.handle, "eglGetDisplay");
_glfw_dlsym(_glfw.egl.handle, "eglGetConfigs"); glfw_dlsym(_glfw.egl.GetError, _glfw.egl.handle, "eglGetError");
_glfw.egl.GetDisplay = (PFN_eglGetDisplay) glfw_dlsym(_glfw.egl.Initialize, _glfw.egl.handle, "eglInitialize");
_glfw_dlsym(_glfw.egl.handle, "eglGetDisplay"); glfw_dlsym(_glfw.egl.Terminate, _glfw.egl.handle, "eglTerminate");
_glfw.egl.GetError = (PFN_eglGetError) glfw_dlsym(_glfw.egl.BindAPI, _glfw.egl.handle, "eglBindAPI");
_glfw_dlsym(_glfw.egl.handle, "eglGetError"); glfw_dlsym(_glfw.egl.CreateContext, _glfw.egl.handle, "eglCreateContext");
_glfw.egl.Initialize = (PFN_eglInitialize) glfw_dlsym(_glfw.egl.DestroySurface, _glfw.egl.handle, "eglDestroySurface");
_glfw_dlsym(_glfw.egl.handle, "eglInitialize"); glfw_dlsym(_glfw.egl.DestroyContext, _glfw.egl.handle, "eglDestroyContext");
_glfw.egl.Terminate = (PFN_eglTerminate) glfw_dlsym(_glfw.egl.CreateWindowSurface, _glfw.egl.handle, "eglCreateWindowSurface");
_glfw_dlsym(_glfw.egl.handle, "eglTerminate"); glfw_dlsym(_glfw.egl.MakeCurrent, _glfw.egl.handle, "eglMakeCurrent");
_glfw.egl.BindAPI = (PFN_eglBindAPI) glfw_dlsym(_glfw.egl.SwapBuffers, _glfw.egl.handle, "eglSwapBuffers");
_glfw_dlsym(_glfw.egl.handle, "eglBindAPI"); glfw_dlsym(_glfw.egl.SwapInterval, _glfw.egl.handle, "eglSwapInterval");
_glfw.egl.CreateContext = (PFN_eglCreateContext) glfw_dlsym(_glfw.egl.QueryString, _glfw.egl.handle, "eglQueryString");
_glfw_dlsym(_glfw.egl.handle, "eglCreateContext"); glfw_dlsym(_glfw.egl.GetProcAddress, _glfw.egl.handle, "eglGetProcAddress");
_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");
if (!_glfw.egl.GetConfigAttrib || if (!_glfw.egl.GetConfigAttrib ||
!_glfw.egl.GetConfigs || !_glfw.egl.GetConfigs ||
@ -714,7 +698,7 @@ bool _glfwCreateContextEGL(_GLFWwindow* window,
// Returns the Visual and depth of the chosen EGLConfig // Returns the Visual and depth of the chosen EGLConfig
// //
#if defined(_GLFW_X11) #if defined(_GLFW_X11)
bool _glfwChooseVisualEGL(const _GLFWwndconfig* wndconfig, bool _glfwChooseVisualEGL(const _GLFWwndconfig* wndconfig UNUSED,
const _GLFWctxconfig* ctxconfig, const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig, const _GLFWfbconfig* fbconfig,
Visual** visual, int* depth) Visual** visual, int* depth)

View File

@ -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'): def init_env(env, pkg_config, at_least_version, test_compile, module='x11'):
ans = env.copy() ans = env.copy()
ans.cflags = [ ans.cflags = list(ans.cflags)
x for x in ans.cflags
if x not in '-Wpedantic -Wextra -pedantic-errors'.split()
]
if not is_macos: if not is_macos:
ans.cflags.append('-pthread') ans.cflags.append('-pthread')
ans.ldpaths.append('-pthread') ans.ldpaths.append('-pthread')

58
glfw/glx_context.c vendored
View File

@ -142,7 +142,7 @@ static bool chooseGLXFBConfig(const _GLFWfbconfig* desired,
// Create the OpenGL context using legacy API // Create the OpenGL context using legacy API
// //
static GLXContext createLegacyContextGLX(_GLFWwindow* window, static GLXContext createLegacyContextGLX(_GLFWwindow* window UNUSED,
GLXFBConfig fbconfig, GLXFBConfig fbconfig,
GLXContext share) GLXContext share)
{ {
@ -222,8 +222,11 @@ static GLFWglproc getProcAddressGLX(const char* procname)
return _glfw.glx.GetProcAddress((const GLubyte*) procname); return _glfw.glx.GetProcAddress((const GLubyte*) procname);
else if (_glfw.glx.GetProcAddressARB) else if (_glfw.glx.GetProcAddressARB)
return _glfw.glx.GetProcAddressARB((const GLubyte*) procname); return _glfw.glx.GetProcAddressARB((const GLubyte*) procname);
else else {
return _glfw_dlsym(_glfw.glx.handle, procname); GLFWglproc ans = NULL;
glfw_dlsym(ans, _glfw.glx.handle, procname);
return ans;
}
} }
static void destroyContextGLX(_GLFWwindow* window) static void destroyContextGLX(_GLFWwindow* window)
@ -280,36 +283,21 @@ bool _glfwInitGLX(void)
return false; return false;
} }
_glfw.glx.GetFBConfigs = glfw_dlsym(_glfw.glx.GetFBConfigs, _glfw.glx.handle, "glXGetFBConfigs");
_glfw_dlsym(_glfw.glx.handle, "glXGetFBConfigs"); glfw_dlsym(_glfw.glx.GetFBConfigAttrib, _glfw.glx.handle, "glXGetFBConfigAttrib");
_glfw.glx.GetFBConfigAttrib = glfw_dlsym(_glfw.glx.GetClientString, _glfw.glx.handle, "glXGetClientString");
_glfw_dlsym(_glfw.glx.handle, "glXGetFBConfigAttrib"); glfw_dlsym(_glfw.glx.QueryExtension, _glfw.glx.handle, "glXQueryExtension");
_glfw.glx.GetClientString = glfw_dlsym(_glfw.glx.QueryVersion, _glfw.glx.handle, "glXQueryVersion");
_glfw_dlsym(_glfw.glx.handle, "glXGetClientString"); glfw_dlsym(_glfw.glx.DestroyContext, _glfw.glx.handle, "glXDestroyContext");
_glfw.glx.QueryExtension = glfw_dlsym(_glfw.glx.MakeCurrent, _glfw.glx.handle, "glXMakeCurrent");
_glfw_dlsym(_glfw.glx.handle, "glXQueryExtension"); glfw_dlsym(_glfw.glx.SwapBuffers, _glfw.glx.handle, "glXSwapBuffers");
_glfw.glx.QueryVersion = glfw_dlsym(_glfw.glx.QueryExtensionsString, _glfw.glx.handle, "glXQueryExtensionsString");
_glfw_dlsym(_glfw.glx.handle, "glXQueryVersion"); glfw_dlsym(_glfw.glx.CreateNewContext, _glfw.glx.handle, "glXCreateNewContext");
_glfw.glx.DestroyContext = glfw_dlsym(_glfw.glx.CreateWindow, _glfw.glx.handle, "glXCreateWindow");
_glfw_dlsym(_glfw.glx.handle, "glXDestroyContext"); glfw_dlsym(_glfw.glx.DestroyWindow, _glfw.glx.handle, "glXDestroyWindow");
_glfw.glx.MakeCurrent = glfw_dlsym(_glfw.glx.GetProcAddress, _glfw.glx.handle, "glXGetProcAddress");
_glfw_dlsym(_glfw.glx.handle, "glXMakeCurrent"); glfw_dlsym(_glfw.glx.GetProcAddressARB, _glfw.glx.handle, "glXGetProcAddressARB");
_glfw.glx.SwapBuffers = glfw_dlsym(_glfw.glx.GetVisualFromFBConfig, _glfw.glx.handle, "glXGetVisualFromFBConfig");
_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");
if (!_glfw.glx.GetFBConfigs || if (!_glfw.glx.GetFBConfigs ||
!_glfw.glx.GetFBConfigAttrib || !_glfw.glx.GetFBConfigAttrib ||
@ -631,8 +619,8 @@ bool _glfwCreateContextGLX(_GLFWwindow* window,
// Returns the Visual and depth of the chosen GLXFBConfig // Returns the Visual and depth of the chosen GLXFBConfig
// //
bool _glfwChooseVisualGLX(const _GLFWwndconfig* wndconfig, bool _glfwChooseVisualGLX(const _GLFWwndconfig* wndconfig UNUSED,
const _GLFWctxconfig* ctxconfig, const _GLFWctxconfig* ctxconfig UNUSED,
const _GLFWfbconfig* fbconfig, const _GLFWfbconfig* fbconfig,
Visual** visual, int* depth) Visual** visual, int* depth)
{ {

5
glfw/glx_context.h vendored
View File

@ -107,8 +107,8 @@ typedef GLXContext (*PFNGLXCREATECONTEXTATTRIBSARBPROC)(Display*,GLXFBConfig,GLX
#define glXCreateWindow _glfw.glx.CreateWindow #define glXCreateWindow _glfw.glx.CreateWindow
#define glXDestroyWindow _glfw.glx.DestroyWindow #define glXDestroyWindow _glfw.glx.DestroyWindow
#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextGLX glx #define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextGLX glx;
#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryGLX glx #define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryGLX glx;
// GLX-specific per-context data // GLX-specific per-context data
@ -178,4 +178,3 @@ bool _glfwChooseVisualGLX(const _GLFWwndconfig* wndconfig,
const _GLFWctxconfig* ctxconfig, const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig, const _GLFWfbconfig* fbconfig,
Visual** visual, int* depth); Visual** visual, int* depth);

2
glfw/ibus_glfw.c vendored
View File

@ -117,7 +117,7 @@ send_text(const char *text, int state) {
// Connection handling {{{ // Connection handling {{{
static DBusHandlerResult 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 // To monitor signals from IBUS, use
//  dbus-monitor --address `ibus address` "type='signal',interface='org.freedesktop.IBus.InputContext'" //  dbus-monitor --address `ibus address` "type='signal',interface='org.freedesktop.IBus.InputContext'"
_GLFWIBUSData *ibus = (_GLFWIBUSData*)user_data; _GLFWIBUSData *ibus = (_GLFWIBUSData*)user_data;

8
glfw/input.c vendored
View File

@ -1371,7 +1371,7 @@ GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state)
return true; return true;
} }
GLFWAPI void glfwSetClipboardString(GLFWwindow* handle, const char* string) GLFWAPI void glfwSetClipboardString(GLFWwindow* handle UNUSED, const char* string)
{ {
assert(string != NULL); assert(string != NULL);
@ -1379,14 +1379,14 @@ GLFWAPI void glfwSetClipboardString(GLFWwindow* handle, const char* string)
_glfwPlatformSetClipboardString(string); _glfwPlatformSetClipboardString(string);
} }
GLFWAPI const char* glfwGetClipboardString(GLFWwindow* handle) GLFWAPI const char* glfwGetClipboardString(GLFWwindow* handle UNUSED)
{ {
_GLFW_REQUIRE_INIT_OR_RETURN(NULL); _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
return _glfwPlatformGetClipboardString(); return _glfwPlatformGetClipboardString();
} }
#if defined(_GLFW_X11) || defined(_GLFW_WAYLAND) #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); assert(string != NULL);
@ -1394,7 +1394,7 @@ GLFWAPI void glfwSetPrimarySelectionString(GLFWwindow* handle, const char* strin
_glfwPlatformSetPrimarySelectionString(string); _glfwPlatformSetPrimarySelectionString(string);
} }
GLFWAPI const char* glfwGetPrimarySelectionString(GLFWwindow* handle) GLFWAPI const char* glfwGetPrimarySelectionString(GLFWwindow* handle UNUSED)
{ {
_GLFW_REQUIRE_INIT_OR_RETURN(NULL); _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
return _glfwPlatformGetPrimarySelectionString(); return _glfwPlatformGetPrimarySelectionString();

32
glfw/internal.h vendored
View File

@ -225,12 +225,32 @@ typedef void (APIENTRY * PFN_vkVoidFunction)(void);
// Swaps the provided pointers // Swaps the provided pointers
#define _GLFW_SWAP_POINTERS(x, y) \ #define _GLFW_SWAP_POINTERS(x, y) \
{ \ do{ \
void* t; \ __typeof__(x) t; \
t = x; \ t = x; \
x = y; \ x = y; \
y = t; \ 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 // Per-thread error structure
// //
@ -367,7 +387,7 @@ struct _GLFWcontext
_GLFWdestroycontextfun destroy; _GLFWdestroycontextfun destroy;
// This is defined in the context API's context.h // 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 // This is defined in egl_context.h
_GLFW_EGL_CONTEXT_STATE; _GLFW_EGL_CONTEXT_STATE;
// This is defined in osmesa_context.h // This is defined in osmesa_context.h
@ -587,9 +607,9 @@ struct _GLFWlibrary
// This is defined in the window API's platform.h // This is defined in the window API's platform.h
_GLFW_PLATFORM_LIBRARY_WINDOW_STATE; _GLFW_PLATFORM_LIBRARY_WINDOW_STATE;
// This is defined in the context API's context.h // 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 // 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 // This is defined in egl_context.h
_GLFW_EGL_LIBRARY_CONTEXT_STATE; _GLFW_EGL_LIBRARY_CONTEXT_STATE;
// This is defined in osmesa_context.h // This is defined in osmesa_context.h

View File

@ -385,7 +385,7 @@ void _glfwDetectJoystickConnectionLinux(void)
////// GLFW platform API ////// ////// GLFW platform API //////
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode) int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode UNUSED)
{ {
// Read all queued events (non-blocking) // Read all queued events (non-blocking)
for (;;) for (;;)
@ -425,6 +425,6 @@ int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode)
return js->present; return js->present;
} }
void _glfwPlatformUpdateGamepadGUID(char* guid) void _glfwPlatformUpdateGamepadGUID(char* guid UNUSED)
{ {
} }

View File

@ -29,7 +29,7 @@
#include <regex.h> #include <regex.h>
#define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickLinux linjs #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" #define _GLFW_PLATFORM_MAPPING_NAME "Linux"
@ -59,4 +59,3 @@ typedef struct _GLFWlibraryLinux
bool _glfwInitJoysticksLinux(void); bool _glfwInitJoysticksLinux(void);
void _glfwTerminateJoysticksLinux(void); void _glfwTerminateJoysticksLinux(void);
void _glfwDetectJoystickConnectionLinux(void); void _glfwDetectJoystickConnectionLinux(void);

3
glfw/linux_notify.c vendored
View File

@ -43,8 +43,7 @@ notification_created(DBusMessage *msg, const char* errmsg, void *data) {
} }
static DBusHandlerResult static DBusHandlerResult
message_handler(DBusConnection *conn, DBusMessage *msg, void *user_data) { message_handler(DBusConnection *conn UNUSED, DBusMessage *msg, void *user_data UNUSED) {
(void)(user_data);
/* printf("session_bus message_handler invoked interface: %s member: %s\n", dbus_message_get_interface(msg), dbus_message_get_member(msg)); */ /* 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")) { if (dbus_message_is_signal(msg, NOTIFICATIONS_IFACE, "ActionInvoked")) {
uint32_t notification_id; uint32_t notification_id;

5
glfw/nsgl_context.h vendored
View File

@ -24,8 +24,8 @@
// //
//======================================================================== //========================================================================
#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextNSGL nsgl #define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextNSGL nsgl;
#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryNSGL nsgl #define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryNSGL nsgl;
// NSGL-specific per-context data // NSGL-specific per-context data
@ -53,4 +53,3 @@ bool _glfwCreateContextNSGL(_GLFWwindow* window,
const _GLFWctxconfig* ctxconfig, const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig); const _GLFWfbconfig* fbconfig);
void _glfwDestroyContextNSGL(_GLFWwindow* window); void _glfwDestroyContextNSGL(_GLFWwindow* window);

View File

@ -43,15 +43,14 @@ static void swapBuffersNSGL(_GLFWwindow* window)
[window->context.nsgl.object flushBuffer]; [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 // As of Mojave this does not work so we use CVDisplayLink instead
(void)(interval);
_glfwInputError(GLFW_API_UNAVAILABLE, _glfwInputError(GLFW_API_UNAVAILABLE,
"NSGL: Swap intervals do not work on macOS"); "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 // There are no NSGL extensions
return false; return false;
@ -63,8 +62,9 @@ static GLFWglproc getProcAddressNSGL(const char* procname)
procname, procname,
kCFStringEncodingASCII); kCFStringEncodingASCII);
GLFWglproc symbol = CFBundleGetFunctionPointerForName(_glfw.nsgl.framework, GLFWglproc symbol;
symbolName); *(void **) &symbol = CFBundleGetFunctionPointerForName(_glfw.nsgl.framework,
symbolName);
CFRelease(symbolName); CFRelease(symbolName);

View File

@ -25,7 +25,6 @@
//======================================================================== //========================================================================
#define _GLFW_PLATFORM_JOYSTICK_STATE int nulljs #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 "" #define _GLFW_PLATFORM_MAPPING_NAME ""

27
glfw/osmesa_context.c vendored
View File

@ -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 // No double buffering on OSMesa
} }
static void swapIntervalOSMesa(int interval) static void swapIntervalOSMesa(int interval UNUSED)
{ {
// No swap interval on OSMesa // No swap interval on OSMesa
} }
static int extensionSupportedOSMesa(const char* extension) static int extensionSupportedOSMesa(const char* extension UNUSED)
{ {
// OSMesa does not have extensions // OSMesa does not have extensions
return false; return false;
@ -145,20 +145,13 @@ bool _glfwInitOSMesa(void)
return false; return false;
} }
_glfw.osmesa.CreateContextExt = (PFN_OSMesaCreateContextExt) glfw_dlsym(_glfw.osmesa.CreateContextExt, _glfw.osmesa.handle, "OSMesaCreateContextExt");
_glfw_dlsym(_glfw.osmesa.handle, "OSMesaCreateContextExt"); glfw_dlsym(_glfw.osmesa.CreateContextAttribs, _glfw.osmesa.handle, "OSMesaCreateContextAttribs");
_glfw.osmesa.CreateContextAttribs = (PFN_OSMesaCreateContextAttribs) glfw_dlsym(_glfw.osmesa.DestroyContext, _glfw.osmesa.handle, "OSMesaDestroyContext");
_glfw_dlsym(_glfw.osmesa.handle, "OSMesaCreateContextAttribs"); glfw_dlsym(_glfw.osmesa.MakeCurrent, _glfw.osmesa.handle, "OSMesaMakeCurrent");
_glfw.osmesa.DestroyContext = (PFN_OSMesaDestroyContext) glfw_dlsym(_glfw.osmesa.GetColorBuffer, _glfw.osmesa.handle, "OSMesaGetColorBuffer");
_glfw_dlsym(_glfw.osmesa.handle, "OSMesaDestroyContext"); glfw_dlsym(_glfw.osmesa.GetDepthBuffer, _glfw.osmesa.handle, "OSMesaGetDepthBuffer");
_glfw.osmesa.MakeCurrent = (PFN_OSMesaMakeCurrent) glfw_dlsym(_glfw.osmesa.GetProcAddress, _glfw.osmesa.handle, "OSMesaGetProcAddress");
_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");
if (!_glfw.osmesa.CreateContextExt || if (!_glfw.osmesa.CreateContextExt ||
!_glfw.osmesa.DestroyContext || !_glfw.osmesa.DestroyContext ||

4
glfw/vulkan.c vendored
View File

@ -66,7 +66,7 @@ bool _glfwInitVulkan(int mode)
return false; return false;
} }
_glfw.vk.GetInstanceProcAddr = (PFN_vkGetInstanceProcAddr) *(void **) &_glfw.vk.GetInstanceProcAddr =
_glfw_dlsym(_glfw.vk.handle, "vkGetInstanceProcAddr"); _glfw_dlsym(_glfw.vk.handle, "vkGetInstanceProcAddr");
if (!_glfw.vk.GetInstanceProcAddr) if (!_glfw.vk.GetInstanceProcAddr)
{ {
@ -260,7 +260,7 @@ GLFWAPI GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance,
} }
#else #else
if (!proc) if (!proc)
proc = (GLFWvkproc) _glfw_dlsym(_glfw.vk.handle, procname); *(void **) &proc = _glfw_dlsym(_glfw.vk.handle, procname);
#endif #endif
return proc; return proc;

5
glfw/wgl_context.h vendored
View File

@ -103,8 +103,8 @@ typedef BOOL (WINAPI * PFN_wglShareLists)(HGLRC,HGLRC);
#define _GLFW_RECREATION_REQUIRED 1 #define _GLFW_RECREATION_REQUIRED 1
#define _GLFW_RECREATION_IMPOSSIBLE 2 #define _GLFW_RECREATION_IMPOSSIBLE 2
#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextWGL wgl #define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextWGL wgl;
#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryWGL wgl #define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryWGL wgl;
// WGL-specific per-context data // WGL-specific per-context data
@ -156,4 +156,3 @@ void _glfwTerminateWGL(void);
bool _glfwCreateContextWGL(_GLFWwindow* window, bool _glfwCreateContextWGL(_GLFWwindow* window,
const _GLFWctxconfig* ctxconfig, const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig); const _GLFWfbconfig* fbconfig);

2
glfw/window.c vendored
View File

@ -82,7 +82,7 @@ _GLFWwindow* _glfwFocusedWindow() {
_GLFWwindow* _glfwWindowForId(GLFWid id) { _GLFWwindow* _glfwWindowForId(GLFWid id) {
_GLFWwindow *w = _glfw.windowListHead; _GLFWwindow *w = _glfw.windowListHead;
while (w) { while (w) {
if (w->id == _glfw.focusedWindowId) return w; if (w->id == id) return w;
w = w->next; w = w->next;
} }
return NULL; return NULL;

119
glfw/wl_init.c vendored
View File

@ -79,12 +79,12 @@ static _GLFWwindow* findWindowFromDecorationSurface(struct wl_surface* surface,
return window; return window;
} }
static void pointerHandleEnter(void* data, static void pointerHandleEnter(void* data UNUSED,
struct wl_pointer* pointer, struct wl_pointer* pointer UNUSED,
uint32_t serial, uint32_t serial,
struct wl_surface* surface, struct wl_surface* surface,
wl_fixed_t sx, wl_fixed_t sx UNUSED,
wl_fixed_t sy) wl_fixed_t sy UNUSED)
{ {
// Happens in the case we just destroyed the surface. // Happens in the case we just destroyed the surface.
if (!surface) if (!surface)
@ -109,10 +109,10 @@ static void pointerHandleEnter(void* data,
_glfwInputCursorEnter(window, true); _glfwInputCursorEnter(window, true);
} }
static void pointerHandleLeave(void* data, static void pointerHandleLeave(void* data UNUSED,
struct wl_pointer* pointer, struct wl_pointer* pointer UNUSED,
uint32_t serial, uint32_t serial,
struct wl_surface* surface) struct wl_surface* surface UNUSED)
{ {
_GLFWwindow* window = _glfw.wl.pointerFocus; _GLFWwindow* window = _glfw.wl.pointerFocus;
@ -154,9 +154,9 @@ static void setCursor(GLFWCursorShape shape)
wl_surface_commit(surface); wl_surface_commit(surface);
} }
static void pointerHandleMotion(void* data, static void pointerHandleMotion(void* data UNUSED,
struct wl_pointer* pointer, struct wl_pointer* pointer UNUSED,
uint32_t time, uint32_t time UNUSED,
wl_fixed_t sx, wl_fixed_t sx,
wl_fixed_t sy) wl_fixed_t sy)
{ {
@ -209,10 +209,10 @@ static void pointerHandleMotion(void* data,
setCursor(cursorShape); setCursor(cursorShape);
} }
static void pointerHandleButton(void* data, static void pointerHandleButton(void* data UNUSED,
struct wl_pointer* pointer, struct wl_pointer* pointer UNUSED,
uint32_t serial, uint32_t serial,
uint32_t time, uint32_t time UNUSED,
uint32_t button, uint32_t button,
uint32_t state) uint32_t state)
{ {
@ -296,9 +296,9 @@ static void pointerHandleButton(void* data,
_glfw.wl.xkb.states.modifiers); _glfw.wl.xkb.states.modifiers);
} }
static void pointerHandleAxis(void* data, static void pointerHandleAxis(void* data UNUSED,
struct wl_pointer* pointer, struct wl_pointer* pointer UNUSED,
uint32_t time, uint32_t time UNUSED,
uint32_t axis, uint32_t axis,
wl_fixed_t value) wl_fixed_t value)
{ {
@ -326,8 +326,8 @@ static const struct wl_pointer_listener pointerListener = {
pointerHandleAxis, pointerHandleAxis,
}; };
static void keyboardHandleKeymap(void* data, static void keyboardHandleKeymap(void* data UNUSED,
struct wl_keyboard* keyboard, struct wl_keyboard* keyboard UNUSED,
uint32_t format, uint32_t format,
int fd, int fd,
uint32_t size) uint32_t size)
@ -351,11 +351,11 @@ static void keyboardHandleKeymap(void* data,
} }
static void keyboardHandleEnter(void* data, static void keyboardHandleEnter(void* data UNUSED,
struct wl_keyboard* keyboard, struct wl_keyboard* keyboard UNUSED,
uint32_t serial, uint32_t serial UNUSED,
struct wl_surface* surface, struct wl_surface* surface,
struct wl_array* keys) struct wl_array* keys UNUSED)
{ {
// Happens in the case we just destroyed the surface. // Happens in the case we just destroyed the surface.
if (!surface) if (!surface)
@ -373,10 +373,10 @@ static void keyboardHandleEnter(void* data,
_glfwInputWindowFocus(window, true); _glfwInputWindowFocus(window, true);
} }
static void keyboardHandleLeave(void* data, static void keyboardHandleLeave(void* data UNUSED,
struct wl_keyboard* keyboard, struct wl_keyboard* keyboard UNUSED,
uint32_t serial, uint32_t serial UNUSED,
struct wl_surface* surface) struct wl_surface* surface UNUSED)
{ {
_GLFWwindow* window = _glfw.wl.keyboardFocus; _GLFWwindow* window = _glfw.wl.keyboardFocus;
@ -388,7 +388,7 @@ static void keyboardHandleLeave(void* data,
} }
static void 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; 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); 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)); 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, static void keyboardHandleKey(void* data UNUSED,
struct wl_keyboard* keyboard, struct wl_keyboard* keyboard UNUSED,
uint32_t serial, uint32_t serial UNUSED,
uint32_t time, uint32_t time UNUSED,
uint32_t key, uint32_t key,
uint32_t state) uint32_t state)
{ {
@ -422,9 +422,9 @@ static void keyboardHandleKey(void* data,
toggleTimer(&_glfw.wl.eventLoopData, _glfw.wl.keyRepeatInfo.keyRepeatTimer, repeatable ? 1 : 0); toggleTimer(&_glfw.wl.eventLoopData, _glfw.wl.keyRepeatInfo.keyRepeatTimer, repeatable ? 1 : 0);
} }
static void keyboardHandleModifiers(void* data, static void keyboardHandleModifiers(void* data UNUSED,
struct wl_keyboard* keyboard, struct wl_keyboard* keyboard UNUSED,
uint32_t serial, uint32_t serial UNUSED,
uint32_t modsDepressed, uint32_t modsDepressed,
uint32_t modsLatched, uint32_t modsLatched,
uint32_t modsLocked, 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); 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, struct wl_keyboard* keyboard,
int32_t rate, int32_t rate,
int32_t delay) int32_t delay)
@ -454,7 +454,7 @@ static const struct wl_keyboard_listener keyboardListener = {
keyboardHandleRepeatInfo, keyboardHandleRepeatInfo,
}; };
static void seatHandleCapabilities(void* data, static void seatHandleCapabilities(void* data UNUSED,
struct wl_seat* seat, struct wl_seat* seat,
enum wl_seat_capability caps) enum wl_seat_capability caps)
{ {
@ -481,9 +481,9 @@ static void seatHandleCapabilities(void* data,
} }
} }
static void seatHandleName(void* data, static void seatHandleName(void* data UNUSED,
struct wl_seat* seat, struct wl_seat* seat UNUSED,
const char* name) const char* name UNUSED)
{ {
} }
@ -492,7 +492,7 @@ static const struct wl_seat_listener seatListener = {
seatHandleName, seatHandleName,
}; };
static void wmBaseHandlePing(void* data, static void wmBaseHandlePing(void* data UNUSED,
struct xdg_wm_base* wmBase, struct xdg_wm_base* wmBase,
uint32_t serial) uint32_t serial)
{ {
@ -503,7 +503,7 @@ static const struct xdg_wm_base_listener wmBaseListener = {
wmBaseHandlePing wmBaseHandlePing
}; };
static void registryHandleGlobal(void* data, static void registryHandleGlobal(void* data UNUSED,
struct wl_registry* registry, struct wl_registry* registry,
uint32_t name, uint32_t name,
const char* interface, const char* interface,
@ -609,8 +609,8 @@ static void registryHandleGlobal(void* data,
} }
static void registryHandleGlobalRemove(void *data, static void registryHandleGlobalRemove(void *data UNUSED,
struct wl_registry *registry, struct wl_registry *registry UNUSED,
uint32_t name) uint32_t name)
{ {
_GLFWmonitor* monitor; _GLFWmonitor* monitor;
@ -642,19 +642,19 @@ static const struct wl_registry_listener registryListener = {
static void registry_handle_global(void* data, static void registry_handle_global(void* data,
struct wl_registry* registry, struct wl_registry* registry UNUSED,
uint32_t name, uint32_t name UNUSED,
const char* interface, const char* interface,
uint32_t version) { uint32_t version UNUSED) {
if (strcmp(interface, "zxdg_decoration_manager_v1") == 0) { if (strcmp(interface, "zxdg_decoration_manager_v1") == 0) {
bool *has_ssd = (bool*)data; bool *has_ssd = (bool*)data;
if (has_ssd) *has_ssd = true; if (has_ssd) *has_ssd = true;
} }
} }
static void registry_handle_global_remove(void *data, static void registry_handle_global_remove(void *data UNUSED,
struct wl_registry *registry, struct wl_registry *registry UNUSED,
uint32_t name) {} uint32_t name UNUSED) {}
GLFWAPI const char* GLFWAPI const char*
glfwWaylandCheckForServerSideDecorations(void) { glfwWaylandCheckForServerSideDecorations(void) {
struct wl_display *display = wl_display_connect(NULL); struct wl_display *display = wl_display_connect(NULL);
@ -694,14 +694,10 @@ int _glfwPlatformInit(void)
return false; return false;
} }
_glfw.wl.cursor.theme_load = (PFN_wl_cursor_theme_load) glfw_dlsym(_glfw.wl.cursor.theme_load, _glfw.wl.cursor.handle, "wl_cursor_theme_load");
_glfw_dlsym(_glfw.wl.cursor.handle, "wl_cursor_theme_load"); glfw_dlsym(_glfw.wl.cursor.theme_destroy, _glfw.wl.cursor.handle, "wl_cursor_theme_destroy");
_glfw.wl.cursor.theme_destroy = (PFN_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.handle, "wl_cursor_theme_destroy"); glfw_dlsym(_glfw.wl.cursor.image_get_buffer, _glfw.wl.cursor.handle, "wl_cursor_image_get_buffer");
_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.wl.egl.handle = _glfw_dlopen("libwayland-egl.so.1"); _glfw.wl.egl.handle = _glfw_dlopen("libwayland-egl.so.1");
if (!_glfw.wl.egl.handle) if (!_glfw.wl.egl.handle)
@ -711,12 +707,9 @@ int _glfwPlatformInit(void)
return false; return false;
} }
_glfw.wl.egl.window_create = (PFN_wl_egl_window_create) glfw_dlsym(_glfw.wl.egl.window_create, _glfw.wl.egl.handle, "wl_egl_window_create");
_glfw_dlsym(_glfw.wl.egl.handle, "wl_egl_window_create"); glfw_dlsym(_glfw.wl.egl.window_destroy, _glfw.wl.egl.handle, "wl_egl_window_destroy");
_glfw.wl.egl.window_destroy = (PFN_wl_egl_window_destroy) glfw_dlsym(_glfw.wl.egl.window_resize, _glfw.wl.egl.handle, "wl_egl_window_resize");
_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.wl.display = wl_display_connect(NULL); _glfw.wl.display = wl_display_connect(NULL);
if (!_glfw.wl.display) if (!_glfw.wl.display)

19
glfw/wl_monitor.c vendored
View File

@ -34,15 +34,15 @@
static void outputHandleGeometry(void* data, static void outputHandleGeometry(void* data,
struct wl_output* output, struct wl_output* output UNUSED,
int32_t x, int32_t x,
int32_t y, int32_t y,
int32_t physicalWidth, int32_t physicalWidth,
int32_t physicalHeight, int32_t physicalHeight,
int32_t subpixel, int32_t subpixel UNUSED,
const char* make, const char* make,
const char* model, const char* model,
int32_t transform) int32_t transform UNUSED)
{ {
struct _GLFWmonitor *monitor = data; struct _GLFWmonitor *monitor = data;
char name[1024]; char name[1024];
@ -57,7 +57,7 @@ static void outputHandleGeometry(void* data,
} }
static void outputHandleMode(void* data, static void outputHandleMode(void* data,
struct wl_output* output, struct wl_output* output UNUSED,
uint32_t flags, uint32_t flags,
int32_t width, int32_t width,
int32_t height, int32_t height,
@ -82,7 +82,7 @@ static void outputHandleMode(void* data,
monitor->wl.currentMode = monitor->modeCount - 1; 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; struct _GLFWmonitor *monitor = data;
for (int i = 0; i < _glfw.monitorCount; i++) { 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, static void outputHandleScale(void* data,
struct wl_output* output, struct wl_output* output UNUSED,
int32_t factor) int32_t factor)
{ {
struct _GLFWmonitor *monitor = data; struct _GLFWmonitor *monitor = data;
@ -198,15 +198,15 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
*mode = monitor->modes[monitor->wl.currentMode]; *mode = monitor->modes[monitor->wl.currentMode];
} }
bool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp) bool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor UNUSED, GLFWgammaramp* ramp UNUSED)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"Wayland: Gamma ramp access is not available"); "Wayland: Gamma ramp access is not available");
return false; return false;
} }
void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor UNUSED,
const GLFWgammaramp* ramp) const GLFWgammaramp* ramp UNUSED)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"Wayland: Gamma ramp access is not available"); "Wayland: Gamma ramp access is not available");
@ -223,4 +223,3 @@ GLFWAPI struct wl_output* glfwGetWaylandMonitor(GLFWmonitor* handle)
_GLFW_REQUIRE_INIT_OR_RETURN(NULL); _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
return monitor->wl.output; return monitor->wl.output;
} }

3
glfw/wl_platform.h vendored
View File

@ -295,7 +295,7 @@ typedef struct _GLFWlibraryWayland
typedef struct _GLFWmonitorWayland typedef struct _GLFWmonitorWayland
{ {
struct wl_output* output; struct wl_output* output;
int name; uint32_t name;
int currentMode; int currentMode;
int x; int x;
@ -321,4 +321,3 @@ void _glfwSetupWaylandDataDevice(void);
void _glfwSetupWaylandPrimarySelectionDevice(void); void _glfwSetupWaylandPrimarySelectionDevice(void);
void animateCursorImage(id_type timer_id, void *data); void animateCursorImage(id_type timer_id, void *data);
struct wl_cursor* _glfwLoadCursor(GLFWCursorShape); struct wl_cursor* _glfwLoadCursor(GLFWCursorShape);

134
glfw/wl_window.c vendored
View File

@ -239,7 +239,7 @@ static struct wl_buffer* createShmBuffer(const GLFWimage* image)
if (fd < 0) if (fd < 0)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _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); length);
return NULL; return NULL;
} }
@ -248,7 +248,7 @@ static struct wl_buffer* createShmBuffer(const GLFWimage* image)
if (data == MAP_FAILED) if (data == MAP_FAILED)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"Wayland: mmap failed: %m"); "Wayland: mmap failed: %%m");
close(fd); close(fd);
return NULL; return NULL;
} }
@ -363,7 +363,7 @@ static void destroyDecorations(_GLFWwindow* window)
} }
static void xdgDecorationHandleConfigure(void* data, static void xdgDecorationHandleConfigure(void* data,
struct zxdg_toplevel_decoration_v1* decoration, struct zxdg_toplevel_decoration_v1* decoration UNUSED,
uint32_t mode) uint32_t mode)
{ {
_GLFWwindow* window = data; _GLFWwindow* window = data;
@ -377,7 +377,7 @@ static const struct zxdg_toplevel_decoration_v1_listener xdgDecorationListener =
}; };
static void handleEnter(void *data, static void handleEnter(void *data,
struct wl_surface *surface, struct wl_surface *surface UNUSED,
struct wl_output *output) struct wl_output *output)
{ {
_GLFWwindow* window = data; _GLFWwindow* window = data;
@ -400,7 +400,7 @@ static void handleEnter(void *data,
} }
static void handleLeave(void *data, static void handleLeave(void *data,
struct wl_surface *surface, struct wl_surface *surface UNUSED,
struct wl_output *output) struct wl_output *output)
{ {
_GLFWwindow* window = data; _GLFWwindow* window = data;
@ -496,15 +496,14 @@ setFullscreen(_GLFWwindow* window, _GLFWmonitor* monitor, bool on)
} }
bool bool
_glfwPlatformToggleFullscreen(_GLFWwindow *window, unsigned int flags) { _glfwPlatformToggleFullscreen(_GLFWwindow *window, unsigned int flags UNUSED) {
(void) flags;
bool already_fullscreen = window->wl.fullscreened; bool already_fullscreen = window->wl.fullscreened;
setFullscreen(window, NULL, !already_fullscreen); setFullscreen(window, NULL, !already_fullscreen);
return !already_fullscreen; return !already_fullscreen;
} }
static void xdgToplevelHandleConfigure(void* data, static void xdgToplevelHandleConfigure(void* data,
struct xdg_toplevel* toplevel, struct xdg_toplevel* toplevel UNUSED,
int32_t width, int32_t width,
int32_t height, int32_t height,
struct wl_array* states) struct wl_array* states)
@ -562,7 +561,7 @@ static void xdgToplevelHandleConfigure(void* data,
} }
static void xdgToplevelHandleClose(void* data, static void xdgToplevelHandleClose(void* data,
struct xdg_toplevel* toplevel) struct xdg_toplevel* toplevel UNUSED)
{ {
_GLFWwindow* window = data; _GLFWwindow* window = data;
_glfwInputWindowCloseRequest(window); _glfwInputWindowCloseRequest(window);
@ -573,7 +572,7 @@ static const struct xdg_toplevel_listener xdgToplevelListener = {
xdgToplevelHandleClose xdgToplevelHandleClose
}; };
static void xdgSurfaceHandleConfigure(void* data, static void xdgSurfaceHandleConfigure(void* data UNUSED,
struct xdg_surface* surface, struct xdg_surface* surface,
uint32_t serial) uint32_t serial)
{ {
@ -726,7 +725,7 @@ incrementCursorImage(_GLFWwindow* window)
} }
void void
animateCursorImage(id_type timer_id, void *data) { animateCursorImage(id_type timer_id UNUSED, void *data UNUSED) {
incrementCursorImage(_glfw.wl.pointerFocus); incrementCursorImage(_glfw.wl.pointerFocus);
} }
@ -945,14 +944,14 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
xdg_toplevel_set_title(window->wl.xdg.toplevel, title); xdg_toplevel_set_title(window->wl.xdg.toplevel, title);
} }
void _glfwPlatformSetWindowIcon(_GLFWwindow* window, void _glfwPlatformSetWindowIcon(_GLFWwindow* window UNUSED,
int count, const GLFWimage* images) int count UNUSED, const GLFWimage* images UNUSED)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"Wayland: Setting window icon not supported"); "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 // A Wayland client is not aware of its position, so just warn and leave it
// as (0, 0) // as (0, 0)
@ -961,7 +960,7 @@ void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
"Wayland: Window position retrieval not supported"); "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 // A Wayland client can not set its position, so just warn
@ -1002,8 +1001,8 @@ void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
} }
} }
void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window UNUSED,
int numer, int denom) int numer UNUSED, int denom UNUSED)
{ {
// TODO: find out how to trigger a resize. // TODO: find out how to trigger a resize.
// The actual limits are checked in the xdg_toplevel::configure handler. // The actual limits are checked in the xdg_toplevel::configure handler.
@ -1043,7 +1042,7 @@ void _glfwPlatformGetWindowContentScale(_GLFWwindow* window,
*yscale = (float) window->wl.scale; *yscale = (float) window->wl.scale;
} }
double _glfwPlatformGetDoubleClickInterval(_GLFWwindow* window) double _glfwPlatformGetDoubleClickInterval(_GLFWwindow* window UNUSED)
{ {
return 0.5; return 0.5;
} }
@ -1099,7 +1098,7 @@ void _glfwPlatformHideWindow(_GLFWwindow* window)
window->wl.visible = false; window->wl.visible = false;
} }
void _glfwPlatformRequestWindowAttention(_GLFWwindow* window) void _glfwPlatformRequestWindowAttention(_GLFWwindow* window UNUSED)
{ {
// TODO // TODO
static bool notified = false; 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 // TODO: Use an actual Wayland API to implement this when one becomes available
static char tty[L_ctermid + 1]; static char tty[L_ctermid + 1];
@ -1123,7 +1122,7 @@ int _glfwPlatformWindowBell(_GLFWwindow* window)
return false; return false;
} }
void _glfwPlatformFocusWindow(_GLFWwindow* window) void _glfwPlatformFocusWindow(_GLFWwindow* window UNUSED)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"Wayland: Focusing a window requires user interaction"); "Wayland: Focusing a window requires user interaction");
@ -1131,9 +1130,9 @@ void _glfwPlatformFocusWindow(_GLFWwindow* window)
void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
_GLFWmonitor* monitor, _GLFWmonitor* monitor,
int xpos, int ypos, int xpos UNUSED, int ypos UNUSED,
int width, int height, int width UNUSED, int height UNUSED,
int refreshRate) int refreshRate UNUSED)
{ {
setFullscreen(window, monitor, monitor != NULL); setFullscreen(window, monitor, monitor != NULL);
_glfwInputWindowMonitor(window, monitor); _glfwInputWindowMonitor(window, monitor);
@ -1144,12 +1143,12 @@ int _glfwPlatformWindowFocused(_GLFWwindow* window)
return _glfw.wl.keyboardFocus == window; return _glfw.wl.keyboardFocus == window;
} }
int _glfwPlatformWindowOccluded(_GLFWwindow* window) int _glfwPlatformWindowOccluded(_GLFWwindow* window UNUSED)
{ {
return false; return false;
} }
int _glfwPlatformWindowIconified(_GLFWwindow* window) int _glfwPlatformWindowIconified(_GLFWwindow* window UNUSED)
{ {
// xdg-shell doesnt give any way to request whether a surface is // xdg-shell doesnt give any way to request whether a surface is
// iconified. // iconified.
@ -1176,7 +1175,7 @@ int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
return window->wl.transparent; return window->wl.transparent;
} }
void _glfwPlatformSetWindowResizable(_GLFWwindow* window, bool enabled) void _glfwPlatformSetWindowResizable(_GLFWwindow* window UNUSED, bool enabled UNUSED)
{ {
// TODO // TODO
_glfwInputError(GLFW_PLATFORM_ERROR, _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 // TODO
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"Wayland: Window attribute setting not implemented yet"); "Wayland: Window attribute setting not implemented yet");
} }
float _glfwPlatformGetWindowOpacity(_GLFWwindow* window) float _glfwPlatformGetWindowOpacity(_GLFWwindow* window UNUSED)
{ {
return 1.f; 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); _glfwPlatformSetCursor(window, window->wl.currentCursor);
} }
@ -1271,7 +1270,7 @@ int _glfwPlatformGetKeyScancode(int key)
int _glfwPlatformCreateCursor(_GLFWcursor* cursor, int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
const GLFWimage* image, const GLFWimage* image,
int xhot, int yhot, int count) int xhot, int yhot, int count UNUSED)
{ {
cursor->wl.buffer = createShmBuffer(image); cursor->wl.buffer = createShmBuffer(image);
if (!cursor->wl.buffer) if (!cursor->wl.buffer)
@ -1305,11 +1304,11 @@ void _glfwPlatformDestroyCursor(_GLFWcursor* cursor)
} }
static void handleRelativeMotion(void* data, static void handleRelativeMotion(void* data,
struct zwp_relative_pointer_v1* pointer, struct zwp_relative_pointer_v1* pointer UNUSED,
uint32_t timeHi, uint32_t timeHi UNUSED,
uint32_t timeLo, uint32_t timeLo UNUSED,
wl_fixed_t dx, wl_fixed_t dx UNUSED,
wl_fixed_t dy, wl_fixed_t dy UNUSED,
wl_fixed_t dxUnaccel, wl_fixed_t dxUnaccel,
wl_fixed_t dyUnaccel) wl_fixed_t dyUnaccel)
{ {
@ -1327,8 +1326,8 @@ static const struct zwp_relative_pointer_v1_listener relativePointerListener = {
handleRelativeMotion handleRelativeMotion
}; };
static void handleLocked(void* data, static void handleLocked(void* data UNUSED,
struct zwp_locked_pointer_v1* lockedPointer) struct zwp_locked_pointer_v1* lockedPointer UNUSED)
{ {
} }
@ -1346,10 +1345,10 @@ static void unlockPointer(_GLFWwindow* window)
window->wl.pointerLock.lockedPointer = NULL; window->wl.pointerLock.lockedPointer = NULL;
} }
static void lockPointer(_GLFWwindow* window); static void lockPointer(_GLFWwindow* window UNUSED);
static void handleUnlocked(void* data, static void handleUnlocked(void* data UNUSED,
struct zwp_locked_pointer_v1* lockedPointer) struct zwp_locked_pointer_v1* lockedPointer UNUSED)
{ {
} }
@ -1471,12 +1470,12 @@ static void send_text(char *text, int fd)
close(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); send_text(_glfw.wl.clipboardString, fd);
} }
static void _glfwSendPrimarySelectionText(void *data, struct zwp_primary_selection_source_v1 *primary_selection_source, static void _glfwSendPrimarySelectionText(void *data UNUSED, struct zwp_primary_selection_source_v1 *primary_selection_source UNUSED,
const char *mime_type, int fd) { const char *mime_type UNUSED, int fd) {
send_text(_glfw.wl.primarySelectionString, 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]); 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) if (_glfw.wl.dataSourceForClipboard == wl_data_source)
_glfw.wl.dataSourceForClipboard = NULL; _glfw.wl.dataSourceForClipboard = NULL;
wl_data_source_destroy(wl_data_source); 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) if (_glfw.wl.dataSourceForPrimarySelection == primary_selection_source)
_glfw.wl.dataSourceForPrimarySelection = NULL; _glfw.wl.dataSourceForPrimarySelection = NULL;
zwp_primary_selection_source_v1_destroy(primary_selection_source); 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, .send = _glfwSendClipboardText,
.cancelled = data_source_canceled, .cancelled = data_source_canceled,
.target = data_source_target, .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, .send = _glfwSendPrimarySelectionText,
.cancelled = primary_selection_source_canceled, .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++) { for (size_t i = 0; i < arraysz(_glfw.wl.dataOffers); i++) {
if (_glfw.wl.dataOffers[i].id == data_offer) { 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(); 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) { struct zwp_primary_selection_offer_v1 *primary_selection_offer) {
for (size_t i = 0; i < arraysz(_glfw.wl.primarySelectionOffers); i++) { for (size_t i = 0; i < arraysz(_glfw.wl.primarySelectionOffers); i++) {
if (_glfw.wl.primarySelectionOffers[i].id == primary_selection_offer) { 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; 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++) { for (size_t i = 0; i < arraysz(_glfw.wl.dataOffers); i++) {
if (_glfw.wl.dataOffers[i].id == id) { if (_glfw.wl.dataOffers[i].id == id) {
set_offer_mimetype(&_glfw.wl.dataOffers[i], mime); 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++) { for (size_t i = 0; i < arraysz(_glfw.wl.primarySelectionOffers); i++) {
if (_glfw.wl.primarySelectionOffers[i].id == id) { if (_glfw.wl.primarySelectionOffers[i].id == id) {
set_offer_mimetype((struct _GLFWWaylandDataOffer*)&_glfw.wl.primarySelectionOffers[i], mime); 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++) { for (size_t i = 0; i < arraysz(_glfw.wl.dataOffers); i++) {
if (_glfw.wl.dataOffers[i].id == id) { if (_glfw.wl.dataOffers[i].id == id) {
_glfw.wl.dataOffers[i].source_actions = actions; _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++) { for (size_t i = 0; i < arraysz(_glfw.wl.dataOffers); i++) {
if (_glfw.wl.dataOffers[i].id == id) { if (_glfw.wl.dataOffers[i].id == id) {
_glfw.wl.dataOffers[i].dnd_action = action; _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, .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; size_t smallest_idx = SIZE_MAX, pos = 0;
for (size_t i = 0; i < arraysz(_glfw.wl.dataOffers); i++) { for (size_t i = 0; i < arraysz(_glfw.wl.dataOffers); i++) {
if (_glfw.wl.dataOffers[i].idx && _glfw.wl.dataOffers[i].idx < smallest_idx) { 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); 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; size_t smallest_idx = SIZE_MAX, pos = 0;
for (size_t i = 0; i < arraysz(_glfw.wl.primarySelectionOffers); i++) { for (size_t i = 0; i < arraysz(_glfw.wl.primarySelectionOffers); i++) {
if (_glfw.wl.primarySelectionOffers[i].idx && _glfw.wl.primarySelectionOffers[i].idx < smallest_idx) { 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); 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++) { for (size_t i = 0; i < arraysz(_glfw.wl.dataOffers); i++) {
if (_glfw.wl.dataOffers[i].id == id) { if (_glfw.wl.dataOffers[i].id == id) {
_glfw.wl.dataOffers[i].offer_type = DRAG_AND_DROP; _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(); 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++) { for (size_t i = 0; i < arraysz(_glfw.wl.dataOffers); i++) {
if (_glfw.wl.dataOffers[i].offer_type == DRAG_AND_DROP) { if (_glfw.wl.dataOffers[i].offer_type == DRAG_AND_DROP) {
wl_data_offer_destroy(_glfw.wl.dataOffers[i].id); 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++) { for (size_t i = 0; i < arraysz(_glfw.wl.dataOffers); i++) {
if (_glfw.wl.dataOffers[i].offer_type == DRAG_AND_DROP) { if (_glfw.wl.dataOffers[i].offer_type == DRAG_AND_DROP) {
char *uri_list = read_data_offer(_glfw.wl.dataOffers[i].id, URI_LIST_MIME); 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, .data_offer = handle_data_offer,
.selection = mark_selection_offer, .selection = mark_selection_offer,
.enter = drag_enter, .enter = drag_enter,
@ -1776,7 +1775,7 @@ const static struct wl_data_device_listener data_device_listener = {
.leave = drag_leave, .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, .data_offer = handle_primary_selection_offer,
.selection = mark_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, "STRING");
wl_data_source_offer(_glfw.wl.dataSourceForClipboard, "UTF8_STRING"); wl_data_source_offer(_glfw.wl.dataSourceForClipboard, "UTF8_STRING");
struct wl_callback *callback = wl_display_sync(_glfw.wl.display); 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); 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, "STRING");
zwp_primary_selection_source_v1_offer(_glfw.wl.dataSourceForPrimarySelection, "UTF8_STRING"); zwp_primary_selection_source_v1_offer(_glfw.wl.dataSourceForPrimarySelection, "UTF8_STRING");
struct wl_callback *callback = wl_display_sync(_glfw.wl.display); 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); 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 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; _GLFWwindow* window = (_GLFWwindow*) data;
if (callback == window->wl.frameCallbackData.current_wl_callback) { if (callback == window->wl.frameCallbackData.current_wl_callback) {
window->wl.frameCallbackData.callback(window->wl.frameCallbackData.id); 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) { GLFWAPI void glfwDBusSetUserNotificationHandler(GLFWDBusnotificationactivatedfun handler) {
glfw_dbus_set_user_notification_activated_handler(handler); glfw_dbus_set_user_notification_activated_handler(handler);
} }

101
glfw/x11_init.c vendored
View File

@ -155,14 +155,10 @@ static bool initExtensions(void)
_glfw.x11.vidmode.handle = _glfw_dlopen("libXxf86vm.so.1"); _glfw.x11.vidmode.handle = _glfw_dlopen("libXxf86vm.so.1");
if (_glfw.x11.vidmode.handle) if (_glfw.x11.vidmode.handle)
{ {
_glfw.x11.vidmode.QueryExtension = (PFN_XF86VidModeQueryExtension) glfw_dlsym(_glfw.x11.vidmode.QueryExtension, _glfw.x11.vidmode.handle, "XF86VidModeQueryExtension");
_glfw_dlsym(_glfw.x11.vidmode.handle, "XF86VidModeQueryExtension"); glfw_dlsym(_glfw.x11.vidmode.GetGammaRamp, _glfw.x11.vidmode.handle, "XF86VidModeGetGammaRamp");
_glfw.x11.vidmode.GetGammaRamp = (PFN_XF86VidModeGetGammaRamp) glfw_dlsym(_glfw.x11.vidmode.SetGammaRamp, _glfw.x11.vidmode.handle, "XF86VidModeSetGammaRamp");
_glfw_dlsym(_glfw.x11.vidmode.handle, "XF86VidModeGetGammaRamp"); glfw_dlsym(_glfw.x11.vidmode.GetGammaRampSize, _glfw.x11.vidmode.handle, "XF86VidModeGetGammaRampSize");
_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.x11.vidmode.available = _glfw.x11.vidmode.available =
XF86VidModeQueryExtension(_glfw.x11.display, XF86VidModeQueryExtension(_glfw.x11.display,
@ -177,10 +173,8 @@ static bool initExtensions(void)
#endif #endif
if (_glfw.x11.xi.handle) if (_glfw.x11.xi.handle)
{ {
_glfw.x11.xi.QueryVersion = (PFN_XIQueryVersion) glfw_dlsym(_glfw.x11.xi.QueryVersion, _glfw.x11.xi.handle, "XIQueryVersion");
_glfw_dlsym(_glfw.x11.xi.handle, "XIQueryVersion"); glfw_dlsym(_glfw.x11.xi.SelectEvents, _glfw.x11.xi.handle, "XISelectEvents");
_glfw.x11.xi.SelectEvents = (PFN_XISelectEvents)
_glfw_dlsym(_glfw.x11.xi.handle, "XISelectEvents");
if (XQueryExtension(_glfw.x11.display, if (XQueryExtension(_glfw.x11.display,
"XInputExtension", "XInputExtension",
@ -207,42 +201,24 @@ static bool initExtensions(void)
#endif #endif
if (_glfw.x11.randr.handle) if (_glfw.x11.randr.handle)
{ {
_glfw.x11.randr.AllocGamma = (PFN_XRRAllocGamma) glfw_dlsym(_glfw.x11.randr.AllocGamma, _glfw.x11.randr.handle, "XRRAllocGamma");
_glfw_dlsym(_glfw.x11.randr.handle, "XRRAllocGamma"); glfw_dlsym(_glfw.x11.randr.FreeGamma, _glfw.x11.randr.handle, "XRRFreeGamma");
_glfw.x11.randr.FreeGamma = (PFN_XRRFreeGamma) glfw_dlsym(_glfw.x11.randr.FreeCrtcInfo, _glfw.x11.randr.handle, "XRRFreeCrtcInfo");
_glfw_dlsym(_glfw.x11.randr.handle, "XRRFreeGamma"); glfw_dlsym(_glfw.x11.randr.FreeGamma, _glfw.x11.randr.handle, "XRRFreeGamma");
_glfw.x11.randr.FreeCrtcInfo = (PFN_XRRFreeCrtcInfo) glfw_dlsym(_glfw.x11.randr.FreeOutputInfo, _glfw.x11.randr.handle, "XRRFreeOutputInfo");
_glfw_dlsym(_glfw.x11.randr.handle, "XRRFreeCrtcInfo"); glfw_dlsym(_glfw.x11.randr.FreeScreenResources, _glfw.x11.randr.handle, "XRRFreeScreenResources");
_glfw.x11.randr.FreeGamma = (PFN_XRRFreeGamma) glfw_dlsym(_glfw.x11.randr.GetCrtcGamma, _glfw.x11.randr.handle, "XRRGetCrtcGamma");
_glfw_dlsym(_glfw.x11.randr.handle, "XRRFreeGamma"); glfw_dlsym(_glfw.x11.randr.GetCrtcGammaSize, _glfw.x11.randr.handle, "XRRGetCrtcGammaSize");
_glfw.x11.randr.FreeOutputInfo = (PFN_XRRFreeOutputInfo) glfw_dlsym(_glfw.x11.randr.GetCrtcInfo, _glfw.x11.randr.handle, "XRRGetCrtcInfo");
_glfw_dlsym(_glfw.x11.randr.handle, "XRRFreeOutputInfo"); glfw_dlsym(_glfw.x11.randr.GetOutputInfo, _glfw.x11.randr.handle, "XRRGetOutputInfo");
_glfw.x11.randr.FreeScreenResources = (PFN_XRRFreeScreenResources) glfw_dlsym(_glfw.x11.randr.GetOutputPrimary, _glfw.x11.randr.handle, "XRRGetOutputPrimary");
_glfw_dlsym(_glfw.x11.randr.handle, "XRRFreeScreenResources"); glfw_dlsym(_glfw.x11.randr.GetScreenResourcesCurrent, _glfw.x11.randr.handle, "XRRGetScreenResourcesCurrent");
_glfw.x11.randr.GetCrtcGamma = (PFN_XRRGetCrtcGamma) glfw_dlsym(_glfw.x11.randr.QueryExtension, _glfw.x11.randr.handle, "XRRQueryExtension");
_glfw_dlsym(_glfw.x11.randr.handle, "XRRGetCrtcGamma"); glfw_dlsym(_glfw.x11.randr.QueryVersion, _glfw.x11.randr.handle, "XRRQueryVersion");
_glfw.x11.randr.GetCrtcGammaSize = (PFN_XRRGetCrtcGammaSize) glfw_dlsym(_glfw.x11.randr.SelectInput, _glfw.x11.randr.handle, "XRRSelectInput");
_glfw_dlsym(_glfw.x11.randr.handle, "XRRGetCrtcGammaSize"); glfw_dlsym(_glfw.x11.randr.SetCrtcConfig, _glfw.x11.randr.handle, "XRRSetCrtcConfig");
_glfw.x11.randr.GetCrtcInfo = (PFN_XRRGetCrtcInfo) glfw_dlsym(_glfw.x11.randr.SetCrtcGamma, _glfw.x11.randr.handle, "XRRSetCrtcGamma");
_glfw_dlsym(_glfw.x11.randr.handle, "XRRGetCrtcInfo"); glfw_dlsym(_glfw.x11.randr.UpdateConfiguration, _glfw.x11.randr.handle, "XRRUpdateConfiguration");
_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");
if (XRRQueryExtension(_glfw.x11.display, if (XRRQueryExtension(_glfw.x11.display,
&_glfw.x11.randr.eventBase, &_glfw.x11.randr.eventBase,
@ -299,12 +275,9 @@ static bool initExtensions(void)
#endif #endif
if (_glfw.x11.xcursor.handle) if (_glfw.x11.xcursor.handle)
{ {
_glfw.x11.xcursor.ImageCreate = (PFN_XcursorImageCreate) glfw_dlsym(_glfw.x11.xcursor.ImageCreate, _glfw.x11.xcursor.handle, "XcursorImageCreate");
_glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorImageCreate"); glfw_dlsym(_glfw.x11.xcursor.ImageDestroy, _glfw.x11.xcursor.handle, "XcursorImageDestroy");
_glfw.x11.xcursor.ImageDestroy = (PFN_XcursorImageDestroy) glfw_dlsym(_glfw.x11.xcursor.ImageLoadCursor, _glfw.x11.xcursor.handle, "XcursorImageLoadCursor");
_glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorImageDestroy");
_glfw.x11.xcursor.ImageLoadCursor = (PFN_XcursorImageLoadCursor)
_glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorImageLoadCursor");
} }
#if defined(__CYGWIN__) #if defined(__CYGWIN__)
@ -314,12 +287,9 @@ static bool initExtensions(void)
#endif #endif
if (_glfw.x11.xinerama.handle) if (_glfw.x11.xinerama.handle)
{ {
_glfw.x11.xinerama.IsActive = (PFN_XineramaIsActive) glfw_dlsym(_glfw.x11.xinerama.IsActive, _glfw.x11.xinerama.handle, "XineramaIsActive");
_glfw_dlsym(_glfw.x11.xinerama.handle, "XineramaIsActive"); glfw_dlsym(_glfw.x11.xinerama.QueryExtension, _glfw.x11.xinerama.handle, "XineramaQueryExtension");
_glfw.x11.xinerama.QueryExtension = (PFN_XineramaQueryExtension) glfw_dlsym(_glfw.x11.xinerama.QueryScreens, _glfw.x11.xinerama.handle, "XineramaQueryScreens");
_glfw_dlsym(_glfw.x11.xinerama.handle, "XineramaQueryExtension");
_glfw.x11.xinerama.QueryScreens = (PFN_XineramaQueryScreens)
_glfw_dlsym(_glfw.x11.xinerama.handle, "XineramaQueryScreens");
if (XineramaQueryExtension(_glfw.x11.display, if (XineramaQueryExtension(_glfw.x11.display,
&_glfw.x11.xinerama.major, &_glfw.x11.xinerama.major,
@ -337,12 +307,9 @@ static bool initExtensions(void)
#endif #endif
if (_glfw.x11.xrender.handle) if (_glfw.x11.xrender.handle)
{ {
_glfw.x11.xrender.QueryExtension = (PFN_XRenderQueryExtension) glfw_dlsym(_glfw.x11.xrender.QueryExtension, _glfw.x11.xrender.handle, "XRenderQueryExtension");
_glfw_dlsym(_glfw.x11.xrender.handle, "XRenderQueryExtension"); glfw_dlsym(_glfw.x11.xrender.QueryVersion, _glfw.x11.xrender.handle, "XRenderQueryVersion");
_glfw.x11.xrender.QueryVersion = (PFN_XRenderQueryVersion) glfw_dlsym(_glfw.x11.xrender.FindVisualFormat, _glfw.x11.xrender.handle, "XRenderFindVisualFormat");
_glfw_dlsym(_glfw.x11.xrender.handle, "XRenderQueryVersion");
_glfw.x11.xrender.FindVisualFormat = (PFN_XRenderFindVisualFormat)
_glfw_dlsym(_glfw.x11.xrender.handle, "XRenderFindVisualFormat");
if (XRenderQueryExtension(_glfw.x11.display, if (XRenderQueryExtension(_glfw.x11.display,
&_glfw.x11.xrender.errorBase, &_glfw.x11.xrender.errorBase,
@ -536,7 +503,7 @@ static Window createHelperWindow(void)
// X error handler // X error handler
// //
static int errorHandler(Display *display, XErrorEvent* event) static int errorHandler(Display *display UNUSED, XErrorEvent* event)
{ {
_glfw.x11.errorCode = event->error_code; _glfw.x11.errorCode = event->error_code;
return 0; return 0;

10
glfw/x11_monitor.c vendored
View File

@ -172,8 +172,8 @@ void _glfwPollMonitorsX11(void)
{ {
if (screens[j].x_org == ci->x && if (screens[j].x_org == ci->x &&
screens[j].y_org == ci->y && screens[j].y_org == ci->y &&
screens[j].width == ci->width && screens[j].width == (short int)ci->width &&
screens[j].height == ci->height) screens[j].height == (short int)ci->height)
{ {
monitor->x11.index = j; monitor->x11.index = j;
break; break;
@ -301,7 +301,7 @@ void _glfwRestoreVideoModeX11(_GLFWmonitor* monitor)
////// GLFW platform API ////// ////// 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) float* xscale, float* yscale)
{ {
if (xscale) if (xscale)
@ -547,7 +547,7 @@ void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
{ {
if (_glfw.x11.randr.available && !_glfw.x11.randr.gammaBroken) 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, _glfwInputError(GLFW_PLATFORM_ERROR,
"X11: Gamma ramp size must match current ramp size"); "X11: Gamma ramp size must match current ramp size");

29
glfw/x11_window.c vendored
View File

@ -139,7 +139,7 @@ static int getWindowState(_GLFWwindow* window)
// Returns whether the event is a selection event // 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) if (event->xany.window != _glfw.x11.helperWindowHandle)
return False; 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 // 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; _GLFWwindow* window = (_GLFWwindow*) pointer;
return event->type == PropertyNotify && 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 // 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; XEvent* notification = (XEvent*) pointer;
return event->type == PropertyNotify && return event->type == PropertyNotify &&
@ -326,8 +326,7 @@ set_fullscreen(_GLFWwindow *window, bool on) {
} }
bool bool
_glfwPlatformToggleFullscreen(_GLFWwindow *window, unsigned int flags) { _glfwPlatformToggleFullscreen(_GLFWwindow *window, unsigned int flags UNUSED) {
(void) flags;
bool already_fullscreen = is_window_fullscreen(window); bool already_fullscreen = is_window_fullscreen(window);
set_fullscreen(window, !already_fullscreen); set_fullscreen(window, !already_fullscreen);
return !already_fullscreen; return !already_fullscreen;
@ -2010,8 +2009,8 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
} }
void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window, void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
int minwidth, int minheight, int minwidth UNUSED, int minheight UNUSED,
int maxwidth, int maxheight) int maxwidth UNUSED, int maxheight UNUSED)
{ {
int width, height; int width, height;
_glfwPlatformGetWindowSize(window, &width, &height); _glfwPlatformGetWindowSize(window, &width, &height);
@ -2019,7 +2018,7 @@ void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
XFlush(_glfw.x11.display); 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; int width, height;
_glfwPlatformGetWindowSize(window, &width, &height); _glfwPlatformGetWindowSize(window, &width, &height);
@ -2092,7 +2091,7 @@ void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
XFree(extents); XFree(extents);
} }
void _glfwPlatformGetWindowContentScale(_GLFWwindow* window, void _glfwPlatformGetWindowContentScale(_GLFWwindow* window UNUSED,
float* xscale, float* yscale) float* xscale, float* yscale)
{ {
if (xscale) if (xscale)
@ -2101,7 +2100,7 @@ void _glfwPlatformGetWindowContentScale(_GLFWwindow* window,
*yscale = _glfw.x11.contentScaleY; *yscale = _glfw.x11.contentScaleY;
} }
double _glfwPlatformGetDoubleClickInterval(_GLFWwindow* window) double _glfwPlatformGetDoubleClickInterval(_GLFWwindow* window UNUSED)
{ {
return 0.5; return 0.5;
} }
@ -2200,7 +2199,7 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
_GLFWmonitor* monitor, _GLFWmonitor* monitor,
int xpos, int ypos, int xpos, int ypos,
int width, int height, int width, int height,
int refreshRate) int refreshRate UNUSED)
{ {
if (window->monitor == monitor) if (window->monitor == monitor)
{ {
@ -2258,7 +2257,7 @@ int _glfwPlatformWindowFocused(_GLFWwindow* window)
return window->x11.handle == focused; return window->x11.handle == focused;
} }
int _glfwPlatformWindowOccluded(_GLFWwindow* window) int _glfwPlatformWindowOccluded(_GLFWwindow* window UNUSED)
{ {
return false; return false;
} }
@ -2339,7 +2338,7 @@ int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
return XGetSelectionOwner(_glfw.x11.display, _glfw.x11.NET_WM_CM_Sx) != None; 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; int width, height;
_glfwPlatformGetWindowSize(window, &width, &height); _glfwPlatformGetWindowSize(window, &width, &height);
@ -2597,7 +2596,7 @@ int _glfwPlatformGetKeyScancode(int key)
int _glfwPlatformCreateCursor(_GLFWcursor* cursor, int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
const GLFWimage* image, const GLFWimage* image,
int xhot, int yhot, int count) int xhot, int yhot, int count UNUSED)
{ {
cursor->x11.handle = _glfwCreateCursorX11(image, xhot, yhot); cursor->x11.handle = _glfwCreateCursorX11(image, xhot, yhot);
if (!cursor->x11.handle) if (!cursor->x11.handle)
@ -2643,7 +2642,7 @@ void _glfwPlatformDestroyCursor(_GLFWcursor* cursor)
XFreeCursor(_glfw.x11.display, cursor->x11.handle); 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) if (window->cursorMode == GLFW_CURSOR_NORMAL)
{ {

12
glfw/xkb_glfw.c vendored
View File

@ -29,6 +29,7 @@
#include <stdlib.h> #include <stdlib.h>
#include "internal.h" #include "internal.h"
#include "xkb_glfw.h" #include "xkb_glfw.h"
START_ALLOW_CASE_RANGE
#define debug(...) if (_glfw.hints.init.debugKeyboard) printf(__VA_ARGS__); #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 S(f, t) case XKB_KEY_##f: return GLFW_KEY_##t
#define F(f, t) S(f, 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 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) map_key(key)
S(KP_Up, UP); S(KP_Up, UP);
S(KP_Down, DOWN); S(KP_Down, DOWN);
@ -115,7 +116,7 @@ glfw_key_for_sym(xkb_keysym_t key) {
#undef D #undef D
#undef R #undef R
#undef S #undef S
}; }
xkb_keysym_t xkb_keysym_t
glfw_xkb_sym_for_key(int key) { glfw_xkb_sym_for_key(int key) {
@ -133,6 +134,7 @@ glfw_xkb_sym_for_key(int key) {
#undef R #undef R
#undef S #undef S
} }
END_ALLOW_CASE_RANGE
#ifdef _GLFW_X11 #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); \ 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); \ xcb_connection_t* conn = XGetXCBConnection(_glfw.x11.display); \
if (conn) state = xkb_x11_state_new_from_device(keymap, conn, xkb->keyboard_device_id); \ 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 #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_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 #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 static inline xkb_keysym_t
compose_symbol(struct xkb_compose_state *composeState, xkb_keysym_t sym, int *compose_completed) { compose_symbol(struct xkb_compose_state *composeState, xkb_keysym_t sym, int *compose_completed) {