129 Commits

Author SHA1 Message Date
Aras Pranckevicius
facb17b0e3 Cleanup: BLI ENUM_OPERATORS cleanup/robustness
BLI code for enums that are meant to be used as "bit flags" defined
an ENUM_OPERATORS macro in BLI_utildefines.h. This cleans up things
related to said macro:

- Move it out into a separate BLI_enum_flags.hh header, instead of
  "random bag of things" that is the current place,
- Update it to no longer need manual indication of highest individual
  bit value. This originally was added in a31a87f89 (2020 Oct), in
  order to silence some UBSan warnings that were coming
  from GPU related structures (looking at current GPU code, I don't
  think this is happening anymore). However, that caused actual
  user-visible bugs due to incorrectly specified max. enum bit value,
  and today 14% of all usages have incorrect highest individual
  bit value spelled out.
    - I have reviewed all usages of operator ~ and none of them are
      used for directly producing a DNA-serialized value; all the
      usages are for masking out other bits for which the new ~
      behavior that just flips all bits is fine.
- Make the macro define flag_is_set() function to ease check of bits
  that are set in C++ enum class cases; update existing cases to use
  that instead of three other ways that were used.

Pull Request: https://projects.blender.org/blender/blender/pulls/148230
2025-10-17 12:57:50 +02:00
Campbell Barton
3349b97987 Core: add --no-window-frame command line option
Add a command line option to load Blender without a window frame.

Currently this is only used on Wayland, enabled for WITH_UI_TESTS since
attempting to load LIBDECOR caused the tests to crash on start on Fedora.
For tests there is no need to use LIBDECOR, so disable the window frame.
This can also be used by users who don't want to use the X11 fallback if
LIBDECOR can't be found.

Ref !147716
2025-10-13 09:47:07 +00:00
Hans Goudey
a68d39e9d9 Cleanup: Formatting
Run `make format` after the library update in the previous commit.
2025-10-02 12:55:42 -04:00
hogan.mastanduno
dde9d21b91 OpenXR: VR Advanced Locomotion Phase 1
Includes the following changes to the existing Locomotion system for VR Scene Inspection:
 * new VR Navigation Preferences and VR Session Settings
 * changes to XR raycast logic and its visualization
 * new XR vignette that appears when moving
 * snap turning

Pull Request: https://projects.blender.org/blender/blender/pulls/144241
2025-10-01 22:16:12 +02:00
Habib Gahbiche
bef15f0ec1 Fix #145633: Revert "Fix #144526: Crash on exit with Video_Editing template"
The fix introduced a high severity bug where exiting Blender after
working with the GPU compositor crashes Blender. We consider #144526 to
be less severe than the newly introduced bug, hence the revert for now.

This reverts commit b2b23e3619.

Pull Request: https://projects.blender.org/blender/blender/pulls/146096
2025-09-11 18:08:52 +02:00
Brecht Van Lommel
099ad9aee6 Refactor: Operator: Support properties dialog with message
Pull Request: https://projects.blender.org/blender/blender/pulls/145476
2025-09-05 19:03:19 +02:00
Harley Acheson
91997ea89f UI: Save Temp Window Sizes & Positions
Allow temporary windows (like File Browser, Preferences, Render,
Drivers, Info) to open at their last positions and sizes.

Pull Request: https://projects.blender.org/blender/blender/pulls/104727
2025-09-05 00:05:50 +02:00
Christoph Neuhauser
1e523e2f5d Fix #143653: Add use of Quality of Service (QoS) API on Windows
This PR adds code for setting the Quality of Service (QoS) level of the
process on Windows. This can, e.g., make sure that on hybrid systems
P-cores are utilized even when the app window is out of focus.

In the following cases, it is adjusted from the default behavior:
- In wm_jobs.cc the QoS level is raised while a priority job is running.
- The command line option `--qos [high|eco|default]` can be used to
  change the QoS level of the process.
- By default, the QoS level is raised for the EEVEE performance tests,
  as they check viewport rendering performance and would otherwise be
  reliant on never going out of focus to not get a downgraded QoS level.
  By default, they are created with an out of focus window at the time
  of landing this PR. This PR makes sure that they actually measure the
  animation replay performance attainable during real-world use.

Pull Request: https://projects.blender.org/blender/blender/pulls/144224
2025-09-01 11:19:17 +02:00
Brecht Van Lommel
20a19c7aa4 Vulkan: Tweaks to improve HDR display on Windows
* Improve accuracy of warning when HDR display is not supported, taking into
  account HDR mode on/off on Windows.
* When HDR mode is disabled on Windows, don't create a HDR swapchain. This
  saves memory, and avoids a color difference on NVIDIA. That's because NVIDIA
  is the only GPU we've tested that allows a HDR swapchain when HDR mode is
  off, and we don't currently know the expected transforms for that case.
* Recreate swapchain when HDR mode on/off switch is detected.
* Update HDR info when window gains focus.

Note this means there is no wide gamut when Windows HDR is off, but it was
already not working. For that we may need to add support for something like
10bit VK_COLOR_SPACE_DISPLAY_P3_NONLINEAR_EXT, or whatever is commonly
available outside of HDR mode.

Pull Request: https://projects.blender.org/blender/blender/pulls/144959
2025-08-28 11:03:24 +02:00
Campbell Barton
4c35ef7a7f Cleanup: rename function for removing handlers, use typed area argument 2025-08-22 19:40:29 +10:00
Miguel Pozo
b2b23e3619 Fix #144526: Crash on exit with Video_Editing template
The crash is caused by libepoxy GL functions pointing to nullptrs.
libepoxy "Automatically initializes as new GL functions are used.",
so to call a function without a GL context bound, the function must
have been called before with a bound context.

This PR ensures there's a valid GL context bound for the whole
`WM_exit` scope.

(4.5 backport candidate)

Pull Request: https://projects.blender.org/blender/blender/pulls/144572
2025-08-20 15:48:20 +02:00
Hans Goudey
56646137fe Refactor: Move some wmWindowManager runtime lists out of DNA
Mainly for the purpose of #127706, though there's plenty more runtime
data to move to the runtime struct out of DNA.

Pull Request: https://projects.blender.org/blender/blender/pulls/144691
2025-08-18 16:13:07 +02:00
Campbell Barton
2c27d2be54 Cleanup: grammar corrections, minor improvements to wording 2025-08-01 21:41:24 +10:00
Campbell Barton
d13540fe7d Cleanup: rename locked interface setting functions
Follow the convention of using terms such as get/set as a suffix.
2025-07-30 13:01:43 +10:00
Campbell Barton
ca0e6e77ec UI: improve percentage display for wm.progress API
wm.progress displayed a percentage in a cryptic
2x2 grid of numbers, so:

```
75
23
```

Represents `75.23%`. This is now shown as `75.23%`
on systems that support RGBA cursors.
2025-07-27 21:26:26 +10:00
Campbell Barton
ea99acb6a2 Fix #107021: Knife cursor lost after status bar pan
Check the modal cursor isn't set before overwriting it for 2D viewport
operators.

Match behavior for image & movie-clip navigation.
2025-07-24 04:37:34 +00:00
Campbell Barton
c52c8874e9 GHOST/Wayland: scalable vector cursor support via cursor-generators
Support showing vector cursors at the appropriate size based on each
monitors DPI.

This solves incorrectly sized cursors with Hi-DPI outputs as well as
supporting outputs with different DPI's.

Instead of passing pixel data, pass an object that can generate cursors,
GHOST/Wayland can then ensure the correct size is used based on the
display the cursor is shown on.

While may sound overly complicated it actually simplifies displaying
cursors on Wayland, especially for multiple monitors at different DPI's.
Showing cursors at higher or lower resolutions than the monitor's DPI
also behaves differently on GNOME & Plasma, resulting in situations
where the cursor would show larger/smaller than expected.

Details:

- Take advantage of the recently added SVG cursors & BLF time cursor
  !140990 & !141367.
- Setting bitmap cursors via GHOST_SetCustomCursorShape is now a no-op
  for Wayland since it's no longer used. This was supported in an
  earlier version of this PR and could be restored if needed.
- While fractional scaling works it relies on the compositor downscaling
  the cursors. Ideally they would be rendered at the target size but
  this isn't a priority as the difference isn't noticeable.

Ref !141597
2025-07-18 12:38:52 +10:00
Guillermo Venegas
1a247fbaa8 Refactor: WM: Make OperatorCallContext an enum class, move to namespace
This allows forward declaring `OpCallContext`, avoiding the
transitive include `WM_Types.hh` in `UI_interface_layout.hh`

Pull Request: https://projects.blender.org/blender/blender/pulls/141804
2025-07-15 03:08:04 +02:00
Jacques Lucke
00c81f5113 Merge branch 'blender-v4.5-release' 2025-07-14 16:30:38 +02:00
YimingWu
4096309753 Fix #141819: Interface Use a flag for WM_set_locked_interface
Different operations may need to lock different part of the interface,
e.g. for rendering, the image editor may still need refreshing while the
interface is locked, but when baking data into a scene, the image editor
needs to be locked because it is not thread safe to get data from a
partially evaluated depsgraph.

This is a better fix on top of 7c8b8b2457
that addresses the root cause with more flexibility for future
operations that requires different interface locking strategy as
well.

Pull Request: https://projects.blender.org/blender/blender/pulls/141866
2025-07-14 16:17:46 +02:00
Campbell Barton
566afb8201 WM: access the windows DPI directly to calculate the mouse-cursor scaling
Instead of relying on the the `U.ui_scale` being set when activating
the window, calculate the cursor size from the windows DPI.

This also de-duplicates cursor scale calculation.
2025-07-13 11:57:29 +10:00
Campbell Barton
41fc42697c Cleanup: rename WM_window_{set_dpi => dpi_set_userdef}
The name read as if it was setting the DPI however the window DPI
was being calculated and written into the #UserDef (U).
2025-07-13 11:31:41 +10:00
Campbell Barton
439253eab5 Cleanup: use consistent terms in capability flags
Consistently use terms "cursor" & "clipboard" as a prefix
so they auto-complete more usefully.

Previously both ordering was used.
2025-07-08 16:35:42 +10:00
Campbell Barton
12f0e3ee78 Merge branch 'blender-v4.5-release' 2025-07-08 10:38:10 +10:00
Campbell Barton
4431d7a369 Fix #141514: Broken cryptomatte picking with multi-windows on Wayland
Only perform window under cursor checks for GHOST back-ends that
have the window positioning capability.
2025-07-08 10:36:10 +10:00
Harley Acheson
ac457b9836 UI: SVG Icons as Internal Custom Mouse Cursors
This PR replaces our current custom mouse cursors (defined in
wm_cursors.cc using bitmaps and masks that we edit with a python
program) with SVG sources that are rasterized at the exact size when
needed. For Windows this would also replace the 29 platform-specific
"cur" files, although this PR does not actually remove those. For Linux
this creates the same kind of cursor as now (1bpp XBitMap) but at a
better size.

Pull Request: https://projects.blender.org/blender/blender/pulls/140990
2025-07-01 04:59:49 +02:00
Campbell Barton
06dfab455a Merge branch 'blender-v4.5-release' 2025-06-26 13:41:47 +10:00
Campbell Barton
582a54b94c NDOF: apply YZ axis swap to rotations
Apply the "Zoom direction" preference to the rotation axis.
Until now, this preference was limited to translations.

Note that the X/Y swap is now applied in the accessor functions instead
of wmNDOFMotionData::tvec because swapping the X/Y axis doesn't work
well in some cases (color picker for example), and it's confusing
of axis swapping is handled in different parts of the code for
rotation & translation.

Ref !140975

Co-authored-by: Patryk-Skowronski <patryk_skowronski@3dconnexion.com>
2025-06-26 03:23:25 +00:00
Campbell Barton
5d553e1dd0 Merge branch 'blender-v4.5-release' 2025-06-25 04:42:53 +00:00
Campbell Barton
2a757f469c Fix cursor size being ignored by custom cursors under Wayland
The theme cursor size was ignored when setting custom cursors
such as the knife, only the DPI from GHOST was taken into account.

This meant cursors such as the knife would sometimes display too small.

Now when the theme-size is larger, a larger cursor will be used.

Currently the theme size is read from XCURSOR_SIZE environment variable
however it may be read from the system preferences in the future.

Also fix the software cursor sizes which incorrectly used the UI scale
preference which is ignored by cursor sizes.
2025-06-25 04:39:57 +00:00
Campbell Barton
827fc096ae Merge branch 'blender-v4.5-release' 2025-06-21 16:51:08 +10:00
Campbell Barton
5280ebc289 NDOF: all spaces now follow the navigation mode preference
Restore expected behavior of the NDOF, especially in the context of
non-3D editors. It addresses the following issues:

- Object mode, 3D viewport:
  With "Lock Horizon" off, the rotation axes will invert unexpectedly,
  making the camera behave similar to a "Fly mode".

- Fly mode, 2D editors:
  Changing a navigation mode to "Fly" makes no effect.
  Applies to UV and Nodes editors, Camera Preview etc.

Related to #140165

This includes some minor API changes back-ported from `main`
since the PR was created for `main`.

Co-authored-by: Patryk-Skowronski <patryk_skowronski@3dconnexion.com>

Ref !140537
2025-06-21 16:38:51 +10:00
Campbell Barton
6046b81e21 Cleanup: various minor chances to the NDOF API
- Use return values for NDOF access functions.
- Pass in event data by const reference as this is never null.
- Don't scale the angle from WM_event_ndof_to_axis_angle by the time
  delta since other functions don't do this, it's strange to make
  this an exception.
- Replace the term "pan" with "translation" since pan in Blender
  typically refers to moving the view in 2D using cursor input,
  not 3D transaction.
- Use a more descriptive term "time_delta" for the time between NDOF
  motion events.
2025-06-14 04:48:21 +00:00
Campbell Barton
8cdccb0154 Refactor: improve error handling for the animation player
- Pass the exit code back from WM_main_playanim instead of calling exit.
- Errors are printed to the stderr.
- Resolve some leaks on exit.

Note that this addresses noisy leaks reported by ASAN which were
flooding the output, but doesn't attempt to address all leaks.
2025-06-10 13:49:41 +10:00
Kamil Galik
64696cc699 NDOF: simplify the UI and preferences
- Navigation modes has been redefined a bit and introduced in a form of
  an enum so that new ones can me implemented in the future.
  Additionally switching between modes shouldn't require any additional
  configurations like inverting all the axes.
  Currently there are only 2 modes implemented,
  but 2 more are planned and will be proposed in follow-up PRs.
  Implemented modes are:

  - Object: works like "Orbit" option.
    but has all axes implicitly inverted
  - Fly: works the same as "Free".

- "Turntable" option has been turned into "Lock Horizon".
  This single option works for both normal navigation and Fly/Walk
  modes now.
- Pan and Rotation axes inversion has been removed from default
  configuration.
- UI has been simplified following the design from #136880.
- Zoom Invert has been removed since it looks like a duplication of
  `NDOF_PANZ_INVERT`.

Ref !139343
2025-06-05 21:29:53 +10:00
Hans Goudey
91803e130f Cleanup: Grammar: Fix uses of "for e.g."
e.g. stands for "exempli gratia" in Latin which means "for example".
The best way to make sure it makes sense when writing is to just expand
it to "for example". In these cases where the text was "for e.g.", that
leaves us with "for for example" which makes no sense. This commit fixes
all 110 cases, mostly just just replacing the words with "for example",
but also restructuring the text a bit more in a few cases, mostly by
moving "e.g." to the beginning of a list in parentheses.

Pull Request: https://projects.blender.org/blender/blender/pulls/139596
2025-05-29 21:21:18 +02:00
Guillermo Venegas
38c08b515f UI: Allow drag multiple files from Blender File Browser
After c00c8b1b37 its possible to handle drag-n-drop with multiple
paths, this commit enables Blender internal File Browser to have
support to start drag events with multiple files.

Pull Request: https://projects.blender.org/blender/blender/pulls/116474
2025-05-08 23:56:38 +02:00
Campbell Barton
dbf6902a19 Fix #137314: Excluded directories ignored when opening from the splash
Regression in [0] which incorrectly swapped the check for the
`use_scripts` property being set with the value it was set to.

Resolve this error as well as the "Recover Last" operator
which never worked.

[0]: 8c688a052c
2025-04-13 12:25:44 +00:00
Sean Kim
5a5db5ea88 WM: Pass tablet tilt data to paint cursor draw callback
Part of #82877

When drawing specialized cursors for the different paint modes via the
`wmPaintCursor` draw callback, tablet tilt direction is unavailable to
use to customize the drawing for the user.

To enable this functionality, this commit adds the `x_tilt` and `y_tilt`
data read while processing MOUSEMOVE events to the `eventstate` variable
so it can be used by consuming functions.

Pull Request: https://projects.blender.org/blender/blender/pulls/137189
2025-04-09 23:07:03 +02:00
Campbell Barton
bcdcc3dbde Refactor: use enum types for event modifiers & types
Use enum types for event modifier and types,
`wmEventModifierFlag` & `wmEventType` respectively.

This helps with readability and avoids unintended mixing with other
types. To quiet GCC's `-Wswitch` warnings many `default` cases needed
to be added to switch statements on event types.

Ref !136759
2025-03-31 23:48:29 +00:00
Campbell Barton
38d9d971e5 WM: add a "Hyper" capability flag
Avoids the need to check against ghost backends.
2025-03-28 13:46:39 +11:00
Campbell Barton
2659ec12f5 Cleanup: replace int with wmOperatorStatus
Follow up to adding wmOperatorStatus, these cases were missed as they
didn't cause compiler warnings.
2025-03-21 08:34:21 +11:00
Campbell Barton
10233e95dd Cleanup: use a typed enum for operator & gizmo callbacks
Callbacks: exec invoke & modal now use a typed enum wmOperatorStatus.

This helps avoid mistakes returning incompatible booleans or other
values which don't make sense for operators to return.

It also makes it more obvious functions in the WM API are intended
to be used to calculate return values for operator callbacks.

Operator enums have been moved into DNA_windowmanager_enums.h
so this can be used in other headers without loading other includes
indirectly.

No functional changes expected.

Ref !136227
2025-03-20 21:11:06 +00:00
Julian Eisel
6c1c5e8923 Asset browser import settings popover with collection instancing option
Part of #134755 / #134766.

Adds options to the new Import Settings popover (added in 7a6beb65f4)
to toggle collection instancing for dragging in collections. It can be
toggled separately for linking and appending, since it's typical to use
instancing for linking, but not appending (current default, also with
this change).

Previously, toggling collection instancing was only possible via the
Adjust Last Operation panel but this wasn't obvious, many people were
not aware. Adding this option based on feedback by the Blender Studio.

Pull Request: https://projects.blender.org/blender/blender/pulls/135996
2025-03-20 18:44:24 +01:00
Sebastian Parborg
09ba1aabbd Refactor: Make the event queue only use runtime data.
Also make it more clear that some of the functions are internal
functions.

Pull Request: https://projects.blender.org/blender/blender/pulls/135181
2025-03-11 14:39:19 +01:00
Sebastian Parborg
ec29eb6580 Refactor: Make it more obvious that wm_event_add is not a static function
By renaming it to WM_ follow the other public functions.
2025-03-11 14:39:18 +01:00
Campbell Barton
bd06baf6e6 WM: rename WM_report* to WM_global_report*, note it's often bad practice
WM_report was originally added for special cases however new code
has been using this in operators for example, where reports should be
sent to the operator via BKE_report, so the caller can handle,
and so Python can catch the errors.

Rename the functions to make them less easily confused with BKE_report
and add a code-comment on why their use should be avoided.
2025-03-11 12:36:17 +11:00
Hans Goudey
d216476458 Cleanup: Use StringRef for UI search menu code
Also use Vector to store menu search items instead of a linked
list. And extend the change into the autocomplete API slightly.
The main benefit is to avoid measuring the length of strings over
and over, but the code also gets simpler.
2025-02-05 18:27:44 -05:00
Campbell Barton
4186175af8 Cleanup: improve code-comments & naming for window decoration styles
- Expand on the code-comment regarding tests & WM_capabilities_flag and
  move it from the caller into the functions body since this is useful
  for other callers, also mention in the doc-string.
- Use a common prefix for `WM_window_decoration_style_*` functions.
- Add a doxy-section for decoration style functions.
2025-02-05 10:56:54 +11:00
Campbell Barton
bc6dc89d50 Cleanup: quiet check_spelling_* warnings, use doxygen doc-strings 2025-02-05 10:29:00 +11:00