Commit Graph

2870 Commits

Author SHA1 Message Date
Camilla Löwy
7b60753aeb Cocoa: Fix segfault querying joystick elements
It is reportedly possible for IOHIDDeviceCopyMatchingElements to return
NULL on macOS 13 if the application lacks input monitoring permissions.

This commit only prevents the segfault.  More work will be needed to
correctly handle this situation, including Game Controller support.

Related to #2320
Closes #2321

(cherry picked from commit 2c1d31009f)
2023-12-12 18:48:53 +01:00
lo-v-ol
217c269d66 EGL: Fix GLFW_CONTEXT_NO_ERROR on Mesa
Mesa EGL requires the context version to be set to 2.0 or greater before
EGL_CONTEXT_OPENGL_NO_ERROR_KHR in the attribute list.

Without this, context creation via Mesa EGL with
EGL_CONTEXT_OPENGL_NO_ERROR_KHR set fails with EGL_BAD_ATTRIBUTE.

Fixes #2348

(cherry picked from commit eeeb56eb23)
2023-12-12 16:04:57 +01:00
FuzzyQuills
7cdd41170b Cocoa: No NSWindowStyleMaskResizable in fullscreen
On macOS 10.15 Catalina and earlier, not having the resizable bit
cleared in NSWindowStyleMask in fullscreen leads to windows minimising
when clicked anywhere in the content area.

On all tested macOS versions it also causes the fullscreen window to be
resizable by the user.

Regression introduced by 0d599026d0.

Fixes #2377
Closes #2405

(cherry picked from commit 8e9a5d29a8)
2023-12-12 15:58:33 +01:00
Camilla Löwy
e0de6ea513 EGL: Only use EGL_EXT_present_opaque on Wayland
The EGL_EXT_present_opaque extension is primarily a workaround meant for
Wayland, even if the language in it doesn't mention this.  GLFW
previously always enabled this extension where supported.  This caused
issues on X11 when running the Nvidia binary blob.

This commit ensures the extension is only enabled on Wayland.

Fixes #2365

This was adapted to 3.3-stable from
46cebb5081.
2023-12-07 18:04:48 +01:00
Camilla Löwy
63bba49e31 Cocoa: Fix compilation error on OS X 10.8
The occlusion state parts of NSWindow are OS X 10.9+ only but we still
(technically) support building for only 10.8.

Fixes #2161

(cherry picked from commit 5e4496cb42)
2023-12-07 18:04:48 +01:00
Peter Johnson
80d45cdfd7 Win32: Fix invalid hat bit mask being accepted
It is reportedly possible to get opposing directions of an XInput DPad
bit mask set simultaneously with some controllers.

This commit ensures that those values are not passed on to other parts
of GLFW.

This commit is based on the PR #2291 by @ PeterJohnson but with the
following changes:
 - moved XInput-specific special case to XInput implementation
 - attempt to preserve data by only masking out the invalid axis
 - admin (credit, changelog, commit message)

Closes #2291

(cherry picked from commit 52405a9d59)
2023-12-07 18:04:48 +01:00
Camilla Löwy
5f936a6276 Fix glfwGetKeyName not checking key token is valid
(cherry picked from commit b1517e5b3e)
2023-12-07 18:04:48 +01:00
Camilla Löwy
c98860db9e Add assertions for context function invariants
Related to #2327

(cherry picked from commit 93d70cb6a8)
2023-12-07 18:04:48 +01:00
Camilla Löwy
cb0dafa7c0 Fix potential violation of invariant
The shared function for reading back context attributes,
_glfwRefreshContextAttribs, did not check whether the newly created
context had been successfully made current.  This violated the invariant
that the context TLS slot always points to a valid window and that its
context is current whenever _glfw.platform.getProcAddress is called.

Related to #2327

This was adapted to 3.3-stable from
fa0ea5c41f and
ddd92a4fa8.
2023-12-07 18:04:08 +01:00
Camilla Löwy
11f517e557 Fix return value on error for glfwGetKeyScancode
The documentation says it should be -1, not zero.

(cherry picked from commit 8c5471d6cd)
2023-12-07 17:33:52 +01:00
Camilla Löwy
31f08cc7fc Wayland: Fix heuristics for what counts as events
The Wayland implementation of glfwWaitEvents* keeps waiting until it
sees evidence that a significant event has been processed.  However,
this included updating an animated cursor (not a significant event)
but did not include previously buffered Wayland events or libdecor
events (definitely significant events).

This commit corrects these cases.

(cherry picked from commit d097e35743)
2023-11-30 21:34:16 +01:00
Camilla Löwy
9809035ed2 Wayland: Fix protocol error on undecorated window
When setting the visibility of a libdecor frame on a compositor that
supports XDG decorations, libdecor 0.1 will update the geometry of the
XDG surface.  GLFW attempted to set the visibility before having told
libdecor what size the content area is.  This caused a Wayland protocol
error when libdecor attempted to set the window size to 0x0.

This commit adds setting the content area size for the libdecor frame
directly after creation, allowing libdecor to know what it's doing.

(cherry picked from commit 23e40548b1)
2023-11-30 21:34:06 +01:00
Camilla Löwy
7cc8879ab9 Wayland: Use Wayland to wait for libdecor to init
Much of libdecor is initialized only after certain events have been
received from the compositor and some parts of libdecor 0.1 are unsafe
to use until this delayed initialization has completed.

Since libdecor does not provide an API to query if or be notified when
this has happened, GLFW processed events until its newly created
libdecor frame had created its XDG shell objects.

This commit switches to using a generic Wayland sync point created just
after libdecor (and presumably its plugin) has set up its delayed
initialization, instead of relying on the more specific implementation
detail mentioned above.

It also makes this wait mandatory before the first libdecor frame is
created instead of a pre-condition for certain libdecor frame calls,
hopefully removing even more dependence on implementation details.

(cherry picked from commit 9fdc425931)
2023-11-30 21:31:58 +01:00
Camilla Löwy
2c09407bff Cleanup
(cherry picked from commit 2a4dd9c28f)
2023-11-28 22:17:40 +01:00
Michael Skec
7c7cc59889 Linux: Fix memory leak when inotify init failed
This introduces regex_compiled boolean to track whether the regex is
compiled successfully.

Closes #2229

(cherry picked from commit c992226a9c)
2023-11-28 22:16:53 +01:00
Camilla Löwy
89bea58b18 Win32: Fix glfwWaitEventsTimeout ignoring messages
The bitmask passed to MsgWaitForMultipleObjects was missing
QS_SENDMESSAGE, causing glfwWaitEventsTimeout not to return when the
thread received messages sent from other threads.

Fixes #2408

(cherry picked from commit 509f4131be)
2023-11-28 22:15:23 +01:00
moritz-h
c754de5deb Win32: Add library name suffix to pkg-config file
Closes #2386

This was adapted to 3.3-stable from
93a3ba8080.
2023-11-27 17:01:35 +01:00
Andy Williams
bf429fb628 Fix macOS Print Screen
Many years ago this value was changed from F13 to Print Screen with
1ae9ce1e0a.  However, this was later
reverted to F13 with 5759d0fdf2.

This changes it back to Print Screen for consistency with other
platforms.

Closes #1786
Fixes #2169

(cherry picked from commit c940695eb0)
2023-11-16 22:50:41 +01:00
Camilla Löwy
8da6223c90 Wayland: Cleanup
Update naming and declarations to current standard.

(cherry picked from commit 3eaf1255b2)
2023-07-19 17:51:56 +02:00
Camilla Löwy
c3f15da23a Wayland: Merge function called once
This brings together the two halves of the cursor setting logic for the
fallback decorations.

(cherry picked from commit 6b48f2be97)
2023-07-19 17:51:53 +02:00
Camilla Löwy
1d766c8b39 Wayland: Fix fallback decorations emitting errors
A GLFW_CURSOR_UNAVAILABLE error would be emitted each time the cursor
moved over the fallback decorations if the standard cursor shape
appropriate for that part was missing on the system.

These errors served no useful purpose and have been removed.

(cherry picked from commit 00a663dafd)
2023-07-19 17:50:49 +02:00
TheBrokenRail
67d722788d Wayland: Fix detection of joysticks after init
Closes #2198

This was adapted to 3.3-stable from
0b94e1b29b and
3fa2360720.
2023-07-19 17:48:46 +02:00
Camilla Löwy
0c2db4a23e Wayland: Add initial support for libdecor
This is partly based on the implementation of libdecor support in
PR #1693 by @ christianrauch.

Where available, the libdecor library is loaded at init and becomes the
preferred method for window decorations.  On compositors that support
XDG decorations, libdecor in turn uses those.  If not, libdecor has
a plug-in archtecture and may load additional libraries to either use
compositor-specific decorations or draw its own.

If necessary, support for libdecor can be disabled with the
GLFW_WAYLAND_LIBDECOR init hint.  This is mostly in case some part of
the dynamic loading or duplication of header material added here turns
out to cause problems with future versions of libdecor-0.so.0.

Fixes #1639
Closes #1693
Related to #1725

This was adapted to 3.3-stable from
fbdb53b9ca.
2023-07-19 17:23:25 +02:00
Camilla Löwy
1ad5df8032 Wayland: Simplify decoration side detection
This commit simplifies the detection of which element of a fallback
decorated window the pointer has entered.  Instead of looping through
the list of windows, the user pointer of fallback decoration surfaces is
set to the GLFW window object.

(cherry picked from commit cd466cf9fd)
2023-03-28 17:46:41 +02:00
Camilla Löwy
95b35c43c2 Wayland: Clean up enum value names
(cherry picked from commit 39f0e86228)
2023-03-28 17:44:56 +02:00
Camilla Löwy
e5d19c9fac Wayland: Simplify per-window ouput scales tracking
This replaces (one case of) manual management of weak links between
windows and monitors, both objects with complex life times, with
wl_object pointers used as opaque key values.

(cherry picked from commit efa9297a41)
2023-03-28 17:43:39 +02:00
Camilla Löwy
5ac970120a Wayland: Use tags to verify proxy ownership
This is in preparation for adding support for libdecor, which creates
its own proxies on our display.  It will likely also be helpful to some
people using native access on Wayland.

This is partly based on the implementation of libdecor support in
PR #1693 by @ christianrauch.

(cherry picked from commit 91c837ace5)
2023-03-28 17:38:33 +02:00
Camilla Löwy
677fbb0f82 Wayland: Remove duplicate setting of user data
The surface user data is already set by wl_surface_add_listener.

(cherry picked from commit 6d9083af03)
2023-03-28 17:36:29 +02:00
Camilla Löwy
a29b5f38c6 Wayland: Stop manually tracking interface versions
This is already tracked by the proxies we care about.

(cherry picked from commit 4cf510511c)
2023-03-28 17:36:22 +02:00
Camilla Löwy
1de73c0dc5 Wayland: Emit size event when setting aspect ratio
(cherry picked from commit c1a79c1c41)
2023-03-28 17:36:18 +02:00
Camilla Löwy
a6e3efbafc Wayland: Fix some missing window refresh events
(cherry picked from commit 8397b39afa)
2023-03-28 17:36:13 +02:00
Camilla Löwy
ba99e20f6a Wayland: Fix decorations not always being created
If a window was initially fullscreen then it would not get an XDG
decoration object.  If the window was later switched to windowed mode it
would then get fallback decorations instead of XDG ones.

(cherry picked from commit 735fc101f5)
2023-03-28 17:36:09 +02:00
Camilla Löwy
8522447792 Wayland: Simplify test for fallback decorations
The GLFW fallback decorations only exist when the window is visible,
decorated and in windowed mode.

(cherry picked from commit 228428fa4f)
2023-03-28 17:36:05 +02:00
Camilla Löwy
ba80e23dab Wayland: Pick more plausible default cursor size
This is not intended as a replacement for actually querying the desktop
for the correct size, but it appears to be a better fallback value.

(cherry picked from commit 82e77dbff4)
2023-03-28 17:36:01 +02:00
Takuro Ashie
b06a91e92b Wayland: Fix wrong array size for _GLFWofferWayland
Closes #2225

(cherry picked from commit 41d8da1cea)
2023-01-07 23:13:16 +01:00
Camilla Löwy
d36d062d72 Win32: Remove unhelpful helper function
(cherry picked from commit ab3ea8ac9f)
2022-10-31 22:13:01 +01:00
Camilla Löwy
493df4a0b5 EGL: Cleanup
Both config parameters are "desired", but one is older and never had its
name updated.

This commit at least makes it clearer that they are similar.

(cherry picked from commit ab1b1edfd0)
2022-10-31 22:05:22 +01:00
Camilla Löwy
31b038663a EGL: Add better error for no stereo
(cherry picked from commit 93e93135f2)
2022-10-31 22:04:00 +01:00
Camilla Löwy
6fb86c089e EGL: Add better errors for client API mismatch
Because EGL ties client API support to configs, attempts to create
a context with an unavailable client API will fail with the unhelpful
"failed to find suitable config" error description.

This attempts to detect cases where there are usable configs for the
other client API and emit a hopefully more helpful error.

Related to #2173

(cherry picked from commit e057666642)
2022-10-31 22:03:56 +01:00
Camilla Löwy
bc36010350 Check if context creation APIs match when sharing
(cherry picked from commit 6b57e08bb0)
2022-10-31 22:03:47 +01:00
Camilla Löwy
bd13f55ca8 WGL: Fix count of displayable pixel formats
We only care about displayable pixel formats (as defined in
WGL_ARB_pixel_format) for window context creation.

This changes pixel format enumeration to ignore non-displayable formats,
which are specified to be listed after displayable ones, by always using
the return value of DescribePixelFormat as the pixel format count.

(cherry picked from commit 2c0f34b60f)
2022-10-31 22:03:35 +01:00
Camilla Löwy
8b4f1ebbea Wayland: Fix window opacity on older systems
On systems lacking the EGL_EXT_present_opaque extension, some
compositors treat any buffer with an alpha channel as per-pixel
transparent.

This commit ignores any EGLConfig with an alpha channel if the extension
is missing and the window is created with GLFW_TRANSPARENT_FRAMEBUFFER
set to false.

This is technically not a breaking change since GLFW_ALPHA_BITS is not
a hard constraint, but it is still going to inconvenience anyone using
the framebuffer alpa channel to store other kinds of data.

Related to #1895

(cherry picked from commit ef6c9d8b4f)
2022-10-31 22:02:06 +01:00
Camilla Löwy
1f675ab62f GLX: Add support for loading glvnd libGLX
(cherry picked from commit c18851f52e)
2022-10-31 21:57:21 +01:00
Camilla Löwy
ed55529ce8 EGL: Add support for loading glvnd libOpenGL
(cherry picked from commit 55aad3c37b)
2022-10-31 21:48:45 +01:00
Camilla Löwy
426c6ed6b1 X11: Preserve unrelated values in WM_NORMAL_HINTS
This stops GLFW overwriting the whole WM_NORMAL_HINTS property every
time it updates size-related parts of it.

(cherry picked from commit 7d73629e50)
2022-10-31 21:48:04 +01:00
Camilla Löwy
3670cd0561 Wayland: Remove unreachable code
This platform function is only called if the cursor is enabled.

(cherry picked from commit 3a5c726d1b)
2022-10-31 21:34:38 +01:00
Camilla Löwy
0ee9b7281b Wayland: Clean up pointer helper function order
(cherry picked from commit 7be6a2cabe)
2022-10-31 21:34:33 +01:00
Camilla Löwy
5f3e5542cf Refactor cursor mode paths
This is the refactoring part of adding GLFW_CURSOR_CAPTURED, separated
out to help keep 3.3-stable similar to the main branch.

Related to #58.

(cherry picked from commit a46f829de8)
2022-10-31 21:29:42 +01:00
Camilla Löwy
632d35e0d4 Wayland: Fix leaks of pointer related objects
(cherry picked from commit 03af6b3d4c)
2022-10-31 21:19:15 +01:00
Camilla Löwy
5189d52ae3 Wayland: Clean up pointer locking
Shorten names and allow C99 declarations.  Replace helper function with
the NULL check it was hiding.  Separate cursor hiding from pointer
locking.

(cherry picked from commit e85b645b8a)
2022-10-31 21:18:12 +01:00