Commit Graph

680 Commits

Author SHA1 Message Date
Camilla Löwy
5ccc756c56 X11: Fix empty event race condition with a pipe
There is a seemingly unavoidable race condition when waiting for data on
the X11 display connection, as long as any other thread is also making
Xlib calls.  The event data we are waiting for could be read by the
other thread as part of looking for the reply to its request, before our
poll has begun.

This commit replaces the X11 event sent by glfwPostEmptyEvent with
writing to an unnamed pipe.  The race condition remains if other Xlib
calls are made on other threads, but glfwPostEmptyEvent should now be
race-free.

This commit is based on work by pcwalton, OlivierSohn, kovidgoyal and
joaodasilva.

Closes #2033
Related to #379
Related to #1281
Related to #1285

(cherry picked from commit cd22e28495)
2022-03-13 16:17:25 +01:00
Camilla Löwy
7f752c17c6 X11: Fix glfwWaitEvents* ignoring joystick events
The data available on the X11 connection may be a reply or an internal
event for an X11 extension.  Previously the check for whether an event
was available for us was done outside waitForEvent.  This prevented data
available on other file descriptors from breaking the outer wait loop.

This commit moves the check for whether an event is available into the
wait functions, where there is enough knowledge to limit the check to
the X11 connection.

Related to #932

(cherry picked from commit 87970b7f26)
2022-03-13 16:13:34 +01:00
Camilla Löwy
811e6bb01c X11: Fix joystick events causing busy waiting
On Linux, the inotify descriptor was included in the set used for
select, but could not break the outer loop, leading to busy waiting
until timeout or the correct X11 event arrived.

This commit adds a new function for waiting just on X11 events.

Fixes #1872

(cherry picked from commit 1e987cb92e)
2022-03-13 16:11:28 +01:00
Camilla Löwy
ca1a98e7a2 X11: Fix event polling when event fd > 1023
This replaces select with poll for checking for data on event file
descriptors, as select cannot handle file descriptors larger than 1023.

Closes #2024

(cherry picked from commit d3e4fcf8b7)
2022-03-13 16:07:11 +01:00
Camilla Löwy
54f2a865e9 GLX: Fix context creation failing unnecessarily
Regression introduced with 3bb5c459d6.

(cherry picked from commit 2e656afc49)
2022-03-13 15:42:22 +01:00
Camilla Löwy
dccec7fcae Cocoa: Fix deprecation warning for kUTTypeURL
We switched to kUTTypeURL when NSURLPboardType was deprecated, as the
official replacement symbol NSPasteboardTypeURL was not available on
every version of macOS supported by GLFW.

kUTTypeURL has now also been deprecated.

This commit moves to a compile-time choice between NSURLPboardType and
NSPasteboardTypeURL depending on the minimum targeted macOS version.

Fixes #2003

(cherry picked from commit 7f6aa587f8)
2022-02-15 21:24:03 +01:00
Camilla Löwy
e155c19f8e Wayland: Fix text input not following key repeat
The manual key repeat implementation did not call text input.

(cherry picked from commit 1a7da42e6e)
2022-02-15 21:22:26 +01:00
Camilla Löwy
1f7ce12cbc Wayland: Implement key name support
(cherry picked from commit 17a9e34fbc)
2022-02-15 21:02:07 +01:00
Camilla Löwy
61497796e6 Wayland: Fix keys reported as wrong or unknown key
(cherry picked from commit 37b7540db9)
2022-02-15 20:58:07 +01:00
Camilla Löwy
86a1d3b628 Wayland: Fix GLFW_VISIBLE affecting full screen
Full screen window creation was not ignoring the GLFW_VISIBLE hint.

(cherry picked from commit 715b874db3)
2022-02-15 20:57:26 +01:00
Camilla Löwy
f5dab59071 Wayland: Fix missing damage event on window show
By definition a hidden window on Wayland does not have valid framebuffer
contents.

This adds a window damage (refresh) event when a window is shown, to
request an initial frame for the now visible window.

(cherry picked from commit 25c521cbe5)
2022-02-15 20:56:21 +01:00
Camilla Löwy
ec934edfbf Wayland: Fix repeated key not released on defocus
Platform code should not generate key events with GLFW_REPEAT.
GLFW_PRESS is translated into GLFW_REPEAT by shared code based on the
key state cache.

This confused the automatic key release logic into not generating an
event with GLFW_RELEASE for a key being repeated when the window lost
input focus.

(cherry picked from commit 3f5dfeaf29)
2022-02-15 20:51:55 +01:00
Camilla Löwy
65fc4fa625 X11: Fix sonames for loaded libraries on OpenBSD
The OpenBSD ports tree assigns its own soname version numbers, so the
hardcoded sonames GLFW uses to load libraries on non-macOS Unices are
often incorrect.  Instead OpenBSD recommends that run-time loading
should leave out the version numbers entirely.  The OpenBSD ld.so then
finds the correct library.

This upstreams the ports tree fixes for Xcursor and EGL, and adds the
corresponding fix for all other run-time loaded library sonames.

Tested on OpenBSD 7.0.

This issue was initially reported on IRC.

(cherry picked from commit 7d060ba4f1)
2022-02-15 20:36:11 +01:00
Jason Francis
8ecb49d143 Wayland: Fix window hiding
Corrects the protocol violation when creating an xdg_surface from a
wl_surface that already has a buffer due to EGL buffer swaps.

This commit is based on PR #1731 by @ghost, but adapted and altered:
 - The XDG surface and role are now only created when a window is shown
   to prevent application lists from showing command-line applications
   with off-screen-only windows
 - The special case of Wayland+EGL buffer swap is now in the EGL code
   to mirror how X11 is handled
 - Adaption to run-time platform selection and separate credits file

Fixes #1492
Closes #1731

(cherry picked from commit 094aa6d3c7)
2021-12-24 01:59:16 +01:00
Camilla Löwy
9240ee5ddf Wayland: Fix key repeat continuing when refocused
If a window lost input focus while a key was held down, the key repeat
mechanism would resume once the window regained focus.

(cherry picked from commit e24fe4b189)
2021-12-24 01:53:53 +01:00
Camilla Löwy
3b806aef27 Wayland: Fix duplicate focus event on activation
(cherry picked from commit c2f0a0ae59)
2021-12-24 01:52:43 +01:00
Emmanuel Gil Peyrot
52133a3690 Wayland: Continue poll() if timerfd can’t be read
In the case the key repeat timerfd was interrupted before read(), the
cursor timerfd wasn’t read at all even when it could.

Related to #1711

(cherry picked from commit 68879081cb)
2021-12-24 01:45:22 +01:00
Camilla Löwy
869e68a015 Start 3.3.7 2021-12-10 01:26:54 +01:00
Camilla Löwy
e10def6de7 Win32: Fix bad content scale on monitor disconnect
The monitor handle could have become invalid just before the call to
GetDpiForMonitor.  It was possible for both window and monitor content
scale queries.

This ensures both that an appropriate error is emitted and that the
retrieved values are zero on error.

Fixes #1615

(cherry picked from commit fbfd7e65c8)
2021-12-08 20:05:32 +01:00
Camilla Löwy
18d7c241f8 Add credits and update changelog
(cherry picked from commit e40fa3bb94)
2021-12-08 20:02:50 +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
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
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
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
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
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
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
65c36563f6 Update changelog
Related to #1840.

(cherry picked from commit ab34cc51c6)
2021-08-03 15:43:49 +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
a18f4e50b0 Add credit
Related to #1931.

(cherry picked from commit b6f7ead3c5)
2021-08-03 14:04:52 +02:00
Camilla Löwy
8f0198e82e Remove errors for gamepad element mismatch
Because there are controllers in the wild using the same hardware ID
despite having different numbers of buttons and axes, an error message
was triggered that was only expected for a corrupted mapping database.

This removes the error for now, in preparation for better error handling
for gamepad mappings overall.

Fixes #1763.

(cherry picked from commit 6876cf8d7e)
2021-08-03 14:04:01 +02:00
Camilla Löwy
b1a8bc5d69 Add missing changelog entry
Related to #1843.

(cherry picked from commit 6f7c61c6b3)
2021-06-25 00:23:11 +02:00
Camilla Löwy
db34aea144 Fix some documentation URLs still using http:
Some URLs in the documentation were overlooked during the switch to
https: for the GLFW website.  This updates those and a few third-party
URLs.

(cherry picked from commit 787295b3af)
2021-06-25 00:23:11 +02:00
Camilla Löwy
6518847f4d Update IRC network to Libera.Chat
The `#glfw` IRC channel is moving to the Libera.Chat network due to the
recent takeover of the Freenode network.

(cherry picked from commit 78380c7761)
2021-06-25 00:23:11 +02:00
Camilla Löwy
8bf39cf1f4 Migrate from Travis CI to GitHub Actions
The old Travis CI .org service has been throttled for a while now and is
said to be shutting down completely next week.

This migrates the Travis CI build jobs to GitHub Actions, with minor
changes.

- The trailing whitespace detection has been removed for now.
- The libegl1-mesa-dev dependency for Wayland has been removed as it
  appears to no longer be necessary for building.

(cherry picked from commit 5a6001a83b)
2021-06-15 18:08:32 +02:00
Camilla Löwy
07c29d1c1c Skip initial buffer swap when single-buffered
This skips the buffer swap after the initial glClear performed during
window creation, if the window is single-buffered.  This call confused
apitrace into thinking the window was double-buffered.

Fixes #1873.

(cherry picked from commit 184377b493)
2021-06-15 18:06:46 +02:00
Camilla Löwy
30b02dd709 Fix description of video mode ordering in docs
The two final sorting criteria were not included in the documentation.

Fixes #1889.

(cherry picked from commit 0e9ec7788b)
2021-06-09 18:32:05 +02:00
Camilla Löwy
5dd6716ee9 Win32: Fix compilation with standalone LLVM
The /clang: suffix passed to Clang-CL was accidentally also passed to
the regular standalone Clang, which caused compilation to fail.  We now
pass /W3 to Clang-CL, which it interprets as -Wall.

The _CRT_SECURE_NO_WARNINGS macro is now defined for both Clang and
Clang-CL.

The /entry: flag passed to link.exe is now also passed to lld-link,
letting the windows subsystem tests and examples link.

Fixes #1807.
Closes #1824.
Closes #1874.

(cherry picked from commit 061a0263a9)
2021-06-09 18:31:39 +02:00
Camilla Löwy
658744e222 Update USE_MSVC_RUNTIME_LIBRARY_DLL for CMake 3.15
This makes USE_MSVC_RUNTIME_LIBRARY_DLL update the directory scope
CMAKE_MSVC_RUNTIME_LIBRARY variable instead of CMAKE_C_FLAGS on CMake
3.15 and later.

Solution proposed by @moritz-h.

Fixes #1783.
Closes #1796.

(cherry picked from commit f4a7329604)
2021-06-09 18:24:31 +02:00
Camilla Löwy
713711f5e9 Start 3.3.5 2021-04-08 20:48:17 +02:00
Camilla Löwy
814b7929c5 Add issue number to changelog
Related to #1863.

(cherry picked from commit 33cd8b865d)
2021-03-21 23:23:17 +01:00
Camilla Löwy
0f46d089e8 X11: Fix attribs not applied on leaving fullscreen
If the GLFW_DECORATED and/or GLFW_FLOATING window attributes were
changed while in fullscreen mode, the changes did not take effect when
the window entered windowed mode.

Bug reported on the GLFW forum.
https://discourse.glfw.org/t/turning-on-off-window-decorations-while-in-full-screen-wont-work-properly/1780

(cherry picked from commit 4afa227a05)
2021-03-19 16:18:12 +01:00
Camilla Löwy
b8202d9ca3 Start 3.3.4 2021-02-23 21:23:46 +01:00
Camilla Löwy
901d30b973 Update changelog
(cherry picked from commit 2c7f3ce91b)
2021-02-17 21:23:27 +01:00