Merge branch 'master'

This commit is contained in:
Doug Binks 2022-06-06 12:55:45 +01:00
commit fc32eb48c5
22 changed files with 979 additions and 254 deletions

View File

@ -44,6 +44,7 @@ video tutorials.
- Noel Cower - Noel Cower
- CuriouserThing - CuriouserThing
- Jason Daly - Jason Daly
- danhambleton
- Jarrod Davis - Jarrod Davis
- Olivier Delannoy - Olivier Delannoy
- Paul R. Deppe - Paul R. Deppe

View File

@ -176,6 +176,8 @@ information on what to include when reporting a bug.
- Bugfix: Gamepad mapping updates could spam `GLFW_INVALID_VALUE` due to - Bugfix: Gamepad mapping updates could spam `GLFW_INVALID_VALUE` due to
incompatible controllers sharing hardware ID (#1763) incompatible controllers sharing hardware ID (#1763)
- Bugfix: Native access functions for context handles did not check that the API matched - Bugfix: Native access functions for context handles did not check that the API matched
- Bugfix: `glfwMakeContextCurrent` would access TLS slot before initialization
- Bugfix: `glfwSetGammaRamp` could emit `GLFW_INVALID_VALUE` before initialization
- [Win32] Added the `GLFW_WIN32_KEYBOARD_MENU` window hint for enabling access - [Win32] Added the `GLFW_WIN32_KEYBOARD_MENU` window hint for enabling access
to the window menu to the window menu
- [Win32] Added a version info resource to the GLFW DLL - [Win32] Added a version info resource to the GLFW DLL
@ -219,6 +221,7 @@ information on what to include when reporting a bug.
- [Win32] Bugfix: `GLFW_KEY_PAUSE` scancode from `glfwGetKeyScancode` did not - [Win32] Bugfix: `GLFW_KEY_PAUSE` scancode from `glfwGetKeyScancode` did not
match event scancode (#1993) match event scancode (#1993)
- [Win32] Bugfix: Instance-local operations used executable instance (#469,#1296,#1395) - [Win32] Bugfix: Instance-local operations used executable instance (#469,#1296,#1395)
- [Win32] Bugfix: The OSMesa library was not unloaded on termination
- [Cocoa] Added support for `VK_EXT_metal_surface` (#1619) - [Cocoa] Added support for `VK_EXT_metal_surface` (#1619)
- [Cocoa] Added locating the Vulkan loader at runtime in an application bundle - [Cocoa] Added locating the Vulkan loader at runtime in an application bundle
- [Cocoa] Moved main menu creation to GLFW initialization time (#1649) - [Cocoa] Moved main menu creation to GLFW initialization time (#1649)
@ -250,6 +253,7 @@ information on what to include when reporting a bug.
- [Cocoa] Bugfix: `kIOMasterPortDefault` was deprecated in macOS 12.0 (#1980) - [Cocoa] Bugfix: `kIOMasterPortDefault` was deprecated in macOS 12.0 (#1980)
- [Cocoa] Bugfix: `kUTTypeURL` was deprecated in macOS 12.0 (#2003) - [Cocoa] Bugfix: `kUTTypeURL` was deprecated in macOS 12.0 (#2003)
- [Cocoa] Bugfix: A connected Apple AirPlay would emit a useless error (#1791) - [Cocoa] Bugfix: A connected Apple AirPlay would emit a useless error (#1791)
- [Cocoa] Bugfix: The EGL and OSMesa libraries were not unloaded on termination
- [X11] Bugfix: The CMake files did not check for the XInput headers (#1480) - [X11] Bugfix: The CMake files did not check for the XInput headers (#1480)
- [X11] Bugfix: Key names were not updated when the keyboard layout changed - [X11] Bugfix: Key names were not updated when the keyboard layout changed
(#1462,#1528) (#1462,#1528)
@ -289,6 +293,8 @@ information on what to include when reporting a bug.
(#379,#1281,#1285,#2033) (#379,#1281,#1285,#2033)
- [X11] Bugfix: Dynamic loading on NetBSD failed due to soname differences - [X11] Bugfix: Dynamic loading on NetBSD failed due to soname differences
- [X11] Bugfix: Left shift of int constant relied on undefined behavior (#1951) - [X11] Bugfix: Left shift of int constant relied on undefined behavior (#1951)
- [X11] Bugfix: The OSMesa libray was not unloaded on termination
- [X11] Bugfix: A malformed response during selection transfer could cause a segfault
- [Wayland] Added dynamic loading of all Wayland libraries - [Wayland] Added dynamic loading of all Wayland libraries
- [Wayland] Added support for key names via xkbcommon - [Wayland] Added support for key names via xkbcommon
- [Wayland] Added support for file path drop events (#2040) - [Wayland] Added support for file path drop events (#2040)
@ -322,6 +328,8 @@ information on what to include when reporting a bug.
- [Wayland] Bugfix: Some errors would cause clipboard string transfer to hang - [Wayland] Bugfix: Some errors would cause clipboard string transfer to hang
- [Wayland] Bugfix: Drag and drop data was misinterpreted as clipboard string - [Wayland] Bugfix: Drag and drop data was misinterpreted as clipboard string
- [Wayland] Bugfix: MIME type matching was not performed for clipboard string - [Wayland] Bugfix: MIME type matching was not performed for clipboard string
- [Wayland] Bugfix: The OSMesa library was not unloaded on termination
- [Wayland] Bugfix: `glfwCreateWindow` could emit `GLFW_FEATURE_UNAVAILABLE`
- [POSIX] Removed use of deprecated function `gettimeofday` - [POSIX] Removed use of deprecated function `gettimeofday`
- [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled - [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled
- [WGL] Disabled the DWM swap interval hack for Windows 8 and later (#1072) - [WGL] Disabled the DWM swap interval hack for Windows 8 and later (#1072)

930
deps/stb_image_write.h vendored

File diff suppressed because it is too large Load Diff

View File

@ -50,11 +50,6 @@ set_target_properties(${GUI_ONLY_BINARIES} ${CONSOLE_BINARIES} PROPERTIES
C_STANDARD 99 C_STANDARD 99
FOLDER "GLFW3/Examples") FOLDER "GLFW3/Examples")
if (GLFW_USE_OSMESA)
find_package(OSMesa REQUIRED)
target_compile_definitions(offscreen PRIVATE USE_NATIVE_OSMESA)
endif()
if (MSVC) if (MSVC)
# Tell MSVC to use main instead of WinMain # Tell MSVC to use main instead of WinMain
set_target_properties(${GUI_ONLY_BINARIES} PROPERTIES set_target_properties(${GUI_ONLY_BINARIES} PROPERTIES

View File

@ -28,11 +28,6 @@
#define GLFW_INCLUDE_NONE #define GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
#if USE_NATIVE_OSMESA
#define GLFW_EXPOSE_NATIVE_OSMESA
#include <GLFW/glfw3native.h>
#endif
#include "linmath.h" #include "linmath.h"
#include <stdlib.h> #include <stdlib.h>
@ -151,12 +146,8 @@ int main(void)
glDrawArrays(GL_TRIANGLES, 0, 3); glDrawArrays(GL_TRIANGLES, 0, 3);
glFinish(); glFinish();
#if USE_NATIVE_OSMESA
glfwGetOSMesaColorBuffer(window, &width, &height, NULL, (void**) &buffer);
#else
buffer = calloc(4, width * height); buffer = calloc(4, width * height);
glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, buffer); glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
#endif
// Write image Y-flipped because OpenGL // Write image Y-flipped because OpenGL
stbi_write_png("offscreen.png", stbi_write_png("offscreen.png",
@ -164,11 +155,7 @@ int main(void)
buffer + (width * 4 * (height - 1)), buffer + (width * 4 * (height - 1)),
-width * 4); -width * 4);
#if USE_NATIVE_OSMESA
// Here is where there's nothing
#else
free(buffer); free(buffer);
#endif
glfwDestroyWindow(window); glfwDestroyWindow(window);

View File

@ -262,13 +262,12 @@ extern "C" {
/* We are building GLFW as a Win32 DLL */ /* We are building GLFW as a Win32 DLL */
#define GLFWAPI __declspec(dllexport) #define GLFWAPI __declspec(dllexport)
#elif defined(_WIN32) && defined(GLFW_DLL) #elif defined(_WIN32) && defined(GLFW_DLL)
/* We are calling GLFW as a Win32 DLL */ /* We are calling a GLFW Win32 DLL */
#define GLFWAPI __declspec(dllimport) #define GLFWAPI __declspec(dllimport)
#elif defined(__GNUC__) && defined(_GLFW_BUILD_DLL) #elif defined(__GNUC__) && defined(_GLFW_BUILD_DLL)
/* We are building GLFW as a shared / dynamic library */ /* We are building GLFW as a Unix shared library */
#define GLFWAPI __attribute__((visibility("default"))) #define GLFWAPI __attribute__((visibility("default")))
#else #else
/* We are building or calling GLFW as a static library */
#define GLFWAPI #define GLFWAPI
#endif #endif
@ -6543,6 +6542,7 @@ GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance, GLFWwindow* window
*/ */
#ifndef GLAPIENTRY #ifndef GLAPIENTRY
#define GLAPIENTRY APIENTRY #define GLAPIENTRY APIENTRY
#define GLFW_GLAPIENTRY_DEFINED
#endif #endif
/* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */ /* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */

View File

@ -116,7 +116,10 @@ extern "C" {
* default it also acts as an OpenGL header * default it also acts as an OpenGL header
* However, glx.h will include gl.h, which will define it unconditionally * However, glx.h will include gl.h, which will define it unconditionally
*/ */
#undef GLAPIENTRY #if defined(GLFW_GLAPIENTRY_DEFINED)
#undef GLAPIENTRY
#undef GLFW_GLAPIENTRY_DEFINED
#endif
#include <GL/glx.h> #include <GL/glx.h>
#endif #endif
#if defined(GLFW_EXPOSE_NATIVE_EGL) #if defined(GLFW_EXPOSE_NATIVE_EGL)
@ -127,7 +130,10 @@ extern "C" {
* default it also acts as an OpenGL header * default it also acts as an OpenGL header
* However, osmesa.h will include gl.h, which will define it unconditionally * However, osmesa.h will include gl.h, which will define it unconditionally
*/ */
#undef GLAPIENTRY #if defined(GLFW_GLAPIENTRY_DEFINED)
#undef GLAPIENTRY
#undef GLFW_GLAPIENTRY_DEFINED
#endif
#include <GL/osmesa.h> #include <GL/osmesa.h>
#endif #endif
@ -486,6 +492,9 @@ GLFWAPI struct wl_surface* glfwGetWaylandWindow(GLFWwindow* window);
* *
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
* *
* @remark Because EGL is initialized on demand, this function will return
* `EGL_NO_DISPLAY` until the first context has been created via EGL.
*
* @thread_safety This function may be called from any thread. Access is not * @thread_safety This function may be called from any thread. Access is not
* synchronized. * synchronized.
* *

View File

@ -677,6 +677,8 @@ void _glfwTerminateCocoa(void)
_glfw_free(_glfw.ns.clipboardString); _glfw_free(_glfw.ns.clipboardString);
_glfwTerminateNSGL(); _glfwTerminateNSGL();
_glfwTerminateEGL();
_glfwTerminateOSMesa();
} // autoreleasepool } // autoreleasepool
} }

View File

@ -931,13 +931,31 @@ int _glfwCreateWindowCocoa(_GLFWwindow* window,
if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig)) if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
return GLFW_FALSE; return GLFW_FALSE;
} }
if (!_glfwRefreshContextAttribs(window, ctxconfig))
return GLFW_FALSE;
} }
if (wndconfig->mousePassthrough)
_glfwSetWindowMousePassthroughCocoa(window, GLFW_TRUE);
if (window->monitor) if (window->monitor)
{ {
_glfwShowWindowCocoa(window); _glfwShowWindowCocoa(window);
_glfwFocusWindowCocoa(window); _glfwFocusWindowCocoa(window);
acquireMonitor(window); acquireMonitor(window);
if (wndconfig->centerCursor)
_glfwCenterCursorInContentArea(window);
}
else
{
if (wndconfig->visible)
{
_glfwShowWindowCocoa(window);
if (wndconfig->focused)
_glfwFocusWindowCocoa(window);
}
} }
return GLFW_TRUE; return GLFW_TRUE;

View File

@ -609,11 +609,12 @@ GLFWbool _glfwStringInExtensionString(const char* string, const char* extensions
GLFWAPI void glfwMakeContextCurrent(GLFWwindow* handle) GLFWAPI void glfwMakeContextCurrent(GLFWwindow* handle)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
_GLFWwindow* previous = _glfwPlatformGetTls(&_glfw.contextSlot); _GLFWwindow* previous;
_GLFW_REQUIRE_INIT(); _GLFW_REQUIRE_INIT();
_glfwPlatformSetTls(&_glfw.usercontextSlot, NULL); _glfwPlatformSetTls(&_glfw.usercontextSlot, NULL);
previous = _glfwPlatformGetTls(&_glfw.contextSlot);
if (window && window->context.client == GLFW_NO_API) if (window && window->context.client == GLFW_NO_API)
{ {

View File

@ -522,6 +522,8 @@ GLFWAPI void glfwSetGammaRamp(GLFWmonitor* handle, const GLFWgammaramp* ramp)
assert(ramp->green != NULL); assert(ramp->green != NULL);
assert(ramp->blue != NULL); assert(ramp->blue != NULL);
_GLFW_REQUIRE_INIT();
if (ramp->size <= 0) if (ramp->size <= 0)
{ {
_glfwInputError(GLFW_INVALID_VALUE, _glfwInputError(GLFW_INVALID_VALUE,
@ -530,8 +532,6 @@ GLFWAPI void glfwSetGammaRamp(GLFWmonitor* handle, const GLFWgammaramp* ramp)
return; return;
} }
_GLFW_REQUIRE_INIT();
if (!monitor->originalRamp.size) if (!monitor->originalRamp.size)
{ {
if (!_glfw.platform.getGammaRamp(monitor, &monitor->originalRamp)) if (!_glfw.platform.getGammaRamp(monitor, &monitor->originalRamp))

View File

@ -128,13 +128,31 @@ int _glfwCreateWindowNull(_GLFWwindow* window,
if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig)) if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
return GLFW_FALSE; return GLFW_FALSE;
} }
if (!_glfwRefreshContextAttribs(window, ctxconfig))
return GLFW_FALSE;
} }
if (wndconfig->mousePassthrough)
_glfwSetWindowMousePassthroughNull(window, GLFW_TRUE);
if (window->monitor) if (window->monitor)
{ {
_glfwShowWindowNull(window); _glfwShowWindowNull(window);
_glfwFocusWindowNull(window); _glfwFocusWindowNull(window);
acquireMonitor(window); acquireMonitor(window);
if (wndconfig->centerCursor)
_glfwCenterCursorInContentArea(window);
}
else
{
if (wndconfig->visible)
{
_glfwShowWindowNull(window);
if (wndconfig->focused)
_glfwFocusWindowNull(window);
}
} }
return GLFW_TRUE; return GLFW_TRUE;

View File

@ -95,30 +95,6 @@
#define GLFW_LINUX_LIBRARY_JOYSTICK_STATE #define GLFW_LINUX_LIBRARY_JOYSTICK_STATE
#endif #endif
#if defined(_WIN32)
#include "win32_thread.h"
#define GLFW_POSIX_TLS_STATE
#define GLFW_POSIX_MUTEX_STATE
#else
#include "posix_thread.h"
#define GLFW_WIN32_TLS_STATE
#define GLFW_WIN32_MUTEX_STATE
#endif
#if defined(_WIN32)
#include "win32_time.h"
#define GLFW_POSIX_LIBRARY_TIMER_STATE
#define GLFW_COCOA_LIBRARY_TIMER_STATE
#elif defined(__APPLE__)
#include "cocoa_time.h"
#define GLFW_WIN32_LIBRARY_TIMER_STATE
#define GLFW_POSIX_LIBRARY_TIMER_STATE
#else
#include "posix_time.h"
#define GLFW_WIN32_LIBRARY_TIMER_STATE
#define GLFW_COCOA_LIBRARY_TIMER_STATE
#endif
#define GLFW_PLATFORM_WINDOW_STATE \ #define GLFW_PLATFORM_WINDOW_STATE \
GLFW_WIN32_WINDOW_STATE \ GLFW_WIN32_WINDOW_STATE \
GLFW_COCOA_WINDOW_STATE \ GLFW_COCOA_WINDOW_STATE \
@ -145,14 +121,6 @@
GLFW_COCOA_JOYSTICK_STATE \ GLFW_COCOA_JOYSTICK_STATE \
GLFW_LINUX_JOYSTICK_STATE GLFW_LINUX_JOYSTICK_STATE
#define GLFW_PLATFORM_TLS_STATE \
GLFW_WIN32_TLS_STATE \
GLFW_POSIX_TLS_STATE \
#define GLFW_PLATFORM_MUTEX_STATE \
GLFW_WIN32_MUTEX_STATE \
GLFW_POSIX_MUTEX_STATE \
#define GLFW_PLATFORM_LIBRARY_WINDOW_STATE \ #define GLFW_PLATFORM_LIBRARY_WINDOW_STATE \
GLFW_WIN32_LIBRARY_WINDOW_STATE \ GLFW_WIN32_LIBRARY_WINDOW_STATE \
GLFW_COCOA_LIBRARY_WINDOW_STATE \ GLFW_COCOA_LIBRARY_WINDOW_STATE \
@ -165,11 +133,6 @@
GLFW_COCOA_LIBRARY_JOYSTICK_STATE \ GLFW_COCOA_LIBRARY_JOYSTICK_STATE \
GLFW_LINUX_LIBRARY_JOYSTICK_STATE GLFW_LINUX_LIBRARY_JOYSTICK_STATE
#define GLFW_PLATFORM_LIBRARY_TIMER_STATE \
GLFW_WIN32_LIBRARY_TIMER_STATE \
GLFW_COCOA_LIBRARY_TIMER_STATE \
GLFW_POSIX_LIBRARY_TIMER_STATE \
#define GLFW_PLATFORM_CONTEXT_STATE \ #define GLFW_PLATFORM_CONTEXT_STATE \
GLFW_WGL_CONTEXT_STATE \ GLFW_WGL_CONTEXT_STATE \
GLFW_NSGL_CONTEXT_STATE \ GLFW_NSGL_CONTEXT_STATE \
@ -184,3 +147,24 @@
GLFW_WGL_USER_CONTEXT_STATE \ GLFW_WGL_USER_CONTEXT_STATE \
GLFW_NSGL_USER_CONTEXT_STATE \ GLFW_NSGL_USER_CONTEXT_STATE \
GLFW_GLX_USER_CONTEXT_STATE GLFW_GLX_USER_CONTEXT_STATE
#if defined(_WIN32)
#include "win32_thread.h"
#define GLFW_PLATFORM_TLS_STATE GLFW_WIN32_TLS_STATE
#define GLFW_PLATFORM_MUTEX_STATE GLFW_WIN32_MUTEX_STATE
#else
#include "posix_thread.h"
#define GLFW_PLATFORM_TLS_STATE GLFW_POSIX_TLS_STATE
#define GLFW_PLATFORM_MUTEX_STATE GLFW_POSIX_MUTEX_STATE
#endif
#if defined(_WIN32)
#include "win32_time.h"
#define GLFW_PLATFORM_LIBRARY_TIMER_STATE GLFW_WIN32_LIBRARY_TIMER_STATE
#elif defined(__APPLE__)
#include "cocoa_time.h"
#define GLFW_PLATFORM_LIBRARY_TIMER_STATE GLFW_COCOA_LIBRARY_TIMER_STATE
#else
#include "posix_time.h"
#define GLFW_PLATFORM_LIBRARY_TIMER_STATE GLFW_POSIX_LIBRARY_TIMER_STATE
#endif

View File

@ -502,6 +502,8 @@ void _glfwUpdateKeyNamesWin32(void)
if (length == -1) if (length == -1)
{ {
// This is a dead key, so we need a second simulated key press
// to make it output its own character (usually a diacritic)
length = ToUnicode(vk, scancode, state, length = ToUnicode(vk, scancode, state,
chars, sizeof(chars) / sizeof(WCHAR), chars, sizeof(chars) / sizeof(WCHAR),
0); 0);
@ -671,6 +673,7 @@ void _glfwTerminateWin32(void)
_glfwTerminateWGL(); _glfwTerminateWGL();
_glfwTerminateEGL(); _glfwTerminateEGL();
_glfwTerminateOSMesa();
freeLibraries(); freeLibraries();
} }

View File

@ -607,7 +607,7 @@ int _glfwPollJoystickWin32(_GLFWjoystick* js, int mode)
{ {
int i, ai = 0, bi = 0, pi = 0; int i, ai = 0, bi = 0, pi = 0;
HRESULT result; HRESULT result;
DIJOYSTATE state; DIJOYSTATE state = {0};
IDirectInputDevice8_Poll(js->win32.device); IDirectInputDevice8_Poll(js->win32.device);
result = IDirectInputDevice8_GetDeviceState(js->win32.device, result = IDirectInputDevice8_GetDeviceState(js->win32.device,

View File

@ -1284,15 +1284,16 @@ static int createNativeWindow(_GLFWwindow* window,
if (window->monitor) if (window->monitor)
{ {
GLFWvidmode mode; MONITORINFO mi = { sizeof(mi) };
GetMonitorInfoW(window->monitor->win32.handle, &mi);
// NOTE: This window placement is temporary and approximate, as the // NOTE: This window placement is temporary and approximate, as the
// correct position and size cannot be known until the monitor // correct position and size cannot be known until the monitor
// video mode has been picked in _glfwSetVideoModeWin32 // video mode has been picked in _glfwSetVideoModeWin32
_glfwGetMonitorPosWin32(window->monitor, &xpos, &ypos); xpos = mi.rcMonitor.left;
_glfwGetVideoModeWin32(window->monitor, &mode); ypos = mi.rcMonitor.top;
fullWidth = mode.width; fullWidth = mi.rcMonitor.right - mi.rcMonitor.left;
fullHeight = mode.height; fullHeight = mi.rcMonitor.bottom - mi.rcMonitor.top;
} }
else else
{ {
@ -1428,7 +1429,7 @@ GLFWbool _glfwRegisterWindowClassWin32(void)
ZeroMemory(&wc, sizeof(wc)); ZeroMemory(&wc, sizeof(wc));
wc.cbSize = sizeof(wc); wc.cbSize = sizeof(wc);
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
wc.lpfnWndProc = (WNDPROC) windowProc; wc.lpfnWndProc = windowProc;
wc.hInstance = _glfw.win32.instance; wc.hInstance = _glfw.win32.instance;
wc.hCursor = LoadCursorW(NULL, IDC_ARROW); wc.hCursor = LoadCursorW(NULL, IDC_ARROW);
wc.lpszClassName = _GLFW_WNDCLASSNAME; wc.lpszClassName = _GLFW_WNDCLASSNAME;
@ -1493,14 +1494,32 @@ int _glfwCreateWindowWin32(_GLFWwindow* window,
if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig)) if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
return GLFW_FALSE; return GLFW_FALSE;
} }
if (!_glfwRefreshContextAttribs(window, ctxconfig))
return GLFW_FALSE;
} }
if (wndconfig->mousePassthrough)
_glfwSetWindowMousePassthroughWin32(window, GLFW_TRUE);
if (window->monitor) if (window->monitor)
{ {
_glfwShowWindowWin32(window); _glfwShowWindowWin32(window);
_glfwFocusWindowWin32(window); _glfwFocusWindowWin32(window);
acquireMonitor(window); acquireMonitor(window);
fitToMonitor(window); fitToMonitor(window);
if (wndconfig->centerCursor)
_glfwCenterCursorInContentArea(window);
}
else
{
if (wndconfig->visible)
{
_glfwShowWindowWin32(window);
if (wndconfig->focused)
_glfwFocusWindowWin32(window);
}
} }
return GLFW_TRUE; return GLFW_TRUE;

View File

@ -215,40 +215,12 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
window->numer = GLFW_DONT_CARE; window->numer = GLFW_DONT_CARE;
window->denom = GLFW_DONT_CARE; window->denom = GLFW_DONT_CARE;
// Open the actual window and create its context
if (!_glfw.platform.createWindow(window, &wndconfig, &ctxconfig, &fbconfig)) if (!_glfw.platform.createWindow(window, &wndconfig, &ctxconfig, &fbconfig))
{ {
glfwDestroyWindow((GLFWwindow*) window); glfwDestroyWindow((GLFWwindow*) window);
return NULL; return NULL;
} }
if (ctxconfig.client != GLFW_NO_API)
{
if (!_glfwRefreshContextAttribs(window, &ctxconfig))
{
glfwDestroyWindow((GLFWwindow*) window);
return NULL;
}
}
if (wndconfig.mousePassthrough)
_glfw.platform.setWindowMousePassthrough(window, GLFW_TRUE);
if (window->monitor)
{
if (wndconfig.centerCursor)
_glfwCenterCursorInContentArea(window);
}
else
{
if (wndconfig.visible)
{
_glfw.platform.showWindow(window);
if (wndconfig.focused)
_glfw.platform.focusWindow(window);
}
}
return (GLFWwindow*) window; return (GLFWwindow*) window;
} }

View File

@ -47,13 +47,38 @@
#include "wayland-pointer-constraints-unstable-v1-client-protocol.h" #include "wayland-pointer-constraints-unstable-v1-client-protocol.h"
#include "wayland-idle-inhibit-unstable-v1-client-protocol.h" #include "wayland-idle-inhibit-unstable-v1-client-protocol.h"
// NOTE: Versions of wayland-scanner prior to 1.17.91 named every global array of
// wl_interface pointers 'types', making it impossible to combine several unmodified
// private-code files into a single compilation unit
// HACK: We override this name with a macro for each file, allowing them to coexist
#define types _glfw_wayland_types
#include "wayland-client-protocol-code.h" #include "wayland-client-protocol-code.h"
#undef types
#define types _glfw_xdg_shell_types
#include "wayland-xdg-shell-client-protocol-code.h" #include "wayland-xdg-shell-client-protocol-code.h"
#undef types
#define types _glfw_xdg_decoration_types
#include "wayland-xdg-decoration-client-protocol-code.h" #include "wayland-xdg-decoration-client-protocol-code.h"
#undef types
#define types _glfw_viewporter_types
#include "wayland-viewporter-client-protocol-code.h" #include "wayland-viewporter-client-protocol-code.h"
#undef types
#define types _glfw_relative_pointer_types
#include "wayland-relative-pointer-unstable-v1-client-protocol-code.h" #include "wayland-relative-pointer-unstable-v1-client-protocol-code.h"
#undef types
#define types _glfw_pointer_constraints_types
#include "wayland-pointer-constraints-unstable-v1-client-protocol-code.h" #include "wayland-pointer-constraints-unstable-v1-client-protocol-code.h"
#undef types
#define types _glfw_idle_inhibit_types
#include "wayland-idle-inhibit-unstable-v1-client-protocol-code.h" #include "wayland-idle-inhibit-unstable-v1-client-protocol-code.h"
#undef types
static void wmBaseHandlePing(void* userData, static void wmBaseHandlePing(void* userData,
struct xdg_wm_base* wmBase, struct xdg_wm_base* wmBase,
@ -664,6 +689,8 @@ int _glfwInitWayland(void)
void _glfwTerminateWayland(void) void _glfwTerminateWayland(void)
{ {
_glfwTerminateEGL(); _glfwTerminateEGL();
_glfwTerminateOSMesa();
if (_glfw.wl.egl.handle) if (_glfw.wl.egl.handle)
{ {
_glfwPlatformFreeModule(_glfw.wl.egl.handle); _glfwPlatformFreeModule(_glfw.wl.egl.handle);

View File

@ -1730,8 +1730,14 @@ int _glfwCreateWindowWayland(_GLFWwindow* window,
if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig)) if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
return GLFW_FALSE; return GLFW_FALSE;
} }
if (!_glfwRefreshContextAttribs(window, ctxconfig))
return GLFW_FALSE;
} }
if (wndconfig->mousePassthrough)
_glfwSetWindowMousePassthroughWayland(window, GLFW_TRUE);
return GLFW_TRUE; return GLFW_TRUE;
} }

View File

@ -1631,6 +1631,7 @@ void _glfwTerminateX11(void)
_glfw.x11.xi.handle = NULL; _glfw.x11.xi.handle = NULL;
} }
_glfwTerminateOSMesa();
// NOTE: These need to be unloaded after XCloseDisplay, as they register // NOTE: These need to be unloaded after XCloseDisplay, as they register
// cleanup callbacks that get called by that function // cleanup callbacks that get called by that function
_glfwTerminateEGL(); _glfwTerminateEGL();

View File

@ -865,20 +865,6 @@ static Atom writeTargetToProperty(const XSelectionRequestEvent* request)
return None; return None;
} }
static void handleSelectionClear(XEvent* event)
{
if (event->xselectionclear.selection == _glfw.x11.PRIMARY)
{
_glfw_free(_glfw.x11.primarySelectionString);
_glfw.x11.primarySelectionString = NULL;
}
else
{
_glfw_free(_glfw.x11.clipboardString);
_glfw.x11.clipboardString = NULL;
}
}
static void handleSelectionRequest(XEvent* event) static void handleSelectionRequest(XEvent* event)
{ {
const XSelectionRequestEvent* request = &event->xselectionrequest; const XSelectionRequestEvent* request = &event->xselectionrequest;
@ -999,13 +985,16 @@ static const char* getSelectionString(Atom selection)
if (!itemCount) if (!itemCount)
{ {
if (targets[i] == XA_STRING) if (string)
{ {
*selectionString = convertLatin1toUTF8(string); if (targets[i] == XA_STRING)
_glfw_free(string); {
*selectionString = convertLatin1toUTF8(string);
_glfw_free(string);
}
else
*selectionString = string;
} }
else
*selectionString = string;
break; break;
} }
@ -1171,12 +1160,7 @@ static void processEvent(XEvent *event)
return; return;
} }
if (event->type == SelectionClear) if (event->type == SelectionRequest)
{
handleSelectionClear(event);
return;
}
else if (event->type == SelectionRequest)
{ {
handleSelectionRequest(event); handleSelectionRequest(event);
return; return;
@ -1853,10 +1837,6 @@ void _glfwPushSelectionToManagerX11(void)
handleSelectionRequest(&event); handleSelectionRequest(&event);
break; break;
case SelectionClear:
handleSelectionClear(&event);
break;
case SelectionNotify: case SelectionNotify:
{ {
if (event.xselection.target == _glfw.x11.SAVE_TARGETS) if (event.xselection.target == _glfw.x11.SAVE_TARGETS)
@ -1972,13 +1952,31 @@ int _glfwCreateWindowX11(_GLFWwindow* window,
if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig)) if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
return GLFW_FALSE; return GLFW_FALSE;
} }
if (!_glfwRefreshContextAttribs(window, ctxconfig))
return GLFW_FALSE;
} }
if (wndconfig->mousePassthrough)
_glfwSetWindowMousePassthroughX11(window, GLFW_TRUE);
if (window->monitor) if (window->monitor)
{ {
_glfwShowWindowX11(window); _glfwShowWindowX11(window);
updateWindowMode(window); updateWindowMode(window);
acquireMonitor(window); acquireMonitor(window);
if (wndconfig->centerCursor)
_glfwCenterCursorInContentArea(window);
}
else
{
if (wndconfig->visible)
{
_glfwShowWindowX11(window);
if (wndconfig->focused)
_glfwFocusWindowX11(window);
}
} }
XFlush(_glfw.x11.display); XFlush(_glfw.x11.display);