Allow keyboard layouts which include "dead keys" to enter diacritics
by calling MapVirtualKeyW even when not key_down.
See D16770 for more details.
Differential Revision: https://developer.blender.org/D16770
Reviewed by Campbell Barton
Cursor motion events on windows read the position from GetCursorPos()
which wasn't always the same location stored in `lParam`.
In situations where events were handled immediately this wasn't often a
problem, for heavier scenes or when updates between event handling was
slow - many in-between cursor events would be incorrect.
This behavior dates back to the initial commit, there doesn't seem to be
a good reason not to use the cursor coordinates from the event.
Noticed when investigating T102346.
Make OpenGL errors match formatting used by GCC & clang
(as well as Blender's logging), so utilities that recognize this
convention can be used to quickly access this location.
This prevents Blender from crashing with an access violation when
stopping a VR session using the DirectX backend. The issue occurred for
any headset on Windows+Nvidia when using the SteamVR runtime and thus
affected a large number of users.
The workaround presented here is to simply skip unregistering the
shared resources on exit, as either of the calls to
`wglDXUnregisterObjectNV()` or `wglDXCloseDeviceNV()` will result in an
access violation. While not ideal, this avoids the crash and doesn't
present any issues when starting a new VR session.
Reviewed By: Severin
Differential Revision: https://developer.blender.org/D16569
MoltenVK is part of the vulkan SDK. Blender requires the vulkan SDK
to compile. This patch adds the MoltenVK includes and libraries to
the Vulkan includes and libraries.
This adds a vulkan backend to GHOST. The code was extracted from the
tmp-vulkan branch. The main difference with the original code is that
GHOST isn't responsible for fallback. For Metal backend there is already
an idea that the GPU module is responsible for the fallback, not the system.
For Blender we target Vulkan 1.2 at the time of this patch.
MoltenVK (needed to convert Vulkan calls to Metal) has been added as
a separate package.
This patch isn't useful for end-users, currently when starting blender with
`--gpu-backend vulkan` it would crash as the `VBBackend` doesn't initialize
the expected global structs in the GPU module.
Validated to be working on Windows and Apple. Linux still needs to be tested.
Reviewed By: fclem
Differential Revision: https://developer.blender.org/D13155
Regression in [0] which exposed a problem with GHOST_kGrabHide on Win32
and to some extent X11.
Prior to [0], walk mode used it's own warping logic (hiding the cursor
& recording the motion between events). Using GHOST's grabbing makes
sense in this case as it's not very convenient for operators to
implement their own cursor warping, however doing so exposed a problem
where the mouse cursor could leave the window.
This would happen because the cursor needed to be within 2px of the
screen edge before warping.
Resolve by warping within a small region in the middle of the window.
Note that warping to the window center on each motion would be ideal
but is more involved as the logic for Win32 & X11 doesn't work properly
when every motion warps, so this needs further investigation to support.
This problem doesn't apply to GHOST/Cocoa which warps every motion event
on the spot and GHOST/Wayland doesn't set the mouse position at all to
implement this functionality.
[0]: 4c4e8cc926a672ac60692b3fb8c20249f9cae679
Some of these functions should use locks although they didn't show up
as needing locks at runtime (using valgrind's helgrind), as some aren't
called often or aren't used at all. Add locks for correctness & to
prevent errors in the future.
- GHOST_SystemWayland::disposeContext
- GHOST_SystemWayland::getAllDisplayDimensions
- GHOST_SystemWayland::getButtons
- GHOST_SystemWayland::getMainDisplayDimensions
- GHOST_SystemWayland::getNumDisplays
- GHOST_WindowWayland::setWindowCustomCursorShape
libdecor has a workaround where creating the window would loop until
the windows configure callback ran.
Simplify this workaround by setting the initial state on the underlying
xdg_toplevel struct.
Also correct mixup between bool / GHOST_TSuccess types.
Avoid keeping allocated overly large events_pending vector in case of
long delays between processing events.
While in practice this isn't likely to cause problems, it's better to
avoid keeping unnecessarily large allocations.
Also remove invalid comment.
Consume events in a thread to prevent Wayland's event buffer from
overflowing Waylands internal buffer and closing the connection.
From a users perspective this seemed like a crash.
Details:
- This is a workaround for a known bug in Wayland [0].
Threaded event handling has been if-defed so it can be removed when
it's no longer needed.
- GTK & QT use threaded event handling to avoid this problem
(SDL on the other hand doesn't).
- The complexity and number of locks needed to handle events in a
separate thread is a significant down-side, but as far as I can see
this is necessary.
- Re-connecting to the Wayland server is possible but not practical as
the OpenGL context is lost and as far as I can tell it's not possible
to keep it active (see: D16492).
[0]: https://gitlab.freedesktop.org/wayland/wayland/-/issues/159
Using a single draw works in my tests and I couldn't reproduce the
issue noted in the comment.
Also apply minor cleanup, assigning a variable before calling methods to
reduce diff-noise in planned changes.
Without this, a fatal error simply floods the stderr with the same
message without exiting.
Also add note on why reconnecting to the display server isn't practical.
It wasn't so obvious which functions were part of the GHOST API
and which system functions were utilities.
This convention was already in place but not always followed.
Add a non-blocking version wrapper for wl_display_dispatch_pending.
This uses roughly the same logic as Wayland_PumpEvents in SDL.
Noticed this when investigating T100855.
Note that performing a round-trip doesn't seem necessary from looking
into QT/GTK & SDL event handling loops.
Support layouts such as AZERTY where the shift key is held for number
keys. Text entry remains unchanged but these keys now activate shortcuts
as expected.
This matches a fix in X11 for the same problem: T47228.