Commit Graph

757 Commits

Author SHA1 Message Date
Camilla Löwy
6dd526fb1a Win32: Fix right Shift scancode when using CJK IME
Fixes #2050
2022-07-11 20:54:22 +02:00
Camilla Löwy
dfb26023fc Update changelog and add credit
Related to #2113
Related to #2120
2022-07-07 23:48:42 +02:00
Camilla Löwy
0d599026d0 Cocoa: Fix clearing of unrelated window style bits
Whenever GLFW changed the window style mask, a new mask was created
from scratch based on the attributes set on the GLFW window object.
This caused us to potentially clear unrelated window style bits.

This was always wrong but became a critical issue when Cocoa began
throwing an exception if an application cleared the
NSWindowStyleMaskFullScreen while the window is in macOS fullscreen.

This commit reworks all style mask editing so it only changes the
relevant bits, preserving all others.

This is only a narrow bug fix to prevent crashes, intended for the
stable branch.  Our interaction with macOS fullscreen is still very
poor.  The next step after this is a set of patches that improve the
interaction between the current API and macOS fullscreen.

Fixes #1886
Fixes #2110
2022-07-07 23:47:48 +02:00
Camilla Löwy
6f8ec4075b Cocoa: Fix GLFW_MAXIMIZED for nonresizable windows
The reasoning here is that glfwRestoreWindow will change nothing for
a windowed non-resizable window on Cocoa, and silently refusing to
maximize seems slightly more like something other platforms would do.

This is possibly either the right thing to do or the wrong one.
2022-07-07 22:24:09 +02:00
Camilla Löwy
98d6e8485b Cocoa: Disable macOS fullscreen when non-resizable
Windows with GLFW_RESIZABLE set to false should not be resizable by the
user.
2022-07-07 22:23:54 +02:00
Camilla Löwy
f35e2274cb Wayland: Fix GLFW_DECORATED for XDG decorations
On a compositor that supports server-side decorations, they were always
enabled in windowed mode, even if GLFW_DECORATED was cleared.
2022-06-21 21:49:06 +02:00
Camilla Löwy
83a134a92f Wayland: Fix mapping failure on wlroots compositor
When showing a window that had already been shown once (and so already
had its shell objects), GLFW would attach a new buffer and commit it
before waiting for the next configure event.  This was a violation of
the XDG shell protocol.

This was allowed to work as intended on GNOME and KDE without error.
However wlroots based compositors would (correctly) emit an error.

Unfortunately, I haven't been able to find a way to get both KDE, GNOME
and Sway to send the configure event we need in order to map the
wl_surface again while keeping our existing shell objects, so with this
commit we now create them for each call to glfwShowWindow and destroy
them for each call to glfwHideWindow.

Fixes #1268
2022-06-21 21:49:05 +02:00
Camilla Löwy
77819c0c54 Wayland: Fix maximized state lost while hidden
If a window was created as maximized, or created as hidden and then
iconified or maximized before first being shown, that state was lost and
the window was shown as restored.
2022-06-21 21:47:35 +02:00
Camilla Löwy
91f18fb576 Wayland: Fix error from glfwSetWindowAspectRatio
The aspect ratio was applied during resize but any call to
glfwSetWindowAspectRatio emitted a GLFW_FEATURE_UNIMPLEMENTED error.
2022-06-21 20:46:06 +02:00
Camilla Löwy
e37ba80b13 Wayland: Fix reporting of monitor scale changes
Content scale events would be emitted when a window surface entered or
left an output, but not when one of a window's current outputs had its
scale changed.
2022-06-21 20:46:06 +02:00
Camilla Löwy
c3ad3d49ed Wayland: Fix duplicate monitor connection events
GLFW would report a monitor as connected each time its wl_output
received an update, for example if its scale changed.

This would also cause the monitor to be added to the monitor array
again, causing glfwTerminate to segfault when it attempted to destroy
its already destroyed wl_output.
2022-06-21 20:46:06 +02:00
Camilla Löwy
209f6cf093 Wayland: Add support for wl_output::name
We now use wl_output::name as the GLFW monitor name, on compositors that
provide this event.
2022-06-21 20:44:52 +02:00
Camilla Löwy
229d628ec4 Wayland: Fix toggling of server-side decorations
This is a temporary local fix to have updates to GLFW_DECORATED mostly
work as intended.  The whole decoration state machine needs to be
restructured, but not by this commit.
2022-06-21 16:00:33 +02:00
Camilla Löwy
a7b6f35500 Wayland: Fix size limits for fallback decorations
The size limits set on our XDG surface did not include the sizes of the
fallback decorations on all sides, when in use.  This led to its content
area being too small.

Related to #2127
2022-06-20 00:57:17 +02:00
Camilla Löwy
0f5b095042 Wayland: Fix erratic fallback decoration behavior
The handler for xdg_toplevel::configure treated the provided size as the
content area size when instead it is the size of the bounding rectangle
of the wl_surface and all its subsurfaces.

This caused the fallback decorations to try positioning themselves
outside themselves, causing feedback loops during interactive resizing.

Fixes #1991
Fixes #2115
Closes #2127
Related to #1914
2022-06-20 00:57:17 +02:00
Camilla Löwy
3bbb41eacc Wayland: Fix glfwInit closing stdin on failure
If platform initialization failed before either timer fd member had been
set to -1 or a valid fd, termination would close stdin.
2022-06-20 00:57:17 +02:00
Camilla Löwy
0b76e3a6f1 Wayland: Fix duplicate window content scale events
The window content scale event was emitted every time the window content
area was resized, even if its scale had not changed.
2022-06-20 00:57:17 +02:00
Camilla Löwy
6857995498 Wayland: Fix glfwSetWindowSize resizing fs windows
glfwSetWindowSize would change the size of fullscreen mode windows as
if they were windowed mode.
2022-06-20 00:57:17 +02:00
Camilla Löwy
fdc72edf81 Wayland: Fix missing fullscreen code path
glfwRestoreWindow assumed it was only called in windowed mode.
2022-06-20 00:57:17 +02:00
Camilla Löwy
f39ffefb6a Wayland: Fix maximization by user being ignored
The internal maximization state was not updated when an event was
received that the user had changed the maximization state of a window,
and no maximization events were emitted.

This affected both the GLFW_MAXIMIZED attribute and glfwRestoreWindow.
2022-06-20 00:57:17 +02:00
Camilla Löwy
ddd087d662 Wayland: Fix behavior of leaving full screen mode
These changes make GLFW fullscreen more consistent, but unfortunately
also make GLFW even more oblivious to user-initiated XDG shell
fullscreen changes.

Fixes #1995
2022-06-20 00:57:17 +02:00
Camilla Löwy
2ae3e0c8d7 Win32: Add separate window class for helper window
The current window procedure needs to deal with messages both for user
created windows and the hidden helper window.

This commit separates out the device message handling of the helper
window, allowing both window procedures to be less complicated.
2022-06-08 23:56:20 +02:00
Camilla Löwy
05f6c13d11 Add support for GLFW_NATIVE_INCLUDE_NONE macro
By default, the glfw3native.h header will include the platform-specific
headers necessary for the return types of GLFW native access functions.

Sometimes it is preferrable to declare those types

This commit adds support for the GLFW_NATIVE_INCLUDE_NONE macro, which
when defined disables the inclusion of all platform-specific headers.

Fixes #1348
2022-06-08 22:14:38 +02:00
Camilla Löwy
26920a1a38 X11: Fix previous error handler not being restored
GLFW did not restore the previous Xlib error handler when removing its
own, instead resetting to the default handler.

This commit saves and restores the previous error handler.

None of this is thread-safe or could ever be.

Fixes #2108
2022-06-08 22:14:38 +02:00
Camilla Löwy
2c204ab52e Fix joystick user pointer NULL during disconnect
The joystick code did not distinguish between the allocation status of
the GLFW joystick object and whether it is connection to an OS level
joystick object.

These are now tracked separately.

Fixes #2092
2022-06-08 22:14:38 +02:00
Camilla Löwy
e9c58bc181 Wayland: Fix missing lock key modifier bits
The modifier bits for lock keys were only set when the corresponding key
was reported as held down or latched, but not when it was released and
locked.
2022-06-08 19:20:01 +02:00
Camilla Löwy
09653b8c54 Move last bits of window setup to platform code
This avoids glfwCreateWindow emitting GLFW_FEATURE_UNAVAILABLE or
GLFW_FEATURE_UNIMPLEMENTED on Wayland because shared code was calling
unimplemented or unavailable platform functions during final setup.

It also makes it consistent with the final setup of full screen windows.
2022-04-28 21:58:06 +02:00
Camilla Löwy
23e6e8e4b7 X11: Fix segfault on malformed INCR response
The code assumed that at least some data would be received via the INCR
mechanism and that, as a result, the string buffer would be allocated.

Bug found by Clang static analysis.
2022-04-28 21:19:08 +02:00
Camilla Löwy
a8d8b760fb X11: Fix OSMesa library not being unloaded 2022-04-28 21:17:39 +02:00
Camilla Löwy
2d281d7928 Wayland: Fix OSMesa library not being unloaded 2022-04-28 21:16:06 +02:00
Camilla Löwy
89514cf0fc Cocoa: Fix EGL and OSMesa not being unloaded 2022-04-28 21:14:11 +02:00
Camilla Löwy
10e9033a29 Win32: Fix OSMesa library not being unloaded 2022-04-28 21:12:36 +02:00
Camilla Löwy
29523dbfbf Fix order of error checks in glfwSetGammaRamp
Initialization should be checked before arguments.
2022-04-21 15:57:15 +02:00
Camilla Löwy
f843d53333 Fix glfwMakeContextCurrent using uninitialized TLS
Issue reported by danhambleton on the GLFW forum:
https://discourse.glfw.org/t/posix-thread-local-storage-tls-error-when-making-context-current/2034
2022-04-21 15:56:01 +02:00
Camilla Löwy
4cb36872a5 Wayland: Add support for file drop events
This adds support for file path drop events in text/uri-list format.

It is based on work by Pilzschaf in #2040.

Closes #2040
2022-04-03 20:09:42 +02:00
Camilla Löwy
8d87be1268 Wayland: Improve handling of pending data offers
The code assumed that all data offers were selections that supported
plaintext UTF-8.

The initial data offer events are now handled almost tolerably.  Only
selection data offers are used for clipboard string and only if they
provide plaintext UTF-8.  Drag and drop data offers are now rejected as
soon as they enter a surface.

Related to #2040
2022-04-03 19:45:09 +02:00
Camilla Löwy
990dc4b388 Wayland: Fix error paths not closing sending fd
Whatever error happens on our end, we should still close the fd so the
other end can move on.
2022-04-03 19:45:09 +02:00
Camilla Löwy
4c110bba41 Wayland: Fix partial writes of clipboard string
The string pointer used to write the contents of our clipboard data
offer was never updated, causing it to repeat parts of the beginning of
the string until the correct number of bytes had been written.
2022-04-03 18:14:50 +02:00
Camilla Löwy
b386371f57 Wayland: Fix double free on data source error
If data source creation fails, the string containing the data for it
would be freed a second time during termination.
2022-04-03 18:14:50 +02:00
Camilla Löwy
9c95cfb9f1 Wayland: Fix handling of clipboard set to self
Passing any part of the result of glfwGetClipboardString to
glfwSetClipboardString would result in, at best, a use-after-free error.
2022-04-03 18:14:50 +02:00
Camilla Löwy
955fbd9d26 Cocoa: Fix AirPlay causing harmless init error
Emitting an error for one specific type of failure in retrieving the
correct name for a display is not very useful, especially when
initialization is otherwise unaffected.

There should be a path for information like that but this isn't it.

Fixes #1791
2022-03-18 00:45:12 +01:00
Camilla Löwy
07a5518c3e Win32: Fix using executable instance and not ours
Operations that take an instance handle should be passed the handle of
whatever module we are inside instead of blindly passing the handle of
the executable.

This commit makes GLFW retrieve its own instance on initialization.

This makes the most difference for window classes, which are
per-instance.  Using the executable instance led to name conflicts if
there were several copies of GLFW in a single process.

Note that having this is still a bad idea unless you know what things to
avoid, and those things are mostly platform-specific.  This is partly
because the library wasn't designed for it and partly because it needs
to save, update and restore various per-process and per-session settings
like current context and video mode.

However, multiple simultaneous copies of GLFW in a single Win32 process
should now at least initialize, like is already the case on other
platforms.

Fixes #469
Fixes #1296
Fixes #1395
Related to #927
Related to #1885
2022-03-18 00:45:04 +01:00
Camilla Löwy
8d9231fe5e Win32: Fix glfwGetKeyScancode for GLFW_KEY_PAUSE
The bug described in 03cfe957e7 was
already present for another key where modifiers changes its scancode.

Related to #1993
2022-03-18 00:22:20 +01:00
Camilla Löwy
03cfe957e7 Win32: Fix scancode and key for Alt+PrtSc events
Alt+PrtSc emits a different scancode than just PrtSc.  Since the GLFW
API assumes each key corresponds to only one scancode, this cannot be
added to the keycodes array.

Instead we replace the scancode at the point of entry.

Fixes #1993
2022-03-18 00:19:01 +01:00
Camilla Löwy
9cc252a406 Revert ad01c1b614
This change broke key names for dead keys, because that depends on
the effect on the global state of simulating two key presses.

Issue found by CTest tests.

Reverts #2018
2022-03-13 16:01:41 +01:00
Camilla Löwy
1461c59aa2 Update changelog and add credit
Related to #1951
2022-03-10 20:04:56 +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
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
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