mirror of
https://github.com/glfw/glfw.git
synced 2025-02-21 07:59:11 +00:00
Merge branch '3.3-stable' into new-cursors-on-3.3-stable
This commit is contained in:
commit
cbce7a3648
11
README.md
11
README.md
@ -101,7 +101,7 @@ located in the `deps/` directory.
|
|||||||
functions
|
functions
|
||||||
- [linmath.h](https://github.com/datenwolf/linmath.h) for linear algebra in
|
- [linmath.h](https://github.com/datenwolf/linmath.h) for linear algebra in
|
||||||
examples
|
examples
|
||||||
- [Nuklear](https://github.com/vurtun/nuklear) for test and example UI
|
- [Nuklear](https://github.com/Immediate-Mode-UI/Nuklear) for test and example UI
|
||||||
- [stb\_image\_write](https://github.com/nothings/stb) for writing images to disk
|
- [stb\_image\_write](https://github.com/nothings/stb) for writing images to disk
|
||||||
|
|
||||||
The documentation is generated with [Doxygen](http://doxygen.org/) if CMake can
|
The documentation is generated with [Doxygen](http://doxygen.org/) if CMake can
|
||||||
@ -138,6 +138,11 @@ information on what to include when reporting a bug.
|
|||||||
- [Cocoa] Bugfix: Failing to retrieve the refresh rate of built-in displays
|
- [Cocoa] Bugfix: Failing to retrieve the refresh rate of built-in displays
|
||||||
could leak memory
|
could leak memory
|
||||||
- [Cocoa] Bugfix: Objective-C files were compiled as C with CMake 3.19 (#1787)
|
- [Cocoa] Bugfix: Objective-C files were compiled as C with CMake 3.19 (#1787)
|
||||||
|
- [Cocoa] Bugfix: Duplicate video modes were not filtered out (#1830)
|
||||||
|
- [Cocoa] Bugfix: Menubar was not clickable on macOS 10.15+ until it lost and
|
||||||
|
regained focus (#1648,#1802)
|
||||||
|
- [Cocoa] Bugfix: Monitor name query could segfault on macOS 11 (#1809,#1833)
|
||||||
|
- [Cocoa] Bugfix: The install name of the installed dylib was relative (#1504)
|
||||||
- [X11] Bugfix: IME input of CJK was broken for "C" locale (#1587,#1636)
|
- [X11] Bugfix: IME input of CJK was broken for "C" locale (#1587,#1636)
|
||||||
- [X11] Bugfix: Xlib errors caused by other parts of the application could be
|
- [X11] Bugfix: Xlib errors caused by other parts of the application could be
|
||||||
reported as GLFW errors
|
reported as GLFW errors
|
||||||
@ -179,13 +184,16 @@ GLFW exists because people around the world donated their time and lent their
|
|||||||
skills.
|
skills.
|
||||||
|
|
||||||
- Bobyshev Alexander
|
- Bobyshev Alexander
|
||||||
|
- Laurent Aphecetche
|
||||||
- Matt Arsenault
|
- Matt Arsenault
|
||||||
|
- ashishgamedev
|
||||||
- David Avedissian
|
- David Avedissian
|
||||||
- Keith Bauer
|
- Keith Bauer
|
||||||
- John Bartholomew
|
- John Bartholomew
|
||||||
- Coşku Baş
|
- Coşku Baş
|
||||||
- Niklas Behrens
|
- Niklas Behrens
|
||||||
- Andrew Belt
|
- Andrew Belt
|
||||||
|
- Nevyn Bengtsson
|
||||||
- Niklas Bergström
|
- Niklas Bergström
|
||||||
- Denis Bernard
|
- Denis Bernard
|
||||||
- Doug Binks
|
- Doug Binks
|
||||||
@ -369,6 +377,7 @@ skills.
|
|||||||
- Waris
|
- Waris
|
||||||
- Jay Weisskopf
|
- Jay Weisskopf
|
||||||
- Frank Wille
|
- Frank Wille
|
||||||
|
- Richard A. Wilkes
|
||||||
- Tatsuya Yatagawa
|
- Tatsuya Yatagawa
|
||||||
- Ryogo Yoshimura
|
- Ryogo Yoshimura
|
||||||
- Lukas Zanner
|
- Lukas Zanner
|
||||||
|
@ -93,7 +93,7 @@ if (glfwVulkanSupported())
|
|||||||
This function returns `GLFW_TRUE` if the Vulkan loader and any minimally
|
This function returns `GLFW_TRUE` if the Vulkan loader and any minimally
|
||||||
functional ICD was found.
|
functional ICD was found.
|
||||||
|
|
||||||
If if one or both were not found, calling any other Vulkan related GLFW function
|
If one or both were not found, calling any other Vulkan related GLFW function
|
||||||
will generate a @ref GLFW_API_UNAVAILABLE error.
|
will generate a @ref GLFW_API_UNAVAILABLE error.
|
||||||
|
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ elseif (_GLFW_OSMESA)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (_GLFW_X11 OR _GLFW_WAYLAND)
|
if (_GLFW_X11 OR _GLFW_WAYLAND)
|
||||||
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
|
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||||
set(glfw_HEADERS ${glfw_HEADERS} linux_joystick.h)
|
set(glfw_HEADERS ${glfw_HEADERS} linux_joystick.h)
|
||||||
set(glfw_SOURCES ${glfw_SOURCES} linux_joystick.c)
|
set(glfw_SOURCES ${glfw_SOURCES} linux_joystick.c)
|
||||||
else()
|
else()
|
||||||
@ -73,7 +73,7 @@ if (_GLFW_X11 OR _GLFW_WAYLAND)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Workaround for CMake not knowing about .m files before version 3.16
|
# Workaround for CMake not knowing about .m files before version 3.16
|
||||||
if ("${CMAKE_VERSION}" VERSION_LESS "3.16" AND APPLE)
|
if (CMAKE_VERSION VERSION_LESS "3.16" AND APPLE)
|
||||||
set_source_files_properties(cocoa_init.m cocoa_joystick.m cocoa_monitor.m
|
set_source_files_properties(cocoa_init.m cocoa_joystick.m cocoa_monitor.m
|
||||||
cocoa_window.m nsgl_context.m PROPERTIES
|
cocoa_window.m nsgl_context.m PROPERTIES
|
||||||
LANGUAGE C)
|
LANGUAGE C)
|
||||||
@ -87,8 +87,8 @@ set_target_properties(glfw PROPERTIES
|
|||||||
POSITION_INDEPENDENT_CODE ON
|
POSITION_INDEPENDENT_CODE ON
|
||||||
FOLDER "GLFW3")
|
FOLDER "GLFW3")
|
||||||
|
|
||||||
if (${CMAKE_VERSION} VERSION_EQUAL "3.1.0" OR
|
if (CMAKE_VERSION VERSION_EQUAL "3.1.0" OR
|
||||||
${CMAKE_VERSION} VERSION_GREATER "3.1.0")
|
CMAKE_VERSION VERSION_GREATER "3.1.0")
|
||||||
|
|
||||||
set_target_properties(glfw PROPERTIES C_STANDARD 99)
|
set_target_properties(glfw PROPERTIES C_STANDARD 99)
|
||||||
else()
|
else()
|
||||||
@ -111,7 +111,7 @@ target_link_libraries(glfw PRIVATE ${glfw_LIBRARIES})
|
|||||||
|
|
||||||
# Make GCC warn about declarations that VS 2010 and 2012 won't accept for all
|
# Make GCC warn about declarations that VS 2010 and 2012 won't accept for all
|
||||||
# source files that VS will build (Clang ignores this because we set -std=c99)
|
# source files that VS will build (Clang ignores this because we set -std=c99)
|
||||||
if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
|
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||||
set_source_files_properties(context.c init.c input.c monitor.c vulkan.c
|
set_source_files_properties(context.c init.c input.c monitor.c vulkan.c
|
||||||
window.c win32_init.c win32_joystick.c
|
window.c win32_init.c win32_joystick.c
|
||||||
win32_monitor.c win32_time.c win32_thread.c
|
win32_monitor.c win32_time.c win32_thread.c
|
||||||
@ -121,11 +121,11 @@ if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Enable a reasonable set of warnings
|
# Enable a reasonable set of warnings
|
||||||
if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR
|
if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR
|
||||||
"${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR
|
CMAKE_C_COMPILER_ID STREQUAL "Clang" OR
|
||||||
"${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang")
|
CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
|
||||||
|
|
||||||
if ("${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC")
|
if (CMAKE_C_SIMULATE_ID STREQUAL "MSVC")
|
||||||
# Tell Clang-CL that this is a Clang flag
|
# Tell Clang-CL that this is a Clang flag
|
||||||
target_compile_options(glfw PRIVATE "/clang:-Wall")
|
target_compile_options(glfw PRIVATE "/clang:-Wall")
|
||||||
else()
|
else()
|
||||||
@ -168,9 +168,6 @@ if (BUILD_SHARED_LIBS)
|
|||||||
elseif (APPLE)
|
elseif (APPLE)
|
||||||
# Add -fno-common to work around a bug in Apple's GCC
|
# Add -fno-common to work around a bug in Apple's GCC
|
||||||
target_compile_options(glfw PRIVATE "-fno-common")
|
target_compile_options(glfw PRIVATE "-fno-common")
|
||||||
|
|
||||||
set_target_properties(glfw PROPERTIES
|
|
||||||
INSTALL_NAME_DIR "${CMAKE_INSTALL_LIBDIR}")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (UNIX)
|
if (UNIX)
|
||||||
|
@ -428,9 +428,6 @@ static GLFWbool initializeTIS(void)
|
|||||||
{
|
{
|
||||||
if (_glfw.hints.init.ns.menubar)
|
if (_glfw.hints.init.ns.menubar)
|
||||||
{
|
{
|
||||||
// In case we are unbundled, make us a proper UI application
|
|
||||||
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
|
|
||||||
|
|
||||||
// Menu bar setup must go between sharedApplication and finishLaunching
|
// Menu bar setup must go between sharedApplication and finishLaunching
|
||||||
// in order to properly emulate the behavior of NSApplicationMain
|
// in order to properly emulate the behavior of NSApplicationMain
|
||||||
|
|
||||||
@ -449,6 +446,11 @@ static GLFWbool initializeTIS(void)
|
|||||||
{
|
{
|
||||||
_glfw.ns.finishedLaunching = GLFW_TRUE;
|
_glfw.ns.finishedLaunching = GLFW_TRUE;
|
||||||
_glfwPlatformPostEmptyEvent();
|
_glfwPlatformPostEmptyEvent();
|
||||||
|
|
||||||
|
// In case we are unbundled, make us a proper UI application
|
||||||
|
if (_glfw.hints.init.ns.menubar)
|
||||||
|
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
|
||||||
|
|
||||||
[NSApp stop:nil];
|
[NSApp stop:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,8 +39,21 @@
|
|||||||
|
|
||||||
// Get the name of the specified display, or NULL
|
// Get the name of the specified display, or NULL
|
||||||
//
|
//
|
||||||
static char* getDisplayName(CGDirectDisplayID displayID)
|
static char* getMonitorName(CGDirectDisplayID displayID, NSScreen* screen)
|
||||||
{
|
{
|
||||||
|
// IOKit doesn't work on Apple Silicon anymore
|
||||||
|
// Luckily, 10.15 introduced -[NSScreen localizedName].
|
||||||
|
// Use it if available, and fall back to IOKit otherwise.
|
||||||
|
if (screen)
|
||||||
|
{
|
||||||
|
if ([screen respondsToSelector:@selector(localizedName)])
|
||||||
|
{
|
||||||
|
NSString* name = [screen valueForKey:@"localizedName"];
|
||||||
|
if (name)
|
||||||
|
return _glfw_strdup([name UTF8String]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
io_iterator_t it;
|
io_iterator_t it;
|
||||||
io_service_t service;
|
io_service_t service;
|
||||||
CFDictionaryRef info;
|
CFDictionaryRef info;
|
||||||
@ -209,31 +222,6 @@ static void endFadeReservation(CGDisplayFadeReservationToken token)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finds and caches the NSScreen corresponding to the specified monitor
|
|
||||||
//
|
|
||||||
static GLFWbool refreshMonitorScreen(_GLFWmonitor* monitor)
|
|
||||||
{
|
|
||||||
if (monitor->ns.screen)
|
|
||||||
return GLFW_TRUE;
|
|
||||||
|
|
||||||
for (NSScreen* screen in [NSScreen screens])
|
|
||||||
{
|
|
||||||
NSNumber* displayID = [screen deviceDescription][@"NSScreenNumber"];
|
|
||||||
|
|
||||||
// HACK: Compare unit numbers instead of display IDs to work around
|
|
||||||
// display replacement on machines with automatic graphics
|
|
||||||
// switching
|
|
||||||
if (monitor->ns.unitNumber == CGDisplayUnitNumber([displayID unsignedIntValue]))
|
|
||||||
{
|
|
||||||
monitor->ns.screen = screen;
|
|
||||||
return GLFW_TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR, "Cocoa: Failed to find a screen for monitor");
|
|
||||||
return GLFW_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns the display refresh rate queried from the I/O registry
|
// Returns the display refresh rate queried from the I/O registry
|
||||||
//
|
//
|
||||||
static double getFallbackRefreshRate(CGDirectDisplayID displayID)
|
static double getFallbackRefreshRate(CGDirectDisplayID displayID)
|
||||||
@ -334,27 +322,46 @@ void _glfwPollMonitorsNS(void)
|
|||||||
if (CGDisplayIsAsleep(displays[i]))
|
if (CGDisplayIsAsleep(displays[i]))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
const uint32_t unitNumber = CGDisplayUnitNumber(displays[i]);
|
||||||
|
NSScreen* screen = nil;
|
||||||
|
|
||||||
|
for (screen in [NSScreen screens])
|
||||||
|
{
|
||||||
|
NSNumber* screenNumber = [screen deviceDescription][@"NSScreenNumber"];
|
||||||
|
|
||||||
|
// HACK: Compare unit numbers instead of display IDs to work around
|
||||||
|
// display replacement on machines with automatic graphics
|
||||||
|
// switching
|
||||||
|
if (CGDisplayUnitNumber([screenNumber unsignedIntValue]) == unitNumber)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// HACK: Compare unit numbers instead of display IDs to work around
|
// HACK: Compare unit numbers instead of display IDs to work around
|
||||||
// display replacement on machines with automatic graphics
|
// display replacement on machines with automatic graphics
|
||||||
// switching
|
// switching
|
||||||
const uint32_t unitNumber = CGDisplayUnitNumber(displays[i]);
|
uint32_t j;
|
||||||
for (uint32_t j = 0; j < disconnectedCount; j++)
|
for (j = 0; j < disconnectedCount; j++)
|
||||||
{
|
{
|
||||||
if (disconnected[j] && disconnected[j]->ns.unitNumber == unitNumber)
|
if (disconnected[j] && disconnected[j]->ns.unitNumber == unitNumber)
|
||||||
{
|
{
|
||||||
|
disconnected[j]->ns.screen = screen;
|
||||||
disconnected[j] = NULL;
|
disconnected[j] = NULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (j < disconnectedCount)
|
||||||
|
continue;
|
||||||
|
|
||||||
const CGSize size = CGDisplayScreenSize(displays[i]);
|
const CGSize size = CGDisplayScreenSize(displays[i]);
|
||||||
char* name = getDisplayName(displays[i]);
|
char* name = getMonitorName(displays[i], screen);
|
||||||
if (!name)
|
if (!name)
|
||||||
name = _glfw_strdup("Unknown");
|
name = _glfw_strdup("Unknown");
|
||||||
|
|
||||||
_GLFWmonitor* monitor = _glfwAllocMonitor(name, size.width, size.height);
|
_GLFWmonitor* monitor = _glfwAllocMonitor(name, size.width, size.height);
|
||||||
monitor->ns.displayID = displays[i];
|
monitor->ns.displayID = displays[i];
|
||||||
monitor->ns.unitNumber = unitNumber;
|
monitor->ns.unitNumber = unitNumber;
|
||||||
|
monitor->ns.screen = screen;
|
||||||
|
|
||||||
free(name);
|
free(name);
|
||||||
|
|
||||||
@ -463,8 +470,11 @@ void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
|
|||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
if (!refreshMonitorScreen(monitor))
|
if (!monitor->ns.screen)
|
||||||
return;
|
{
|
||||||
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
|
"Cocoa: Cannot query content scale without screen");
|
||||||
|
}
|
||||||
|
|
||||||
const NSRect points = [monitor->ns.screen frame];
|
const NSRect points = [monitor->ns.screen frame];
|
||||||
const NSRect pixels = [monitor->ns.screen convertRectToBacking:points];
|
const NSRect pixels = [monitor->ns.screen convertRectToBacking:points];
|
||||||
@ -483,8 +493,11 @@ void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor,
|
|||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
if (!refreshMonitorScreen(monitor))
|
if (!monitor->ns.screen)
|
||||||
return;
|
{
|
||||||
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
|
"Cocoa: Cannot query workarea without screen");
|
||||||
|
}
|
||||||
|
|
||||||
const NSRect frameRect = [monitor->ns.screen visibleFrame];
|
const NSRect frameRect = [monitor->ns.screen visibleFrame];
|
||||||
|
|
||||||
@ -527,7 +540,7 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Skip duplicate modes
|
// Skip duplicate modes
|
||||||
if (i < *count)
|
if (j < *count)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
(*count)++;
|
(*count)++;
|
||||||
|
@ -342,9 +342,9 @@ struct _GLFWcontext
|
|||||||
int robustness;
|
int robustness;
|
||||||
int release;
|
int release;
|
||||||
|
|
||||||
PFNGLGETSTRINGIPROC GetStringi;
|
PFNGLGETSTRINGIPROC GetStringi;
|
||||||
PFNGLGETINTEGERVPROC GetIntegerv;
|
PFNGLGETINTEGERVPROC GetIntegerv;
|
||||||
PFNGLGETSTRINGPROC GetString;
|
PFNGLGETSTRINGPROC GetString;
|
||||||
|
|
||||||
_GLFWmakecontextcurrentfun makeCurrent;
|
_GLFWmakecontextcurrentfun makeCurrent;
|
||||||
_GLFWswapbuffersfun swapBuffers;
|
_GLFWswapbuffersfun swapBuffers;
|
||||||
@ -396,23 +396,23 @@ struct _GLFWwindow
|
|||||||
_GLFWcontext context;
|
_GLFWcontext context;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
GLFWwindowposfun pos;
|
GLFWwindowposfun pos;
|
||||||
GLFWwindowsizefun size;
|
GLFWwindowsizefun size;
|
||||||
GLFWwindowclosefun close;
|
GLFWwindowclosefun close;
|
||||||
GLFWwindowrefreshfun refresh;
|
GLFWwindowrefreshfun refresh;
|
||||||
GLFWwindowfocusfun focus;
|
GLFWwindowfocusfun focus;
|
||||||
GLFWwindowiconifyfun iconify;
|
GLFWwindowiconifyfun iconify;
|
||||||
GLFWwindowmaximizefun maximize;
|
GLFWwindowmaximizefun maximize;
|
||||||
GLFWframebuffersizefun fbsize;
|
GLFWframebuffersizefun fbsize;
|
||||||
GLFWwindowcontentscalefun scale;
|
GLFWwindowcontentscalefun scale;
|
||||||
GLFWmousebuttonfun mouseButton;
|
GLFWmousebuttonfun mouseButton;
|
||||||
GLFWcursorposfun cursorPos;
|
GLFWcursorposfun cursorPos;
|
||||||
GLFWcursorenterfun cursorEnter;
|
GLFWcursorenterfun cursorEnter;
|
||||||
GLFWscrollfun scroll;
|
GLFWscrollfun scroll;
|
||||||
GLFWkeyfun key;
|
GLFWkeyfun key;
|
||||||
GLFWcharfun character;
|
GLFWcharfun character;
|
||||||
GLFWcharmodsfun charmods;
|
GLFWcharmodsfun charmods;
|
||||||
GLFWdropfun drop;
|
GLFWdropfun drop;
|
||||||
} callbacks;
|
} callbacks;
|
||||||
|
|
||||||
// This is defined in the window API's platform.h
|
// This is defined in the window API's platform.h
|
||||||
|
Loading…
Reference in New Issue
Block a user