Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update GLFW 3.3 source code (2019/11/25) #261

Merged
merged 1 commit into from
Nov 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion v3.3/glfw/GLFW_C_REVISION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
e4e9581557826bd522158ab9159859e20e10700e
2bac7ee8da526257d808bd026b027246c98e4f2f
12 changes: 12 additions & 0 deletions v3.3/glfw/glfw/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,18 @@ set_target_properties(glfw PROPERTIES
POSITION_INDEPENDENT_CODE ON
FOLDER "GLFW3")

if (${CMAKE_VERSION} VERSION_EQUAL "3.1.0" OR
${CMAKE_VERSION} VERSION_GREATER "3.1.0")

set_target_properties(glfw PROPERTIES C_STANDARD 99)
else()
# Remove this fallback when removing support for CMake version less than 3.1
target_compile_options(glfw PRIVATE
"$<$<C_COMPILER_ID:AppleClang>:-std=c99>"
"$<$<C_COMPILER_ID:Clang>:-std=c99>"
"$<$<C_COMPILER_ID:GNU>:-std=c99>")
endif()

target_compile_definitions(glfw PRIVATE _GLFW_USE_CONFIG_H)
target_include_directories(glfw PUBLIC
"$<BUILD_INTERFACE:${GLFW_SOURCE_DIR}/include>"
Expand Down
2 changes: 1 addition & 1 deletion v3.3/glfw/glfw/src/cocoa_joystick.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include <IOKit/hid/IOHIDKeys.h>

#define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickNS ns
#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE
#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyJoystick; }

#define _GLFW_PLATFORM_MAPPING_NAME "Mac OS X"

Expand Down
2 changes: 1 addition & 1 deletion v3.3/glfw/glfw/src/cocoa_monitor.m
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ void _glfwPollMonitorsNS(void)
CGDirectDisplayID* displays = calloc(displayCount, sizeof(CGDirectDisplayID));
CGGetOnlineDisplayList(displayCount, displays, &displayCount);

for (uint32_t i = 0; i < _glfw.monitorCount; i++)
for (int i = 0; i < _glfw.monitorCount; i++)
_glfw.monitors[i]->ns.screen = nil;

_GLFWmonitor** disconnected = NULL;
Expand Down
3 changes: 3 additions & 0 deletions v3.3/glfw/glfw/src/cocoa_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
typedef void* id;
#endif

// NOTE: Many Cocoa enum values have been renamed and we need to build across
// SDK versions where one is unavailable or the other deprecated
// We use the newer names in code and these macros to handle compatibility
#if MAC_OS_X_VERSION_MAX_ALLOWED < 101200
#define NSBitmapFormatAlphaNonpremultiplied NSAlphaNonpremultipliedBitmapFormat
#define NSEventMaskAny NSAnyEventMask
Expand Down
10 changes: 6 additions & 4 deletions v3.3/glfw/glfw/src/cocoa_window.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,14 @@
//
static NSUInteger getStyleMask(_GLFWwindow* window)
{
NSUInteger styleMask = 0;
NSUInteger styleMask = NSWindowStyleMaskMiniaturizable;

if (window->monitor || !window->decorated)
styleMask |= NSWindowStyleMaskBorderless;
else
{
styleMask |= NSWindowStyleMaskTitled |
NSWindowStyleMaskClosable |
NSWindowStyleMaskMiniaturizable;
NSWindowStyleMaskClosable;

if (window->resizable)
styleMask |= NSWindowStyleMaskResizable;
Expand Down Expand Up @@ -816,7 +815,7 @@ static GLFWbool createNativeWindow(_GLFWwindow* window,
[window->ns.object setLevel:NSMainMenuWindowLevel + 1];
else
{
[window->ns.object center];
[(NSWindow*) window->ns.object center];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The line that was causing the warning.

_glfw.ns.cascadePoint =
NSPointToCGPoint([window->ns.object cascadeTopLeftFromPoint:
NSPointFromCGPoint(_glfw.ns.cascadePoint)]);
Expand Down Expand Up @@ -962,6 +961,9 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
[window->ns.object close];
window->ns.object = nil;

// HACK: Allow Cocoa to catch up before returning
_glfwPlatformPollEvents();

} // autoreleasepool
}

Expand Down
2 changes: 0 additions & 2 deletions v3.3/glfw/glfw/src/mappings.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ const char* _glfwDefaultMappings[] =
"030000000d0f00008700000000000000,Fighting Stick mini 4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
"030000000d0f00002700000000000000,FIGHTING STICK V3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
"78696e70757403000000000000000000,Fightstick TES,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,lefttrigger:a2,rightshoulder:b5,righttrigger:a5,start:b7,x:b2,y:b3,platform:Windows,",
"03000000790000000600000000000000,G-Shark GS-GP702,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b3,y:b0,platform:Windows,",
"03000000260900002625000000000000,Gamecube Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,lefttrigger:a4,leftx:a0,lefty:a1,righttrigger:a5,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Windows,",
"030000008f0e00000d31000000000000,GAMEPAD 3 TURBO,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
"03000000280400000140000000000000,GamePad Pro USB,a:b1,b:b2,back:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
Expand Down Expand Up @@ -207,7 +206,6 @@ const char* _glfwDefaultMappings[] =
"030000008305000031b0000000000000,Cideko AK08b,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
"03000000260900008888000088020000,Cyber Gadget GameCube Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:a5,rightx:a2,righty:a3~,start:b7,x:b2,y:b3,platform:Mac OS X,",
"03000000a306000022f6000001030000,Cyborg V.3 Rumble Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:-a3,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Mac OS X,",
"03000000790000000600000000000000,G-Shark GP-702,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b3,y:b0,platform:Mac OS X,",
"03000000ad1b000001f9000000000000,Gamestop BB-070 X360 Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
"0500000047532047616d657061640000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Mac OS X,",
"030000000d0f00005f00000000010000,Hori Fighting Commander 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
Expand Down
3 changes: 3 additions & 0 deletions v3.3/glfw/glfw/src/nsgl_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
//
//========================================================================

// NOTE: Many Cocoa enum values have been renamed and we need to build across
// SDK versions where one is unavailable or the other deprecated
// We use the newer names in code and these macros to handle compatibility
#if MAC_OS_X_VERSION_MAX_ALLOWED < 101400
#define NSOpenGLContextParameterSwapInterval NSOpenGLCPSwapInterval
#define NSOpenGLContextParameterSurfaceOpacity NSOpenGLCPSurfaceOpacity
Expand Down
4 changes: 2 additions & 2 deletions v3.3/glfw/glfw/src/nsgl_context.m
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
return GLFW_FALSE;
}

NSOpenGLContext* share = NULL;
NSOpenGLContext* share = nil;

if (ctxconfig->share)
share = ctxconfig->share->context.nsgl.object;
Expand Down Expand Up @@ -412,7 +412,7 @@ GLFWAPI id glfwGetNSGLContext(GLFWwindow* handle)
if (window->context.client == GLFW_NO_API)
{
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
return NULL;
return nil;
}

return window->context.nsgl.object;
Expand Down
4 changes: 2 additions & 2 deletions v3.3/glfw/glfw/src/null_joystick.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
//
//========================================================================

#define _GLFW_PLATFORM_JOYSTICK_STATE int nulljs
#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE int nulljs
#define _GLFW_PLATFORM_JOYSTICK_STATE struct { int dummyJoystick; }
#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyLibraryJoystick; }

#define _GLFW_PLATFORM_MAPPING_NAME ""

14 changes: 7 additions & 7 deletions v3.3/glfw/glfw/src/null_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@

#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNull null

#define _GLFW_PLATFORM_CONTEXT_STATE
#define _GLFW_PLATFORM_MONITOR_STATE
#define _GLFW_PLATFORM_CURSOR_STATE
#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE
#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE
#define _GLFW_EGL_CONTEXT_STATE
#define _GLFW_EGL_LIBRARY_CONTEXT_STATE
#define _GLFW_PLATFORM_CONTEXT_STATE struct { int dummyContext; }
#define _GLFW_PLATFORM_MONITOR_STATE struct { int dummyMonitor; }
#define _GLFW_PLATFORM_CURSOR_STATE struct { int dummyCursor; }
#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE struct { int dummyLibraryWindow; }
#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE struct { int dummyLibraryContext; }
#define _GLFW_EGL_CONTEXT_STATE struct { int dummyEGLContext; }
#define _GLFW_EGL_LIBRARY_CONTEXT_STATE struct { int dummyEGLLibraryContext; }

#include "osmesa_context.h"
#include "posix_time.h"
Expand Down
2 changes: 1 addition & 1 deletion v3.3/glfw/glfw/src/win32_joystick.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
//========================================================================

#define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickWin32 win32
#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE int dummy
#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyLibraryJoystick; }

#define _GLFW_PLATFORM_MAPPING_NAME "Windows"

Expand Down
2 changes: 1 addition & 1 deletion v3.3/glfw/glfw/src/win32_window.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ static void updateFramebufferTransparency(const _GLFWwindow* window)
// issue. When set to black, something is making the hit test
// not resize with the window frame.
SetLayeredWindowAttributes(window->win32.handle,
RGB(0, 193, 48), 255, LWA_COLORKEY);
RGB(255, 0, 255), 255, LWA_COLORKEY);
}

DeleteObject(region);
Expand Down
6 changes: 3 additions & 3 deletions v3.3/glfw/glfw/src/wl_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR
#define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorWayland wl
#define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorWayland wl

#define _GLFW_PLATFORM_CONTEXT_STATE
#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE
#define _GLFW_PLATFORM_CONTEXT_STATE struct { int dummyContext; }
#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE struct { int dummyLibraryContext; }

struct wl_cursor_image {
uint32_t width;
Expand Down Expand Up @@ -332,7 +332,7 @@ typedef struct _GLFWlibraryWayland
typedef struct _GLFWmonitorWayland
{
struct wl_output* output;
int name;
uint32_t name;
int currentMode;

int x;
Expand Down
11 changes: 4 additions & 7 deletions v3.3/glfw/glfw/src/x11_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -793,13 +793,10 @@ static GLFWbool initExtensions(void)
//
static void getSystemContentScale(float* xscale, float* yscale)
{
// NOTE: Fall back to the display-wide DPI instead of RandR monitor DPI if
// Xft.dpi retrieval below fails as we don't currently have an exact
// policy for which monitor a window is considered to "be on"
float xdpi = DisplayWidth(_glfw.x11.display, _glfw.x11.screen) *
25.4f / DisplayWidthMM(_glfw.x11.display, _glfw.x11.screen);
float ydpi = DisplayHeight(_glfw.x11.display, _glfw.x11.screen) *
25.4f / DisplayHeightMM(_glfw.x11.display, _glfw.x11.screen);
// Start by assuming the default X11 DPI
// NOTE: Some desktop environments (KDE) may remove the Xft.dpi field when it
// would be set to 96, so assume that is the case if we cannot find it
float xdpi = 96.f, ydpi = 96.f;

// NOTE: Basing the scale on Xft.dpi where available should provide the most
// consistent user experience (matches Qt, Gtk, etc), although not
Expand Down
10 changes: 10 additions & 0 deletions v3.3/glfw/glfw/src/x11_monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,16 @@ void _glfwPollMonitorsX11(void)
heightMM = oi->mm_height;
}

if (widthMM <= 0 || heightMM <= 0)
{
// HACK: If RandR does not provide a physical size, assume the
// X11 default 96 DPI and calcuate from the CRTC viewport
// NOTE: These members are affected by rotation, unlike the mode
// info and output info members
widthMM = (int) (ci->width * 25.4f / 96.f);
heightMM = (int) (ci->height * 25.4f / 96.f);
}

_GLFWmonitor* monitor = _glfwAllocMonitor(oi->name, widthMM, heightMM);
monitor->x11.output = sr->outputs[i];
monitor->x11.crtc = oi->crtc;
Expand Down
43 changes: 19 additions & 24 deletions v3.3/glfw/glfw/src/x11_window.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@
#define Button6 6
#define Button7 7

// Motif WM hints flags
#define MWM_HINTS_DECORATIONS 2
#define MWM_DECOR_ALL 1

#define _GLFW_XDND_VERSION 5


Expand Down Expand Up @@ -2536,33 +2540,24 @@ void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled)

void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled)
{
if (enabled)
{
XDeleteProperty(_glfw.x11.display,
window->x11.handle,
_glfw.x11.MOTIF_WM_HINTS);
}
else
struct
{
struct
{
unsigned long flags;
unsigned long functions;
unsigned long decorations;
long input_mode;
unsigned long status;
} hints;
unsigned long flags;
unsigned long functions;
unsigned long decorations;
long input_mode;
unsigned long status;
} hints = {0};

hints.flags = 2; // Set decorations
hints.decorations = 0; // No decorations
hints.flags = MWM_HINTS_DECORATIONS;
hints.decorations = enabled ? MWM_DECOR_ALL : 0;

XChangeProperty(_glfw.x11.display, window->x11.handle,
_glfw.x11.MOTIF_WM_HINTS,
_glfw.x11.MOTIF_WM_HINTS, 32,
PropModeReplace,
(unsigned char*) &hints,
sizeof(hints) / sizeof(long));
}
XChangeProperty(_glfw.x11.display, window->x11.handle,
_glfw.x11.MOTIF_WM_HINTS,
_glfw.x11.MOTIF_WM_HINTS, 32,
PropModeReplace,
(unsigned char*) &hints,
sizeof(hints) / sizeof(long));
}

void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
Expand Down