Commit Graph

4407 Commits

Author SHA1 Message Date
Camilla Löwy
18d7c241f8 Add credits and update changelog
(cherry picked from commit e40fa3bb94)
2021-12-08 20:02:50 +01:00
Stephen Gutekanst
6281424988 X11: Fix undefined behavior in glfwSetWindowIcon
The conversion of window icon image data involves unsigned char color
values being promoted to int and then shifted to the left by 24.  For
32-bit ints this is just far enough to trigger undefined behavior.

It worked by accident because of how current compilers translate this
piece of code.

This was caught by @slimsag while working on [Zig bindings for GLFW][1],
and diagnosed together with @Andoryuuta, as described [in an
article][2].  Zig has UBSan enabled by default, which caught this
undefined behavior.

[1]: https://github.com/hexops/mach-glfw
[2]: https://devlog.hexops.com/2021/perfecting-glfw-for-zig-and-finding-undefined-behavior#finding-lurking-undefined-behavior-in-6-year-old-glfw-code

Thanks to Maato, martinhath, dcousens, drfuchs and Validark for helping
to refine the solution.

This commit message was rewritten by @elmindreda to hopefully reflect
the conclusions of the pull request thread.

Related to hexops/mach#20
Closes #1986

(cherry picked from commit 9cd4d2fa20)
2021-12-08 19:58:12 +01:00
Stephen Gutekanst
81d762bf66 Fix docs calling GLFW_CONTEXT_REVISION a hint
This docstring previously indicated that GLFW_CONTEXT_REVISION was
a window hint and attribute, but in fact it is only a window attribute
(there is no code which uses this constant in any other context.)

We noticed this in https://github.com/hexops/mach/pull/71/files#r749741814

Closes #1992

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
(cherry picked from commit 37fc28bff6)
2021-11-30 19:04:56 +01:00
Camilla Löwy
486724c433 Update comments for global mutable data
(cherry picked from commit b3a98f8555)
2021-11-30 19:04:38 +01:00
luz paz
55528e9178 Fix source comment typo
Closes #1982

(cherry picked from commit eacc1cafba)
2021-11-30 19:04:14 +01:00
Camilla Löwy
689840f2eb Add credit
Related to #1998

(cherry picked from commit a30cd6acef)
2021-11-30 19:04:04 +01:00
InKryption
c59092619a Add missing error to glfwGetClipboardString docs
Add GLFW_FORMAT_UNAVAILABLE to the list of possible errors in the
reference documentation for glfwGetClipboardString.

Slightly edited by @elmindreda.

Closes #1998

(cherry picked from commit bb193325cc)
2021-11-30 19:03:59 +01:00
Camilla Löwy
bfd9eaf092 Fix mappings for gamepads present at init
Joysticks already connected when GLFW was initalized did not get gamepad
mappings applied to them.

Regression introduced by 74a8ba26c3.

This change was backported without taking into account that 3.3.x does
not have on-demand joystick init.

Fixes #1996
2021-11-24 23:09:24 +01:00
Camilla Löwy
6902435005 Update changelog 2021-11-24 23:08:49 +01:00
Camilla Löwy
6eb24a49df Add credit
Related to #1994

(cherry picked from commit b55a517ae0)
2021-11-24 23:02:05 +01:00
Jan Ekström
bec6e7565b Cocoa: Use MACH_PORT_NULL for default IOKit port
Looking into the definition of kIOMainPortDefault, the following
description can be found:

When specifying a main port to IOKit functions, the NULL argument
indicates "use the default". This is a synonym for NULL, if you'd
rather use a named constant.

Thus, we do not have to utilize an external symbol for the identifier
of the default main IOKit port, but MACH_PORT_NULL suffice. This
simplifies compatibility between macOS versions as the symbol was
renamed with macOS 12.0.

Fixes #1985
Closes #1994

(cherry picked from commit 544790666b)
2021-11-24 23:01:46 +01:00
Camilla Löwy
19543afbfb Start 3.3.6 2021-10-28 22:16:41 +02:00
Camilla Löwy
d3b73abba0 Add missing changelog entries
(cherry picked from commit fb0f2f92a3)
2021-10-28 13:24:20 +02:00
Camilla Löwy
fbdb08c43e Fix some spelling errors in changelog
(cherry picked from commit 83d3fb08ec)
2021-10-28 13:18:38 +02:00
Camilla Löwy
71316f843c Update changelog and add credit
Related to #1980

(cherry picked from commit 999962bd2f)
2021-10-28 12:40:42 +02:00
Josh Codd
472d45c07b Cocoa: Fix deprecation of kIOMasterPortDefault
This adds a workaround for kIOMasterPortDefault having been deprecated
in favor of kIOMainPortDefault in macOS 12.0.

Closes #1980

(cherry picked from commit f75c251dec)
2021-10-28 12:39:39 +02:00
Camilla Löwy
85f37ada6d Move list of contributors to separate file
Fixes #1839

(cherry picked from commit 53d7622a3a)
2021-10-28 12:33:40 +02:00
Camilla Löwy
b77a9b1d0d Fix GLFW_INCLUDE_GLEXT being ignored for glcorearb
The GLFW_INCLUDE_GLCOREARB branch was left out when GLFW_INCLUDE_GLEXT
was originally added, for reasons that are lost to history.  The current
versions of these headers seem to co-exist just fine.

Issue reported on IRC.

(cherry picked from commit 309d79376f)
2021-10-28 12:31:02 +02:00
Ioannis Tsakpinis
db85858062 Fix context API checks in native access functions
(cherry picked from commit 727db55c3a)
2021-10-28 12:29:57 +02:00
Camilla Löwy
ca676357c0 Win32: Remove timeGetTime fallback for timer
The performance counter API is guaranteed to succeed on Windows XP and
later so there is no need for a fallback.

This removes our last dependency on winmm.

(cherry picked from commit b6834bf2a1)
2021-10-28 12:24:38 +02:00
Camilla Löwy
4ea7485fbe Remove blank line before the end of some structs
(cherry picked from commit efe764b492)
2021-10-28 12:14:58 +02:00
Camilla Löwy
73b6754a67 Document possible native access function errors
(cherry picked from commit 983c44b255)
2021-10-28 12:13:36 +02:00
Camilla Löwy
2d3ce6eaae Make native access functions verify context API
The native access functions for context handles did not verify that the
context had been created with the same API the function was for.

This makes these functions emit GLFW_NO_WINDOW_CONTEXT on API mismatch.

(cherry picked from commit cca9008db2)
2021-10-28 12:13:19 +02:00
Camilla Löwy
cec0b33ee1 Remove Doxyfile tags obsoleted by Doxygen 1.9.2
Fixes #1932
2021-10-17 20:34:05 +02:00
Camilla Löwy
9400bc9f35 Remove potentially incorrect claim
(cherry picked from commit 4be0444ee6)
2021-10-13 23:11:53 +02:00
Camilla Löwy
1a7e4da343 Fix docs for Windows monitor size calculation
This sentence was truncated by 951a9583fa
and then not updated when content scale support was added with
16bf872117.

(cherry picked from commit 6a20053102)
2021-10-13 23:11:48 +02:00
Camilla Löwy
95df61e5ed Cocoa: Fix unresponsive cursor after cursor warp
This is a companion to 157ebb80aa and
fixes the same issue for calls to glfwSetCursorPos.

Related to #1962

(cherry picked from commit 6ed5294223)
2021-10-13 23:11:00 +02:00
Ioannis Tsakpinis
c32fefc6a0 Cocoa: Fix unresponsive cursor after ungrab
There is a suppression interval (0.25 seconds by default) after a call
to CGWarpMouseCursorPosition, during which local hardware events
(keyboard and mouse) are ignored. GLFW already calls
CGEventSourceSetLocalEventsSuppressionInterval with a value of 0.0, but
it doesn't help in this case, there is still a short delay before the
cursor can be moved. Moving the CGAssociateMouseAndMouseCursorPosition
call after the cursor position has been restored, fixes the issue.

Closes #1962

(cherry picked from commit 157ebb80aa)
2021-10-13 23:10:15 +02:00
Waris Boonyasiriwat
6bb5f5d59d Wayland: Fix cursor offset when shape changes
The Wayland protocol spec[1] states that set_cursor must be called
with the serial number of the enter event.  However, GLFW is passing in
the serial number of the latest received event, which does not meet the
protocol spec.

[1] https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_pointer

As a result, set_cursor calls were simply ignored by the compositor.

This fix complies with the protocol more closely by specifically caching
the enter event serial, and using it for all set_cursor calls.

Fixes #1706
Closes #1899

(cherry picked from commit e7758c506d)
2021-10-13 23:06:40 +02:00
Koray Kilinc
33ff23dc07 Wayland: Fix some keys not repeating
According to the libxkbcommon documentation[1], xkb_keymap_key_repeats
requires keymap and keycode as input:

int xkb_keymap_key_repeats( struct xkb_keymap * keymap,
			    xkb_keycode_t key)

However, in inputChar in wl_input.c we are passing in xkb_keysym_t,
which was a type mismatch.

This results in some keys not repeating when they should and vice versa.

[1] https://xkbcommon.org/doc/current/group__components.html#ga9d7f998efeca98b3afc7c257bbac90a8

Closes #1908.

(cherry picked from commit 216d5e8402)
2021-09-01 19:47:59 +02:00
Camilla Löwy
cf70b10692 Remove truism from end of gamepad mapping regexp
The rest of the line is guaranteed to either contain or not contain
characters.

(cherry picked from commit 7c25dff002)
2021-08-27 17:22:05 +02:00
Camilla Löwy
0a3fb9940f Simplify CMake if-statement variable references
Variables in CMake if-statements (and only in if-statements) do not need
to be explicitly dereferenced; a thing I did not always know.

(cherry picked from commit daed5edd6e)
2021-08-27 17:22:01 +02:00
Camilla Löwy
c113c59926 Raise maximum known CMake version to 3.20
This has seemed to work well on all platforms for a while.

(cherry picked from commit d7b7c3b12a)
2021-08-27 17:21:27 +02:00
Camilla Löwy
ffe0795e64 Name parameters for callback function types
Started adding these because of Doxygen warnings but it should have been
done regardless.

(cherry picked from commit 4e557437f2)
2021-08-27 17:20:08 +02:00
Richard Boldiš
1d7339f3fc Win32: Fix invalid preprocessor command 'warning'
The GCCism #warning had snuck into the Win32 platform code.

Merges #1953.

(cherry picked from commit 2ac7e20aaf)
2021-08-27 17:20:00 +02:00
Camilla Löwy
50b09938e7 X11: Fix function returning before cleanup
The _glfwPlatformSetWindowFloating function would return without freeing
the state array if the window was already in the requested state.

(cherry picked from commit 071d7c0f46)
2021-08-27 17:19:46 +02:00
Camilla Löwy
123643df2d Remove unneccessary quotes in CMake conditions
(cherry picked from commit 87d5646f5d)
2021-08-27 17:16:56 +02:00
Camilla Löwy
ab5f006cff Update comment for msvcrt CMake option
(cherry picked from commit 9a0e88a016)
2021-08-27 17:14:15 +02:00
Camilla Löwy
74a8ba26c3 Simplify parsing of default gamepad mappings
The outer glfwUpdateGamepadMappings function is now bypassed when
parsing the default gamepad mappings.  The data in mappings.h does not
contain any comments or line breaks.  Also this is done before joystick
support has been initialized, so there is no need to look for matching
devices.

Finally, the array of default mappings is pre-allocated.  This has no
measurable performance impact but does generate a lot of calls, which
won't be nice for a user provided custom allocator to deal with.

(cherry picked from commit 201400b974)
2021-08-27 17:13:12 +02:00
Camilla Löwy
929286ca47 Update gamepad mappings from upstream
(cherry picked from commit afa78b4270)
2021-08-27 17:13:01 +02:00
Camilla Löwy
d3317b4937 Add gamepad mapping filtering by backend
This fixes gamepad mappings being included in GLFW binaries that would
then never use them because they were for a different platform.

(cherry picked from commit 0c90e1a33f)
2021-08-03 16:01:03 +02:00
Camilla Löwy
b3b82cdd78 Add custom target for updating gamepad mappings
(cherry picked from commit 01778329ec)
2021-08-03 16:00:30 +02:00
Camilla Löwy
20a7962a9b Improve error description for invalid scancodes
(cherry picked from commit 56092814f3)
2021-08-03 15:59:59 +02:00
Camilla Löwy
44ad296813 Expand list of distro derivatives slightly
(cherry picked from commit 3dc7349c35)
2021-08-03 15:59:24 +02:00
Camilla Löwy
1b0eac9c58 Add Fedora package names to compilation guide
(cherry picked from commit 9e1ee3f263)
2021-08-03 15:46:11 +02:00
Camilla Löwy
65c36563f6 Update changelog
Related to #1840.

(cherry picked from commit ab34cc51c6)
2021-08-03 15:43:49 +02:00
Stephen Gowen
1e98fc325d Cocoa: Fix macro redefinition warning
This avoids generating a macro redefinition warning when the
GL_SILENCE_DEPRECATION macro has been defined for the whole of a larger
project.

Closes #1840.

(cherry picked from commit 1d88a2e3d6)
2021-08-03 15:43:16 +02:00
Camilla Löwy
545b6c7970 Cocoa: Fix MoltenVK layer scale out of sync
The contents scale of the hosted CAMetalLayer created for MoltenVK was
updated only after the GLFW content scale and framebuffer size events
were emitted, causing the layer to get out of sync with the monitor the
window was on.

(cherry picked from commit 076bfd55be)
2021-08-03 15:43:03 +02:00
Camilla Löwy
a7202e2341 Cocoa: Remove calls to -update on nil
These calls have no effect unless the context was created with NSGL.

(cherry picked from commit 836e709503)
2021-08-03 15:41:57 +02:00
Camilla Löwy
9a5511b311 Improve library compilation guide somewhat
Related to #1931.

(cherry picked from commit 3b95970482)
2021-08-03 14:31:31 +02:00