Commit Graph

2266 Commits

Author SHA1 Message Date
Harley Acheson
93a629f147 Fix T103119: Allow Win32 Diacritical Composition
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
2022-12-13 18:30:20 -08:00
Jacques Lucke
b50c475cd2 Cleanup: move listbase.c to c++ 2022-12-13 18:13:10 +01:00
Campbell Barton
a132b068bc Cleanup: use ELEM macro 2022-12-08 13:59:42 +11:00
Thomas Dinges
de9f32a666 Merge branch 'blender-v3.4-release' 2022-12-06 18:27:44 +01:00
Campbell Barton
38e1b92b7a Fix T102964: Key-map event type values changed for NDOF buttons
Regression in [0] changed NDOF key-map values.

Restore the previous values & add missing view buttons to
rna_enum_event_type_items.

[0]: ecda118be407163096641db36b6ee8bf1d88ee55

Differential Revision: https://developer.blender.org/D16701
2022-12-06 18:26:24 +01:00
Campbell Barton
979b295154 Fix incorrect cursor motion coordinates for WIN32
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.
2022-12-06 17:18:01 +11:00
Campbell Barton
d486f33d63 GHOST: OpenGL errors now use "file:line: " contention for errors
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.
2022-12-06 14:48:38 +11:00
Campbell Barton
9cb061f4f0 Cleanup: spelling in comments 2022-12-05 12:58:18 +11:00
Campbell Barton
0dee238c8c Cleanup: remove duplicate doc-strings
Duplicating doc-strings in both header & implementation
should be avoided as they often diverge & maintaining them is more work.
2022-12-05 12:54:04 +11:00
Peter Kim
63ae0939ed Merge branch 'blender-v3.4-release' 2022-11-23 10:22:42 +09:00
Peter Kim
db28a8b3d1 Fix T102322: Crash on exiting VR session when using DirectX backend
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
2022-11-23 10:21:17 +09:00
Jeroen Bakker
dd5fdb9370 GPU: Add MoltenVK as dependencies to Vulkan SDK.
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.
2022-11-22 14:07:34 +01:00
Jeroen Bakker
b79e5ae4f2 GHOST: Add missing C_API function to header file.
- GHOST_GetDrawingContext was missing.
2022-11-22 12:45:49 +01:00
Jeroen Bakker
6dac345a64 GHOST: Vulkan Backend.
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
2022-11-22 11:29:09 +01:00
Campbell Barton
4cac8025f0 Cleanup: use int32_t type, update comments
Reference WIP patches for warping on the spot, follow up to T102346.
2022-11-20 10:39:43 +11:00
Campbell Barton
9fd6dae793 Fix T102346: Mouse escapes window during walk navigation
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
2022-11-19 20:57:59 +11:00
Campbell Barton
33fa053fe8 GHOST/Wayland: add missing lock in setWindowCursorShape
Also add some comments for locking.
2022-11-16 21:35:56 +11:00
Campbell Barton
02fa3a8128 Cleanup: remove unused window_manger reference in GHOST_WindowWayland 2022-11-16 21:04:30 +11:00
Campbell Barton
88c9f1266d GHOST/Wayland: add additional locks for correctness
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
2022-11-16 12:32:13 +11:00
Campbell Barton
1f5e1b59a3 GHOST/Wayland: quiet key modifier warning under gnome-shell
This was already suppressed in `getModifierKeys`,
but `keyboard_depressed_state_key_event` was still warning.
2022-11-16 12:31:30 +11:00
Campbell Barton
c2c41fb14c Fix missing title-bar redrawing with Wayland & libdecor
Regression in [0], changing active/inactive missed redrawing the
title-bar,

[0]: 37b256e26feb454d9febd84dac1b1ce8b8d84d90
2022-11-16 12:31:30 +11:00
Campbell Barton
64a114d11c GHOST/Wayland: add build option to set the XDG app-id
Add WITH_GHOST_WAYLAND_APP_ID so people making custom builds may
differentiate the blender instance by version/branch etc.
2022-11-16 12:31:30 +11:00
Campbell Barton
d1a5f24e73 Cleanup: move GHOST_WindowWayland::swapBuffers behind ifdef
The callback is only used for an assertion.
2022-11-16 12:31:30 +11:00
Campbell Barton
aee5fcc120 GHOST/Wayland: improve workaround for libdecor setting the window state
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.
2022-11-16 12:31:29 +11:00
Campbell Barton
9f0e9f36be GHOST/Wayland: extend on comments regarding locking 2022-11-16 12:31:29 +11:00
Campbell Barton
3ff7d0796d GHOST/Wayland: limit the size of the events_pending vector
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.
2022-11-15 16:36:57 +11:00
Campbell Barton
37b256e26f Fix T100855: Input while Blender is unresponsive exits under Wayland
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
2022-11-15 15:26:31 +11:00
Campbell Barton
f1646a4d5e GHOST/Wayland: share logic for xdg/libdecor window configuration
Split frame & frame_pending structs, making window actions simpler
to reason about.
2022-11-15 14:49:44 +11:00
Campbell Barton
56f783d883 GHOST/Wayland: only use a single swapBuffers for libdecor redrawing
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.
2022-11-15 12:30:54 +11:00
Campbell Barton
0190b104c8 GHOST/Wayland: fix building when GHOST_OPENGL_ALPHA is defined 2022-11-14 12:01:26 +11:00
Campbell Barton
d7971972fa GHOST/Wayland: call exit() when Wayland has a fatal error
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.
2022-11-14 10:37:08 +11:00
Campbell Barton
fe6114aaf5 GHOST/Wayland: remove display listener (was warning on startup)
This already has a default listener which uses waylands logging.
2022-11-14 10:12:34 +11:00
Campbell Barton
a582abd923 Cleanup: add a system reference to the wayland window
Avoid relying on GHOST_ISystem::getSystem(), store the system instead.
2022-11-12 17:35:17 +11:00
Campbell Barton
436e6dca24 Fix window title not redrawing with Wayland/libdecor 2022-11-12 17:06:58 +11:00
Campbell Barton
bc3f5c7e14 GHOST/Wayland: skip resizing the EGL surface unnecessarily
wl_egl_window_resize ran when the window became active/inactive for e.g.
2022-11-12 16:38:51 +11:00
Campbell Barton
787ae01dad Cleanup: move title into GWL_Window
Nearly all Wayland window data is stored in this struct,
follow this convention so GWL_Window functions can be self contained.
2022-11-12 16:26:53 +11:00
Campbell Barton
19ba229391 Cleanup: move Wayland window state utilities into lower level functions
Add low level gwl_window_* functions.
2022-11-12 16:26:51 +11:00
Campbell Barton
2a17fd40a5 Fix non-interactive window borders after changes to event handling
Regression in [0] causes LIBDECOR interactions not to be detected.

[0]: deb8ae6bd1edb0983d9ac972b2c95090f4c5e642
2022-11-12 16:26:50 +11:00
Campbell Barton
7931ae0df3 Cleanup: use snake-case for WAYLAND utility functions
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.
2022-11-12 15:25:51 +11:00
Campbell Barton
deb8ae6bd1 GHOST/Wayland: replace roundtrip with dispatch_pending
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.
2022-11-12 15:11:43 +11:00
Campbell Barton
2a6a492a82 GHOST/Wayland: report a message when there is a fatal error
Help troubleshooting T100855.
2022-11-10 16:51:44 +11:00
Campbell Barton
4b6d58fd6d Cleanup: minor naming changes, make listener struct const 2022-11-10 16:47:55 +11:00
Campbell Barton
7e4e8cca7d GHOST/Wayland: add wl_display_listener for debugging
Currently only used for logging to help with debugging.
2022-11-10 11:12:52 +11:00
Campbell Barton
79dae1a43f Cleanup: compiler warnings (unused-parameter & missing-declarations) 2022-11-10 11:10:01 +11:00
Campbell Barton
fb52a09840 Fix T102287: Unhandled Numpad Separator on QWERTZ under Wayland 2022-11-09 14:33:39 +11:00
Campbell Barton
60043a6158 Cleanup: quiet unused argument warning 2022-11-05 17:08:53 +11:00
Campbell Barton
889b3385b5 Cleanup: spelling in comments 2022-11-02 10:18:19 +11:00
Campbell Barton
fe863b59db Fix T102194: unhandled number keys on AZERTY layout under Wayland
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.
2022-11-01 14:28:54 +11:00
Campbell Barton
afc091c3c4 Cleanup: spelling in comments 2022-11-01 12:24:58 +11:00
Campbell Barton
4d78211070 Cleanup: disambiguate naming for Wayland surfaces
Name surfaces for their use.
2022-11-01 11:32:17 +11:00