Commit Graph

4584 Commits

Author SHA1 Message Date
Camilla Löwy
1461c59aa2 Update changelog and add credit
Related to #1951
2022-03-10 20:04:56 +01:00
Slemmie
b54fb0af10 X11: Fix undefined behavior in bit shift of int
Closes #1951
2022-03-10 19:58:41 +01:00
Camilla Löwy
8f9ff8503e Formatting 2022-03-10 19:36:10 +01:00
Camilla Löwy
aa803f7de5 Win32: Update rationale for reimplementation
It is true that plain MinGW lacks this header, but that is not the main
reason for reimplementing IsWindowsVersionOrGreater.
2022-03-10 19:35:23 +01:00
Camilla Löwy
34573798f4 Win32: Rename Windows 10 macros for clarity
This switches the Windows 10 version helper macros to include the
version numbers listed in MSDN requirements sections.
2022-03-10 19:32:21 +01:00
Camilla Löwy
8ff9ed92b4 Win32: Fix calls to encoding compatibility macros
Calls to Unicode specific functions should be made explicit.
2022-03-10 19:31:28 +01:00
Camilla Löwy
723f3eb40d Win32: Fix maximization showing a hidden window
The normal way of maximizing a window also makes it visible.  This
implements window maximization manually for when the window passed to
glfwMaximizeWindow is hidden.

This will very likely not be forward-compatible and should be replaced.
2022-03-10 19:30:20 +01:00
Camilla Löwy
1eef3a363e Fix dependency list for X11 on Cygwin 2022-03-10 19:15:13 +01:00
Camilla Löwy
367d06deaf Win32: Fix scale fixup losing initial position
The window content scale correction at creation overwrote the inital,
more pleasant placement of the window by CW_USEDEFAULT, if the window
was created with GLFW_MAXIMIZED set.  This is because the translation
to screen coordinates was done using the current position, not the
position from the restored window rect.
2022-03-10 17:10:55 +01:00
Camilla Löwy
a730acf8e5 Win32: Fix rect of undecorated maximized windows
A window created maximized and undecorated would cover the whole monitor
Windows placed it on instead of just that monitor's workarea.

This commit adjusts the maximized rect to cover just the workarea,
similar to how undecorated windows that become maximized are handled
during WM_GETMINMAXINFO.

Fixes #1806
2022-03-10 17:07:55 +01:00
Camilla Löwy
adc202d2c3 POSIX: Fix undeclared function warning on Cygwin 2022-03-04 13:37:38 +01:00
Camilla Löwy
d78b0a4ead X11: Fix sonames for loaded libraries on NetBSD
The NetBSD sonames for X11 and related libraries is more stable than on
OpenBSD but the version numbers are still bumped more often than their
Linux counterparts, even excluding the one-time version bump across all
X11 related libraries.

This commit moves to using version-less sonames for X11 and related
libraries on NetBSD, which will hopefully be more forward-compatible
than hard-coding NetBSD-specific sonames.

This may not be the correct long-term solution but it runs now.

Binaries also appear to need an LD_LIBRARY_PATH or rpath entry of
/usr/X11R7/lib in order for the libraries to be found by dlopen.

Tested on NetBSD 9.2.
2022-03-04 00:00:59 +01:00
Camilla Löwy
1e0c3bca7f Update version of VS used on windows-latest 2022-03-03 23:17:45 +01:00
Camilla Löwy
71742d9a27 Wayland: Improve event processing with timeout
If the polling was interrupted by a signal or by incomplete or unrelated
data on any file descriptor, handleEvents could return before the full
timeout had elapsed.

This retries the Wayland prepare-to-read and poll until the full timeout
has elapsed or until any event was processed.  Unfortunately, due to how
the Wayland client API is designed, this also includes the delete_id
for the frame callback created by eglSwapBuffers.

This means glfwWaitEvents* are still not fully functional on Wayland.
See #1911 for more details.
2022-03-03 22:58:09 +01:00
Camilla Löwy
a32cbf6d4f Wayland: Fix glfwPostEmptyEvent not always working
The display sync requests in glfwPostEmptyEvent could just accumulate as
the display was never flushed on secondary threads.

This adds a proper flush after each sync request.

Fixes #1520
Closes #1521
2022-03-03 22:24:09 +01:00
Camilla Löwy
7ce1f3e1cf Formatting 2022-03-03 22:24:09 +01:00
Camilla Löwy
bb9d699ae6 Share X11 fd polling logic with Wayland
This moves the X11 polling implementation to a separate file where it
can be used by either the X11 or Wayland backend or both.

This code should be POSIX compatible where necessary but will use the
lower latency but non-standard polling functions ppoll or pollts where
those are available.

This commit is based on work by OlivierSohn and kovidgoyal.

Fixes #1281
Closes #1285
2022-03-03 22:23:57 +01:00
Camilla Löwy
203a7c59d2 Wayland: Cancel display fd read before callbacks
Cancel the prepared-to-read state on the calling thread before starting
to call back to user code.

Emitting close requests here is not a good choice but that is for
a future commit to address.
2022-03-03 22:16:59 +01:00
Camilla Löwy
3c2913dcb9 Wayland: Fix potential incomplete display flushing
The flushing of a Wayland display may need to be done in several steps,
signalled by it failing with EAGAIN.
2022-03-03 22:16:59 +01:00
Camilla Löwy
84b0923fe6 X11: Use lower-latency poll where available
This uses ppoll for waiting on file descriptors with a timeout, where
that function has been available a while.  On NetBSD, which will be
getting ppoll in the next release, the equivalent pollts is used.

This commit is based on work by OlivierSohn and kovidgoyal.

Related to #1281
Related to #1285
2022-03-03 22:16:59 +01:00
Camilla Löwy
cd22e28495 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
2022-03-03 22:16:59 +01:00
Camilla Löwy
363d471441 Cleanup 2022-03-03 22:16:59 +01:00
Camilla Löwy
87970b7f26 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
2022-03-03 22:16:49 +01:00
Camilla Löwy
1e987cb92e 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
2022-03-03 22:15:42 +01:00
Camilla Löwy
92b5c67b50 X11: Retry poll when failed with EINTR or EAGAIN
Both of these errors should just lead to local retry.
2022-03-02 19:59:08 +01:00
Camilla Löwy
d3e4fcf8b7 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
2022-03-02 19:38:41 +01:00
Camilla Löwy
ad01c1b614 Win32: Fix key name code changing global key state
This prevents glfwInit from potentially clobbering the dead key state
for other applications.

Closes #2018
2022-03-02 19:38:41 +01:00
Camilla Löwy
789d2924c0 Formatting
Make it clear that context attribute helper macros are macros.
2022-03-02 19:38:41 +01:00
Camilla Löwy
2e656afc49 GLX: Fix context creation failing unnecessarily
Regression introduced with 3bb5c459d6.
2022-03-02 19:38:41 +01:00
Camilla Löwy
20adc18aa5 Wayland: Clean up monitor scale update 2022-03-02 19:38:41 +01:00
Camilla Löwy
152f50cd01 Wayland: Fix error type for allocation failure 2022-02-11 13:11:54 +01:00
Camilla Löwy
4a68926bfd Wayland: Remove unnecessary NULL checks
It is fine to pass NULL to _glfw_free.
2022-02-11 13:11:08 +01:00
Camilla Löwy
a28adba06a Wayland: Fix multiple copies of single constant 2022-02-11 13:11:08 +01:00
Camilla Löwy
97da62a027 Cocoa: Clarify comments on compatibility macros 2022-02-09 22:13:14 +01:00
Camilla Löwy
e023618daa Remove Doxyfile tag deprecated by Doxygen 1.9.3 2022-02-02 21:49:06 +01:00
Camilla Löwy
7f6aa587f8 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
2022-02-02 19:20:32 +01:00
Camilla Löwy
df8d7bc892 Wayland: Clean up modifier key event handler
Adapt style and naming to match the rest of the project.
2021-12-31 13:32:25 +01:00
Camilla Löwy
0ce611958e Wayland: Clean up key translation
Adapt style and naming to match the rest of the project.
2021-12-31 13:32:25 +01:00
Camilla Löwy
1a7da42e6e Wayland: Fix text input not following key repeat
The manual key repeat implementation did not call text input.
2021-12-31 13:30:16 +01:00
Camilla Löwy
bf99587005 Wayland: Clean up key event handler
Adapt style and naming to match the rest of the project.
2021-12-31 13:27:22 +01:00
Camilla Löwy
293d19a153 Wayland: Require xkbcommon 0.5.0 or greater
The Wayland backend now requires xkbcommon-compose, which was added in
version 0.5.0.  xkbcommon 0.5.0 was released in 2014.

This removes the non-composing fallback path for text input.
2021-12-31 13:27:22 +01:00
Camilla Löwy
b70259e52d Wayland: Clean up text input
Adapt style and naming to match the rest of the project.
2021-12-31 13:27:22 +01:00
Camilla Löwy
fe7be39793 Clean up internal Unicode code point handling
Call code points by their name and store them as uint32_t.
2021-12-31 13:27:22 +01:00
Camilla Löwy
17a9e34fbc Wayland: Implement key name support 2021-12-31 13:27:22 +01:00
Camilla Löwy
cb22c54119 Move UTF-8 encoding to shared code
This will be used by the Wayland code too.
2021-12-31 13:27:22 +01:00
Camilla Löwy
37b7540db9 Wayland: Fix keys reported as wrong or unknown key 2021-12-31 13:27:18 +01:00
Camilla Löwy
715b874db3 Wayland: Fix GLFW_VISIBLE affecting full screen
Full screen window creation was not ignoring the GLFW_VISIBLE hint.
2021-12-31 13:13:21 +01:00
Camilla Löwy
8aaea57421 Fix gamma test not checking for NULL return value 2021-12-31 13:13:21 +01:00
Camilla Löwy
25c521cbe5 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.
2021-12-31 13:13:21 +01:00
Camilla Löwy
c05acf6246 Wayland: Fix window not visible after initial swap
A window created with GLFW_VISIBLE set was not made visible by the
initial buffer swap during context attribute refresh.

Regression introduced by @elmindreda in
094aa6d3c7.
2021-12-31 01:32:18 +01:00