From c7d6a44e33b6cbebdce1c3121aa163317f85098a Mon Sep 17 00:00:00 2001 From: Ray Date: Sat, 2 Jun 2018 18:26:29 +0200 Subject: [PATCH] Update GLFW to latest dev version (master branch) --- .../glfw/CMake/modules/FindVulkan.cmake | 5 ----- src/external/glfw/README.md | 2 ++ src/external/glfw/include/GLFW/glfw3.h | 20 +++++++++++++++++-- src/external/glfw/src/CMakeLists.txt | 16 +++++++-------- src/external/glfw/src/input.c | 5 +++-- src/external/glfw/src/internal.h | 2 ++ src/external/glfw/src/win32_platform.h | 4 +++- src/external/glfw/src/window.c | 13 +++++++++++- src/external/glfw/src/x11_window.c | 5 +++-- 9 files changed, 50 insertions(+), 22 deletions(-) diff --git a/src/external/glfw/CMake/modules/FindVulkan.cmake b/src/external/glfw/CMake/modules/FindVulkan.cmake index 103554bb..5004356b 100644 --- a/src/external/glfw/CMake/modules/FindVulkan.cmake +++ b/src/external/glfw/CMake/modules/FindVulkan.cmake @@ -27,11 +27,6 @@ if (WIN32) "$ENV{VULKAN_SDK}/Bin32" "$ENV{VK_SDK_PATH}/Bin32") endif() -elseif (APPLE) - find_library(VULKAN_LIBRARY vulkan.1 HINTS - "$ENV{VULKAN_SDK}/macOS/lib") - find_path(VULKAN_INCLUDE_DIR NAMES vulkan/vulkan.h HINTS - "$ENV{VULKAN_SDK}/macOS/include") else() find_path(VULKAN_INCLUDE_DIR NAMES vulkan/vulkan.h HINTS "$ENV{VULKAN_SDK}/include") diff --git a/src/external/glfw/README.md b/src/external/glfw/README.md index 0573dcd9..82d4806a 100644 --- a/src/external/glfw/README.md +++ b/src/external/glfw/README.md @@ -165,6 +165,8 @@ information on what to include when reporting a bug. - Added `GLFW_HOVERED` window attribute for polling cursor hover state (#1166) - Added `GLFW_CENTER_CURSOR` window hint for controlling cursor centering (#749,#842) +- Added `GLFW_FOCUS_ON_SHOW` window hint and attribute to control input focus + on calling show window (#1189) - Added `GLFW_JOYSTICK_HAT_BUTTONS` init hint (#889) - Added `GLFW_LOCK_KEY_MODS` input mode and `GLFW_MOD_*_LOCK` mod bits (#946) - Added macOS specific `GLFW_COCOA_RETINA_FRAMEBUFFER` window hint diff --git a/src/external/glfw/include/GLFW/glfw3.h b/src/external/glfw/include/GLFW/glfw3.h index 00256d4d..990fe3f7 100644 --- a/src/external/glfw/include/GLFW/glfw3.h +++ b/src/external/glfw/include/GLFW/glfw3.h @@ -819,6 +819,12 @@ extern "C" { * Mouse cursor hover [window attribute](@ref GLFW_HOVERED_attrib). */ #define GLFW_HOVERED 0x0002000B +/*! @brief Input focus on calling show window hint and attribute + * + * Input focus [window hint](@ref GLFW_FOCUS_ON_SHOW_hint) or + * [window attribute](@ref GLFW_FOCUS_ON_SHOW_attrib). + */ +#define GLFW_FOCUS_ON_SHOW 0x0002000C /*! @brief Framebuffer bit depth hint. * @@ -3085,6 +3091,11 @@ GLFWAPI void glfwMaximizeWindow(GLFWwindow* window); * hidden. If the window is already visible or is in full screen mode, this * function does nothing. * + * By default, windowed mode windows are focused when shown + * Set the [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_hint) window hint + * to change this behavior for all newly created windows, or change the + * behavior for an existing window with @ref glfwSetWindowAttrib. + * * @param[in] window The window to make visible. * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref @@ -3132,6 +3143,10 @@ GLFWAPI void glfwHideWindow(GLFWwindow* window); * initially created. Set the [GLFW_FOCUSED](@ref GLFW_FOCUSED_hint) to * disable this behavior. * + * Also by default, windowed mode windows are focused when shown + * with @ref glfwShowWindow. Set the + * [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_hint) to disable this behavior. + * * __Do not use this function__ to steal focus from other applications unless * you are certain that is what the user wants. Focus stealing can be * extremely disruptive. @@ -3306,8 +3321,9 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* window, int attrib); * * The supported attributes are [GLFW_DECORATED](@ref GLFW_DECORATED_attrib), * [GLFW_RESIZABLE](@ref GLFW_RESIZABLE_attrib), - * [GLFW_FLOATING](@ref GLFW_FLOATING_attrib) and - * [GLFW_AUTO_ICONIFY](@ref GLFW_AUTO_ICONIFY_attrib). + * [GLFW_FLOATING](@ref GLFW_FLOATING_attrib), + * [GLFW_AUTO_ICONIFY](@ref GLFW_AUTO_ICONIFY_attrib) and + * [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_attrib). * * Some of these attributes are ignored for full screen windows. The new * value will take effect if the window is later made windowed. diff --git a/src/external/glfw/src/CMakeLists.txt b/src/external/glfw/src/CMakeLists.txt index 6d3e33a5..22ce68f1 100644 --- a/src/external/glfw/src/CMakeLists.txt +++ b/src/external/glfw/src/CMakeLists.txt @@ -92,9 +92,7 @@ if (${CMAKE_C_COMPILER_ID} STREQUAL GNU OR ${CMAKE_C_COMPILER_ID} STREQUAL Clang COMPILE_FLAGS -Wdeclaration-after-statement) endif() -add_library(glfw_objlib OBJECT ${glfw_SOURCES} ${glfw_HEADERS}) -add_library(glfw $) - +add_library(glfw ${glfw_SOURCES} ${glfw_HEADERS}) set_target_properties(glfw PROPERTIES OUTPUT_NAME ${GLFW_LIB_NAME} VERSION ${GLFW_VERSION} @@ -102,11 +100,11 @@ set_target_properties(glfw PROPERTIES POSITION_INDEPENDENT_CODE ON FOLDER "GLFW3") -target_compile_definitions(glfw_objlib PRIVATE _GLFW_USE_CONFIG_H) -target_include_directories(glfw_objlib PUBLIC +target_compile_definitions(glfw PRIVATE _GLFW_USE_CONFIG_H) +target_include_directories(glfw PUBLIC "$" "$/include>") -target_include_directories(glfw_objlib PRIVATE +target_include_directories(glfw PRIVATE "${GLFW_SOURCE_DIR}/src" "${GLFW_BINARY_DIR}/src" ${glfw_INCLUDE_DIRS}) @@ -115,11 +113,11 @@ target_include_directories(glfw_objlib PRIVATE # the inclusion of stddef.h (by glfw3.h), which is itself included before # win32_platform.h. We define them here until a saner solution can be found # NOTE: MinGW-w64 and Visual C++ do /not/ need this hack. -target_compile_definitions(glfw_objlib PRIVATE +target_compile_definitions(glfw PRIVATE "$<$:UNICODE;WINVER=0x0501>") # Enable a reasonable set of warnings (no, -Wextra is not reasonable) -target_compile_options(glfw_objlib PRIVATE +target_compile_options(glfw PRIVATE "$<$:-Wall>" "$<$:-Wall>") @@ -137,7 +135,7 @@ if (BUILD_SHARED_LIBS) endif() elseif (APPLE) # Add -fno-common to work around a bug in Apple's GCC - target_compile_options(glfw_objlib PRIVATE "-fno-common") + target_compile_options(glfw PRIVATE "-fno-common") set_target_properties(glfw PROPERTIES INSTALL_NAME_DIR "lib${LIB_SUFFIX}") diff --git a/src/external/glfw/src/input.c b/src/external/glfw/src/input.c index 42975452..b0bb3de4 100644 --- a/src/external/glfw/src/input.c +++ b/src/external/glfw/src/input.c @@ -32,7 +32,6 @@ #include #include #include -#include // Internal key state used for sticky keys #define _GLFW_STICK 3 @@ -1086,7 +1085,9 @@ GLFWAPI int glfwUpdateGamepadMappings(const char* string) while (*c) { - if (isxdigit(*c)) + if ((*c >= '0' && *c <= '9') || + (*c >= 'a' && *c <= 'f') || + (*c >= 'A' && *c <= 'F')) { char line[1024]; diff --git a/src/external/glfw/src/internal.h b/src/external/glfw/src/internal.h index 92bbfcce..9fc626dd 100644 --- a/src/external/glfw/src/internal.h +++ b/src/external/glfw/src/internal.h @@ -267,6 +267,7 @@ struct _GLFWwndconfig GLFWbool floating; GLFWbool maximized; GLFWbool centerCursor; + GLFWbool focusOnShow; struct { GLFWbool retina; char frameName[256]; @@ -372,6 +373,7 @@ struct _GLFWwindow GLFWbool decorated; GLFWbool autoIconify; GLFWbool floating; + GLFWbool focusOnShow; GLFWbool shouldClose; void* userPointer; GLFWvidmode videoMode; diff --git a/src/external/glfw/src/win32_platform.h b/src/external/glfw/src/win32_platform.h index 9a669215..59815146 100644 --- a/src/external/glfw/src/win32_platform.h +++ b/src/external/glfw/src/win32_platform.h @@ -242,7 +242,9 @@ typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)( #include "egl_context.h" #include "osmesa_context.h" -#define _GLFW_WNDCLASSNAME L"GLFW30" +#if !defined(_GLFW_WNDCLASSNAME) + #define _GLFW_WNDCLASSNAME L"GLFW30" +#endif #define _glfw_dlopen(name) LoadLibraryA(name) #define _glfw_dlclose(handle) FreeLibrary((HMODULE) handle) diff --git a/src/external/glfw/src/window.c b/src/external/glfw/src/window.c index 38a8982b..4ed415ca 100644 --- a/src/external/glfw/src/window.c +++ b/src/external/glfw/src/window.c @@ -201,6 +201,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, window->decorated = wndconfig.decorated; window->autoIconify = wndconfig.autoIconify; window->floating = wndconfig.floating; + window->focusOnShow = wndconfig.focusOnShow; window->cursorMode = GLFW_CURSOR_NORMAL; window->minwidth = GLFW_DONT_CARE; @@ -267,6 +268,7 @@ void glfwDefaultWindowHints(void) _glfw.hints.window.focused = GLFW_TRUE; _glfw.hints.window.autoIconify = GLFW_TRUE; _glfw.hints.window.centerCursor = GLFW_TRUE; + _glfw.hints.window.focusOnShow = GLFW_TRUE; // The default is 24 bits of color, 24 bits of depth and 8 bits of stencil, // double buffered @@ -370,6 +372,9 @@ GLFWAPI void glfwWindowHint(int hint, int value) case GLFW_CENTER_CURSOR: _glfw.hints.window.centerCursor = value ? GLFW_TRUE : GLFW_FALSE; return; + case GLFW_FOCUS_ON_SHOW: + _glfw.hints.window.focusOnShow = value ? GLFW_TRUE : GLFW_FALSE; + return; case GLFW_CLIENT_API: _glfw.hints.context.client = value; return; @@ -755,7 +760,9 @@ GLFWAPI void glfwShowWindow(GLFWwindow* handle) return; _glfwPlatformShowWindow(window); - _glfwPlatformFocusWindow(window); + + if (window->focusOnShow) + _glfwPlatformFocusWindow(window); } GLFWAPI void glfwRequestWindowAttention(GLFWwindow* handle) @@ -810,6 +817,8 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib) return _glfwPlatformWindowMaximized(window); case GLFW_HOVERED: return _glfwPlatformWindowHovered(window); + case GLFW_FOCUS_ON_SHOW: + return window->focusOnShow; case GLFW_TRANSPARENT_FRAMEBUFFER: return _glfwPlatformFramebufferTransparent(window); case GLFW_RESIZABLE: @@ -886,6 +895,8 @@ GLFWAPI void glfwSetWindowAttrib(GLFWwindow* handle, int attrib, int value) if (!window->monitor) _glfwPlatformSetWindowFloating(window, value); } + else if (attrib == GLFW_FOCUS_ON_SHOW) + window->focusOnShow = value; else _glfwInputError(GLFW_INVALID_ENUM, "Invalid window attribute 0x%08X", attrib); } diff --git a/src/external/glfw/src/x11_window.c b/src/external/glfw/src/x11_window.c index fc24f285..1c4e9c3c 100644 --- a/src/external/glfw/src/x11_window.c +++ b/src/external/glfw/src/x11_window.c @@ -2672,8 +2672,9 @@ void _glfwPlatformPollEvents(void) #if defined(__linux__) _glfwDetectJoystickConnectionLinux(); #endif - int count = XPending(_glfw.x11.display); - while (count--) + XPending(_glfw.x11.display); + + while (XQLength(_glfw.x11.display)) { XEvent event; XNextEvent(_glfw.x11.display, &event);