UwU 1 miesiąc temu
rodzic
commit
3171d38407
100 zmienionych plików z 566 dodań i 1253 usunięć
  1. 13 33
      CMakeLists.txt
  2. 116 128
      CMakeModules/DownloadCEF.cmake
  3. 1 2
      CMakeModules/FindFFMPEG.cmake
  4. 0 15
      CMakeModules/FindMPV.cmake
  5. 2 4
      src/WallpaperEngine/Application/ApplicationContext.cpp
  6. 16 50
      src/WallpaperEngine/Application/ApplicationContext.h
  7. 34 58
      src/WallpaperEngine/Application/WallpaperApplication.cpp
  8. 23 65
      src/WallpaperEngine/Application/WallpaperApplication.h
  9. 3 14
      src/WallpaperEngine/Audio/AudioContext.h
  10. 0 1
      src/WallpaperEngine/Audio/AudioStream.cpp
  11. 14 56
      src/WallpaperEngine/Audio/AudioStream.h
  12. 11 46
      src/WallpaperEngine/Audio/Drivers/AudioDriver.h
  13. 0 3
      src/WallpaperEngine/Audio/Drivers/Detectors/AudioPlayingDetector.h
  14. 3 11
      src/WallpaperEngine/Audio/Drivers/Detectors/HeadphonesDetector.h
  15. 1 2
      src/WallpaperEngine/Audio/Drivers/Detectors/PulseAudioPlayingDetector.cpp
  16. 2 4
      src/WallpaperEngine/Audio/Drivers/PulseProcessVolume.h
  17. 3 11
      src/WallpaperEngine/Audio/Drivers/Recorders/PlaybackRecorder.h
  18. 4 8
      src/WallpaperEngine/Audio/Drivers/Recorders/PulseAudioPlaybackRecorder.cpp
  19. 1 2
      src/WallpaperEngine/Audio/Drivers/Recorders/PulseAudioPlaybackRecorder.h
  20. 5 9
      src/WallpaperEngine/Audio/Drivers/SDLAudioDriver.cpp
  21. 2 5
      src/WallpaperEngine/Audio/Drivers/SDLAudioDriver.h
  22. 5 15
      src/WallpaperEngine/Audio/Hrtf.h
  23. 4 13
      src/WallpaperEngine/Audio/SpectrumAnalyzer.h
  24. 3 9
      src/WallpaperEngine/Audio/SpectrumProcessor.h
  25. 2 5
      src/WallpaperEngine/Data/Assets/Texture.h
  26. 1 6
      src/WallpaperEngine/Data/Builders/VectorBuilder.h
  27. 4 13
      src/WallpaperEngine/Data/JSON.h
  28. 1 3
      src/WallpaperEngine/Data/Model/Color.h
  29. 2 5
      src/WallpaperEngine/Data/Model/ImageAdjustments.h
  30. 2 4
      src/WallpaperEngine/Data/Model/Model.h
  31. 14 27
      src/WallpaperEngine/Data/Model/Object.h
  32. 4 10
      src/WallpaperEngine/Data/Model/Property.h
  33. 2 5
      src/WallpaperEngine/Data/Model/PropertyAnimation.h
  34. 2 7
      src/WallpaperEngine/Data/Model/UserSetting.h
  35. 2 3
      src/WallpaperEngine/Data/Parsers/DynamicValueParser.cpp
  36. 4 9
      src/WallpaperEngine/Data/Parsers/Localization.h
  37. 2 4
      src/WallpaperEngine/Data/Parsers/ObjectParser.cpp
  38. 1 5
      src/WallpaperEngine/Data/Utils/AudioSensitivity.h
  39. 1 4
      src/WallpaperEngine/Data/Utils/MemoryStream.h
  40. 0 4
      src/WallpaperEngine/Data/Utils/TypeCaster.h
  41. 7 13
      src/WallpaperEngine/Debugging/CallStack.cpp
  42. 5 5
      src/WallpaperEngine/Debugging/CallStack.h
  43. 2 4
      src/WallpaperEngine/Desktop/GnomeShell.h
  44. 2 3
      src/WallpaperEngine/Desktop/HostWayland.cpp
  45. 3 7
      src/WallpaperEngine/Desktop/HostWayland.h
  46. 3 6
      src/WallpaperEngine/Desktop/HyprlandIPC.h
  47. 2 4
      src/WallpaperEngine/Desktop/SessionBus.h
  48. 2 5
      src/WallpaperEngine/Desktop/UserShortcut.cpp
  49. 3 6
      src/WallpaperEngine/Desktop/UserShortcut.h
  50. 4 5
      src/WallpaperEngine/FileSystem/Adapters/Types.h
  51. 1 5
      src/WallpaperEngine/FileSystem/Container.cpp
  52. 2 14
      src/WallpaperEngine/FileSystem/Container.h
  53. 1 1
      src/WallpaperEngine/Input/Drivers/GLFWMouseInput.cpp
  54. 2 5
      src/WallpaperEngine/Input/Drivers/KDECursorInput.h
  55. 1 2
      src/WallpaperEngine/Input/Drivers/WaylandMouseInput.h
  56. 2 12
      src/WallpaperEngine/Input/MouseInput.h
  57. 2 10
      src/WallpaperEngine/Media/MediaSource.h
  58. 3 10
      src/WallpaperEngine/Media/ThumbnailPalette.h
  59. 2 4
      src/WallpaperEngine/Render/CFBO.cpp
  60. 1 4
      src/WallpaperEngine/Render/CFBO.h
  61. 2 5
      src/WallpaperEngine/Render/CTexture.h
  62. 4 8
      src/WallpaperEngine/Render/CWallpaper.cpp
  63. 10 25
      src/WallpaperEngine/Render/CWallpaper.h
  64. 6 19
      src/WallpaperEngine/Render/Camera.h
  65. 2 5
      src/WallpaperEngine/Render/Drivers/Detectors/WaylandFullScreenDetector.h
  66. 1 4
      src/WallpaperEngine/Render/Drivers/Detectors/X11FullScreenDetector.cpp
  67. 1 2
      src/WallpaperEngine/Render/Drivers/GLFWOpenGLDriver.cpp
  68. 2 4
      src/WallpaperEngine/Render/Drivers/HeadlessOpenGLDriver.cpp
  69. 2 6
      src/WallpaperEngine/Render/Drivers/HeadlessOpenGLDriver.h
  70. 1 2
      src/WallpaperEngine/Render/Drivers/Output/GLFWWindowOutput.cpp
  71. 3 5
      src/WallpaperEngine/Render/Drivers/Output/WaylandOutputViewport.cpp
  72. 3 8
      src/WallpaperEngine/Render/Drivers/Output/X11Output.cpp
  73. 2 5
      src/WallpaperEngine/Render/Drivers/Output/X11Output.h
  74. 1 4
      src/WallpaperEngine/Render/Drivers/VideoDriver.h
  75. 1 2
      src/WallpaperEngine/Render/Drivers/VideoFactories.cpp
  76. 5 8
      src/WallpaperEngine/Render/Drivers/WaylandOpenGLDriver.cpp
  77. 5 10
      src/WallpaperEngine/Render/GifAnimation.h
  78. 1 3
      src/WallpaperEngine/Render/ImageDecoder.h
  79. 2 5
      src/WallpaperEngine/Render/ModelData.h
  80. 3 9
      src/WallpaperEngine/Render/Objects/CCamera.h
  81. 24 59
      src/WallpaperEngine/Render/Objects/CImage.cpp
  82. 4 10
      src/WallpaperEngine/Render/Objects/CImage.h
  83. 4 5
      src/WallpaperEngine/Render/Objects/CMesh.cpp
  84. 6 14
      src/WallpaperEngine/Render/Objects/CMesh.h
  85. 25 51
      src/WallpaperEngine/Render/Objects/CParticle.cpp
  86. 5 9
      src/WallpaperEngine/Render/Objects/CParticle.h
  87. 2 5
      src/WallpaperEngine/Render/Objects/CRenderable.h
  88. 3 8
      src/WallpaperEngine/Render/Objects/CSound.h
  89. 13 21
      src/WallpaperEngine/Render/Objects/CText.cpp
  90. 2 6
      src/WallpaperEngine/Render/Objects/CText.h
  91. 21 32
      src/WallpaperEngine/Render/Objects/Effects/CPass.cpp
  92. 7 19
      src/WallpaperEngine/Render/Objects/Effects/CPass.h
  93. 3 9
      src/WallpaperEngine/Render/Objects/PuppetClipping.h
  94. 4 9
      src/WallpaperEngine/Render/Objects/PuppetPhysics.h
  95. 12 22
      src/WallpaperEngine/Render/Objects/PuppetRig.cpp
  96. 3 9
      src/WallpaperEngine/Render/Objects/PuppetRig.h
  97. 5 12
      src/WallpaperEngine/Render/Objects/PuppetRootMotion.h
  98. 2 3
      src/WallpaperEngine/Render/Objects/TextLayout.cpp
  99. 3 6
      src/WallpaperEngine/Render/Objects/TextLayout.h
  100. 1 2
      src/WallpaperEngine/Render/RenderContext.cpp

+ 13 - 33
CMakeLists.txt

@@ -17,7 +17,7 @@ if(NOT DEMOMODE)
     set(DEMOMODE 0)
 endif()
 
-# if you're developing you might find this debug option useful for shader output, although RenderDoc is encouraged
+# verbose shader output for debugging, RenderDoc is usually the better tool
 if(NOT ERRORONLY)
     set(ERRORONLY 0)
 endif()
@@ -39,7 +39,7 @@ find_package(PulseAudio REQUIRED)
 find_package(Freetype REQUIRED)
 find_package(PkgConfig REQUIRED)
 pkg_check_modules(HARFBUZZ REQUIRED IMPORTED_TARGET harfbuzz)
-# scene scripts run on V8 like Wallpaper Engine's scenescript64.dll, taken from the system's Node.js library
+# scene scripts run on V8 from the system's Node.js library, like WE's scenescript64.dll
 find_package(V8 10.2 REQUIRED)
 
 set(ENABLE_OPT OFF)
@@ -48,11 +48,8 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
 set(KISSFFT_TEST OFF)
 set(KISSFFT_TOOLS OFF)
 
-# Download CEF of specified version for current platform
 set(CEF_VERSION "135.0.17+gcbc1c5b+chromium-135.0.7049.52")
-# CEF_DISTRIBUTION_TYPE default value should be different based on the type of build
-# debug builds should use standard versions
-# while release version can do with the minimal version
+# debug builds use the standard CEF distribution, release builds the minimal one
 if(CMAKE_BUILD_TYPE STREQUAL "Debug")
     set(default_cef_dist "standard")
 else()
@@ -115,12 +112,11 @@ message(STATUS "Using CEF for ${CMAKE_SYSTEM_NAME} - ${CEF_PLATFORM} (${CEF_ARCH
 include(DownloadCEF)
 DownloadCEF("${CEF_PLATFORM}" "${CEF_VERSION}" "${CMAKE_CURRENT_BINARY_DIR}/cef")
 
-# add cef's cmake files to the lookup so we can use those directly
 list(APPEND CMAKE_MODULE_PATH "${CEF_ROOT}/cmake")
 
 find_package(CEF REQUIRED)
 
-# remove some switches that forbid us from using things that are commonplace in our codebase
+# drop CEF switches our code can't build with
 list(REMOVE_ITEM CEF_CXX_COMPILER_FLAGS -fno-exceptions)
 list(REMOVE_ITEM CEF_CXX_COMPILER_FLAGS -fno-rtti)
 list(REMOVE_ITEM CEF_CXX_COMPILER_FLAGS -std=c++17)
@@ -135,9 +131,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/output)
 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
 set(TARGET_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/output)
 
-# RPATH configuration: use build directories during development, but $ORIGIN after installation
-# NOTE: \$ORIGIN must be escaped because CMake treats $VAR as variable expansion.
-# IMPORTANT: This must be set BEFORE any add_executable()/add_library() calls in this directory.
+# build dirs as RPATH during development, \$ORIGIN once installed (escaped for CMake); must come before any add_executable()
 set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
 set(CMAKE_INSTALL_RPATH "\$ORIGIN;\$ORIGIN/lib;\$ORIGIN/lib64")
 set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
@@ -149,7 +143,7 @@ set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
 add_subdirectory(src/External/SPIRV-Cross-WallpaperEngine spirv-cross)
 add_subdirectory(src/External/kissfft kissfft)
 unset(CMAKE_POLICY_DEFAULT_CMP0077)
-# only msdfgen's core is needed (text MSDF glyphs), its own CMake project wants vcpkg/skia/tinyxml for the rest
+# only msdfgen's core is needed, its own CMake project pulls in vcpkg/skia/tinyxml
 file(GLOB MSDFGEN_CORE_SOURCES src/External/msdfgen/core/*.cpp)
 add_library(msdfgen-core STATIC ${MSDFGEN_CORE_SOURCES})
 target_include_directories(msdfgen-core PUBLIC src/External/msdfgen)
@@ -159,7 +153,6 @@ add_subdirectory(src/External/argparse argparse)
 if(BUILD_TESTING)
     add_subdirectory(src/External/Catch2)
 endif()
-# try to enable wayland builds when possible
 pkg_check_modules(WAYLAND_SUPPORT wayland-cursor wayland-protocols egl wayland-egl)
 option(DISABLE_KDE_FEATURES "Build without the KDE Plasma integration (plasma-shell surfaces, KWin fullscreen detection and cursor tracking)" OFF)
 
@@ -319,10 +312,7 @@ set_target_properties(ceflib
 ADD_LOGICAL_TARGET(libcef_lib "${CEF_LIB_DEBUG}" "${CEF_LIB_RELEASE}")
 PRINT_CEF_CONFIG()
 
-# Embed scene-script builtins (builtins.js) into a generated header, so the JS can
-# live in its own file (lint/syntax-highlight friendly) instead of an inline literal.
-# Added to the global include_directories so both the library and the tests target
-# (which recompiles the common sources) can find the generated header.
+# builtins.js embedded into a generated header, on the global include path so tests find it too
 set(WPENGINE_GENERATED_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated")
 set(WPENGINE_BUILTINS_JS "${CMAKE_CURRENT_SOURCE_DIR}/src/WallpaperEngine/Scripting/resources/builtins.js")
 file(READ "${WPENGINE_BUILTINS_JS}" WPENGINE_SCRIPT_BUILTINS)
@@ -333,8 +323,7 @@ configure_file(
 # re-run configuration (regenerating the header) whenever the .js changes
 set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${WPENGINE_BUILTINS_JS}")
 
-# OpenAL Soft 1.21.1's built-in HRTF data set (hrtf/Default HRTF.mhr, MIT KEMAR based), the same bytes WE's
-# mediaextensions64.dll embeds, as a byte array for the sound objects' headphones rendering
+# OpenAL Soft's default HRTF data set (the same bytes WE embeds) as a byte array
 set(WPENGINE_DEFAULT_HRTF "${CMAKE_CURRENT_SOURCE_DIR}/src/WallpaperEngine/Audio/resources/default_hrtf.mhr")
 file(READ "${WPENGINE_DEFAULT_HRTF}" WPENGINE_DEFAULT_HRTF_HEX HEX)
 string(REGEX REPLACE "([0-9a-f][0-9a-f])" "0x\\1," WPENGINE_DEFAULT_HRTF_BYTES "${WPENGINE_DEFAULT_HRTF_HEX}")
@@ -803,7 +792,6 @@ target_compile_definitions(linux-wallpaperengine-lib PUBLIC ERRORONLY=${ERRORONL
 target_compile_definitions(linux-wallpaperengine-lib PUBLIC DEMOMODE=${DEMOMODE})
 
 if (BUILD_TESTING)
-    # tests should give as much output as possible
     target_compile_definitions(tests PRIVATE ERRORONLY=0)
     target_compile_definitions(tests PRIVATE DEMOMODE=0)
 endif()
@@ -811,7 +799,6 @@ endif()
 if(X11_SUPPORT_FOUND)
     target_compile_definitions(linux-wallpaperengine-lib PUBLIC ENABLE_X11)
 
-    # make sure some of the X11 functions we'll use are available
     check_function_exists(XSetIOErrorExitHandler HAVE_XSETIOERROREXITHANDLER)
 
     if(HAVE_XSETIOERROREXITHANDLER)
@@ -859,16 +846,14 @@ set_target_properties(linux-wallpaperengine-lib PROPERTIES
     LIBRARY_OUTPUT_DIRECTORY ${TARGET_OUTPUT_DIRECTORY})
 
 add_dependencies(linux-wallpaperengine-lib libcef_dll_wrapper glslang spirv-cross-core spirv-cross-glsl)
-# custom version of cef's SET_EXECUTABLE_TARGET_PROPERTIES that fixes C files being compiled with the wrong parameters
+# CEF's SET_EXECUTABLE_TARGET_PROPERTIES without C++ flags on C files
 REPLACED_SET_EXECUTABLE_TARGET_PROPERTIES(linux-wallpaperengine-lib)
 
 add_executable(linux-wallpaperengine
     src/main.cpp)
 
 target_link_libraries (linux-wallpaperengine PUBLIC linux-wallpaperengine-lib)
-# libcef has to load before libc: Chromium's close() wrapper finds libc's with dlsym (RTLD_NEXT), which only searches
-# the objects after libcef. Debian and Ubuntu link --as-needed by default, which dropped the direct dependency and left
-# libcef behind libc, so the web host aborted with "close symbol missing" (portable release, Flatpak, Debian builds)
+# libcef has to load before libc (Chromium finds close() via RTLD_NEXT), --as-needed distros dropped the dependency
 target_link_options (linux-wallpaperengine PRIVATE -Wl,--no-as-needed)
 
 # Chromium child processes of the web host, only libcef and the page shim
@@ -888,8 +873,7 @@ target_link_libraries(linux-wallpaperengine-web-helper PRIVATE
 add_dependencies(linux-wallpaperengine-web-helper libcef_dll_wrapper)
 REPLACED_SET_EXECUTABLE_TARGET_PROPERTIES(linux-wallpaperengine-web-helper)
 
-# GNOME 45-48: started by the Shell extension so our windows belong to a Shell-spawned client; static so it also
-# runs on the host for Flatpak builds
+# GNOME 45-48 helper spawned by the Shell extension, static so it also runs on the host for Flatpak
 include(CheckCSourceCompiles)
 set(CMAKE_REQUIRED_LINK_OPTIONS -static)
 check_c_source_compiles("int main(void) { return 0; }" LWE_CAN_LINK_STATIC)
@@ -908,8 +892,7 @@ add_custom_target(gnome-shell-extension ALL
 add_dependencies(gnome-shell-extension linux-wallpaperengine-gnome-helper)
 add_dependencies(linux-wallpaperengine gnome-shell-extension)
 
-# Install the main executable and shared library via install(TARGETS)
-# so that CMake automatically strips/replaces the build-time RPATH.
+# install(TARGETS) so CMake replaces the build-time RPATH
 install(TARGETS linux-wallpaperengine linux-wallpaperengine-web-helper
     RUNTIME DESTINATION .
 )
@@ -917,10 +900,7 @@ install(TARGETS linux-wallpaperengine-lib
     LIBRARY DESTINATION .
 )
 
-# Install everything else from the output directory (CEF resources, helper binaries, etc.)
-# but exclude the files already handled by install(TARGETS) above.
-# the icon and a hidden desktop entry, which gives windows of the engine (app id and X11 class linux-wallpaperengine)
-# their icon
+# icon and a hidden desktop entry for the engine's windows
 install(DIRECTORY resources/icons/hicolor DESTINATION share/icons)
 install(FILES resources/linux-wallpaperengine.desktop DESTINATION share/applications)
 

+ 116 - 128
CMakeModules/DownloadCEF.cmake

@@ -1,128 +1,116 @@
-# Copyright (c) 2016 The Chromium Embedded Framework Authors. All rights
-# reserved. Use of this source code is governed by a BSD-style license that
-# can be found in the LICENSE file.
-
-# Download the CEF binary distribution for |platform| and |version| to
-# |download_dir|. The |CEF_ROOT| variable will be set in global scope pointing
-# to the extracted location.
-# Visit https://cef-builds.spotifycdn.com/index.html for the list of
-# supported platforms and versions.
-
-function(DownloadCEF platform version download_dir)
-  # Specify the binary distribution type and download directory.
-  set(CEF_DISTRIBUTION "cef_binary_${version}_${platform}")
-  set(CEF_DOWNLOAD_DIR "${download_dir}")
-
-  # The location where we expect the extracted binary distribution.
-  set(CEF_ROOT "${CEF_DOWNLOAD_DIR}/${CEF_DISTRIBUTION}" CACHE INTERNAL "CEF_ROOT")
-
-  # Download and/or extract the binary distribution if necessary.
-  if(NOT IS_DIRECTORY "${CEF_ROOT}")
-    set(CEF_DOWNLOAD_FILENAME "${CEF_DISTRIBUTION}.tar.bz2")
-    set(CEF_DOWNLOAD_PATH "${CEF_DOWNLOAD_DIR}/${CEF_DOWNLOAD_FILENAME}")
-    if(NOT EXISTS "${CEF_DOWNLOAD_PATH}")
-      set(CEF_DOWNLOAD_URL "https://cef-builds.spotifycdn.com/${CEF_DOWNLOAD_FILENAME}")
-      string(REPLACE "+" "%2B" CEF_DOWNLOAD_URL_ESCAPED ${CEF_DOWNLOAD_URL})
-
-      # Download the SHA1 hash for the binary distribution.
-      message(STATUS "Downloading ${CEF_DOWNLOAD_PATH}.sha1 from ${CEF_DOWNLOAD_URL_ESCAPED}...")
-      file(DOWNLOAD "${CEF_DOWNLOAD_URL_ESCAPED}.sha1" "${CEF_DOWNLOAD_PATH}.sha1")
-      file(READ "${CEF_DOWNLOAD_PATH}.sha1" CEF_SHA1)
-
-      # Download the binary distribution and verify the hash.
-      message(STATUS "Downloading ${CEF_DOWNLOAD_PATH}...")
-      file(
-        DOWNLOAD "${CEF_DOWNLOAD_URL_ESCAPED}" "${CEF_DOWNLOAD_PATH}"
-        EXPECTED_HASH SHA1=${CEF_SHA1}
-        SHOW_PROGRESS
-        )
-    endif()
-
-    # Extract the binary distribution.
-    message(STATUS "Extracting ${CEF_DOWNLOAD_PATH}...")
-    execute_process(
-      COMMAND ${CMAKE_COMMAND} -E tar xzf "${CEF_DOWNLOAD_DIR}/${CEF_DOWNLOAD_FILENAME}"
-      WORKING_DIRECTORY ${CEF_DOWNLOAD_DIR}
-      )
-  endif()
-endfunction()
-
-
-# Set common target properties. Use SET_LIBRARY_TARGET_PROPERTIES() or
-# SET_EXECUTABLE_TARGET_PROPERTIES() instead of calling this macro directly.
-macro(REPLACED_SET_COMMON_TARGET_PROPERTIES target)
-  # Compile flags. (MODIFIED FOR C/C++ SEPARATION)
-  target_compile_options(${target} PRIVATE $<$<COMPILE_LANGUAGE:C>:${CEF_COMPILER_FLAGS} ${CEF_C_COMPILER_FLAGS}>)
-  target_compile_options(${target} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:${CEF_COMPILER_FLAGS} ${CEF_CXX_COMPILER_FLAGS}>)
-  target_compile_options(${target} PRIVATE $<$<CONFIG:Debug>:${CEF_COMPILER_FLAGS_DEBUG} ${CEF_CXX_COMPILER_FLAGS_DEBUG}>)
-  target_compile_options(${target} PRIVATE $<$<CONFIG:Release>:${CEF_COMPILER_FLAGS_RELEASE} ${CEF_CXX_COMPILER_FLAGS_RELEASE}>)
-
-  # Compile definitions.
-  target_compile_definitions(${target} PRIVATE ${CEF_COMPILER_DEFINES})
-  target_compile_definitions(${target} PRIVATE $<$<CONFIG:Debug>:${CEF_COMPILER_DEFINES_DEBUG}>)
-  target_compile_definitions(${target} PRIVATE $<$<CONFIG:Release>:${CEF_COMPILER_DEFINES_RELEASE}>)
-
-  # Include directories.
-  target_include_directories(${target} PRIVATE ${CEF_INCLUDE_PATH})
-
-  # Linker flags.
-  if(CEF_LINKER_FLAGS)
-    string(REPLACE ";" " " _flags_str "${CEF_LINKER_FLAGS}")
-    set_property(TARGET ${target} PROPERTY LINK_FLAGS ${_flags_str})
-  endif()
-  if(CEF_LINKER_FLAGS_DEBUG)
-    string(REPLACE ";" " " _flags_str "${CEF_LINKER_FLAGS_DEBUG}")
-    set_property(TARGET ${target} PROPERTY LINK_FLAGS_DEBUG ${_flags_str})
-  endif()
-  if(CEF_LINKER_FLAGS_RELEASE)
-    string(REPLACE ";" " " _flags_str "${CEF_LINKER_FLAGS_RELEASE}")
-    set_property(TARGET ${target} PROPERTY LINK_FLAGS_RELEASE ${_flags_str})
-  endif()
-
-  if(OS_MAC)
-    # Set Xcode target properties.
-    set_target_properties(${target} PROPERTIES
-            XCODE_ATTRIBUTE_ALWAYS_SEARCH_USER_PATHS                    NO
-            XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD                 "gnu++11"   # -std=gnu++11
-            XCODE_ATTRIBUTE_CLANG_LINK_OBJC_RUNTIME                     NO          # -fno-objc-link-runtime
-            XCODE_ATTRIBUTE_CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS  YES         # -Wobjc-missing-property-synthesis
-            XCODE_ATTRIBUTE_COPY_PHASE_STRIP                            NO
-            XCODE_ATTRIBUTE_DEAD_CODE_STRIPPING[variant=Release]        YES         # -Wl,-dead_strip
-            XCODE_ATTRIBUTE_GCC_C_LANGUAGE_STANDARD                     "c99"       # -std=c99
-            XCODE_ATTRIBUTE_GCC_CW_ASM_SYNTAX                           NO          # No -fasm-blocks
-            XCODE_ATTRIBUTE_GCC_DYNAMIC_NO_PIC                          NO
-            XCODE_ATTRIBUTE_GCC_ENABLE_CPP_EXCEPTIONS                   NO          # -fno-exceptions
-            XCODE_ATTRIBUTE_GCC_ENABLE_CPP_RTTI                         NO          # -fno-rtti
-            XCODE_ATTRIBUTE_GCC_ENABLE_PASCAL_STRINGS                   NO          # No -mpascal-strings
-            XCODE_ATTRIBUTE_GCC_INLINES_ARE_PRIVATE_EXTERN              YES         # -fvisibility-inlines-hidden
-            XCODE_ATTRIBUTE_GCC_OBJC_CALL_CXX_CDTORS                    YES         # -fobjc-call-cxx-cdtors
-            XCODE_ATTRIBUTE_GCC_SYMBOLS_PRIVATE_EXTERN                  YES         # -fvisibility=hidden
-            XCODE_ATTRIBUTE_GCC_THREADSAFE_STATICS                      NO          # -fno-threadsafe-statics
-            XCODE_ATTRIBUTE_GCC_TREAT_WARNINGS_AS_ERRORS                YES         # -Werror
-            XCODE_ATTRIBUTE_GCC_VERSION                                 "com.apple.compilers.llvm.clang.1_0"
-            XCODE_ATTRIBUTE_GCC_WARN_ABOUT_MISSING_NEWLINE              YES         # -Wnewline-eof
-            XCODE_ATTRIBUTE_USE_HEADERMAP                               NO
-            OSX_ARCHITECTURES_DEBUG                                     "${CMAKE_OSX_ARCHITECTURES}"
-            OSX_ARCHITECTURES_RELEASE                                   "${CMAKE_OSX_ARCHITECTURES}"
-    )
-  endif()
-endmacro()
-
-# Set executable-specific properties.
-macro(REPLACED_SET_EXECUTABLE_TARGET_PROPERTIES target)
-  REPLACED_SET_COMMON_TARGET_PROPERTIES(${target})
-
-  # Executable linker flags.
-  if(CEF_EXE_LINKER_FLAGS)
-    string(REPLACE ";" " " _flags_str "${CEF_EXE_LINKER_FLAGS}")
-    set_property(TARGET ${target} PROPERTY LINK_FLAGS ${_flags_str})
-  endif()
-  if(CEF_EXE_LINKER_FLAGS_DEBUG)
-    string(REPLACE ";" " " _flags_str "${CEF_EXE_LINKER_FLAGS_DEBUG}")
-    set_property(TARGET ${target} PROPERTY LINK_FLAGS_DEBUG ${_flags_str})
-  endif()
-  if(CEF_EXE_LINKER_FLAGS_RELEASE)
-    string(REPLACE ";" " " _flags_str "${CEF_EXE_LINKER_FLAGS_RELEASE}")
-    set_property(TARGET ${target} PROPERTY LINK_FLAGS_RELEASE ${_flags_str})
-  endif()
-endmacro()
+# Copyright (c) 2016 The Chromium Embedded Framework Authors. All rights
+# reserved. Use of this source code is governed by a BSD-style license that
+# can be found in the LICENSE file.
+
+# Download the CEF binary distribution for |platform| and |version| to
+# |download_dir|. The |CEF_ROOT| variable will be set in global scope pointing
+# to the extracted location.
+# Visit https://cef-builds.spotifycdn.com/index.html for the list of
+# supported platforms and versions.
+
+function(DownloadCEF platform version download_dir)
+  set(CEF_DISTRIBUTION "cef_binary_${version}_${platform}")
+  set(CEF_DOWNLOAD_DIR "${download_dir}")
+
+  set(CEF_ROOT "${CEF_DOWNLOAD_DIR}/${CEF_DISTRIBUTION}" CACHE INTERNAL "CEF_ROOT")
+
+  if(NOT IS_DIRECTORY "${CEF_ROOT}")
+    set(CEF_DOWNLOAD_FILENAME "${CEF_DISTRIBUTION}.tar.bz2")
+    set(CEF_DOWNLOAD_PATH "${CEF_DOWNLOAD_DIR}/${CEF_DOWNLOAD_FILENAME}")
+    if(NOT EXISTS "${CEF_DOWNLOAD_PATH}")
+      set(CEF_DOWNLOAD_URL "https://cef-builds.spotifycdn.com/${CEF_DOWNLOAD_FILENAME}")
+      string(REPLACE "+" "%2B" CEF_DOWNLOAD_URL_ESCAPED ${CEF_DOWNLOAD_URL})
+
+      message(STATUS "Downloading ${CEF_DOWNLOAD_PATH}.sha1 from ${CEF_DOWNLOAD_URL_ESCAPED}...")
+      file(DOWNLOAD "${CEF_DOWNLOAD_URL_ESCAPED}.sha1" "${CEF_DOWNLOAD_PATH}.sha1")
+      file(READ "${CEF_DOWNLOAD_PATH}.sha1" CEF_SHA1)
+
+      message(STATUS "Downloading ${CEF_DOWNLOAD_PATH}...")
+      file(
+        DOWNLOAD "${CEF_DOWNLOAD_URL_ESCAPED}" "${CEF_DOWNLOAD_PATH}"
+        EXPECTED_HASH SHA1=${CEF_SHA1}
+        SHOW_PROGRESS
+        )
+    endif()
+
+    message(STATUS "Extracting ${CEF_DOWNLOAD_PATH}...")
+    execute_process(
+      COMMAND ${CMAKE_COMMAND} -E tar xzf "${CEF_DOWNLOAD_DIR}/${CEF_DOWNLOAD_FILENAME}"
+      WORKING_DIRECTORY ${CEF_DOWNLOAD_DIR}
+      )
+  endif()
+endfunction()
+
+
+# Set common target properties. Use SET_LIBRARY_TARGET_PROPERTIES() or
+# SET_EXECUTABLE_TARGET_PROPERTIES() instead of calling this macro directly.
+macro(REPLACED_SET_COMMON_TARGET_PROPERTIES target)
+  # separate C and C++ flags (modified from CEF)
+  target_compile_options(${target} PRIVATE $<$<COMPILE_LANGUAGE:C>:${CEF_COMPILER_FLAGS} ${CEF_C_COMPILER_FLAGS}>)
+  target_compile_options(${target} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:${CEF_COMPILER_FLAGS} ${CEF_CXX_COMPILER_FLAGS}>)
+  target_compile_options(${target} PRIVATE $<$<CONFIG:Debug>:${CEF_COMPILER_FLAGS_DEBUG} ${CEF_CXX_COMPILER_FLAGS_DEBUG}>)
+  target_compile_options(${target} PRIVATE $<$<CONFIG:Release>:${CEF_COMPILER_FLAGS_RELEASE} ${CEF_CXX_COMPILER_FLAGS_RELEASE}>)
+
+  target_compile_definitions(${target} PRIVATE ${CEF_COMPILER_DEFINES})
+  target_compile_definitions(${target} PRIVATE $<$<CONFIG:Debug>:${CEF_COMPILER_DEFINES_DEBUG}>)
+  target_compile_definitions(${target} PRIVATE $<$<CONFIG:Release>:${CEF_COMPILER_DEFINES_RELEASE}>)
+
+  target_include_directories(${target} PRIVATE ${CEF_INCLUDE_PATH})
+
+  if(CEF_LINKER_FLAGS)
+    string(REPLACE ";" " " _flags_str "${CEF_LINKER_FLAGS}")
+    set_property(TARGET ${target} PROPERTY LINK_FLAGS ${_flags_str})
+  endif()
+  if(CEF_LINKER_FLAGS_DEBUG)
+    string(REPLACE ";" " " _flags_str "${CEF_LINKER_FLAGS_DEBUG}")
+    set_property(TARGET ${target} PROPERTY LINK_FLAGS_DEBUG ${_flags_str})
+  endif()
+  if(CEF_LINKER_FLAGS_RELEASE)
+    string(REPLACE ";" " " _flags_str "${CEF_LINKER_FLAGS_RELEASE}")
+    set_property(TARGET ${target} PROPERTY LINK_FLAGS_RELEASE ${_flags_str})
+  endif()
+
+  if(OS_MAC)
+    set_target_properties(${target} PROPERTIES
+            XCODE_ATTRIBUTE_ALWAYS_SEARCH_USER_PATHS                    NO
+            XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD                 "gnu++11"   # -std=gnu++11
+            XCODE_ATTRIBUTE_CLANG_LINK_OBJC_RUNTIME                     NO          # -fno-objc-link-runtime
+            XCODE_ATTRIBUTE_CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS  YES         # -Wobjc-missing-property-synthesis
+            XCODE_ATTRIBUTE_COPY_PHASE_STRIP                            NO
+            XCODE_ATTRIBUTE_DEAD_CODE_STRIPPING[variant=Release]        YES         # -Wl,-dead_strip
+            XCODE_ATTRIBUTE_GCC_C_LANGUAGE_STANDARD                     "c99"       # -std=c99
+            XCODE_ATTRIBUTE_GCC_CW_ASM_SYNTAX                           NO          # No -fasm-blocks
+            XCODE_ATTRIBUTE_GCC_DYNAMIC_NO_PIC                          NO
+            XCODE_ATTRIBUTE_GCC_ENABLE_CPP_EXCEPTIONS                   NO          # -fno-exceptions
+            XCODE_ATTRIBUTE_GCC_ENABLE_CPP_RTTI                         NO          # -fno-rtti
+            XCODE_ATTRIBUTE_GCC_ENABLE_PASCAL_STRINGS                   NO          # No -mpascal-strings
+            XCODE_ATTRIBUTE_GCC_INLINES_ARE_PRIVATE_EXTERN              YES         # -fvisibility-inlines-hidden
+            XCODE_ATTRIBUTE_GCC_OBJC_CALL_CXX_CDTORS                    YES         # -fobjc-call-cxx-cdtors
+            XCODE_ATTRIBUTE_GCC_SYMBOLS_PRIVATE_EXTERN                  YES         # -fvisibility=hidden
+            XCODE_ATTRIBUTE_GCC_THREADSAFE_STATICS                      NO          # -fno-threadsafe-statics
+            XCODE_ATTRIBUTE_GCC_TREAT_WARNINGS_AS_ERRORS                YES         # -Werror
+            XCODE_ATTRIBUTE_GCC_VERSION                                 "com.apple.compilers.llvm.clang.1_0"
+            XCODE_ATTRIBUTE_GCC_WARN_ABOUT_MISSING_NEWLINE              YES         # -Wnewline-eof
+            XCODE_ATTRIBUTE_USE_HEADERMAP                               NO
+            OSX_ARCHITECTURES_DEBUG                                     "${CMAKE_OSX_ARCHITECTURES}"
+            OSX_ARCHITECTURES_RELEASE                                   "${CMAKE_OSX_ARCHITECTURES}"
+    )
+  endif()
+endmacro()
+
+macro(REPLACED_SET_EXECUTABLE_TARGET_PROPERTIES target)
+  REPLACED_SET_COMMON_TARGET_PROPERTIES(${target})
+
+  if(CEF_EXE_LINKER_FLAGS)
+    string(REPLACE ";" " " _flags_str "${CEF_EXE_LINKER_FLAGS}")
+    set_property(TARGET ${target} PROPERTY LINK_FLAGS ${_flags_str})
+  endif()
+  if(CEF_EXE_LINKER_FLAGS_DEBUG)
+    string(REPLACE ";" " " _flags_str "${CEF_EXE_LINKER_FLAGS_DEBUG}")
+    set_property(TARGET ${target} PROPERTY LINK_FLAGS_DEBUG ${_flags_str})
+  endif()
+  if(CEF_EXE_LINKER_FLAGS_RELEASE)
+    string(REPLACE ";" " " _flags_str "${CEF_EXE_LINKER_FLAGS_RELEASE}")
+    set_property(TARGET ${target} PROPERTY LINK_FLAGS_RELEASE ${_flags_str})
+  endif()
+endmacro()

+ 1 - 2
CMakeModules/FindFFMPEG.cmake

@@ -31,8 +31,7 @@ if(FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR)
   # in cache already
   set(FFMPEG_FOUND TRUE)
 else()
-  # use pkg-config to get the directories and then use these values
-  # in the FIND_PATH() and FIND_LIBRARY() calls
+  # pkg-config's directories as hints for find_path/find_library
   find_package(PkgConfig)
   if(PKG_CONFIG_FOUND)
     pkg_check_modules(_FFMPEG_AVCODEC libavcodec)

+ 0 - 15
CMakeModules/FindMPV.cmake

@@ -12,21 +12,12 @@
 #
 ###############################################################################
 
-#
-### Global Configuration Section
-#
 SET(_MPV_REQUIRED_VARS MPV_INCLUDE_DIR MPV_LIBRARY)
 
-#
-### MPV uses pkgconfig.
-#
 if(PKG_CONFIG_FOUND)
   pkg_check_modules(PC_MPV QUIET mpv)
 endif(PKG_CONFIG_FOUND)
 
-#
-### Look for the include files.
-#
 find_path(
   MPV_INCLUDE_DIR
   NAMES mpv/client.h
@@ -36,9 +27,6 @@ find_path(
   DOC "MPV include directory"
 )
 
-#
-### Look for the libraries
-#
 set(_MPV_LIBRARY_NAMES mpv)
 if(PC_MPV_LIBRARIES)
   set(_MPV_LIBRARY_NAMES ${PC_MPV_LIBRARIES})
@@ -66,9 +54,6 @@ mark_as_advanced(MPV_INCLUDE_DIR)
 mark_as_advanced(MPV_LIBRARY_DIRS)
 set(MPV_INCLUDE_DIRS ${MPV_INCLUDE_DIR})
 
-#
-### Check if everything was found and if the version is sufficient.
-#
 include(FindPackageHandleStandardArgs)
 find_package_handle_standard_args(
   MPV

+ 2 - 4
src/WallpaperEngine/Application/ApplicationContext.cpp

@@ -314,7 +314,6 @@ std::optional<bool> ApplicationContext::resolveEffectVisibility (int id, const s
 
 std::optional<float> ApplicationContext::resolveAudioSensitivity (int id, const std::string& name) const {
     // "*" is a wildcard default, checked last so a specific id/name match always wins
-    // regardless of the map's (alphabetically ordered) iteration order.
     std::optional<float> wildcard;
 
     for (const auto& [token, multiplier] : this->settings.general.audioSensitivity) {
@@ -348,8 +347,7 @@ std::optional<ApplicationContext::HRTF_MODE> ApplicationContext::parseHrtfMode (
 }
 
 std::optional<float> ApplicationContext::resolveSoundVolume (int id, const std::string& name) const {
-    // "*" is a wildcard default, checked last so a specific id/name match always wins (same rule as
-    // resolveAudioSensitivity).
+    // "*" checked last, like resolveAudioSensitivity
     std::optional<float> wildcard;
 
     for (const auto& [token, volume] : this->settings.general.soundVolume) {
@@ -383,7 +381,7 @@ void ApplicationContext::loadSettingsFromArgv () {
 	    }
 	});
 
-    // Internal, hidden: marks a self-re-exec as a disposable CEF host for one Web wallpaper.
+    // hidden: self-re-exec as a disposable CEF host for one Web wallpaper
     backgroundGroup.add_argument ("--web-host").flag ().hidden ().store_into (this->settings.general.webHost);
 
     backgroundGroup.add_argument ("--web-host-shm")

+ 16 - 50
src/WallpaperEngine/Application/ApplicationContext.h

@@ -27,48 +27,25 @@ public:
 
     void loadSettingsFromArgv ();
 
-    /**
-     * Resolves whether an object/layer should be force-shown or force-hidden based on the
-     * --disable-object/--enable-object overrides, matching id or name against either.
-     *
-     * @return true to force visible, false to force hidden, nullopt to leave the scene's own value alone
-     */
+    // --disable-object/--enable-object by id or name: true shows, false hides, nullopt keeps the scene's value
     [[nodiscard]] std::optional<bool> resolveObjectVisibility (int id, const std::string& name) const;
 
-    /** true to force visible, false to force hidden, nullopt to leave the scene's own value, from
-     * --disable-effect/--enable-effect */
+    // same for --disable-effect/--enable-effect
     [[nodiscard]] std::optional<bool> resolveEffectVisibility (int id, const std::string& name) const;
 
-    /**
-     * Resolves the --audio-sensitivity multiplier for an object/layer, matching id or name, or
-     * falling back to a "*" wildcard default if one was given and no more specific match exists.
-     *
-     * @return the configured multiplier, or nullopt if this object has no override (use the
-     *         wallpaper's original minvalue/maxvalue unchanged)
-     */
+    // --audio-sensitivity by id or name, falling back to "*"; nullopt keeps minvalue/maxvalue
     [[nodiscard]] std::optional<float> resolveAudioSensitivity (int id, const std::string& name) const;
 
-    /**
-     * Resolves the --sound-volume override for a Sound object, matching id or name, or falling
-     * back to a "*" wildcard default if one was given and no more specific match exists.
-     *
-     * @return the configured volume (0-1), or nullopt if this object has no override (use the
-     *         wallpaper's original volume unchanged)
-     */
+    // --sound-volume (0-1) by id or name, falling back to "*"; nullopt keeps the wallpaper's volume
     [[nodiscard]] std::optional<float> resolveSoundVolume (int id, const std::string& name) const;
 
     enum WINDOW_MODE {
 	NORMAL_WINDOW = 0,
-	/** Draw to the window server desktop */
 	DESKTOP_BACKGROUND = 1,
 	EXPLICIT_WINDOW = 2,
     };
 
-    /**
-     * Wayland-only: which wlr-layer-shell layer to anchor the wallpaper surface to.
-     * Different compositors treat layers differently; e.g. niri's
-     * `place-within-backdrop` layer-rule only applies to BACKGROUND surfaces.
-     */
+    // wlr-layer-shell layer, e.g. niri's place-within-backdrop only applies to BACKGROUND
     enum WAYLAND_LAYER {
 	WAYLAND_LAYER_BACKGROUND = 0,
 	WAYLAND_LAYER_BOTTOM = 1,
@@ -113,7 +90,7 @@ public:
 	glm::vec2 offset = { 0.0f, 0.0f };
 	/** WE's alignment position, x, y and zoom, see --alignment-position */
 	WallpaperEngine::Render::WallpaperState::Alignment alignment = {};
-	/** Color shown outside the wallpaper's bounds when clamp is border, see --corner-color */
+	// shown outside the wallpaper when clamp is border, see --corner-color
 	glm::vec4 cornerColor = { 0.0f, 0.0f, 0.0f, 1.0f };
 	/** Image filter, color options and flip, see --image-filter */
 	WallpaperEngine::Data::Model::ImageAdjustments imageAdjustments = {};
@@ -128,7 +105,7 @@ public:
 	    bool dumpStructure;
 	    bool noShaderCache;
 	    bool disableParticles;
-	    /** Grows a scene's render canvas to fit every image layer that extends past it, see --expand-canvas */
+	    // see --expand-canvas
 	    bool expandCanvas;
 	    /** Loads assets the way their author meant where WE's loader drops them, see --repair-assets */
 	    bool repairAssets = false;
@@ -163,13 +140,13 @@ public:
 	    std::map<std::string, std::string> properties;
 	    std::map<std::string, WallpaperEngine::Render::WallpaperState::TextureUVsScaling> screenScalings;
 	    std::map<std::string, TextureFlags> screenClamps;
-	    /** Manual zoom factor for different screens, layered on top of the scaling mode */
+	    // see --zoom
 	    std::map<std::string, float> screenZooms;
-	    /** Re-centers a cropping scaling mode/zoom's visible window for different screens, see --offset */
+	    // see --offset
 	    std::map<std::string, glm::vec2> screenOffsets;
 	    /** WE's alignment settings for different screens, see --alignment-position */
 	    std::map<std::string, WallpaperEngine::Render::WallpaperState::Alignment> screenAlignments;
-	    /** Corner color for different screens, shown outside the wallpaper's bounds when clamp is border */
+	    // see --corner-color
 	    std::map<std::string, glm::vec4> screenCornerColors;
 	    /** Image filter, color options and flip for different screens, see --image-filter */
 	    std::map<std::string, WallpaperEngine::Data::Model::ImageAdjustments> screenImageAdjustments;
@@ -178,11 +155,7 @@ public:
 	    std::optional<PlaylistDefinition> defaultPlaylist;
 	    /** Span groups: multiple monitors sharing one stretched wallpaper */
 	    std::vector<SpanGroup> spanGroups;
-	    /**
-	     * Internal, not advertised in --help: marks this process as a disposable CEF host for a
-	     * single Web wallpaper instead of embedding CEF in the main engine process. Requires
-	     * webHostShm/Width/Height.
-	     */
+	    // hidden: disposable CEF host for one Web wallpaper, needs webHostShm/Width/Height
 	    bool webHost;
 	    std::string webHostShm;
 	    uint32_t webHostWidth;
@@ -199,23 +172,16 @@ public:
 	    WallpaperEngine::VideoPlayback::VideoSegments videoSegments;
 	    /** mpv hwdec value for every video player, see --hwdec */
 	    std::string hwdec;
-	    /** Freezes scene time entirely (scripts, particles, effects and puppet meshes all stop advancing), see
-	     * --disable-animations */
+	    // freezes scene time entirely, see --disable-animations
 	    bool freezeAnimations;
 	    bool pauseOnFullscreen;
-	    /**
-	     * Wayland-only: if true, only consider fullscreen toplevels that are also activated.
-	     * Useful for compositors with "virtual" fullscreen windows (e.g. scrollable tiling).
-	     */
+	    // only fullscreen toplevels that are also activated count (scrollable tiling compositors)
 	    bool pauseOnFullscreenOnlyWhenActive;
 	    /** WE's "Other application focused: Pause" (--pause-on-focus) */
 	    bool pauseOnFocus;
 	    /** wlroots: maximized toplevels pause their outputs too (KDE and GNOME always do, like WE) */
 	    bool pauseOnMaximized;
-	    /**
-	     * Wayland-only: list of app_id substrings to ignore for fullscreen pause.
-	     * Example: "firefox" will match "org.mozilla.firefox".
-	     */
+	    // app_id substrings ignored for fullscreen pause ("firefox" matches org.mozilla.firefox)
 	    std::vector<std::string> fullscreenPauseIgnoreAppIds;
 	    /** Wayland-only: PQ output on monitors in HDR mode and HDR video, see --hdr */
 	    bool hdr;
@@ -238,11 +204,11 @@ public:
 		WallpaperEngine::Render::WallpaperState::TextureUVsScaling scalingMode;
 		/** Manual zoom factor layered on top of scalingMode, see --zoom */
 		float zoom;
-		/** Re-centers a cropping scaling mode/zoom's visible window, see --offset */
+		// see --offset
 		glm::vec2 offset;
 		/** WE's alignment position, x, y and zoom, see --alignment-position */
 		WallpaperEngine::Render::WallpaperState::Alignment alignment;
-		/** Corner color shown outside the wallpaper's bounds when clamp is border, see --corner-color */
+		// see --corner-color
 		glm::vec4 cornerColor;
 		/** Image filter, color options and flip, see --image-filter */
 		WallpaperEngine::Data::Model::ImageAdjustments imageAdjustments;

+ 34 - 58
src/WallpaperEngine/Application/WallpaperApplication.cpp

@@ -72,8 +72,7 @@ void CustomGLDebugCallback (
 	return;
     }
 
-    // libmpv's own renderer reuses a GL_STATIC_DRAW buffer with glBufferSubData every frame of every video
-    // wallpaper, a performance hint that would drown out everything else
+    // libmpv rebuffers a GL_STATIC_DRAW buffer every video frame, that hint would drown out everything else
     if (type == GL_DEBUG_TYPE_PERFORMANCE) {
 	return;
     }
@@ -493,7 +492,7 @@ bool WallpaperApplication::makeAnyViewportCurrent () const {
 
 bool WallpaperApplication::preflightWallpaper (const std::string& path) {
     try {
-	// avoid mutating state, just ensure project.json parses
+	// only checks that project.json parses
 	const auto source = this->openProjectSource (path);
 	const auto& json = source.json;
 	if (!json.contains ("type") || !json.contains ("file")) {
@@ -611,7 +610,7 @@ void WallpaperApplication::advancePlaylist (
     if (!loaded) {
 	playlist.failedIndices.insert (playlist.order[playlist.orderIndex]);
 
-	// Keep current position; next timer tick will retry advancement
+	// keep the position, the next tick retries
 	sLog.error ("Failed to load wallpaper for ", screen, ", will retry on next cycle");
     }
 
@@ -649,7 +648,7 @@ namespace {
 /** Everything a control-file request can carry; any field left unset means "don't touch this" */
 struct HotswapRequest {
     std::optional<std::string> path;
-    /** True once a "layers=1" line was seen, meaning disabledObjects/enabledObjects below are a full replacement */
+    // a layers=1 line makes disabledObjects/enabledObjects a full replacement
     bool layersProvided = false;
     std::vector<std::string> disabledObjects;
     std::vector<std::string> enabledObjects;
@@ -658,7 +657,7 @@ struct HotswapRequest {
     std::vector<std::string> disabledEffects;
     std::vector<std::string> enabledEffects;
     std::optional<std::string> disableAnimations;
-    /** True once at least one "property=name=value" line was seen */
+    // set by any property=name=value line
     bool propertiesProvided = false;
     std::map<std::string, std::string> properties;
     std::optional<int> volume;
@@ -667,7 +666,7 @@ struct HotswapRequest {
     std::optional<std::string> xray;
     /** "stretch"/"fit"/"fill"/"center"/"default" */
     std::optional<std::string> scaling;
-    /** floating-point zoom factor layered on top of scaling, e.g. "1.5" */
+    // zoom factor on top of scaling, e.g. "1.5"
     std::optional<std::string> zoom;
     /** "X,Y" offset re-center, each axis in [-1, 1], e.g. "0.5,-1" */
     std::optional<std::string> offset;
@@ -680,10 +679,10 @@ struct HotswapRequest {
     std::optional<std::string> repairAssets;
     /** hex RGB/RGBA color, e.g. "000000" or "#1a1a1aff" */
     std::optional<std::string> cornerColor;
-    /** image-filter/image-filter-strength/brightness/contrast/saturation/hue/color-options/flip, see --image-filter */
+    // see --image-filter
     ImageAdjustments imageAdjustments;
     bool imageAdjustmentsProvided = false;
-    /** floating-point playback speed multiplier, e.g. "0.5" */
+    // playback speed multiplier, e.g. "0.5"
     std::optional<std::string> speed;
     /** seconds, m:ss or h:mm:ss, "" or "none" clears it, see --video-start/--video-end */
     std::optional<std::string> videoStart;
@@ -700,10 +699,10 @@ struct HotswapRequest {
     std::optional<std::string> audioScreen;
     /** 0-128, see --ambient-volume */
     std::optional<std::string> ambientVolume;
-    /** True once at least one "audio-sensitivity=id=multiplier" line was seen */
+    // set by any audio-sensitivity=id=multiplier line
     bool audioSensitivityProvided = false;
     std::map<std::string, std::string> audioSensitivity;
-    /** True once at least one "sound-volume=id=volume" line was seen */
+    // set by any sound-volume=id=volume line
     bool soundVolumeProvided = false;
     std::map<std::string, std::string> soundVolume;
 };
@@ -926,9 +925,8 @@ void WallpaperApplication::checkHotswapRequest () {
 	return;
     }
 
-    // overrides belong to the wallpaper they were set for, object ids and generic property names
-    // ("newproperty1") collide across wallpapers, so a new wallpaper starts without the old ones and
-    // only gets whatever this same request carries for it
+    // overrides belong to the wallpaper they were set for (ids and generic property names collide), a new one only gets
+    // what this request carries
     if (request.path.has_value ()) {
 	auto& general = this->m_context.settings.general;
 
@@ -1106,9 +1104,8 @@ void WallpaperApplication::checkHotswapRequest () {
 	return;
     }
 
-    // volume/xray/speed-only requests are pure live setters with nothing to reload. Properties
-    // and audio sensitivity, like layers, are baked into the scene graph at parse time, so they
-    // need the same reload, as do the expanded canvas (it sizes the scene's framebuffers) and repaired assets.
+    // volume/xray/speed are live setters; layers, effects, properties, audio sensitivity, expanded canvas and repaired
+    // assets are baked in at load
     if (!request.path.has_value () && !request.layersProvided && !request.effectsProvided && !request.propertiesProvided
 	&& !request.audioSensitivityProvided && !sceneSettingsChanged) {
 	return;
@@ -1553,8 +1550,7 @@ void WallpaperApplication::applySpeedHotswap (const std::string& value) {
 
     this->m_context.settings.render.playbackSpeed = speed;
 
-    // Particles/effects/scripts read settings.render.playbackSpeed directly every frame, but
-    // video wallpapers are driven by mpv's own clock and need the change pushed explicitly.
+    // video wallpapers run on mpv's clock and need the speed pushed, everything else reads it every frame
     if (this->m_renderContext) {
 	for (const auto& [screen, wallpaper] : this->m_renderContext->getWallpapers ()) {
 	    if (wallpaper->is<WallpaperEngine::Render::Wallpapers::CVideo> ()) {
@@ -1829,11 +1825,8 @@ void considerAudioReactive (
     }
 }
 
-// Mirrors exactly the set of fields ScriptableObject/CImage/CText/CParticle register with the
-// script engine (see Scripting/ScriptableObject.cpp, Render/Objects/CImage.cpp, CText.cpp,
-// CParticle.cpp) - "origin" is always the base object's own field (never overridden per-type),
-// while scale/angles/visible fall back to the generic group* fields only for object types that
-// don't provide their own (Sound, Light, plain groups).
+// the fields ScriptableObject/CImage/CText/CParticle register with the script engine; scale/angles/visible fall back to
+// group* for types without their own
 std::vector<AudioReactiveProperty> collectAudioReactiveProperties (const Object& object) {
     std::vector<AudioReactiveProperty> result;
 
@@ -1996,10 +1989,7 @@ void WallpaperApplication::applySoundVolumeHotswap (const std::map<std::string,
 	}
     }
 
-    // Sound objects already read their own DynamicValue live every frame (see
-    // CSound::applyEffectiveVolume), so re-resolving and pushing the new value straight into the
-    // currently loaded projects' live objects is enough - no reload needed, unlike properties/
-    // audio-sensitivity which are baked into the scene graph at parse time.
+    // Sound objects read their volume every frame (CSound::applyEffectiveVolume), no reload needed
     for (const auto& [background, info] : this->m_backgrounds) {
 	this->setupSoundVolumeForProject (*info);
     }
@@ -2073,8 +2063,7 @@ bool WallpaperApplication::applyPropertiesLive (const std::vector<std::string>&
 }
 
 void WallpaperApplication::setupBrowser () {
-    // CEF allows one CefInitialize/CefShutdown per process, so only the --web-host process hosts it. Chromium's own
-    // children go to WebBrowserContext::runSubprocess from main ()
+    // CEF allows one CefInitialize/CefShutdown per process, so only the --web-host process hosts it
     if (!this->m_context.settings.general.webHost || this->m_browserContext) {
 	return;
     }
@@ -2117,8 +2106,7 @@ void WallpaperApplication::runWebHost () {
 
     CefWindowInfo windowInfo;
     windowInfo.SetAsWindowless (0);
-    // frames are produced when the main process asks for them (see the loop below), so they line up with what it
-    // presents instead of drifting against a free running 60Hz timer
+    // frames come when the main process asks, so they line up with what it presents
     windowInfo.external_begin_frame_enabled = true;
 
     CefBrowserSettings browserSettings;
@@ -2162,8 +2150,8 @@ void WallpaperApplication::runWebHost () {
     CEF::PageBridge bridge (browser, *shm, project.properties, *client);
 
     while (!shm->quitRequested.load (std::memory_order_acquire)) {
-	// The heartbeat keeps the page alive (timers, videos, first paint) when the main process isn't rendering, for
-	// example while the surface is fully covered and the compositor stops sending frame callbacks.
+	// the heartbeat keeps the page alive while the main process isn't rendering (surface covered, no frame
+	// callbacks)
 	const auto now = std::chrono::steady_clock::now ();
 	const uint32_t frameRequest = shm->frameRequestSeq.load (std::memory_order_acquire);
 
@@ -2231,15 +2219,13 @@ void WallpaperApplication::runWebHost () {
 	    lastRight = right;
 	}
 
-	// Short, this is also how often input and audio get a chance to be handed to the page and how soon a painted
-	// frame gets picked up. A frame request from the main process cuts the wait short.
+	// short, this also paces input/audio handoff and frame pickup; a frame request cuts it short
 	shm->waitForFrameRequest (lastFrameRequest, 1);
     }
 
     browser->GetHost ()->CloseBrowser (true);
 
-    // CloseBrowser() only requests an async close - wait briefly for it to finish before
-    // CefShutdown() below tears everything down out from under it
+    // CloseBrowser() is async, give it time to finish before CefShutdown()
     for (int i = 0; i < 500 && !client->isClosed (); i++) {
 	CefDoMessageLoopWork ();
     }
@@ -2279,8 +2265,8 @@ void WallpaperApplication::takeScreenshot (const std::filesystem::path& filename
 	const int vpWidth = viewport->viewport.z - viewport->viewport.x;
 	const int vpHeight = viewport->viewport.w - viewport->viewport.y;
 
-	// bind the wallpaper's FBO to read from it directly
-	// this is more reliable than the default framebuffer on some drivers (NVIDIA/Wayland)
+	// read the wallpaper's FBO directly, more reliable than the default framebuffer on some drivers
+	// (NVIDIA/Wayland)
 	glBindFramebuffer (GL_FRAMEBUFFER, wallpaper->renderAdjustedFramebuffer ());
 
 	glFinish ();
@@ -2308,7 +2294,6 @@ void WallpaperApplication::takeScreenshot (const std::filesystem::path& filename
 	    continue;
 	}
 
-	// Get the UV coordinates which define the visible portion based on scaling mode
 	const glm::vec4 uvs = wallpaper->getOutputUVs ();
 
 	captures.push_back (
@@ -2323,7 +2308,7 @@ void WallpaperApplication::takeScreenshot (const std::filesystem::path& filename
     const auto extension = filename.extension ();
     const std::string extStr = extension.string ();
 
-    // Offload pixel processing and saving to a background thread to avoid hitches
+    // process and save off the render thread
     std::thread ([captures, width, height, vflip, extStr, filename] () {
 	auto* bitmap = new uint8_t[width * height * 3] { 0 };
 
@@ -2340,7 +2325,6 @@ void WallpaperApplication::takeScreenshot (const std::filesystem::path& filename
 		return static_cast<int> (std::floor (center * readSize - samples * 0.5 + 0.5));
 	    };
 
-	    // sample the bitmap from the UV-defined visible region
 	    for (int y = 0; y < capture.vpHeight; y++) {
 		for (int x = 0; x < capture.vpWidth; x++) {
 		    const int srcX
@@ -2364,7 +2348,7 @@ void WallpaperApplication::takeScreenshot (const std::filesystem::path& filename
 
 		    const int count = samplesX * samplesY;
 		    const int xfinal = x + capture.xoffset;
-		    // FBO content is not flipped like default framebuffer, so invert vflip logic
+		    // FBOs aren't flipped like the default framebuffer
 		    const int yfinal = vflip ? y : (capture.vpHeight - y - 1);
 
 		    if (yfinal >= 0 && yfinal < height && xfinal >= 0 && xfinal < width) {
@@ -2568,16 +2552,8 @@ void WallpaperApplication::setupOpenGLDebugging () {
 void WallpaperApplication::setup () {
     this->setupOutput ();
 
-    // we_manager launches us with LD_PRELOAD forcing the system's libEGL, because CEF's own
-    // bundled libEGL sits next to us on LD_LIBRARY_PATH and would otherwise shadow it and break
-    // our own Wayland/EGL output. That preload has already done its job for our own process by
-    // this point (setupOutput() above just created our GL context with it) - but it stays in the
-    // environment we inherit, and CEF's own subprocesses (spawned lazily, e.g. the GPU process
-    // the moment a web wallpaper's WebGL content first needs one) would inherit it too, forcing
-    // Mesa's system EGL onto CEF's ANGLE stack instead of the bundled EGL it actually expects.
-    // That silently breaks WebGL - no crash, no error, just a canvas that never paints anything.
-    // Unsetting it here only affects processes we fork+exec after this point; it doesn't undo
-    // anything already loaded into our own process by the dynamic linker at our own startup.
+    // we_manager's LD_PRELOAD (system libEGL) has done its job here, but CEF's subprocesses would inherit it and WebGL
+    // silently stops painting only affects processes started after this point
     unsetenv ("LD_PRELOAD");
 
     this->setupAudio ();
@@ -2638,8 +2614,8 @@ void WallpaperApplication::render () {
 	timeinfo = localtime (&seconds);
 	g_Daytime = static_cast<float> ((timeinfo->tm_hour * 60) + timeinfo->tm_min) / (24.0f * 60.0f);
 
-	// LWE_FIXED_TIMESTEP=<seconds> advances animations by the same step every frame no matter how
-	// long the frame really took, so frame N always shows the same moment (regression renders)
+	// LWE_FIXED_TIMESTEP=<seconds>: same step every frame so frame N always shows the same moment (regression
+	// renders)
 	static const float fixedTimestep = [] {
 	    const char* value = std::getenv ("LWE_FIXED_TIMESTEP");
 	    return value != nullptr ? std::max (0.0f, std::strtof (value, nullptr)) : 0.0f;
@@ -2651,8 +2627,8 @@ void WallpaperApplication::render () {
 
 	g_TimeLast = g_Time;
 	if (!this->m_context.settings.render.freezeAnimations) {
-	    // WE steps a frame by at most a quarter second and at least 1e-4 (2.8.42 main loop sub_140110630, what
-	    // sub_14017FA70 and engine.frametime get), a long stall doesn't make scripts catch up all at once
+	    // WE clamps a frame's step to [1e-4, 0.25] (2.8.42 sub_140110630), a stall doesn't make scripts catch up at
+	    // once
 	    g_Time += std::clamp (
 		std::min (rawDelta, 0.25f) * this->m_context.settings.render.playbackSpeed, 0.0001f, 0.25f
 	    );

+ 23 - 65
src/WallpaperEngine/Application/WallpaperApplication.h

@@ -38,11 +38,7 @@ public:
     void show ();
     void signal (int signal);
 
-    /**
-     * Entry point for a disposable CEF host child process (settings.general.webHost) instead of
-     * embedding CEF in the main engine process. Never touches Wayland/GL/audio. Runs until the
-     * main process signals quit through shared memory (or this process is killed).
-     */
+    // entry point of a disposable --web-host CEF process, no Wayland/GL/audio; runs until the main process signals quit
     void runWebHost ();
 
     [[nodiscard]] const std::map<std::string, ProjectUniquePtr>& getBackgrounds () const;
@@ -78,23 +74,23 @@ private:
     void setupProperties ();
     void setupPropertiesForProject (const Project& project);
 
-    /** Prints objects/layers for every loaded background, triggered by --list-objects */
+    // --list-objects
     void listObjects () const;
     void listObjectsForProject (const std::string& background, const Project& project) const;
 
-    /** Prints per-object effects (bloom, blur, glow, etc) for every loaded background, triggered by --list-effects */
+    // --list-effects
     void listEffects () const;
     void listEffectsForProject (const std::string& background, const Project& project) const;
 
-    /** Applies --audio-sensitivity overrides for every loaded background */
+    // --audio-sensitivity
     void setupAudioSensitivity ();
     void setupAudioSensitivityForProject (const Project& project) const;
 
-    /** Prints audio-reactive objects/properties for every loaded background, triggered by --list-audio-objects */
+    // --list-audio-objects
     void listAudioObjects () const;
     void listAudioObjectsForProject (const std::string& background, const Project& project) const;
 
-    /** Applies --sound-volume overrides for every loaded background */
+    // --sound-volume
     void setupSoundVolume ();
     void setupSoundVolumeForProject (const Project& project) const;
 
@@ -127,52 +123,33 @@ private:
     std::vector<std::size_t> buildPlaylistOrder (const ApplicationContext::PlaylistDefinition& definition);
     bool makeAnyViewportCurrent () const;
 
-    /**
-     * Pushes a volume change live to already-running video players and the SDL audio mixer,
-     * without touching the loaded projects. volume is 0-128, matching --volume.
-     */
+    // pushes a volume (0-128, like --volume) live to video players and the SDL mixer
     void applyVolumeHotswap (int volume);
     void applyFpsHotswap (int fps);
 
     /** "full"/"normal"/"disabled", or the older "on"/"off"/"toggle" */
     void applyXrayHotswap (const std::string& value);
 
-    /**
-     * Pushes a scaling mode change ("stretch"/"fit"/"fill"/"center"/"default") live to every
-     * currently rendered wallpaper, without reloading the loaded projects. Applies to all screens,
-     * same as the other hotswap setters below.
-     */
+    // "stretch"/"fit"/"fill"/"center"/"default", live on every screen
     void applyScalingHotswap (const std::string& value);
 
-    /** Pushes a manual zoom factor (e.g. "1.5") live to every currently rendered wallpaper */
+    // e.g. "1.5"
     void applyZoomHotswap (const std::string& value);
 
-    /** Pushes an offset re-center (e.g. "0.5,-1") live to every currently rendered wallpaper */
+    // e.g. "0.5,-1"
     void applyOffsetHotswap (const std::string& value);
-    /** Pushes WE's alignment settings ("position,x,y,zoom" in its 0-100/0-200 units) live to every wallpaper */
+    // "position,x,y,zoom" in WE's 0-100/0-200 units
     void applyAlignmentHotswap (const std::string& value);
 
-    /**
-     * Pushes a force-disable-parallax toggle live. This is a straight passthrough to
-     * settings.mouse.disableparallax, which every parallax-capable object (CImage/CText/CParticle) and
-     * CScene's mouse-follow logic already reads directly every frame, so no reload or per-wallpaper
-     * plumbing is needed at all. value is "on"/"off"/"toggle" (also "1"/"0"/"true"/"false").
-     */
+    // passthrough to settings.mouse.disableparallax, read every frame; "on"/"off"/"toggle" (or "1"/"0"/"true"/"false")
     void applyParallaxHotswap (const std::string& value);
 
-    /**
-     * Pushes a corner color change (hex RGB/RGBA, e.g. "000000" or "#1a1a1aff") live to every
-     * currently rendered wallpaper. Only visible where clamp mode is border.
-     */
+    // hex RGB/RGBA, e.g. "000000" or "#1a1a1aff"; only visible where clamp is border
     void applyCornerColorHotswap (const std::string& value);
     /** Merges the fields set in the request into every screen's image settings and applies them live */
     void applyImageAdjustmentsHotswap (const ImageAdjustments& request);
 
-    /**
-     * Pushes a playback speed multiplier (e.g. "0.5") live. Straight passthrough to
-     * settings.render.playbackSpeed, which render() reads directly every frame to scale the
-     * dt fed into g_Time, so no reload or per-wallpaper plumbing is needed at all.
-     */
+    // e.g. "0.5", passthrough to settings.render.playbackSpeed which render() reads every frame
     void applySpeedHotswap (const std::string& value);
 
     /** Video wallpapers restart from the first part, video-start/video-end make it one part */
@@ -185,38 +162,22 @@ private:
     void applyVideoSeekHotswap (const std::string& value);
     void applyHwdecHotswap (const std::string& value);
 
-    /**
-     * Pushes a new --audio-screen restriction live (empty value clears it back to "no
-     * restriction"), then re-applies audio policy to every currently rendered wallpaper.
-     */
+    // empty clears the restriction, then re-applies the audio policy
     void applyAudioScreenHotswap (const std::string& value);
 
-    /** Pushes a new --ambient-volume (0-128) live, then re-applies audio policy to every currently rendered wallpaper
-     */
+    // 0-128, then re-applies the audio policy
     void applyAmbientVolumeHotswap (const std::string& value);
 
-    /**
-     * Pushes --sound-volume overrides (id-or-name -> 0-1 volume) live to every Sound object in the
-     * currently loaded projects, without reloading - unlike --set-property/--audio-sensitivity,
-     * Sound objects already re-read their own volume every frame (see CSound::render()), so this
-     * is a pure live setter.
-     */
+    // id-or-name -> 0-1 volume, live since Sound objects re-read their volume every frame
     void applySoundVolumeHotswap (const std::map<std::string, std::string>& targets);
     /** false when one of them needs a reload */
     bool applyPropertiesLive (const std::vector<std::string>& names);
 
-    /**
-     * Recomputes and pushes CWallpaper::setAudioPolicy() to every currently rendered wallpaper
-     * based on settings.audio.audioScreen/ambientVolume. Span-group screens share a single
-     * CWallpaper instance across several screen names, so this groups by instance first and
-     * only mutes one if none of its screens match audioScreen.
-     */
+    // setAudioPolicy() from audioScreen/ambientVolume; a span group's shared wallpaper is muted only if none of its
+    // screens match
     void applyAudioPolicy ();
 
-    /**
-     * Figures out what background a given screen is currently showing, so a layers-only
-     * hotswap can reload it without the caller having to resend the path
-     */
+    // the background a screen shows, so a layers-only hotswap can reload it without a path
     [[nodiscard]] std::string resolveScreenBackgroundPath (const std::string& screen) const;
     /** Screen suffix for script localStorage's screen store */
     [[nodiscard]] std::string storageScreen (const std::string& screen) const;
@@ -228,15 +189,12 @@ private:
     /** Command line and control file settings for this screen (or span group) over what the preset carries */
     [[nodiscard]] ImageAdjustments
     resolveScreenImageAdjustments (const std::string& screen, const Project& project) const;
-    // The resolution a Web wallpaper on this screen will actually be rendered at - falls back to
-    // the combined bounding box of every active screen if this one isn't registered yet.
+    // a Web wallpaper's render size on this screen, the bounding box of all screens if it isn't registered yet
     [[nodiscard]] glm::ivec2 resolveScreenRenderSize (const std::string& screen) const;
     /** The span group loaded as this "span:<first screen>" key, null for a plain screen */
     [[nodiscard]] const ApplicationContext::SpanGroup* findSpanGroup (const std::string& screen) const;
-    /**
-     * Builds the wallpaper for a screen or span group key and puts it on its outputs, a span group's one wallpaper
-     * on every screen of the group. Throws when the wallpaper can't be built, the outputs keep what they had
-     */
+    // builds the wallpaper for a screen or span group and puts it on its outputs; throws on failure, the outputs keep
+    // what they had
     void installWallpaper (
 	const std::string& screen, const Project& project, const std::filesystem::path& path, bool holdPrevious
     );

+ 3 - 14
src/WallpaperEngine/Audio/AudioContext.h

@@ -34,17 +34,10 @@ namespace Audio {
 
 	void removeStream (int streamId) const;
 
-	/**
-	 * Overrides the volume used to mix a single stream, instead of the driver's global volume
-	 *
-	 * @param streamId The stream to change
-	 * @param volume 0-128, or a negative value to go back to using the global volume
-	 */
+	// 0-128, negative goes back to the global volume
 	void setStreamVolume (int streamId, int volume) const;
 
-	/**
-	 * Scales the left and right channel of a stream on top of its volume
-	 */
+	// left/right gains on top of the volume
 	void setStreamGains (int streamId, float left, float right) const;
 
 	void setStreamPaused (int streamId, bool paused) const;
@@ -54,11 +47,7 @@ namespace Audio {
 	/** The HRTF data set while sound objects render for headphones, nullptr otherwise */
 	[[nodiscard]] const Hrtf::Store* getHrtf () const;
 
-	/**
-	 * TODO: MAYBE THIS SHOULD BE OUR OWN DEFINITIONS INSTEAD OF LIBRARY SPECIFIC ONES?
-	 *
-	 * @return The audio format the driver supports
-	 */
+	// TODO: our own format definitions instead of ffmpeg's?
 	[[nodiscard]] AVSampleFormat getFormat () const;
 	[[nodiscard]] int getSampleRate () const;
 	[[nodiscard]] int getChannels () const;

+ 0 - 1
src/WallpaperEngine/Audio/AudioStream.cpp

@@ -459,7 +459,6 @@ void AudioStream::stop () {
 	return;
     }
 
-    // stop the threads running
     this->m_initialized = false;
 }
 

+ 14 - 56
src/WallpaperEngine/Audio/AudioStream.h

@@ -37,10 +37,7 @@ using namespace WallpaperEngine::FileSystem;
 class AudioStream {
 public:
     AudioStream (AudioContext& context, const std::string& filename);
-    /**
-     * @param repeat Set before the reader thread starts, a short file could otherwise be read to its end before a later
-     * setRepeat () call
-     */
+    // repeat is set before the reader starts, a short file could be read to its end before a setRepeat () call
     AudioStream (AudioContext& context, const ReadStreamSharedPtr& buffer, bool repeat = false);
     AudioStream (AudioContext& audioContext, AVCodecContext* context);
     ~AudioStream ();
@@ -49,21 +46,13 @@ public:
 
     enum class Dequeued { Packet, Empty, Finished };
 
-    /**
-     * Takes the next packet off the queue into m_decodePacket without waiting
-     *
-     * @return Empty when the reader hasn't queued more yet, Finished once it never will
-     */
+    // next packet into m_decodePacket without waiting; Empty if nothing is queued yet, Finished once nothing will be
     Dequeued dequeuePacket ();
 
-    /**
-     * Called by the file reader thread when a repeating stream starts over, the decoder drains up to the marker
-     */
+    // from the reader thread when a repeating stream starts over
     void queueLoopMarker ();
 
-    /**
-     * Called by the file reader thread when it will not queue any more packets
-     */
+    // from the reader thread once it won't queue more packets
     void markReaderFinished ();
 
     [[nodiscard]] AudioContext& getAudioContext () const;
@@ -72,78 +61,48 @@ public:
     [[nodiscard]] AVFormatContext* getFormatContext () const;
     [[nodiscard]] int getAudioStream () const;
     [[nodiscard]] bool isInitialized () const;
-    /**
-     * @return Length of the file in seconds, 0 if the container doesn't say
-     */
+    // seconds, 0 if the container doesn't say
     [[nodiscard]] double getDuration () const;
-    /**
-     * @return Channel count of the file itself, before resampling to the driver's layout
-     */
+    // before resampling to the driver's layout
     [[nodiscard]] int getSourceChannels () const;
     void setRepeat (bool newRepeat = true);
     [[nodiscard]] bool isRepeat () const;
     void stop ();
     [[nodiscard]] ReadStreamSharedPtr& getBuffer ();
-    /**
-     * @return The SDL_cond used to signal waiting for data
-     */
     [[nodiscard]] SDL_cond* getWaitCondition () const;
     [[nodiscard]] size_t getQueueSize () const;
     [[nodiscard]] int getQueuePacketCount () const;
-    /**
-     * @return The duration (in seconds) of the queued data to be played
-     */
+    // seconds
     [[nodiscard]] int64_t getQueueDuration () const;
     [[nodiscard]] AVRational getTimeBase () const;
 
-    /**
-     * Plays the stream at the driver's rate the way an OpenAL Soft 1.21.1 source plays a file at its own rate (WE hands
-     * every sound file to OpenAL as is, mediaextensions64.dll sub_18000D530): linear interpolation over a 12 bit fixed
-     * point position, the step rounded from file rate / device rate. Past the end the last frame is held, like the
-     * padding OpenAL loads after a queue's end.
-     *
-     * @param out Interleaved float frames in the driver's channel layout
-     * @return Frames written, 0 when nothing is decoded yet, < 0 once the voice is over
-     */
+    // plays at the driver's rate like an OpenAL Soft 1.21.1 source (WE hands files to OpenAL as is, sub_18000D530):
+    // linear interpolation, 12 bit fixed point step, last frame held past the end returns frames written, 0 if nothing
+    // is decoded yet, < 0 once the voice is over
     int read (float* out, int frames);
 
-    /**
-     * How OpenAL splits the next update of this many frames into mixing passes (Voice::mix): a step above 1 reads more
-     * source frames than it writes, and one pass loads at most BufferLineSize of them
-     */
+    // how OpenAL splits the next update into mixing passes (Voice::mix), at most BufferLineSize source frames each
     [[nodiscard]] std::vector<int> passes (int frames) const;
 
     /** Whether the voice played past the file's end, OpenAL then stops it after the current update */
     [[nodiscard]] bool ended () const;
 
-    /**
-     * What a stopping voice mixes in its last update when it has no buffer left (alSourceStop, or the natural end): up
-     * to 24 of the upcoming frames, cut per channel before the one closest to zero and held from there (voice.cpp)
-     */
+    // a stopping voice's last update without buffers: up to 24 upcoming frames, cut per channel before the one closest
+    // to zero and held (voice.cpp)
     void stopTail (float* out, int frames);
 
 private:
-    /**
-     * Initializes ffmpeg to read the given file
-     */
     void loadCustomContent (const char* filename = nullptr);
     /** Converts the decoded frame to float in the driver's channel layout at the file's rate, onto m_source */
     bool convertFrame ();
     /** Converts what the converter still holds once the decoder is drained */
     void flushConverter ();
-    /**
-     * Decodes the next frame onto m_source without waiting
-     *
-     * @return 1 when frames were added, 0 when nothing is queued yet, -1 at the end or on an error
-     */
+    // decodes the next frame onto m_source without waiting: 1 added, 0 nothing queued, -1 end or error
     int decodeSource ();
     /** Makes sure m_source holds this many frames past the read position, unless the file ends first */
     void fillSource (size_t frames);
     [[nodiscard]] const float* sourceFrame (size_t frame) const;
     bool doQueue (AVPacket* pkt);
-    /**
-     * Initializes queues and ffmpeg resampling
-     */
     void initialize ();
 
     SwrContext* m_swrctx = nullptr;
@@ -152,7 +111,6 @@ private:
     bool m_repeat = false;
     /** Set once the reader thread has exited, so nothing waits for packets that will never come */
     std::atomic<bool> m_readerFinished = false;
-    /** The codec context that contains the original audio format information */
     AVCodecContext* m_context = nullptr;
     AVFormatContext* m_formatContext = nullptr;
     int m_audioStream = NO_AUDIO_STREAM;

+ 11 - 46
src/WallpaperEngine/Audio/Drivers/AudioDriver.h

@@ -39,73 +39,38 @@ namespace Audio {
 	    );
 
 	    virtual ~AudioDriver () = default;
-	    /**
-	     * Registers the given stream in the driver for playing
-	     *
-	     * @param volume Initial volume override (0-128), -1 = the global volume
-	     * @param left Initial gain of the left channel
-	     * @param right Initial gain of the right channel
-	     */
+	    // volume 0-128 or -1 for the global volume, left/right are the initial channel gains
 	    virtual int addStream (AudioStream* stream, int volume = -1, float left = 1.0f, float right = 1.0f) = 0;
 
 	    virtual void removeStream (int streamId) = 0;
 
-	    /**
-	     * Overrides the volume used to mix a single stream, instead of the driver's global volume
-	     *
-	     * @param streamId The stream to change
-	     * @param volume 0-128, or a negative value to go back to using the global volume
-	     */
+	    // 0-128, negative goes back to the global volume
 	    virtual void setStreamVolume (int streamId, int volume) = 0;
 
-	    /**
-	     * Scales each output channel of a stream, on top of its volume
-	     *
-	     * @param left Gain of the left channel
-	     * @param right Gain of the right channel
-	     */
+	    // per channel gains on top of the volume
 	    virtual void setStreamGains (int streamId, float left, float right) = 0;
 
-	    /**
-	     * A paused stream keeps its position and isn't decoded until it is resumed
-	     */
+	    // a paused stream keeps its position and isn't decoded
 	    virtual void setStreamPaused (int streamId, bool paused) = 0;
-	    /**
-	     * Stops a stream the way OpenAL stops a source: one more update without new audio (only an HRTF voice's
-	     * delayed samples fade out), then it is removed; the driver keeps the stream alive until then
-	     */
+	    // stops like an OpenAL source: one more update without new audio (an HRTF voice's delay fades out), then
+	    // removed
 	    virtual void stopStream (int streamId, std::unique_ptr<AudioStream> stream) {
 		this->removeStream (streamId);
 	    }
-	    /**
-	     * Mixes the stream through the HRTF renderer with these filters while HRTF is on, nullptr goes back to the
-	     * channel gains
-	     */
+	    // mixes through HRTF with these filters while it's on, nullptr goes back to the channel gains
 	    virtual void setStreamHrtf (int streamId, const StreamHrtf* hrtf) { }
-	    /**
-	     * @return The HRTF data set at the output rate while headphones rendering is on, nullptr otherwise
-	     */
+	    // at the output rate while headphones rendering is on, nullptr otherwise
 	    [[nodiscard]] virtual const Hrtf::Store* getHrtf () const { return nullptr; }
 
-	    /**
-	     * Updates status of the different audio settings
-	     *
-	     * @param dt Seconds since the previous frame, scaled by the playback speed
-	     */
+	    // dt is seconds since the previous frame, scaled by the playback speed
 	    virtual void update (float dt);
 
-	    /**
-	     * TODO: MAYBE THIS SHOULD BE OUR OWN DEFINITIONS INSTEAD OF LIBRARY SPECIFIC ONES?
-	     *
-	     * @return The audio format the driver supports
-	     */
+	    // TODO: our own format definitions instead of ffmpeg's?
 	    [[nodiscard]] virtual AVSampleFormat getFormat () const = 0;
 	    [[nodiscard]] virtual int getSampleRate () const = 0;
 	    [[nodiscard]] virtual int getChannels () const = 0;
 	    Application::ApplicationContext& getApplicationContext () const;
-	    /**
-	     * @return The audio playing detector to use to stop playing sound when something else starts playing
-	     */
+	    // stops sound when something else starts playing
 	    [[nodiscard]] Detectors::AudioPlayingDetector& getAudioDetector () const;
 	    [[nodiscard]] Recorders::PlaybackRecorder& getRecorder () const;
 	    void setRecorder (Recorders::PlaybackRecorder& recorder);

+ 0 - 3
src/WallpaperEngine/Audio/Drivers/Detectors/AudioPlayingDetector.h

@@ -22,9 +22,6 @@ namespace Audio::Drivers::Detectors {
 
 	virtual ~AudioPlayingDetector () = default;
 
-	/**
-	 * @return If any kind of sound is currently playing on the default audio device
-	 */
 	[[nodiscard]] bool anythingPlaying () const;
 
 	void setIsPlaying (bool newState);

+ 3 - 11
src/WallpaperEngine/Audio/Drivers/Detectors/HeadphonesDetector.h

@@ -5,17 +5,9 @@
 #include <string>
 
 namespace WallpaperEngine::Audio::Drivers::Detectors {
-/**
- * Whether the default output is headphones, the question OpenAL Soft's WASAPI backend asks Windows when WE opens its
- * audio device (endpoint form factor Headphones or Headset on a stereo device, mediaextensions64.dll sub_180186400).
- * Here it is the default sink's form factor or active port type. WE reopens the device on every endpoint change while
- * its "reloadaudio" setting is on (sub_14006CEA0), so the answer follows sink and default sink changes.
- *
- * A sound server that goes away (a PipeWire restart) is waited for, not polled: the new context connects with
- * PA_CONTEXT_NOFAIL, and libpulse then waits for org.pulseaudio.Server to appear on D-Bus, which pipewire-pulse and
- * PulseAudio claim once they listen. Without D-Bus, or with PULSE_SERVER set, libpulse can't wait that way and the
- * detector tries again every 2 s.
- */
+// whether the default output is headphones, what OpenAL Soft's WASAPI backend asks Windows (Headphones/Headset form
+// factor on stereo, sub_180186400); follows sink changes like WE's reloadaudio a server that goes away is waited for
+// with PA_CONTEXT_NOFAIL over D-Bus, without D-Bus or with PULSE_SERVER it retries every 2 s
 class HeadphonesDetector {
 public:
     HeadphonesDetector ();

+ 1 - 2
src/WallpaperEngine/Audio/Drivers/Detectors/PulseAudioPlayingDetector.cpp

@@ -42,7 +42,7 @@ PulseAudioPlayingDetector::PulseAudioPlayingDetector (
 
     pa_context_connect (this->m_context, nullptr, PA_CONTEXT_NOFLAGS, nullptr);
 
-    // lock until pulseaudio allows connection
+    // wait until pulseaudio accepts the connection
     while (pa_context_get_state (this->m_context) != PA_CONTEXT_READY) {
 	pa_mainloop_iterate (this->m_mainloop, 1, nullptr);
     }
@@ -71,7 +71,6 @@ void PulseAudioPlayingDetector::update () {
 
     pa_operation* op = pa_context_get_server_info (this->m_context, defaultSinkInfoCallback, this);
 
-    // wait until all the operations are done
     while (pa_operation_get_state (op) == PA_OPERATION_RUNNING) {
 	pa_mainloop_iterate (this->m_mainloop, 1, nullptr);
     }

+ 2 - 4
src/WallpaperEngine/Audio/Drivers/PulseProcessVolume.h

@@ -8,10 +8,8 @@
 #include <pulse/pulseaudio.h>
 
 namespace WallpaperEngine::Audio::Drivers {
-/**
- * Sets the volume of the PulseAudio streams of one process tree (matched by application.process.id), which is
- * how --volume reaches a web wallpaper since CEF can only mute. Never blocks, failed connections are retried.
- */
+// volume of one process tree's PulseAudio streams, how --volume reaches web wallpapers since CEF can only mute; never
+// blocks
 class PulseProcessVolume {
 public:
     explicit PulseProcessVolume (pid_t root);

+ 3 - 11
src/WallpaperEngine/Audio/Drivers/Recorders/PlaybackRecorder.h

@@ -17,23 +17,15 @@ public:
 
     virtual ~PlaybackRecorder () = default;
 
-    /**
-     * Runs once per rendered frame, turns the latest captured spectrum into audio16/32/64
-     *
-     * @param dt Seconds since the previous frame, scaled by the playback speed
-     */
+    // once per rendered frame, latest spectrum into audio16/32/64
     virtual void update (float dt);
 
     /** Guards the captured spectrum for recorders that fill it from a background capture thread; no-op by default */
     virtual void lock () const { }
     virtual void unlock () const { }
 
-    /**
-     * Registers a callback to be pushed every new spectrum instead of polling audio64 once per rendered frame,
-     * which at low --fps values adds up to a whole frame of latency. Does nothing for recorders that don't capture.
-     *
-     * @return An id for removeSpectrumListener. After that call returns the callback is guaranteed not to be running
-     */
+    // pushes every new spectrum instead of polling audio64 per frame (a frame of latency at low --fps); not running
+    // anymore once removeSpectrumListener returns
     int addSpectrumListener (SpectrumListener listener);
     void removeSpectrumListener (int id);
 

+ 4 - 8
src/WallpaperEngine/Audio/Drivers/Recorders/PulseAudioPlaybackRecorder.cpp

@@ -15,8 +15,7 @@ namespace {
     constexpr int CAPTURE_CHANNELS = 2;
     constexpr auto CAPTURE_TIMEOUT = std::chrono::milliseconds (1000);
 
-    // Timestamp helper backing the debug-only capture markers below - useful for tracking down
-    // audio-to-visual delay regressions in the future.
+    // timestamps for the debug capture markers (audio-to-visual delay)
     std::string wallClockTimestamp () {
 	const auto now = std::chrono::system_clock::now ();
 	const auto ms = std::chrono::duration_cast<std::chrono::milliseconds> (now.time_since_epoch ()) % 1000;
@@ -203,7 +202,7 @@ void pa_context_notify_cb (pa_context* ctx, void* userdata) {
 		    pa_operation_unref (o);
 		}
 
-		// context being ready means to fetch the sink too
+		// a ready context fetches the sink too
 		pa_operation* o2 = pa_context_get_server_info (ctx, &pa_server_info_cb, userdata);
 
 		if (o2) {
@@ -244,11 +243,8 @@ PulseAudioPlaybackRecorder::PulseAudioPlaybackRecorder () :
 	pa_mainloop_iterate (this->m_mainloop, 1, nullptr);
     }
 
-    // Capture used to be pumped from the render loop (pa_mainloop_iterate() once per frame via
-    // update()), so a slow frame - a GPU/compositor stall, a heavy shader pass - stalled capture
-    // along with it. PulseAudio/PipeWire then force-drops the backlog once its buffer overflows,
-    // so the wallpaper "catches up" all at once instead of reacting smoothly. Capture now runs on
-    // its own thread so it keeps draining regardless of what rendering is doing.
+    // capture on its own thread: pumped from the render loop a slow frame stalled it and the server force-dropped the
+    // backlog
     this->m_captureThread
 	= SDL_CreateThread (&PulseAudioPlaybackRecorder::captureThreadEntry, "lwe-audiocapture", this);
 }

+ 1 - 2
src/WallpaperEngine/Audio/Drivers/Recorders/PulseAudioPlaybackRecorder.h

@@ -44,8 +44,7 @@ private:
     WallpaperEngine::Audio::SpectrumAnalyzer m_analyzer;
     std::chrono::steady_clock::time_point m_lastSamples = std::chrono::steady_clock::now ();
 
-    // Capture runs on its own thread (see the constructor) so it keeps draining PulseAudio
-    // regardless of how long a render frame takes
+    // own thread so capture keeps draining however long a frame takes
     SDL_Thread* m_captureThread = nullptr;
     mutable SDL_mutex* m_dataMutex = nullptr;
     std::atomic<bool> m_running { true };

+ 5 - 9
src/WallpaperEngine/Audio/Drivers/SDLAudioDriver.cpp

@@ -46,7 +46,7 @@ void audio_callback (void* userdata, uint8_t* streamData, int length) {
 
     memset (streamData, 0, length);
 
-    // if audio is playing do not do anything here!
+    // do nothing while other audio plays
     if (driver->getAudioDetector ().anythingPlaying ()) {
 	return;
     }
@@ -386,10 +386,8 @@ int SDLAudioDriver::addStream (AudioStream* stream, int volume, float left, floa
     return newStreamId;
 }
 void SDLAudioDriver::removeStream (int streamId) {
-    // must hold the same lock the SDL audio callback thread holds while it iterates m_streams and
-    // calls into each stream (decodeFrame, ...) - without it, erasing here can race
-    // the callback's map iteration (heap corruption) and the caller may go on to delete the
-    // AudioStream while the callback thread is still using it
+    // same lock the audio callback holds while iterating m_streams, else erasing races it and the stream may be deleted
+    // in use
     SDL_LockMutex (this->m_streamListMutex);
 
     if (const auto it = this->m_streams.find (streamId); it != this->m_streams.end ()) {
@@ -401,10 +399,8 @@ void SDLAudioDriver::removeStream (int streamId) {
 }
 
 void SDLAudioDriver::setStreamVolume (int streamId, int volume) {
-    // no stream list lock here: every sound calls this each frame, and the audio callback holds that lock
-    // while it decodes and mixes all streams, which would make the render thread wait on every callback.
-    // The map is only modified by addStream/removeStream on the render thread, the same
-    // thread calling this, and the callback only reads it, so the lookup is safe and the volume is atomic
+    // no lock: called every frame per sound and the callback holds it while mixing; only this thread modifies the map,
+    // the volume is atomic
     if (const auto it = this->m_streams.find (streamId); it != this->m_streams.end ()) {
 	it->second->volume.store (volume, std::memory_order_relaxed);
     }

+ 2 - 5
src/WallpaperEngine/Audio/Drivers/SDLAudioDriver.h

@@ -97,11 +97,8 @@ private:
     /** OpenAL's HRTF path for the voices of one update: convolve, then ProcessHrtf, added to out */
     void mixHrtf (const std::vector<SDLAudioBuffer*>& voices, float* out, int frames);
 
-    /**
-     * Frames OpenAL Soft mixes per update in WE: its default 20 ms period (882 at 44.1 kHz, alcOpenDevice) as a
-     * multiple of the WASAPI endpoint period at the device rate (sub_180186400); the mixer thread renders an update
-     * whenever that much of the WASAPI buffer is free
-     */
+    // frames WE's OpenAL Soft mixes per update: its 20 ms default (882 at 44.1 kHz) as a multiple of the WASAPI period
+    // at the device rate (sub_180186400)
     int m_updateFrames = 960;
     /** mixed updates the device hasn't taken yet */
     std::vector<float> m_pending;

+ 5 - 15
src/WallpaperEngine/Audio/Hrtf.h

@@ -5,14 +5,9 @@
 #include <memory>
 #include <vector>
 
-/**
- * OpenAL Soft 1.21.1's HRTF renderer, the one WE's mediaextensions64.dll links statically (alc/hrtf.cpp,
- * core/mixer/hrtfbase.h, alc/voice.cpp DoHrtfMix, common/polyphase_resampler.cpp; LGPL, Chris Robinson). WE
- * creates its context without attributes, so OpenAL turns HRTF on by itself for a stereo headphones/headset endpoint
- * (aluInitRenderer sub_1801990F0, WASAPI form factor 3 or 5 in sub_180186400) and renders in its default "full" mode:
- * every voice is convolved with the built-in KEMAR data set (embedded byte for byte in the DLL), resampled to the
- * device rate.
- */
+// OpenAL Soft 1.21.1's HRTF renderer as linked into WE's mediaextensions64.dll (alc/hrtf.cpp, hrtfbase.h, voice.cpp
+// DoHrtfMix, polyphase_resampler.cpp; LGPL, Chris Robinson) OpenAL turns it on by itself for stereo headphones/headset
+// endpoints (sub_1801990F0, sub_180186400): full mode, built-in KEMAR set resampled to the device rate
 namespace WallpaperEngine::Audio::Hrtf {
 constexpr unsigned HistoryLength = 64;
 constexpr unsigned HrirLength = 128;
@@ -66,13 +61,8 @@ class Mixer {
 public:
     explicit Mixer (unsigned irSize);
 
-    /**
-     * DoHrtfMix for one channel over one mixing pass of count samples (at most BufferLineSize).
-     *
-     * @param counter OpenAL's fade counter: 0 on a voice's first update (no fade), the update size after that, minus
-     * what earlier passes of the update mixed
-     * @param outPos where the pass starts in the update, the IR crossfade only happens in the first pass
-     */
+    // DoHrtfMix for one channel over a pass of count samples; counter is OpenAL's fade counter (0 on a voice's first
+    // update), the IR crossfade only happens at outPos 0
     void mix (
 	Channel& channel, const Filter& target, const float* samples, unsigned count, unsigned counter,
 	unsigned outPos = 0

+ 4 - 13
src/WallpaperEngine/Audio/SpectrumAnalyzer.h

@@ -6,12 +6,8 @@
 #include "kiss_fft.h"
 
 namespace WallpaperEngine::Audio {
-/**
- * Turns captured samples into the 64 band left/right spectrum the way wallpaper64.exe's capture thread does
- * (sub_1400B2850). Samples are collected into blocks of two thirds of the FFT size, every block is transformed
- * on its own (no overlap) and the bins are folded into 64 bands on a pow(x, 0.25) curve. The result is linear
- * magnitude, SpectrumProcessor turns it into what shaders and scripts see.
- */
+// 64 band left/right spectrum like wallpaper64.exe's capture thread (sub_1400B2850): blocks of 2/3 the FFT size, no
+// overlap, bins folded on a pow(x, 0.25) curve, linear magnitude
 class SpectrumAnalyzer {
 public:
     static constexpr int BANDS = 64;
@@ -22,13 +18,8 @@ public:
     SpectrumAnalyzer (const SpectrumAnalyzer&) = delete;
     SpectrumAnalyzer& operator= (const SpectrumAnalyzer&) = delete;
 
-    /**
-     * Feeds one packet of interleaved samples (1 or 2 channels, -1..1). WE takes a packet only up to the end of
-     * the block it is filling and drops the rest of it, so does this.
-     *
-     * @param bands Receives [left 64 | right 64] when a block completed
-     * @return If a block completed and bands was written
-     */
+    // one packet of 1-2 channel samples, the rest past the block's end is dropped like WE; true with bands [left 64 |
+    // right 64] when a block completed
     bool feed (const float* samples, std::size_t frames, int channels, float* bands);
 
     /** Drops the partially filled block, WE does this on silent packets and capture errors */

+ 3 - 9
src/WallpaperEngine/Audio/SpectrumProcessor.h

@@ -1,19 +1,13 @@
 #pragma once
 
 namespace WallpaperEngine::Audio {
-/**
- * The per-frame half of wallpaper64.exe's audio pipeline (main loop sub_1400E7240): scales each group of 8 bands
- * by a slowly tracking level of that group, smooths the result and limits how fast it may move, then builds the
- * 64/32/16 band buffers shaders, scripts and particles read. Each buffer is [left | right | average].
- */
+// per-frame half of WE's audio pipeline (sub_1400E7240): per-group level tracking, smoothing and rate limits, then the
+// [left | right | average] 64/32/16 band buffers
 class SpectrumProcessor {
 public:
     static constexpr int GROUPS = 16;
 
-    /**
-     * @param raw [left 64 | right 64] from SpectrumAnalyzer
-     * @param dt Seconds since the previous frame (already scaled by playback speed)
-     */
+    // raw is [left 64 | right 64] from SpectrumAnalyzer, dt already scaled by playback speed
     void update (const float* raw, float dt);
 
     float audio16[16 * 3] = { 0 };

+ 2 - 5
src/WallpaperEngine/Data/Assets/Texture.h

@@ -97,10 +97,7 @@ enum TextureFlags {
 	| TextureFlags_MaskComponents,
 };
 
-/**
- * A part of a mipmap swapped in while a user property condition holds (TEXB0004, wallpaper64.exe 2.8.42
- * sub_14015C8D0), e.g. an alternative outfit painted over the base image
- */
+// part of a mipmap swapped in while a user property condition holds (TEXB0004, sub_14015C8D0)
 struct MipmapPatch {
     uint32_t key = 0;
     uint32_t x = 0;
@@ -153,7 +150,7 @@ struct Texture {
     /** The number after TEXB / TEXS (sub_14015E580) */
     uint32_t containerVersion = 0;
     uint32_t animatedVersion = 0;
-    /** Bitmask of TextureFlags, stored as raw uint32_t */
+    // TextureFlags bitmask
     uint32_t flags = TextureFlags_NoFlags;
     uint32_t width = 0;
     uint32_t height = 0;

+ 1 - 6
src/WallpaperEngine/Data/Builders/VectorBuilder.h

@@ -13,7 +13,6 @@ namespace WallpaperEngine::Data::Builders {
 using namespace WallpaperEngine::Data::Utils::SFINAE;
 
 class VectorBuilder {
-    /** Calls the proper std::strto* function based on the incoming type */
     template <typename type> static type convert (const char* str);
 
     /** Some scenes write vectors as "x,y,z" or pad them with extra spaces ("x  y"), reduce them to "x y z" */
@@ -39,10 +38,7 @@ class VectorBuilder {
     }
 
 public:
-    /**
-     * Returns the vector size (1-4) encoded in a space-separated string.
-     * TODO: move/rename, doesn't really belong here
-     */
+    // vector size (1-4) of a space-separated string. TODO: doesn't belong here
     static int preparseSize (const std::string& input) {
 	const auto str = normalizeSeparators (input);
 	const char* p = str.c_str ();
@@ -65,7 +61,6 @@ public:
 	return 4;
     }
 
-    /** Parses a space-separated string into a glm::vec using std::strto* functions */
     template <int length, typename type, glm::qualifier qualifier>
     [[nodiscard]] static glm::vec<length, type, qualifier> parse (const std::string& input) {
 	static_assert (length >= 1 && length <= 4, "Invalid vector length");

+ 4 - 13
src/WallpaperEngine/Data/JSON.h

@@ -27,12 +27,7 @@ using JSON = nlohmann::basic_json<
     std::map, std::vector, std::string, bool, std::int64_t, std::uint64_t, double, std::allocator,
     nlohmann::adl_serializer, std::vector<std::uint8_t>, JsonExtensions>;
 
-/**
- * Small extensions class that is used as base class of nlohmann's implementation.
- *
- * Provides shorthand methods to reduce the amount of handling required for specific situations
- * (mainly throwing readable exceptions when a value is missing, optional/default values, user settings...)
- */
+// nlohmann base with shorthands: readable missing-value errors, optional/default values, user settings
 class JsonExtensions {
 public:
     using base_type = JSON;
@@ -47,9 +42,8 @@ public:
     [[nodiscard]] glm::vec<length, type, qualifier> get () const {
 	const auto& node = this->base ();
 
-	// Most scenes store vectors as "x y z" strings, but some fields (text objects' "size"/"padding")
-	// show up as a bare number (uniform across components) or a JSON array instead. Callers rely on
-	// this being noexcept, so fall back to zero and log rather than throw.
+	// vectors are usually "x y z" strings, but text "size"/"padding" can be a number or array; callers need
+	// noexcept, so log and fall back to zero
 	try {
 	    if (node.is_array ()) {
 		glm::vec<length, type, qualifier> result (static_cast<type> (0));
@@ -175,10 +169,7 @@ public:
 	return operator glm::vec<length, typename GlmVecTraits<T>::type, qualifier> ();
     }
 
-    /**
-     * Parses a wallpaper/asset file the way WE's own loader accepts it: trailing commas
-     * before ] or } and comments are allowed (workshop effect.json files ship with them)
-     */
+    // parses like WE's loader: trailing commas before ] or } and comments are allowed
     [[nodiscard]] static base_type parseAsset (const std::string& content);
 
 private:

+ 1 - 3
src/WallpaperEngine/Data/Model/Color.h

@@ -2,9 +2,7 @@
 #include <glm/vec4.hpp>
 
 namespace WallpaperEngine::Data::Model {
-/**
- * Representation of a color using RGBA components in the 0.0f - 1.0f range
- */
+// RGBA in 0-1
 struct Color : private glm::vec4 {
     using glm::vec4::vec4;
     using glm::vec4::operator=;

+ 2 - 5
src/WallpaperEngine/Data/Model/ImageAdjustments.h

@@ -4,11 +4,8 @@
 #include <string>
 
 namespace WallpaperEngine::Data::Model {
-/**
- * Wallpaper Engine's own per-wallpaper image settings from its browser's properties panel, in its slider units:
- * brightness, contrast, saturation and hue go 0-100 with 50 as neutral, filter strength goes 0-100.
- * Unset fields fall through to the next source (command line, then preset, then Wallpaper Engine's defaults).
- */
+// WE's per-wallpaper image settings in its slider units (0-100, 50 neutral; filter strength 0-100)
+// unset fields fall through: command line, preset, WE's defaults
 struct ImageAdjustments {
     /** wec_e, the color options only apply while this is on */
     std::optional<bool> colorEnabled;

+ 2 - 4
src/WallpaperEngine/Data/Model/Model.h

@@ -13,8 +13,7 @@ struct ModelStruct {
     std::string filename;
     MaterialUniquePtr material;
     bool solidlayer;
-    /** Marked GPU-instanced but not actually batched - each object still renders individually with
-     *  its own transform/color, visually equivalent to batching but not a single draw call. */
+    // not actually batched, each object still draws on its own
     bool instanced;
     bool fullscreen;
     bool passthrough;
@@ -24,8 +23,7 @@ struct ModelStruct {
     bool nopadding;
     std::optional<int> width;
     std::optional<int> height;
-    /** Offset of the autosize canvas center from the puppet's actual content pivot - needed when the
-     *  rig doesn't sit in the middle of its bounding box (e.g. an arm attached at the wrist). */
+    // autosize canvas center offset from the puppet's content pivot (rigs off-center in their bounds)
     std::optional<glm::vec2> cropOffset;
     std::optional<std::string> puppet;
 };

+ 14 - 27
src/WallpaperEngine/Data/Model/Object.h

@@ -42,13 +42,12 @@ struct ObjectData {
     mutable std::optional<int> parent;
     /** Name of a named attachment point on the parent's puppet rig to follow, if any */
     mutable std::optional<std::string> attachment;
-    /** Explicit paint-order override (scene.json's "sortorder") - lower draws first (further back).
-     *  Falls back to this object's array position when absent. */
+    // scene.json "sortorder", lower draws first; the array position otherwise
     std::optional<int> sortOrder;
     /** object +292, 0 unless set (sub_1401E0530) */
     UserSettingUniquePtr sortOrderValue;
     UserSettingUniquePtr origin;
-    /** Transform fields for generic scene/group objects. Typed objects keep their own transform fields. */
+    // generic scene/group objects only, typed objects keep their own
     UserSettingUniquePtr groupScale;
     UserSettingUniquePtr groupAngles;
     UserSettingUniquePtr groupVisible;
@@ -57,8 +56,7 @@ struct ObjectData {
     UserSettingUniquePtr solid;
     /** A visible object hit by the cursor keeps the objects below it from getting cursor events */
     UserSettingUniquePtr disablePropagation;
-    /** Drawn with a perspective camera in 2D scenes (general.perspectiveoverridefov), only the object's own flag counts
-     */
+    // perspective camera in 2D scenes (perspectiveoverridefov), only the object's own flag counts
     UserSettingUniquePtr perspective;
     /** Drawn into the planar reflection (_rt_Reflection), only a JSON false turns it off (sub_14018FF60) */
     bool reflected = true;
@@ -152,8 +150,8 @@ struct ImageData {
     /** Applied after the material is rendered */
     std::vector<ImageEffectUniquePtr> effects;
     std::vector<ImageAnimationLayerUniquePtr> animationLayers;
-    /** A "shape": "quad" object: no image, only its last effect drawn straight onto the scene on a square of the scene
-     *  height (wallpaper64.exe 2.8.42 shape class, vtable off_140491D10) */
+    // "shape": "quad": no image, only its last effect drawn onto the scene on a square of the scene height (2.8.42
+    // shape class)
     bool shape = false;
 };
 
@@ -169,8 +167,7 @@ enum SoundPlaybackMode { PlaybackMode_Single = 0, PlaybackMode_Loop = 1, Playbac
 struct SoundData {
     SoundPlaybackMode playbackmode;
     std::vector<std::string> sounds;
-    /** Per-object volume (0-1), independent of the global volume - lets a wallpaper with several
-     *  Sound objects (e.g. alternate music tracks) mute all but one via --set-property */
+    // per-object volume (0-1) on top of the global one, e.g. to mute all but one music track via --set-property
     UserSettingUniquePtr volume;
     /** Sound stays muted until a script calls play() on its layer */
     UserSettingUniquePtr startsilent;
@@ -968,15 +965,11 @@ struct ParticleData {
     std::vector<ParticleRenderer> renderers;
     std::vector<ParticleControlPoint> controlPoints;
     std::vector<ParticleChild> children;
-    /**
-     * Bit per control point slot that a remapvalue/remapinitialvalue writes (output "controlpoint",
-     * outputcontrolpoint0). WE's loader flags those 0x10000: the engine stops moving them itself
-     */
+    // control point slots a remapvalue/remapinitialvalue writes (output "controlpoint"), WE flags those 0x10000 and
+    // stops moving them itself
     uint8_t remapOutputControlPoints = 0;
-    /**
-     * The color the particle file's own color initializer (or colorchange) centers on, and whether it has one.
-     * An instanceoverride color is compared against it (wallpaper64.exe sub_1401C45F0)
-     */
+    // the color the file's color initializer (or colorchange) centers on, instanceoverride colors compare against it
+    // (sub_1401C45F0)
     glm::vec3 colorReference = glm::vec3 (1.0f);
     bool hasColor = false;
     /** The override color multiplies the spawn color: no color initializer or a scene older than version 5 */
@@ -993,13 +986,12 @@ public:
 };
 
 struct TextData {
-    /** Initial text content to render (for scripted text, this is the `value` placeholder) */
+    // initial text, the `value` placeholder for scripted text
     UserSettingUniquePtr text;
     /** Font reference from scene (e.g. "fonts/VCR_OSD_MONO.ttf" or "systemfont_arial") */
     std::string font;
     /** Font size in points, optionally bound to a user setting or script */
     UserSettingUniquePtr pointSize;
-    /** Bounding box size */
     glm::vec2 size;
     UserSettingUniquePtr scale;
     /** Text color as linear-space RGB */
@@ -1061,10 +1053,7 @@ public:
 	Object (std::move (data)), TextData (std::move (textData)) { };
     ~Text () override = default;
 };
-/**
- * "point" is the old light that feeds the four fixed slots of genericimage2 and friends
- * (g_LightsPosition/g_LightsColorPremultiplied), the "l" prefixed ones are the newer LightingV1 lights
- */
+// "point" is the legacy light for genericimage2's four fixed slots, the "l" prefixed ones are LightingV1
 enum class LightType { Legacy, Point, Spot, Tube, Directional };
 
 struct LightData {
@@ -1102,10 +1091,8 @@ public:
 	Object (std::move (data)), LightData (std::move (lightData)) { };
     ~Light () override = default;
 };
-/**
- * One entry of a camera object's "path" file: keyframed eye/center/up (per component, missing ones keep the
- * camera's own transform), zoom (2D scenes) and fov (3D scenes), played like a property animation
- */
+// a camera "path" file entry: keyframed eye/center/up (missing components keep the camera's transform), zoom (2D) and
+// fov (3D)
 struct CameraTimeline {
     std::string name;
     bool visible = true;

+ 4 - 10
src/WallpaperEngine/Data/Model/Property.h

@@ -132,10 +132,8 @@ public:
 	}
     }
 
-    /**
-     * Presets can carry combo values the wallpaper never listed as an option (a 30 second slideshow interval stored
-     * as 0.5, say), Wallpaper Engine hands those to the page as they are so this makes room for one
-     */
+    // presets can carry combo values the wallpaper never listed (a 30 s interval stored as 0.5), WE passes them through
+    // as is
     void allowValue (const std::string& value) { this->values.emplace (value, value); }
 
     using Property::update;
@@ -208,8 +206,7 @@ private:
 
 class PropertyFile final : public Property {
 public:
-    /** fileType is what the project restricts the property to ("video", or empty for images), only relevant for
-     * directories */
+    // fileType is the project's restriction ("video", or empty for images), only for directories
     explicit PropertyFile (
 	PropertyData data, const std::string& value, bool directory = false, std::string fileType = ""
     ) : Property (std::move (data)), m_directory (directory), m_fileType (std::move (fileType)) {
@@ -238,10 +235,7 @@ private:
     std::string m_value;
 };
 
-/**
- * Starts out unassigned whatever the wallpaper ships, only a value the user set (--set-property or a hotswap)
- * points it anywhere, see Desktop::UserShortcut
- */
+// unassigned whatever the wallpaper ships, only a user value (--set-property or a hotswap) points it anywhere
 class PropertyUserShortcut final : public Property {
 public:
     explicit PropertyUserShortcut (PropertyData data) : Property (std::move (data)) {

+ 2 - 5
src/WallpaperEngine/Data/Model/PropertyAnimation.h

@@ -27,11 +27,8 @@ struct AnimationEvent {
     std::string name;
 };
 
-/**
- * Keyframe timeline stored under a property's "animation" key. One curve per vector component
- * (c0..c3); a component with no keyframes is left alone. Properties linked through
- * children/parent share the playback state of the root one.
- */
+// a property's "animation" keyframes, one curve per component (c0..c3), empty curves leave it alone; linked properties
+// share the root's playback
 struct PropertyAnimation {
     enum class Mode { Single, Loop, Mirror };
 

+ 2 - 7
src/WallpaperEngine/Data/Model/UserSetting.h

@@ -8,17 +8,12 @@
 
 namespace WallpaperEngine::Data::Model {
 struct UserSetting {
-    /**
-     * The value of this setting, can be a few different things:
-     * - a value connected to the property
-     * - a default value
-     * - a static value
-     */
+    // a property-bound, default or static value
     DynamicValueUniquePtr value;
     /** The property this setting takes the value from (if specified) */
     PropertySharedPtr property;
     /** Condition required for this setting, this should be possible to run in JS' V8 */
     std::optional<ConditionInfo> condition;
-    /** TODO: Value might come from a script and not have conditions, implement this later */
+    // TODO: values from scripts without conditions
 };
 } // namespace WallpaperEngine::Data::Model

+ 2 - 3
src/WallpaperEngine/Data/Parsers/DynamicValueParser.cpp

@@ -30,9 +30,8 @@ bool isNumericVector (const std::string& str) {
     return count >= 2;
 }
 
-// wallpaper64 sub_1401A4DB0: a "relative" animation is turned into an absolute one at load by adding the
-// property's value to the c0..c2 keys. Only a string value with three space separated parts qualifies, anything
-// else keeps the keys as they are
+// sub_1401A4DB0: a "relative" animation becomes absolute at load by adding the property's value to c0..c2, only for a
+// three part string value
 std::optional<glm::vec3> relativeAnimationBase (const json& value) {
     if (!value.is_string ()) {
 	return std::nullopt;

+ 4 - 9
src/WallpaperEngine/Data/Parsers/Localization.h

@@ -9,20 +9,15 @@
 namespace WallpaperEngine::Data::Parsers {
 using JSON = WallpaperEngine::Data::JSON::JSON;
 
-/**
- * Resolves the texts of a project's properties. Workshop projects only store keys like "ui_background_mode_img" in
- * their properties and keep the actual strings, one table per language, under general.localization.
- */
+// workshop properties store keys like "ui_background_mode_img", the strings live per language under
+// general.localization
 class Localization {
 public:
     /** locale is something like "de-de", by default the one the user's environment asks for */
     explicit Localization (const std::optional<JSON>& general, std::string locale = systemLocale ());
 
-    /**
-     * @return The readable text for a property text or option label: looked up in the user's language, then in
-     * English, with the markup Wallpaper Engine's own UI renders (<small>, <hr>...) removed. Keys that are in no table
-     * are made readable as far as that's possible.
-     */
+    // readable text for a property label: user's language, then English, without WE's UI markup; unknown keys made
+    // readable
     [[nodiscard]] std::string resolve (const std::string& text) const;
 
     /** Drops markup and the parts meant as small print, and tidies whitespace */

+ 2 - 4
src/WallpaperEngine/Data/Parsers/ObjectParser.cpp

@@ -191,10 +191,8 @@ std::string stringOr (const JSON& it, const char* key, const char* fallback) {
     return value != it.end () && value->is_string () ? value->get<std::string> () : fallback;
 }
 
-/**
- * wallpaper64.exe sub_1401C45F0: the color a particle file's color initializer centers on. The last colorrandom,
- * hsvcolorrandom or colorlist wins, without one the first colorchange's start value. Saved as "%.5f" and read back
- */
+// sub_1401C45F0: what a particle file's color initializer centers on, the last colorrandom/hsvcolorrandom/colorlist or
+// the first colorchange's start; saved as "%.5f" and read back
 std::pair<glm::vec3, bool> deriveColorReference (const JSON& particle) {
     glm::vec3 reference (1.0f);
     bool hasColor = false;

+ 1 - 5
src/WallpaperEngine/Data/Utils/AudioSensitivity.h

@@ -3,11 +3,7 @@
 #include <utility>
 
 namespace WallpaperEngine::Data::Utils {
-/**
- * Recomputes an audio-reactive script property's minvalue/maxvalue around their authored midpoint,
- * scaled by `multiplier`: 0 collapses the range to the midpoint (locked, no pulse), 1 is a no-op
- * (the wallpaper's original authored behavior), and >1 exaggerates the swing.
- */
+// scales minvalue/maxvalue around their midpoint: 0 locks it, 1 changes nothing, >1 exaggerates the swing
 inline std::pair<float, float> scaleAudioRange (float originalMin, float originalMax, float multiplier) {
     const float mid = (originalMin + originalMax) / 2.0f;
     const float half = (originalMax - originalMin) / 2.0f * multiplier;

+ 1 - 4
src/WallpaperEngine/Data/Utils/MemoryStream.h

@@ -11,10 +11,7 @@ struct MemoryStream : std::istream, private std::streambuf {
 	this->setg (this->m_buffer.get (), this->m_buffer.get (), this->m_buffer.get () + size);
     }
 
-    // Callers occasionally derive seek offsets from untrusted file contents (e.g. a corrupt or
-    // unrecognized .mdl section) and never clamp them. Without clamping here, gptr() can end up past
-    // egptr(); the next read then has libstdc++'s xsgetn compute a negative "bytes available" count,
-    // which turns into a huge size_t passed to memmove and segfaults.
+    // offsets can come from corrupt files, past egptr() libstdc++'s xsgetn would memmove a huge size and segfault
     std::streambuf::pos_type
     seekoff (std::streambuf::off_type off, std::ios_base::seekdir dir, std::ios_base::openmode which) override {
 	char* target = gptr ();

+ 0 - 4
src/WallpaperEngine/Data/Utils/TypeCaster.h

@@ -3,10 +3,6 @@
 #include <stdexcept>
 
 namespace WallpaperEngine::Data::Utils {
-/**
- * A simple implementation of type and sub-types casting to be as explicit
- * as possible while being performant
- */
 class TypeCaster {
 public:
     virtual ~TypeCaster () = default;

+ 7 - 13
src/WallpaperEngine/Debugging/CallStack.cpp

@@ -64,9 +64,9 @@ using namespace std;
 const char* CallStack::Unknown_Function = "[unknown function]";
 const char* CallStack::Unknown_Module = "[unknown module]";
 
-CallStack::CallStack (void) { /* Nothing to do */ }
+CallStack::CallStack (void) { }
 
-CallStack::~CallStack (void) { /* Nothing to do */ }
+CallStack::~CallStack (void) { }
 
 string CallStack::Demangle (const char* name) {
 #if defined(_MSC_VER)
@@ -89,13 +89,12 @@ string CallStack::Demangle (const char* name) {
 class noncopyable // Like the one in boost.
 {
 protected:
-    noncopyable (void) { /* Nothing to do */ }
+    noncopyable (void) { }
 
 private:
     noncopyable (const noncopyable&);
     noncopyable& operator= (const noncopyable&);
 };
-// A global thread mutex class.
 class mutex : noncopyable {
 public:
     mutex (void) { InitializeCriticalSection (&cs); }
@@ -114,7 +113,7 @@ public:
 	GetModuleFileName (NULL, procname, sizeof (procname));
 
 	bfd_init ();
-	abfd = bfd_openr (procname, NULL); // Obtain the bfd pointer.
+	abfd = bfd_openr (procname, NULL);
 	if (abfd == NULL) {
 	    fprintf (stderr, "Error: Failed to parse the executable format.\n");
 	    return;
@@ -132,7 +131,6 @@ public:
 	}
 	free (matching);
 
-	// Obtain the symbol table.
 	unsigned int dummy = 0;
 	if (bfd_read_minisymbols (abfd, FALSE, reinterpret_cast<void**> (&symbol_table), &dummy) == 0
 	    && bfd_read_minisymbols (abfd, TRUE, reinterpret_cast<void**> (&symbol_table), &dummy) < 0) {
@@ -152,7 +150,7 @@ public:
 	fnis_para para;
 	para.symbol_table = symbol_table;
 	para.counter = offset;
-	bfd_map_over_sections (abfd, &find_function_name_in_section, &para); // Call the corresponding functions.
+	bfd_map_over_sections (abfd, &find_function_name_in_section, &para);
 	return para.function;
     }
 
@@ -170,10 +168,10 @@ private:
     static void find_function_name_in_section (bfd* tabfd, asection* tsec, void* tpara) {
 	fnis_para& para = *static_cast<fnis_para*> (tpara);
 	if (!para.function.empty ()) {
-	    return; // We have got the name.
+	    return;
 	}
 	if (!(bfd_get_section_flags (tabfd, tsec) & SEC_ALLOC)) {
-	    return; // Allocate space for this section.
+	    return;
 	}
 	bfd_vma vma = bfd_get_section_vma (tabfd, tsec);
 	if (para.counter < vma || vma + bfd_get_section_size (tsec) <= para.counter) {
@@ -182,7 +180,6 @@ private:
 	const char* function = NULL;
 	const char* file = NULL;
 	unsigned int line = 0;
-	// Get corresponding file and function name, and line number.
 	if (bfd_find_nearest_line (tabfd, tsec, para.symbol_table, para.counter - vma, &file, &function, &line)
 	    && function) {
 	    para.function = CallStack::Demangle (function);
@@ -195,7 +192,6 @@ private:
 void CallStack::GetCalls (vector<CallStack::CallInfo>& calls) {
 #if defined(_WIN32)
 
-    // Prepare context.
     cs.lock ();
     if (!SymInitialize (GetCurrentProcess (), 0, TRUE)) {
 	fprintf (stderr, "Error: Failed to initialize symbol context.\n");
@@ -205,7 +201,6 @@ void CallStack::GetCalls (vector<CallStack::CallInfo>& calls) {
     bfd_usage bfdu;
 #endif
 
-    // Prepare variables.
 #if defined(_M_AMD64)
     const DWORD machine = IMAGE_FILE_MACHINE_AMD64;
 #else
@@ -237,7 +232,6 @@ void CallStack::GetCalls (vector<CallStack::CallInfo>& calls) {
     char symbol_buffer[sizeof (IMAGEHLP_SYMBOL) + 255];
     char module_name_raw[MAX_PATH];
 
-    // Go over stack.
     calls.clear ();
     while (StackWalk (machine, process, thread, &frame, &context, 0, SymFunctionTableAccess, SymGetModuleBase, 0)) {
 	if (has_limit && limit == 0) {

+ 5 - 5
src/WallpaperEngine/Debugging/CallStack.h

@@ -57,17 +57,17 @@ public:
 
     class CallInfo {
     public:
-	CallInfo (void) { /* Nothing to do */ }
+	CallInfo (void) { }
 	CallInfo (long long unsigned int toffset, const string& tfunction, const string& tmodule) :
-	    offset (toffset), function (tfunction), module (tmodule) { /* Nothing to do */ }
-	~CallInfo (void) { /* Nothing to do */ }
+	    offset (toffset), function (tfunction), module (tmodule) { }
+	~CallInfo (void) { }
 	long unsigned int offset;
 	string function;
 	string module;
     };
 
-    static void GetCalls (vector<CallStack::CallInfo>& calls); // Get the call information.
-    static string Demangle (const char* name); // Demangle the C++ function name.
+    static void GetCalls (vector<CallStack::CallInfo>& calls);
+    static string Demangle (const char* name);
 };
 
 }

+ 2 - 4
src/WallpaperEngine/Desktop/GnomeShell.h

@@ -45,10 +45,8 @@ public:
     [[nodiscard]] bool vanished () const { return this->m_vanished; }
     /** GNOME 45-48: needs a Shell-spawned connection, see openWaylandSocket */
     [[nodiscard]] bool needsHelper () const { return this->m_needsHelper; }
-    /**
-     * The extension spawns the helper via Meta.WaylandClient, returns the connection it hands over or -1. The
-     * helper lives as long as this object, Mutter drops the client when it exits.
-     */
+    // the extension spawns the helper via Meta.WaylandClient, returns its connection or -1; Mutter drops the client
+    // when the helper exits
     [[nodiscard]] int openWaylandSocket ();
 
     /** non-blocking */

+ 2 - 3
src/WallpaperEngine/Desktop/HostWayland.cpp

@@ -124,9 +124,8 @@ int hostConnection () {
     int fd = -1;
 
     if (bound) {
-	// Flatpak keeps the host's name for the sandbox's socket unless it is a path or doesn't start with "wayland-",
-	// then the sandbox gets "wayland-0". That one is left to the host's own WAYLAND_DISPLAY (libwayland's default
-	// is wayland-0 too)
+	// the sandbox's socket keeps the host's name unless that is a path or not "wayland-*", then it's wayland-0,
+	// left to the host's own WAYLAND_DISPLAY
 	const std::string name = std::filesystem::path (display != nullptr ? display : "wayland-0").filename ();
 	const char* runtime = std::getenv ("XDG_RUNTIME_DIR");
 	std::vector<std::string> arguments { "flatpak-spawn", "--host" };

+ 3 - 7
src/WallpaperEngine/Desktop/HostWayland.h

@@ -3,13 +3,9 @@
 struct wl_display;
 
 namespace WallpaperEngine::Desktop {
-/**
- * A Wayland connection for the engine. Inside a Flatpak the compositor sees the app through Flatpak's
- * wp_security_context socket, and Hyprland (and other wlroots compositors) hide zwlr_layer_shell_v1 and the foreign
- * toplevel list from sandboxed clients. When that socket has no layer shell, the connection comes from the helper
- * started on the host through flatpak-spawn, which connects to the compositor's own socket and hands it over. The app
- * can run host commands anyway (org.freedesktop.Flatpak), this gains nothing it didn't have. Null on failure.
- */
+// a Wayland connection for the engine: Flatpak's wp_security_context socket hides layer shell and foreign toplevels on
+// wlroots compositors (Hyprland), then the connection comes from a host helper via flatpak-spawn (nothing the app
+// couldn't already do). Null on failure
 wl_display* connectWayland ();
 
 /** Whether connectWayland goes through the host helper, decided on first use */

+ 3 - 6
src/WallpaperEngine/Desktop/HyprlandIPC.h

@@ -4,12 +4,9 @@
 #include <string>
 
 namespace WallpaperEngine::Desktop {
-/**
- * The request socket of the Hyprland we run on, empty when there is none. HYPRLAND_INSTANCE_SIGNATURE names it; without
- * the variable (a Flatpak started outside the session's environment) or when it names a gone instance, the live ones in
- * $XDG_RUNTIME_DIR/hypr are looked at: the one whose hyprland.lock names our Wayland display, else the newest, but that
- * one only when XDG_CURRENT_DESKTOP (currentDesktop) names Hyprland, a nested or other session's instance isn't ours
- */
+// the request socket of our Hyprland, empty when there is none: HYPRLAND_INSTANCE_SIGNATURE, else (Flatpak, stale
+// variable) the live instance in $XDG_RUNTIME_DIR/hypr whose hyprland.lock names our display, else the newest one when
+// XDG_CURRENT_DESKTOP (currentDesktop) names Hyprland
 std::string findHyprlandSocket (
     const std::string& runtimeDir, const char* signature, const char* waylandDisplay, const char* currentDesktop
 );

+ 2 - 4
src/WallpaperEngine/Desktop/SessionBus.h

@@ -10,10 +10,8 @@ std::string runtimeDirectory ();
 /** A key of /.flatpak-info's [Instance] group (instance-id, app-path, ...), empty outside a Flatpak or when missing */
 std::string flatpakInfo (const std::string& key);
 
-/**
- * This process in names other processes see (D-Bus names, KWin scripts, sockets, shm): the pid, inside a Flatpak
- * "<instance id>_<pid>", since every run of a Flatpak has a pid namespace of its own and pids repeat between them
- */
+// this process in names others see (D-Bus, KWin scripts, sockets, shm): the pid, "<instance id>_<pid>" in a Flatpak
+// since pids repeat between sandboxes
 std::string processTag ();
 
 /** The descriptor sent along one byte over a unix socket (SCM_RIGHTS), -1 on failure */

+ 2 - 5
src/WallpaperEngine/Desktop/UserShortcut.cpp

@@ -244,11 +244,8 @@ bool isExecutableFile (const std::string& path) {
     return stat (path.c_str (), &info) == 0 && S_ISREG (info.st_mode) && access (path.c_str (), X_OK) == 0;
 }
 
-/**
- * Double fork so the app is reparented away from the engine and never becomes a zombie. Everything the child
- * needs is prepared before fork() since the engine is multithreaded. The engine's own library path and preloads
- * would break other programs, so they are left out of the environment.
- */
+// double fork so the app is reparented and never a zombie, everything prepared before fork() (threaded engine); our
+// library path and preloads are left out of its environment
 bool spawnDetached (std::vector<std::string> arguments, const std::string& workingDirectory = "") {
     if (arguments.empty ()) {
 	return false;

+ 3 - 6
src/WallpaperEngine/Desktop/UserShortcut.h

@@ -5,12 +5,9 @@
 #include <string>
 
 namespace WallpaperEngine::Desktop {
-/**
- * What a "usershortcut" property points at once the user assigned it, and how to open it. Values are either the
- * real engine's JSON ({"commandtype": "file" | "directory" | "web" | "command", "file": ..., "arguments": ...},
- * plus "application" for a .desktop file) or a plain string: a .desktop file or id, a URL, a folder or a file.
- * Commands are only ever run when explicitly typed as one.
- */
+// what an assigned "usershortcut" points at: WE's JSON ({"commandtype": "file" | "directory" | "web" | "command",
+// "file", "arguments", "application"}) or a plain string (.desktop file or id, URL, folder, file); commands only run
+// when typed as one
 struct UserShortcut {
     enum class Type { Application, File, Directory, Web, Command };
 

+ 4 - 5
src/WallpaperEngine/FileSystem/Adapters/Types.h

@@ -12,8 +12,8 @@
 namespace WallpaperEngine::FileSystem::Adapters {
 using namespace WallpaperEngine::Data::Utils;
 
-// Whether candidate is wanted with one "workshop/<anything>" segment inserted before the basename.
-// Scripts reference bundled workshop-dependency assets by their original, un-prefixed name.
+// candidate is path with one "workshop/<anything>" segment before the basename, scripts use dependency assets'
+// un-prefixed names
 inline bool isWorkshopDependencyAliasOf (const std::string& candidate, const std::filesystem::path& wanted) {
     const std::string dir = wanted.parent_path ().generic_string ();
     const std::string basename = wanted.filename ().string ();
@@ -49,9 +49,8 @@ inline std::string shortNameChars (std::string_view part) {
     return out;
 }
 
-// Which sibling a Windows 8.3 alias like "KONACH~1.TEX" stood for on the author's disk. Scenes sometimes reference
-// those (3810078802), but packages and copies only carry the long names. Windows numbers the aliases sharing a
-// basis and extension in creation order, which isn't stored anywhere, so the siblings are taken in name order.
+// the sibling a Windows 8.3 alias like "KONACH~1.TEX" stood for (3810078802); Windows numbers aliases in creation
+// order, which isn't stored, so siblings go in name order
 inline std::optional<std::string> resolveShortNameAlias (std::vector<std::string> siblings, const std::string& wanted) {
     const auto dot = wanted.rfind ('.');
     const std::string stem = wanted.substr (0, dot);

+ 1 - 5
src/WallpaperEngine/FileSystem/Container.cpp

@@ -13,11 +13,7 @@
 using namespace WallpaperEngine::FileSystem;
 using namespace WallpaperEngine::FileSystem::Adapters;
 
-/**
- * Normalizes a path to strip relative components; not a security measure, just lets adapters
- * with no real filesystem behind them trust the input without much validation.
- * @see https://en.cppreference.com/w/cpp/filesystem/path/lexically_normal
- */
+// strips relative components so adapters can trust the path, not a security measure
 std::filesystem::path normalize_path (const std::filesystem::path& input_path) {
     return input_path.lexically_normal ();
 }

+ 2 - 14
src/WallpaperEngine/FileSystem/Container.h

@@ -19,28 +19,16 @@ public:
 
     [[nodiscard]] std::string readString (const std::filesystem::path& path) const;
 
-    /**
-     * Tries to resolve the given file into an absolute, real, filesystem path
-     * to be used as info for other tools that might require it (like MPV)
-     *
-     * @param path The path to resolve to a real file
-     * @return The full public, absolute path to the given file
-     */
+    // the real filesystem path, for tools like mpv
     [[nodiscard]] std::filesystem::path physicalPath (const std::filesystem::path& path) const;
 
-    /**
-     *
-     * @param path Base of the mountpoint
-     * @param mountPoint Where in the VFS to mount it
-     */
     AdapterSharedPtr mount (const std::filesystem::path& path, const std::filesystem::path& mountPoint);
 
     VirtualAdapter& getVFS () const;
 
     void registerAdapterFactory (FactoryUniquePtr factory);
 
-    /** Looks for a workshop-dependency-prefixed variant of path across every mounted adapter, only as a fallback when
-     * the literal path fails */
+    // workshop-dependency-prefixed variant across all adapters, fallback when the literal path fails
     [[nodiscard]] std::optional<std::filesystem::path>
     resolveWorkshopDependencyAlias (const std::filesystem::path& path) const;
 

+ 1 - 1
src/WallpaperEngine/Input/Drivers/GLFWMouseInput.cpp

@@ -21,7 +21,7 @@ void GLFWMouseInput::update () {
 
     glfwGetCursorPos (this->m_driver.getWindow (), &this->m_mousePosition.x, &this->m_mousePosition.y);
 
-    // Convert from GLFW coordinate system (Y=0 at top) to OpenGL coordinate system (Y=0 at bottom)
+    // GLFW has y down, GL y up
     const glm::ivec2 framebufferSize = this->m_driver.getFramebufferSize ();
     this->m_mousePosition.y = static_cast<double> (framebufferSize.y) - this->m_mousePosition.y;
 

+ 2 - 5
src/WallpaperEngine/Input/Drivers/KDECursorInput.h

@@ -13,11 +13,8 @@
 
 namespace WallpaperEngine::Input::Drivers {
 
-// Background layer-shell surfaces never receive real pointer motion events, and there's no
-// portable Wayland protocol to just ask the compositor for the cursor position. KWin itself
-// always knows it though, so this loads a small script into the running KWin instance via its
-// Scripting D-Bus interface; the script forwards workspace.cursorPosChanged to a D-Bus service
-// hosted here. If setup fails, isInitialized() is false and callers should fall back elsewhere.
+// background layer-shell surfaces get no pointer motion and Wayland has no cursor query, so a KWin script forwards
+// workspace.cursorPosChanged over D-Bus; check isInitialized()
 class KDECursorInput {
 public:
     KDECursorInput ();

+ 1 - 2
src/WallpaperEngine/Input/Drivers/WaylandMouseInput.h

@@ -41,8 +41,7 @@ private:
     [[nodiscard]] std::optional<glm::dvec2> queryHyprlandCursorPosition ();
     [[nodiscard]] static std::string findHyprlandSocket ();
 #ifdef ENABLE_X11
-    // last-resort fallback: XWayland's root window pointer only tracks the real cursor while it's
-    // over an XWayland-backed window, but that's still better than nothing on compositors with no IPC
+    // last resort: XWayland's root pointer only tracks the cursor over XWayland windows
     [[nodiscard]] std::optional<glm::dvec2> queryX11CursorPosition () const;
 #endif /* ENABLE_X11 */
     /** the pointer in that output's buffer pixels, y up */

+ 2 - 12
src/WallpaperEngine/Input/MouseInput.h

@@ -6,18 +6,8 @@
 namespace WallpaperEngine::Input {
 enum MouseClickStatus : int { Released = 0, Clicked = 1 };
 
-/**
- * Handles mouse input for the background
- *
- * Coordinate System Convention:
- * - Engine uses OpenGL bottom-left origin (Y=0 at bottom, Y=height at top)
- * - Window systems (GLFW/Wayland) use top-left origin (Y=0 at top, Y=height at bottom)
- * - CEF/web uses top-left origin (Y=0 at top, Y=height at bottom)
- *
- * Input drivers convert from window system coordinates to OpenGL coordinates.
- * Render code normalizes OpenGL coordinates (0=bottom, 1=top).
- * Web wallpapers convert from OpenGL coordinates to CEF coordinates.
- */
+// engine coordinates are GL y up, GLFW/Wayland/CEF are y down; drivers convert to GL, web wallpapers convert back for
+// CEF
 class MouseInput {
 public:
     virtual ~MouseInput () = default;

+ 2 - 10
src/WallpaperEngine/Media/MediaSource.h

@@ -41,17 +41,9 @@ public:
 
     virtual void update ();
 
-    /**
-     * @param listener The callback to call when media info changes
-     *
-     * @return A function that can be called to remove the listener
-     */
+    // returns a function removing the listener
     std::function<void ()> addMetadataListener (std::function<void (const MediaInfo&)> listener);
-    /**
-     * @param listener The callback to call when media info changes
-     *
-     * @return A function that can be called to remove the listener
-     */
+    // returns a function removing the listener
     std::function<void ()> addAlbumArtListener (std::function<void (const MediaInfo&)> listener);
 
     [[nodiscard]] const MediaInfo& getMediaInfo () const { return m_mediaInfo; }

+ 3 - 10
src/WallpaperEngine/Media/ThumbnailPalette.h

@@ -8,9 +8,7 @@
 #include <glm/vec3.hpp>
 
 namespace WallpaperEngine::Media {
-/**
- * The colors scripts receive with a media thumbnail event.
- */
+// the colors scripts get with a media thumbnail event
 struct ThumbnailPalette {
     glm::vec3 primary = { 0.12f, 0.12f, 0.12f };
     glm::vec3 secondary = { 0.0f, 0.0f, 0.0f };
@@ -21,14 +19,9 @@ struct ThumbnailPalette {
     glm::vec3 highContrast = { 1.0f, 1.0f, 1.0f };
 };
 
-/**
- * Picks the dominant colors of an RGBA8 image: the most common colors that are visibly different
- * from each other, most common first.
- */
+// the most common, visibly different colors of an RGBA8 image, most common first
 ThumbnailPalette computeThumbnailPalette (const uint8_t* rgba, size_t width, size_t height);
 
-/**
- * Decodes the image at the given path and returns its palette, or the default one if it cannot be read.
- */
+// the default palette if the image can't be read
 ThumbnailPalette loadThumbnailPalette (const std::string& path);
 } // namespace WallpaperEngine::Media

+ 2 - 4
src/WallpaperEngine/Render/CFBO.cpp

@@ -84,8 +84,7 @@ CFBO::CFBO (
     } else if (flags & TextureFlags_ClampUVsBorder) {
 	glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
 	glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
-	// without this the border defaults to transparent black, which GL_LINEAR filtering smears
-	// into the last edge texel; this keeps out-of-bounds areas (letterboxing, zoomed-out scaling) solid
+	// an opaque border, else GL_LINEAR smears transparent black into the edge texels (letterboxing, zoomed out)
 	glTexParameterfv (GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, &borderColor.x);
     } else {
 	glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
@@ -126,8 +125,7 @@ CFBO::CFBO (
 	sLog.exception ("Framebuffers are not properly set");
     }
 
-    // must start transparent: the scene clear color is often opaque and would make empty layer
-    // areas render as solid rectangles
+    // start transparent, an opaque scene clear color would make empty layer areas solid
     GLfloat previousClearColor[4] = {};
     glGetFloatv (GL_COLOR_CLEAR_VALUE, previousClearColor);
     glClearColor (0.0f, 0.0f, 0.0f, 0.0f);

+ 1 - 4
src/WallpaperEngine/Render/CFBO.h

@@ -17,10 +17,7 @@ public:
     );
     ~CFBO () override;
 
-    /**
-     * Parses a "RRGGBB" or "RRGGBBAA" hex color (an optional leading '#' is stripped), or
-     * std::nullopt if value isn't a valid hex color. Used for --corner-color and its hotswap key.
-     */
+    // "RRGGBB" or "RRGGBBAA" with an optional '#', for --corner-color
     static std::optional<glm::vec4> parseColor (const std::string& value);
 
     /** Adds a depth buffer, only 3D scenes draw into the scene buffer with depth testing */

+ 2 - 5
src/WallpaperEngine/Render/CTexture.h

@@ -19,9 +19,6 @@ namespace WallpaperEngine::Render {
 class RenderContext;
 using namespace WallpaperEngine::Data::Assets;
 using namespace WallpaperEngine::VideoPlayback::MPV;
-/**
- * A normal texture file in WallpaperEngine's format
- */
 class CTexture final : public TextureProvider, public Helpers::ContextAware {
 public:
     explicit CTexture (RenderContext& context, TextureUniquePtr header);
@@ -38,9 +35,9 @@ public:
     [[nodiscard]] const std::vector<FrameSharedPtr>& getFrames () const override;
     [[nodiscard]] bool isAnimated () const override;
 
-    /** For video CTextures, playback only starts once usage count goes above zero (initializes mpv if needed) */
+    // video textures start playing (and set up mpv) once the count goes above zero
     void incrementUsageCount () const override;
-    /** For video CTextures, playback only stops once usage count reaches zero (de-initializes mpv if needed) */
+    // and stop once it's back at zero
     void decrementUsageCount () const override;
     void update () const override;
     bool isReady () const override;

+ 4 - 8
src/WallpaperEngine/Render/CWallpaper.cpp

@@ -39,16 +39,14 @@ CWallpaper::CWallpaper (
     constexpr GLfloat position[] = { -1.0f, 1.0f,  0.0f, 1.0,  1.0f, 0.0f, -1.0f, -1.0f, 0.0f,
 				     -1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f,  -1.0f, 0.0f };
 
-    // GL_DYNAMIC_DRAW: render() rewrites this buffer's contents (via glBufferSubData) whenever
-    // the wallpaper's UVs change. The attrib pointer/enable state below is captured by the VAO
-    // once here rather than redone every render() call - only the buffer's contents change later.
+    // GL_DYNAMIC_DRAW, render() rewrites it when the UVs change; the VAO keeps the attrib setup
     glGenBuffers (1, &this->m_texCoordBuffer);
     glBindBuffer (GL_ARRAY_BUFFER, this->m_texCoordBuffer);
     glBufferData (GL_ARRAY_BUFFER, sizeof (texCoords), texCoords, GL_DYNAMIC_DRAW);
     glEnableVertexAttribArray (this->a_TexCoord);
     glVertexAttribPointer (this->a_TexCoord, 2, GL_FLOAT, GL_FALSE, 0, nullptr);
 
-    // Static for the object's lifetime, so its attrib setup also only needs to happen once here.
+    // static, set up once
     glGenBuffers (1, &this->m_positionBuffer);
     glBindBuffer (GL_ARRAY_BUFFER, this->m_positionBuffer);
     glBufferData (GL_ARRAY_BUFFER, sizeof (position), position, GL_STATIC_DRAW);
@@ -533,8 +531,7 @@ void CWallpaper::present (const glm::ivec4& viewport, const glm::ivec2& globalPo
     float ustart, uend, vstart, vend;
 
     if (this->m_spanInfo.has_value ()) {
-	// span mode: scale the wallpaper to the bounding box using the normal scaling rules
-	// (fill/fit/stretch/default), then slice per monitor
+	// span: scale to the bounding box with the normal scaling rules, then slice per monitor
 	const auto& span = this->m_spanInfo.value ();
 	const float spanW = static_cast<float> (span.totalBounds.z);
 	const float spanH = static_cast<float> (span.totalBounds.w);
@@ -547,8 +544,7 @@ void CWallpaper::present (const glm::ivec4& viewport, const glm::ivec2& globalPo
 	const float baseVstart = base.z;
 	const float baseVend = base.w;
 
-	// this viewport's relative position within the bounding box [0..1]; logicalSize is in the
-	// same coordinate space as globalPosition and totalBounds
+	// this viewport's position in the bounding box [0..1]
 	float relLeft = (static_cast<float> (globalPosition.x) - spanX) / spanW;
 	float relRight = (static_cast<float> (globalPosition.x + logicalSize.x) - spanX) / spanW;
 

+ 10 - 25
src/WallpaperEngine/Render/CWallpaper.h

@@ -68,42 +68,30 @@ public:
 
     virtual void setPause (bool newState);
 
-    /**
-     * Applies the current audio policy to this wallpaper (see --audio-screen/--ambient-volume):
-     * whether it should be muted outright (its screen isn't the designated audio screen), and
-     * the volume non-video content should use instead of the main --volume, if any.
-     *
-     * Default no-op; overridden by wallpaper types that actually produce audio.
-     */
+    // --audio-screen/--ambient-volume: muted off the audio screen, ambientVolume replaces --volume for non-video
+    // content; no-op by default
     virtual void setAudioPolicy (bool muted, std::optional<int> ambientVolume);
 
     [[nodiscard]] const AssetLocator& getAssetLocator () const;
     AudioContext& getAudioContext () const;
     [[nodiscard]] const WallpaperState& getState () const;
 
-    /** Changes the scaling mode live, without reloading the wallpaper (used by the hotswap control file) */
+    // live, for the hotswap control file
     void setScalingMode (WallpaperState::TextureUVsScaling mode);
 
-    /** Changes the manual zoom factor live, without reloading the wallpaper (used by the hotswap control file) */
+    // live, for the hotswap control file
     void setZoom (float zoom);
 
-    /** Re-centers a cropping scaling mode's visible window live (see WallpaperState::setOffset) */
+    // live, see WallpaperState::setOffset
     void setOffset (float offsetX, float offsetY);
     [[nodiscard]] const glm::vec4& getCornerColor () const { return this->m_cornerColor; }
     /** WE's alignment position, x, y and zoom live (see WallpaperState::setAlignment) */
     void setAlignment (const WallpaperState::Alignment& alignment);
 
-    /**
-     * Changes the color shown outside the wallpaper's bounds (Center/Fit letterboxing, zoomed-out
-     * scaling) live, without reloading the wallpaper. Only visible when the clamp mode is border
-     * (the default) rather than clamp/repeat.
-     */
+    // color outside the wallpaper's bounds (letterboxing, zoomed out), live; only visible when clamp is border
     void setCornerColor (const glm::vec4& color);
 
-    /**
-     * Wallpaper Engine's image filter, color options and flip, applied live on the way to the screen like its
-     * materials/util/ccsimple.json pass. Unset fields take Wallpaper Engine's defaults
-     */
+    // WE's image filter, color options and flip, live like its ccsimple.json pass; unset fields take WE's defaults
     void setImageAdjustments (const ImageAdjustments& adjustments);
     [[nodiscard]] bool isFlippedHorizontally () const { return this->m_flipHorizontal; }
     [[nodiscard]] bool hasImageAdjustments () const;
@@ -156,9 +144,7 @@ public:
     /** This frame's --ssaa factor per axis */
     [[nodiscard]] int getSupersampling () const { return this->m_supersampling; }
 
-    // maxRenderSize is only meaningful for Web wallpapers (see CWeb) - the largest resolution this
-    // wallpaper instance will ever be asked to render at: a single screen's size normally, or a span
-    // group's combined bounding box when spanned. Ignored for Scene/Video.
+    // maxRenderSize: the largest size a Web wallpaper renders at (a span's bounding box), ignored otherwise
     static std::unique_ptr<CWallpaper> fromWallpaper (
 	const Wallpaper& wallpaper, RenderContext& context, AudioContext& audioContext,
 	const std::filesystem::path& resolvedBackgroundPath, const WallpaperState::TextureUVsScaling& scalingMode,
@@ -223,8 +209,7 @@ private:
     GLint a_TexCoord = GL_NONE;
     GLuint m_destFramebuffer = GL_NONE;
     void setupShaders ();
-    // UVs last uploaded to m_texCoordBuffer - render() skips the upload when these haven't
-    // changed. NaN so the first render() call always uploads.
+    // UVs last uploaded, NaN so the first render() uploads
     float m_uploadedUstart = std::numeric_limits<float>::quiet_NaN ();
     float m_uploadedUend = std::numeric_limits<float>::quiet_NaN ();
     float m_uploadedVstart = std::numeric_limits<float>::quiet_NaN ();
@@ -265,7 +250,7 @@ private:
     glm::dvec2 m_spanCursor = { 0, 0 };
     void updateSpanBounds ();
     void updateSpanCursor (const glm::ivec4& viewport, const glm::ivec2& globalPosition, const glm::ivec2& logicalSize);
-    // Avoids redundant renderFrame calls when the same wallpaper is shared across viewports (span mode)
+    // renders once per frame when shared across span viewports
     uint32_t m_lastRenderedFrame = UINT32_MAX;
     glm::ivec2 m_screenSize = { 0, 0 };
     std::string m_storageScreen;

+ 6 - 19
src/WallpaperEngine/Render/Camera.h

@@ -19,16 +19,9 @@ public:
     Camera (Wallpapers::CScene& scene, const SceneData::Camera& camera);
     ~Camera ();
 
-    /**
-     * @param width Layout width, what object positions are computed against
-     * @param height Layout height
-     * @param canvasWidth What actually gets rendered, centered on the layout (0 = same as the layout width)
-     * @param canvasHeight Same as canvasWidth, for the height
-     */
+    // width/height is the layout objects are positioned in, canvas the rendered size centered on it (0 = layout size)
     void setOrthogonalProjection (float width, float height, float canvasWidth = 0.0f, float canvasHeight = 0.0f);
-    /**
-     * 3D scenes: the scene camera becomes perspective, getProjection/getLookAt stay a screen space camera for 2D layers
-     */
+    // 3D scenes: the scene camera becomes perspective, getProjection/getLookAt stay screen space for 2D layers
     void setPerspectiveProjection (float width, float height);
 
     [[nodiscard]] const glm::vec3& getCenter () const;
@@ -54,10 +47,7 @@ public:
     [[nodiscard]] float getNearZ () const;
     [[nodiscard]] float getFarZ () const;
 
-    /**
-     * Per frame view from a camera object, in WE's world space (y up, origin at the bottom left of the scene).
-     * 2D scenes ignore the scene.json eye (WE resets it), so without a camera object this is the identity
-     */
+    // per frame view from a camera object in WE's world space (y up, origin bottom left); identity without one in 2D
     void setWorldView (const glm::mat4& view);
     /** 2D scenes: general zoom times the camera object's zoom, scales around the scene center (sub_14017FA70) */
     void setZoom (float zoom);
@@ -66,12 +56,9 @@ public:
     [[nodiscard]] const glm::mat4& getWorldView () const;
     /** The fov the last setPerspectiveView used */
     [[nodiscard]] float getViewFov () const;
-    /**
-     * The part of the canvas the output shows, as margins cut off each side (left, right, bottom, top, y up, negative
-     * for letterboxing), and the output's aspect. 2D scenes project that region onto the whole scene buffer
-     * (sub_140183A70), 3D scenes take the aspect for their perspective. Also rebuilds the camera of layers with
-     * "perspective" set (sub_1401E5B60)
-     */
+    // the canvas part the output shows as margins (left, right, bottom, top, y up, negative for letterboxing) and its
+    // aspect; 2D scenes project it onto the scene buffer (sub_140183A70), 3D ones use the aspect; also rebuilds
+    // "perspective" layers (sub_1401E5B60)
     void setVisibleRegion (const glm::vec4& margins, float outputAspect);
     /** After the view and zoom of a frame are set */
     void updatePerspectiveLayers ();

+ 2 - 5
src/WallpaperEngine/Render/Drivers/Detectors/WaylandFullScreenDetector.h

@@ -25,11 +25,8 @@ struct WindowState;
 
 namespace WallpaperEngine::Render::Drivers::Detectors {
 
-/**
- * wlroots foreign toplevel: fullscreen (and with --pause-on-maximized maximized) windows pause the outputs they are on.
- * A toplevel on no output we know the name of counts everywhere, a compositor that never sends output_enter is no
- * worse off than before.
- */
+// wlroots foreign toplevel: fullscreen (and with --pause-on-maximized maximized) windows pause their outputs, toplevels
+// on unknown outputs count everywhere
 class WaylandFullScreenDetector final : public FullScreenDetector {
 public:
     struct Output {

+ 1 - 4
src/WallpaperEngine/Render/Drivers/Detectors/X11FullScreenDetector.cpp

@@ -44,8 +44,7 @@ X11FullScreenDetector::X11FullScreenDetector (Application::ApplicationContext& a
 	sLog.exception ("X11 FullScreen Detector initialized with the wrong video driver... This is a bug...");
     }
 
-    // not chaining the previous handler: these only need to ignore X11 errors, and chaining
-    // could stop the app under weird circumstances
+    // not chaining the previous handler, it could stop the app
     XSetErrorHandler (CustomXErrorHandler);
     XSetIOErrorHandler (CustomXIOErrorHandler);
 
@@ -251,14 +250,12 @@ void X11FullScreenDetector::initialize () {
     for (int i = 0; i < screenResources->noutput; i++) {
 	const XRROutputInfo* info = XRRGetOutputInfo (this->m_display, screenResources, screenResources->outputs[i]);
 
-	// screen not in use, ignore it
 	if (info == nullptr || info->connection != RR_Connected) {
 	    continue;
 	}
 
 	XRRCrtcInfo* crtc = XRRGetCrtcInfo (this->m_display, screenResources, info->crtc);
 
-	// screen not active, ignore it
 	if (crtc == nullptr) {
 	    continue;
 	}

+ 1 - 2
src/WallpaperEngine/Render/Drivers/GLFWOpenGLDriver.cpp

@@ -31,8 +31,7 @@ GLFWOpenGLDriver::GLFWOpenGLDriver (const char* windowTitle, ApplicationContext&
     glfwWindowHint (GLFW_CONTEXT_VERSION_MAJOR, 3);
     glfwWindowHint (GLFW_CONTEXT_VERSION_MINOR, 3);
     glfwWindowHint (GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
-    // required for glDebugMessageCallback (WallpaperApplication::setupOpenGLDebugging) on drivers that
-    // only emit KHR_debug output when the context is created with this flag
+    // drivers only emit KHR_debug output for debug contexts
     glfwWindowHint (GLFW_OPENGL_DEBUG_CONTEXT, GLFW_TRUE);
     glfwWindowHint (GLFW_VISIBLE, getenv ("LWE_DEBUG_VISIBLE_WINDOW") ? GLFW_TRUE : GLFW_FALSE);
     glfwWindowHintString (GLFW_X11_CLASS_NAME, "linux-wallpaperengine");

+ 2 - 4
src/WallpaperEngine/Render/Drivers/HeadlessOpenGLDriver.cpp

@@ -45,8 +45,7 @@ EGLDisplay openDisplay () {
 	}
     }
 
-    // with an iGPU and a dedicated card, EGL often lists the iGPU first; the card driving the boot
-    // display is the better guess
+    // EGL often lists the iGPU first, the card driving the boot display is the better guess
     std::ranges::stable_partition (candidates, [] (const auto& candidate) {
 	const auto name = std::filesystem::path (candidate.second).filename ();
 	std::ifstream bootVga ("/sys/class/drm" / name / "device/boot_vga");
@@ -232,8 +231,7 @@ void HeadlessOpenGLDriver::dispatchEventQueue () {
 
     this->m_output->updateRender ();
 
-    // there's no swap to throttle on, so keep at most one frame queued on the GPU instead of letting
-    // --fps 1000 pile up work faster than it gets done
+    // no swap to throttle on, keep at most one frame queued so --fps 1000 can't pile up work
     if (this->m_lastFrame != nullptr) {
 	glClientWaitSync (this->m_lastFrame, GL_SYNC_FLUSH_COMMANDS_BIT, GL_TIMEOUT_IGNORED);
 	glDeleteSync (this->m_lastFrame);

+ 2 - 6
src/WallpaperEngine/Render/Drivers/HeadlessOpenGLDriver.h

@@ -13,12 +13,8 @@
 namespace WallpaperEngine::Render::Drivers {
 using namespace WallpaperEngine::Application;
 
-/**
- * Renders into an offscreen EGL pbuffer on a GPU render node, no window system involved. Picked with
- * XDG_SESSION_TYPE=headless together with --window, meant for screenshots and regression runs on
- * machines without a display (Xvfb only offers software rendering). LWE_HEADLESS_DEVICE=/dev/dri/renderDN
- * chooses the GPU, otherwise the first one EGL lists is used.
- */
+// offscreen EGL pbuffer on a GPU render node for XDG_SESSION_TYPE=headless with --window (screenshots, regression runs;
+// Xvfb is software only) LWE_HEADLESS_DEVICE=/dev/dri/renderDN picks the GPU, else EGL's first
 class HeadlessOpenGLDriver final : public VideoDriver {
 public:
     explicit HeadlessOpenGLDriver (ApplicationContext& context, WallpaperApplication& app);

+ 1 - 2
src/WallpaperEngine/Render/Drivers/Output/GLFWWindowOutput.cpp

@@ -50,8 +50,7 @@ void* GLFWWindowOutput::getImageBuffer () const { return nullptr; }
 uint32_t GLFWWindowOutput::getImageBufferSize () const { return 0; }
 
 void GLFWWindowOutput::updateRender () const {
-    // re-read framebuffer size every frame so runtime resizes (EXPLICIT_WINDOW resizeWindow, or a
-    // WM-initiated resize) re-stretch the scene instead of cropping the render at the old size
+    // re-read every frame so window resizes re-stretch the scene instead of cropping it
     this->m_fullWidth = this->m_driver.getFramebufferSize ().x;
     this->m_fullHeight = this->m_driver.getFramebufferSize ().y;
 

+ 3 - 5
src/WallpaperEngine/Render/Drivers/Output/WaylandOutputViewport.cpp

@@ -472,8 +472,7 @@ void WaylandOutputViewport::prepareSurface () {
     this->setupFractionalScale ();
     this->setInputRegion (m_driver->getApp ().getContext ().settings.mouse.enabled);
 
-    // fully opaque: lets the compositor skip alpha-blending, always a win since wallpapers are the
-    // bottommost visible content
+    // fully opaque, the compositor can skip blending
     wl_region* opaqueRegion = wl_compositor_create_region (m_driver->getWaylandContext ()->compositor);
     wl_region_add (opaqueRegion, 0, 0, INT32_MAX, INT32_MAX);
     wl_surface_set_opaque_region (surface, opaqueRegion);
@@ -529,9 +528,8 @@ void WaylandOutputViewport::createEGLSurface () {
 	sLog.exception ("Failed to make egl current");
     }
 
-    // frames are paced by our own frame callbacks; with the default interval of 1 Mesa blocks inside
-    // eglSwapBuffers until the compositor shows the previous frame, which never happens while the
-    // surface isn't presented and stalls the whole main loop
+    // paced by our frame callbacks; with interval 1 Mesa blocks in eglSwapBuffers while the surface isn't presented,
+    // stalling the main loop
     eglSwapInterval (m_driver->getEGLContext ()->display, 0);
 
     this->m_driver->getOutput ().reset ();

+ 3 - 8
src/WallpaperEngine/Render/Drivers/Output/X11Output.cpp

@@ -61,8 +61,7 @@ void X11Output::free () {
     this->m_screens.clear ();
     this->m_viewports.clear ();
 
-    // XDestroyImage() already frees m_imageData itself (via its default destroy_image proc, which
-    // calls XFree()/free() on the buffer XCreateImage() was given) - it must not be freed again here
+    // XDestroyImage() frees m_imageData itself
     if (this->m_desktopWindow != None) {
 	XDestroyWindow (this->m_display, this->m_desktopWindow);
 	this->m_desktopWindow = None;
@@ -120,14 +119,12 @@ void X11Output::discoverOutputs (XRRScreenResources* screenResources) {
     for (int i = 0; i < screenResources->noutput; i++) {
 	const XRROutputInfo* info = XRRGetOutputInfo (this->m_display, screenResources, screenResources->outputs[i]);
 
-	// screen not in use, ignore it
 	if (info == nullptr || info->connection != RR_Connected) {
 	    continue;
 	}
 
 	XRRCrtcInfo* crtc = XRRGetCrtcInfo (this->m_display, screenResources, info->crtc);
 
-	// screen not active, ignore it
 	if (crtc == nullptr) {
 	    continue;
 	}
@@ -214,8 +211,7 @@ void X11Output::initX11Background () {
     this->m_gc = XCreateGC (this->m_display, this->m_pixmap, 0, nullptr);
     XFillRectangle (this->m_display, this->m_pixmap, this->m_gc, 0, 0, this->m_fullWidth, this->m_fullHeight);
     XSetWindowBackgroundPixmap (this->m_display, this->m_root, this->m_pixmap);
-    // XCreateImage() takes ownership of this buffer and frees it itself (via free()) when the
-    // XImage is destroyed, so it must be allocated with malloc(), not new[]
+    // XCreateImage() frees this with free(), so malloc() it
     this->m_imageSize = this->m_fullWidth * this->m_fullHeight * 4;
     this->m_imageData = static_cast<char*> (malloc (this->m_imageSize));
     this->m_image = XCreateImage (
@@ -229,8 +225,7 @@ void X11Output::updateRender () const {
 	this->m_display, this->m_pixmap, this->m_gc, this->m_image, 0, 0, 0, 0, this->m_fullWidth, this->m_fullHeight
     );
 
-    // _XROOTPMAP_ID/ESETROOT_PMAP_ID let other programs (compositors) know about the background
-    // pixmap instead of clearing it, and forces a compositor refresh (tested with picom)
+    // _XROOTPMAP_ID/ESETROOT_PMAP_ID tell compositors about the background pixmap and force a refresh (picom)
     const Atom prop_root = XInternAtom (this->m_display, "_XROOTPMAP_ID", False);
     const Atom prop_esetroot = XInternAtom (this->m_display, "ESETROOT_PMAP_ID", False);
     XChangeProperty (

+ 2 - 5
src/WallpaperEngine/Render/Drivers/Output/X11Output.h

@@ -34,11 +34,8 @@ private:
     void initX11Background ();
     void free ();
 
-    /**
-     * XFCE, MATE and LXQt hide the root behind an opaque desktop window (xfdesktop, caja, pcmanfm-qt). While one is
-     * mapped, frames go into our own window stacked right above it, with an empty input region so clicks still reach
-     * theirs. Translucent ones (nemo-desktop) are left alone.
-     */
+    // XFCE, MATE and LXQt cover the root with an opaque desktop window; frames then go into our own window right above
+    // it, input passing through. Translucent ones (nemo-desktop) are left alone
     void updateDesktopWindow () const;
     [[nodiscard]] Window findCoveringDesktopWindow (const std::vector<Window>& stacking) const;
     [[nodiscard]] std::vector<Window> stackingOrder () const;

+ 1 - 4
src/WallpaperEngine/Render/Drivers/VideoDriver.h

@@ -40,10 +40,7 @@ public:
     [[nodiscard]] virtual void* getWaylandDisplay () const { return nullptr; }
     /** The X11 Display, if rendering goes through X11 (mpv needs it for zero-copy hwdec) */
     [[nodiscard]] virtual void* getX11Display () const { return nullptr; }
-    /**
-     * --hdr was asked for and the compositor can take PQ content: videos then decode to linear BT.2020 and
-     * HDR outputs get PQ, see CWallpaper::setOutputHDR
-     */
+    // --hdr and a compositor that takes PQ: videos decode to linear BT.2020, HDR outputs get PQ
     [[nodiscard]] virtual bool isHDRAvailable () const { return false; }
     virtual void dispatchEventQueue () = 0;
     /** Reads window events without drawing, used while paused */

+ 1 - 2
src/WallpaperEngine/Render/Drivers/VideoFactories.cpp

@@ -64,8 +64,7 @@ std::unique_ptr<VideoDriver> VideoFactories::createVideoDriver (
 	sLog.exception ("Cannot find a driver for window mode ", mode, " and XDG_SESSION_TYPE ", xdgSessionType);
     }
 
-    // windowed modes have one handler for every session type, stored under a fixed key; the only
-    // session-specific one is the headless driver (XDG_SESSION_TYPE=headless)
+    // windowed modes share one handler under a fixed key, only headless is session specific
     auto factory = sessionTypeToFactory->second.find (xdgSessionType);
 
     if (mode != Application::ApplicationContext::DESKTOP_BACKGROUND && xdgSessionType != "headless") {

+ 5 - 8
src/WallpaperEngine/Render/Drivers/WaylandOpenGLDriver.cpp

@@ -241,8 +241,7 @@ handleGlobal (void* data, struct wl_registry* registry, uint32_t name, const cha
 static void handleGlobalRemoved (void* data, struct wl_registry* registry, uint32_t id) {
     const auto driver = static_cast<WaylandOpenGLDriver*> (data);
 
-    // a monitor being unplugged/disabled removes its global; leaving the viewport around leaks its
-    // layer-shell/EGL surfaces for the rest of this client's connection since nothing else disconnects it
+    // an unplugged monitor removes its global, a kept viewport would leak its layer-shell/EGL surfaces
     const auto it
 	= std::ranges::find_if (driver->m_screens, [id] (const auto* viewport) { return viewport->waylandName == id; });
 
@@ -369,8 +368,7 @@ void WaylandOpenGLDriver::initEGL () {
 	3,
 	EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR,
 	EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR,
-	// required for glDebugMessageCallback (WallpaperApplication::setupOpenGLDebugging) on drivers that
-	// only emit KHR_debug output when the context is created with this flag; Mesa tends to be lenient
+	// drivers only emit KHR_debug output for debug contexts
 	EGL_CONTEXT_FLAGS_KHR,
 	EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR,
 	EGL_NONE,
@@ -712,8 +710,7 @@ void WaylandOpenGLDriver::initGLEW () {
     glewExperimental = GL_TRUE;
     if (const GLenum result = glewInit (); result != GLEW_OK) {
 	const char* error = reinterpret_cast<const char*> (glewGetErrorString (result));
-	// on Wayland+EGL, GLEW may report GLEW_ERROR_NO_GLX_DISPLAY or a null string when the build
-	// also includes X11 but no GLX display is present; non-fatal, the EGL context is already current
+	// GLEW reports GLEW_ERROR_NO_GLX_DISPLAY or null without a GLX display, harmless since EGL is current
 	if (result == GLEW_ERROR_NO_GLX_DISPLAY || error == nullptr) {
 	    sLog.out ("Failed to initialize GLEW, but continuing with EGL context: ", error ? error : "No GLX display");
 	} else {
@@ -772,8 +769,8 @@ void WaylandOpenGLDriver::dispatchEventQueue () {
 	this->setupLateOutputs ();
     }
 
-    // rendering only continues from frame callbacks, so a surface that never got its first frame or whose
-    // callback the compositor dropped would stay blank forever; this also draws the very first frame
+    // rendering continues from frame callbacks, so this redraws surfaces that missed their first frame or a dropped
+    // callback (and draws the very first frame)
     const auto now = std::chrono::steady_clock::now ();
 
     for (const auto& o : this->m_screens) {

+ 5 - 10
src/WallpaperEngine/Render/GifAnimation.h

@@ -6,21 +6,16 @@
 #include <vector>
 
 namespace WallpaperEngine::Render {
-/**
- * Animated GIF player for user-picked .gif image properties, a port of WE 2.8.42's resourceutil64 GIF exports
- * (PrepareGIF/OpenGIF/AdvanceGIF/FreeGIF). Their decoder is an older stb_image variant: frames come out at the
- * logical screen size, disposal 2 fills with a palette colour instead of the previous background, and the
- * stream rewinds to the first frame after the trailer.
- */
+// animated GIFs for .gif image properties, a port of WE 2.8.42's resourceutil64 GIF exports
+// (PrepareGIF/OpenGIF/AdvanceGIF/FreeGIF) an older stb_image: frames at the logical screen size, disposal 2 fills a
+// palette colour, rewinds after the trailer
 class GifAnimation {
 public:
     /** nullptr when the data isn't a GIF (PrepareGIF's stbi__gif_test) */
     static std::unique_ptr<GifAnimation> open (const void* data, size_t size);
 
-    /**
-     * AdvanceGIF: steps the frame timer by dt seconds and decodes the next frame once it runs out. The first call
-     * always decodes. Returns true when pixels () holds a new frame
-     */
+    // AdvanceGIF: steps the timer by dt, decodes the next frame once it runs out (always on the first call); true when
+    // pixels () changed
     bool advance (float dt);
 
     [[nodiscard]] const uint8_t* pixels () const { return m_out.data (); }

+ 1 - 3
src/WallpaperEngine/Render/ImageDecoder.h

@@ -10,8 +10,6 @@ namespace WallpaperEngine::Render {
  */
 stbi_uc* decodeImageRGBA (const void* data, size_t size, int& width, int& height);
 
-/**
- * Size of the image once decoded with decodeImageRGBA, without decoding it
- */
+// decoded size without decoding
 bool decodedImageSize (const void* data, size_t size, int& width, int& height);
 } // namespace WallpaperEngine::Render

+ 2 - 5
src/WallpaperEngine/Render/ModelData.h

@@ -11,11 +11,8 @@
 #include <glm/vec3.hpp>
 
 namespace WallpaperEngine::Render {
-/**
- * Script generated geometry (thisScene.createModelData, wallpaper64.exe 2.8.42 engine interface slots 10-12:
- * sub_14018C720, sub_1401D6400, sub_14018D8B0). Every shape becomes a mesh like the ones of a .mdl, model layers
- * created with the token draw them (sub_14021AD10)
- */
+// script geometry (thisScene.createModelData, 2.8.42 engine slots 10-12: sub_14018C720, sub_1401D6400, sub_14018D8B0),
+// shapes become .mdl-like meshes drawn by model layers with the token
 namespace ModelData {
     /** Vertex format bits a script can use (scenescript64 sub_18162FD40) */
     constexpr uint32_t FORMAT_POSITION = 0x1;

+ 3 - 9
src/WallpaperEngine/Render/Objects/CCamera.h

@@ -11,11 +11,8 @@
 namespace WallpaperEngine::Render::Objects {
 using namespace WallpaperEngine::Data::Model;
 
-/**
- * A "camera" object draws nothing, the last visible one in the scene sets the view: its position is the eye, it looks
- * down its own -z axis with its y axis as up (wallpaper64.exe 2.8.42 sub_1401891A0). With a "path" file it plays
- * those timelines one after another instead of holding still (sub_1401F2AD0)
- */
+// draws nothing, the last visible one sets the view: eye at its position, looking down its -z with y up
+// (sub_1401891A0); with a "path" file it plays those timelines in turn (sub_1401F2AD0)
 class CCamera final : public Scripting::ScriptableObject {
 public:
     struct Pose {
@@ -29,10 +26,7 @@ public:
     CCamera (Wallpapers::CScene& scene, const SceneCamera& camera);
 
     [[nodiscard]] const SceneCamera& getCamera () const;
-    /**
-     * Advances the running timeline by dt and samples it. world is the camera's own world matrix, parent its
-     * parent's; nothing comes back when the camera has no path
-     */
+    // advances and samples the running timeline, nothing when the camera has no path
     std::optional<Pose> updateTimeline (float dt, const glm::mat4& world, const glm::mat4& parent);
 
 private:

+ 24 - 59
src/WallpaperEngine/Render/Objects/CImage.cpp

@@ -89,12 +89,8 @@ struct PuppetMeshBlock {
     uint32_t indexBytes = 0;
 };
 
-// Finds every byte offset that could plausibly be a MDLV mesh header (DWORD vertexByteLength
-// immediately followed by that many bytes of vertex data, then a DWORD indexByteLength followed by
-// that many bytes of indices, all landing before the MDLS block). This intentionally doesn't know or
-// care about the per-vertex stride - that's resolved afterwards against whatever candidates come back,
-// since the stride isn't reliably predictable from the MDLV header version alone (see
-// resolvePuppetVertexLayout).
+// byte offsets that could be an MDLV mesh header (vertex and index byte lengths fitting before MDLS), the stride is
+// resolved later (resolvePuppetVertexLayout)
 std::vector<PuppetMeshBlock> findPuppetMeshBlockCandidates (
     const BinaryReader& reader, size_t markerSize, size_t mdlsOffset, size_t meshHeaderSize
 ) {
@@ -133,9 +129,7 @@ struct PuppetVertexLayout {
     size_t uvOffset = 0;
 };
 
-// Reads raw positions/UVs/indices for a candidate (block, stride) pair. The UV pair has only ever
-// been observed as the trailing 8 bytes of the vertex record, whatever bone/weight data precedes it
-// (position(12) + ... + uv(8)), so uvOffset = stride - 8 throughout.
+// the UV pair is always the last 8 bytes of a vertex, so uvOffset = stride - 8
 struct PuppetMeshData {
     std::vector<GLfloat> positions;
     std::vector<GLfloat> texcoords;
@@ -190,9 +184,7 @@ std::optional<PuppetMeshData> readPuppetMeshData (
     return data;
 }
 
-// Blend indices/weights are always the 32 bytes immediately before the UV pair, regardless of stride
-// (see docs/rendering/MDL_FILES.md) - position(12) + [normal(12) + tangent4(16), wide format only] +
-// blendindices(16) + blendweight(16) + uv(8).
+// blend indices/weights are the 32 bytes before the UV pair whatever the stride (docs/rendering/MDL_FILES.md)
 struct PuppetBlendData {
     std::vector<glm::uvec4> indices;
     std::vector<glm::vec4> weights;
@@ -238,11 +230,8 @@ std::optional<PuppetBlendData> readPuppetBlendData (
     return data;
 }
 
-// Scores how plausible a candidate vertex layout is: real puppet meshes are triangulated warp grids,
-// so triangles formed by adjacent indices should be small relative to the mesh's overall size. A wrong
-// stride reinterprets bone/weight bytes as positions, which decorrelates neighbouring vertices and
-// produces comparatively huge, inconsistent triangles. Lower is better; nullopt if unscorable (e.g. a
-// degenerate single-point mesh).
+// lower is better: a wrong stride reads bone data as positions and gives huge, inconsistent triangles; nullopt for
+// degenerate meshes
 std::optional<double> scorePuppetMeshCoherence (const PuppetMeshData& data) {
     if (data.indices.size () < 3) {
 	return std::nullopt;
@@ -286,15 +275,12 @@ std::optional<double> scorePuppetMeshCoherence (const PuppetMeshData& data) {
     return (totalEdgeLength / static_cast<double> (edgeCount)) / diagonal;
 }
 
-// The MDLV vertex layout isn't reliably predictable from the header version number alone - the same
-// version (e.g. MDLV0023) has been observed with different per-vertex strides depending on how many
-// bone influences a given puppet part carries. So instead of a fixed version->stride table, every
-// plausible stride is tried against every candidate mesh header found in the file, and whichever
-// combination produces the most coherent triangulated mesh wins.
+// the same MDLV version comes with different strides, so every plausible stride is tried on every candidate header and
+// the most coherent mesh wins
 std::optional<PuppetVertexLayout>
 resolvePuppetVertexLayout (const BinaryReader& reader, size_t markerSize, size_t mdlsOffset, size_t meshHeaderSize) {
     constexpr size_t minVertexStride = 20; // position (12 bytes) + uv (8 bytes), no bone data at all
-    constexpr size_t maxVertexStride = 256; // generous upper bound, comfortably covers multi-bone rigs
+    constexpr size_t maxVertexStride = 256; // covers multi-bone rigs
     constexpr size_t strideStep = 4; // every field observed so far is a 4-byte float/uint
 
     const auto candidates = findPuppetMeshBlockCandidates (reader, markerSize, mdlsOffset, meshHeaderSize);
@@ -694,10 +680,8 @@ CImage::CImage (Wallpapers::CScene& scene, const Image& image) :
 	    size.x = static_cast<float> (scene.getCanvasWidth ());
 	    size.y = static_cast<float> (scene.getCanvasHeight ());
 	}
-	// TODO: create a dummy texture of correct size, fbo constructors should be enough, but this should be
-	// properly handled
-	// solid layers are often declared far larger than the scene, nothing samples
-	// these buffers past the canvas so only the layout size has to stay as declared
+	// TODO: a dummy texture of the right size
+	// solid layers are often declared far larger than the scene, nothing samples past the canvas
 	const glm::vec2 placeholderSize = { std::min (size.x, static_cast<float> (scene.getCanvasWidth ())),
 					    std::min (size.y, static_cast<float> (scene.getCanvasHeight ())) };
 
@@ -706,7 +690,7 @@ CImage::CImage (Wallpapers::CScene& scene, const Image& image) :
 	);
     }
 
-    // If the wallpaper doesn't specify a size, fall back to the texture or model dimensions
+    // no size given, use the texture's or model's
     if ((size.x == 0.0f || size.y == 0.0f) && this->m_texture != nullptr) {
 	size.x = static_cast<float> (this->m_texture->getRealWidth ());
 	size.y = static_cast<float> (this->m_texture->getRealHeight ());
@@ -745,7 +729,6 @@ CImage::CImage (Wallpapers::CScene& scene, const Image& image) :
 
     this->updateScenePosition (size);
 
-    // register both FBOs into the scene
     std::ostringstream nameA, nameB;
 
     // WE renders layers with LIGHTING or REFLECTION unlit into _rt_imageLayerAlbedo_<id> when they have offscreen
@@ -1431,9 +1414,7 @@ bool CImage::loadPuppetMesh (const glm::vec2& size) {
 }
 
 void CImage::updatePuppetPositionBuffer (const glm::vec2& size) {
-    // once an animation clip is driving the mesh, its skinned output replaces the static bind pose
-    // as the source of truth - the bind pose (m_puppetRawPositions) is kept around unchanged, since
-    // skinning is recomputed from it fresh every frame, not accumulated from the previous frame
+    // an animation clip's skinned output replaces the bind pose, skinning starts from the bind pose every frame
     const auto& source
 	= !this->m_puppetSkinnedPositions.empty () ? this->m_puppetSkinnedPositions : this->m_puppetRawPositions;
 
@@ -1451,10 +1432,7 @@ void CImage::updatePuppetPositionBuffer (const glm::vec2& size) {
     for (size_t index = 0; index + 2 < source.size (); index += 3) {
 	positions.push_back (bufferOffset.x + source[index]);
 	positions.push_back (bufferOffset.y - source[index + 1]);
-	// raw .mdl Z values aren't used by this engine's orthographic puppet compositing (depth test
-	// is disabled for puppets; layering comes from draw order + alpha blending) - and glm::ortho's
-	// clip.z = -localZ has no near/far normalization, so a puppet's real mesh depth (tens of units)
-	// would get clipped outside [-1,1] and lose most of the mesh. Zero it instead.
+	// depth isn't used for puppets and glm::ortho would clip their real mesh depth, so zero it
 	positions.push_back (0.0f);
     }
 
@@ -2072,13 +2050,8 @@ void CImage::setupPuppetGeometryCallback (Effects::CPass* pass) const {
 		}
 	    }
 
-	    // updatePuppetPositionBuffer flips Y when converting mesh-space positions to screen space,
-	    // which mirrors the mesh and reverses triangle winding relative to what the MDL file's index
-	    // buffer encodes - but not necessarily uniformly across the whole mesh, since real puppet
-	    // meshes aren't guaranteed to be consistently wound to begin with. Puppet content is flat 2D
-	    // art with no real backface concept, so rather than chase the "correct" winding, just never
-	    // cull it - a material requesting cullmode "normal" would otherwise silently drop whichever
-	    // subset of triangles ends up on the wrong side, which looks like patchy missing geometry.
+	    // the y flip reverses winding, not even uniformly since puppet meshes aren't consistently wound; flat 2D
+	    // art, so never cull
 	    glDisable (GL_CULL_FACE);
 	},
 	[this, pass] () {
@@ -3452,15 +3425,9 @@ void CImage::setupPasses () {
 	if (!writesToTarget && this->shouldRenderFinalPass (std::next (cur) == end)) {
 	    drawTo = this->getScene ().getFBO ();
 
-	    // A puppet with no effects has its geometry pass be both the first AND the last pass, drawn
-	    // straight into the shared scene FBO below - same as any other object's final pass, so it
-	    // needs the same screen-space projection. updatePuppetPositionBuffer() bakes this object's
-	    // resolved scene position/scale directly into m_puppetSpacePosition (mirroring what
-	    // uploadGeometryBuffers does for a normal quad's sceneSpacePosition), so m_modelViewProjectionScreen
-	    // is the correct projection for those vertices now, not the local-canvas m_modelViewProjectionCopy
-	    // this pass otherwise uses when rendering to an intermediate, object-sized target. The
-	    // spacePosition reassignment below is a no-op for puppets either way - the puppet geometry
-	    // callback always binds m_puppetSpacePosition itself, ignoring whatever spacePosition holds.
+	    // a puppet without effects draws its mesh straight into the scene FBO, so it takes the screen projection
+	    // like any final pass (m_puppetSpacePosition already holds the scene position, the puppet callback binds it
+	    // itself)
 	    spacePosition = this->getSceneSpacePosition ();
 	    texcoord = isFirstPass ? this->m_texcoordDirect : this->m_texcoordFinal;
 	    projection = &this->m_modelViewProjectionScreen;
@@ -3849,10 +3816,9 @@ void CImage::updateGeometryBuffers () {
 }
 
 namespace {
-// keeps an edge pair (e.g. m_pos.x/.z) from sliding into the on-screen part of the canvas once `offset` is added
-// to both, so the image never uncovers ground it doesn't have pixels for; an image too small to cover it on this
-// axis has no ground to uncover, it is an object sitting on the scene and moves freely. Canvas cropped away by the
-// cover scaling is free to scroll in, WE has no clamp at all (sub_14018AAC0 adds the raw offset to the view)
+// keeps an edge pair (m_pos.x/.z) from sliding into the visible canvas, so the image never uncovers ground it has no
+// pixels for; images too small to cover the axis move freely and cropped canvas may scroll in. WE has no clamp
+// (sub_14018AAC0)
 float clampParallaxAxis (float offset, float edgeA, float edgeB, float visibleLow, float visibleHigh) {
     const float low = std::min (edgeA, edgeB);
     const float high = std::max (edgeA, edgeB);
@@ -3902,9 +3868,8 @@ void CImage::updateScreenSpacePosition () {
     if (scene.getScene ().camera.parallax.enabled->value->getBool () && !fullscreen && !camera.isPerspective ()) {
 	glm::vec2 offset = scene.getParallaxOffset (this->getImage ());
 
-	// a texture that isn't UV-clamped tiles/repeats instead of showing black past its edges (GL_REPEAT,
-	// see CTexture.cpp), so sliding it further is harmless and exempt from the clamp; scene.json's own
-	// "clampuvs" overrides the base texture's flag the same way it does for the composite FBOs above
+	// a texture that isn't UV-clamped repeats, sliding it further is harmless; scene.json "clampuvs" overrides the
+	// texture's flag
 	const bool textureTiles = !this->getImage ().clampUVs && this->getTexture () != nullptr
 	    && (this->getTexture ()->getFlags () & TextureFlags_ClampUVs) == 0;
 

+ 4 - 10
src/WallpaperEngine/Render/Objects/CImage.h

@@ -122,11 +122,8 @@ public:
      *  the scripts run so they read and change this frame's pose */
     void updatePuppetPose ();
 
-    /**
-     * Bone access for IImageLayer scripts (wallpaper64 2.8.42 sub_140211070). Matrices are column-vector glm, the
-     * transpose of WE's row-vector ones with the same 16 floats in memory. Scene matrices are object world * bone,
-     * local ones relative to the parent bone. Only valid while hasPuppetPose(), for bones below the bone count.
-     */
+    // IImageLayer bone access (2.8.42 sub_140211070): glm column-vector matrices, same memory as WE's; scene = object
+    // world * bone, local = relative to the parent bone. Valid while hasPuppetPose()
     [[nodiscard]] bool hasPuppetPose () const;
     /** sub_140210400: first target of that name, -1 for none */
     [[nodiscard]] int getBlendShapeIndex (const std::string& name) const;
@@ -163,11 +160,8 @@ public:
     bool destroyPuppetAnimationLayersByName (const std::string& name);
     bool destroyPuppetAnimationLayer (size_t serial);
 
-    /**
-     * ITextureAnimation (wallpaper64 2.8.42 sub_14020E670, members sub_1402131A0): a layer's own clock for its
-     * animated texture. Attached it follows the texture's shared clock; pause, stop, setFrame and a rate other
-     * than 1 detach it, join attaches it again. Frames are indices in the texture's frame list
-     */
+    // ITextureAnimation (2.8.42 sub_14020E670): a layer's own clock for its animated texture; pause, stop, setFrame and
+    // rate != 1 detach it from the shared clock, join reattaches
     struct TextureAnimation {
 	/** +72 */
 	bool detached = false;

+ 4 - 5
src/WallpaperEngine/Render/Objects/CMesh.cpp

@@ -307,11 +307,10 @@ std::vector<MdlMesh> readMdlMeshes (
     return meshes;
 }
 
-// MDMP (sub_140261880): per mesh of the file a u16 target count, and with targets the deltas' scale, the vertex count
-// and per target a u64, a name and blobs of 16 bit signed normalized values: positions (3 per vertex), normals with
-// mesh flag 0x400, more with 0x800/0x1000, four values with 0x2000. sub_1401D7760 packs every target's deltas one after
-// another into a square texture: positions only, or positions and normals interleaved per vertex; with 0x800 it stays
-// empty. The shader scales them by g_MorphWeights[0]
+// MDMP (sub_140261880): per mesh a u16 target count, then scale, vertex count and per target a u64, name and snorm16
+// blobs (positions, normals with 0x400, more with 0x800/0x1000, four with 0x2000) sub_1401D7760 packs every target's
+// deltas into a square texture, positions or positions+normals interleaved, empty with 0x800; scaled by
+// g_MorphWeights[0]
 void loadMorphTargets (
     const std::vector<char>& data, size_t section, const std::vector<uint32_t>& meshFlags, std::vector<MdlMesh>& meshes
 ) {

+ 6 - 14
src/WallpaperEngine/Render/Objects/CMesh.h

@@ -13,11 +13,8 @@
 namespace WallpaperEngine::Render::Objects {
 using namespace WallpaperEngine::Data::Model;
 
-/**
- * A 3D model ("model" objects), in 3D scenes or placed in a 2D one. Every mesh in the .mdl has its own material and is
- * drawn straight into the scene buffer with depth testing. Models with a skeleton play their animation layers like
- * puppets and are skinned on the GPU (SKINNING, g_Bones)
- */
+// a 3D model object: each .mdl mesh has its own material and draws into the scene buffer with depth testing; skeletons
+// play animation layers like puppets, skinned on the GPU
 class CMesh final : public Scripting::ScriptableObject, private PuppetRootMotionHost {
 public:
     CMesh (Wallpapers::CScene& scene, const Mesh& mesh);
@@ -41,10 +38,8 @@ public:
     [[nodiscard]] int getBoneCount () const { return this->m_boneCount; }
     /** g_Bones: getBoneCount () float4x3 matrices, column major */
     [[nodiscard]] const std::vector<float>& getBones () const { return this->m_bones; }
-    /**
-     * What a child attached to the named MDAT point gets its local matrix multiplied with (sub_140224970): the posed
-     * bone in model space times the point's matrix. Nothing for an unknown name (sub_1402248C0 matches it exactly)
-     */
+    // posed bone in model space times the MDAT point's matrix, what attached children multiply with (sub_140224970);
+    // exact name match
     [[nodiscard]] std::optional<glm::mat4> getAttachmentMatrix (const std::string& name) const;
     [[nodiscard]] const glm::mat4& getModelMatrix () const;
     [[nodiscard]] const glm::mat3& getNormalMatrix () const;
@@ -62,11 +57,8 @@ public:
     [[nodiscard]] glm::vec3 cursorLocalPosition (const glm::vec2& ndc) const;
     /** hitBox: first bone box the cursor line enters (sub_140223810), local becomes the entry point in its space */
     [[nodiscard]] std::optional<std::string> cursorHitBox (const glm::vec2& ndc, glm::vec3& local) const;
-    /**
-     * Draws the meshes whose material blends "normal" or "alphatocoverage" into the bound shadow map through
-     * viewProjection (GL clip space) with the caster program, the others don't cast (sub_1402222A0 in mode 0).
-     * cullViewProjection is the same viewport in WE's clip space, what its frustum culling tests against
-     */
+    // meshes blending "normal" or "alphatocoverage" into the bound shadow map (sub_1402222A0 mode 0);
+    // cullViewProjection is the same viewport in WE's clip space for culling
     void renderShadowCaster (
 	GLuint program, GLint modelViewProjection, GLint alphaTest, const glm::mat4& viewProjection,
 	const glm::mat4& cullViewProjection

+ 25 - 51
src/WallpaperEngine/Render/Objects/CParticle.cpp

@@ -88,11 +88,11 @@ CParticle::CParticle (Wallpapers::CScene& scene, const Particle& particle) :
 	m_rng.seed (rd ());
     }
 
-    // Read renderer config early - buffer sizing below depends on it
+    // renderer config first, buffer sizes depend on it
     if (!m_particle.renderers.empty ()) {
 	const auto& renderer = m_particle.renderers[0];
 	if (renderer.name == "rope" || renderer.name == "ropetrail") {
-	    // Both rope and ropetrail use genericropeparticle shader
+	    // rope and ropetrail both use genericropeparticle
 	    m_useRopeRenderer = true;
 	    m_ropeSubdivision = std::clamp (static_cast<int> (renderer.subdivision), 0, 32);
 	    m_ropeUVScale = renderer.uvScale;
@@ -138,7 +138,6 @@ CParticle::CParticle (Wallpapers::CScene& scene, const Particle& particle) :
 	m_vertices.resize (segments * 4 * ROPE_FLOATS_PER_VERTEX);
 	m_indices.resize (segments * 6);
     } else {
-	// 4 vertices, 6 indices per particle
 	const int verticesPerParticle = 4;
 	const int indicesPerParticle = 6;
 
@@ -178,7 +177,7 @@ void CParticle::setup () {
     if (m_particle.material && m_particle.material->material && !m_particle.material->material->passes.empty ()) {
 	auto& firstPass = *m_particle.material->material->passes.begin ();
 
-	// Overbright: brightness multiplier for additive particles
+	// overbright multiplies additive particles
 	auto overbrightIt = firstPass->constants.find ("ui_editor_properties_overbright");
 	if (overbrightIt != firstPass->constants.end ()) {
 	    m_overbright = overbrightIt->second->value->getFloat ();
@@ -260,8 +259,7 @@ void CParticle::simulate () {
 
     // the first update only starts the clock (no dt spike, no initial burst)
     if (m_time == 0.0) {
-	// "starttime" prewarms the system so it starts already populated instead of every
-	// particle visibly leaving the emitter at once
+	// starttime prewarms the system so it starts populated
 	if (playback == Playback::Playing) {
 	    this->prewarm (currentTime);
 	}
@@ -273,7 +271,7 @@ void CParticle::simulate () {
     m_time = currentTime;
 
     if (dt > 0.0f) {
-	// Cap dt to prevent simulation instability across different FPS
+	// cap dt for stability at low fps
 	dt = std::min (dt, 0.1f);
 	update (dt);
     }
@@ -474,8 +472,7 @@ void CParticle::update (float dt) {
 	m_particles[i].age += dt;
     }
 
-    // Order-preserving compaction: particles only die from lifetime expiry (never from
-    // size, since size can oscillate), and index 0 must stay the oldest particle
+    // order-preserving compaction, index 0 stays the oldest
     uint32_t writeIdx = 0;
     for (uint32_t readIdx = 0; readIdx < m_particleCount; readIdx++) {
 	if (m_particles[readIdx].isAlive ()) {
@@ -1672,7 +1669,7 @@ EmitterFunc CParticle::createSphereEmitter (const ParticleEmitter& emitter) {
 
     int controlPointIndex = emitter.controlPoint;
 
-    // Auto-detect control point 0 if not specified and CP0 has linkMouse
+    // control point 0 with linkMouse when none is given
     if (controlPointIndex == -1 && !m_particle.controlPoints.empty ()) {
 	const auto& cp0 = m_particle.controlPoints[0];
 	if ((cp0.flags & 1) != 0) { // bit 0 = linkMouse
@@ -4544,8 +4541,7 @@ void CParticle::setupPass () {
 	}
     }
 
-    // Force texture 0 to use the input (particle texture) rather than the shader's
-    // default "util/white" annotation, which would override it in setupRenderTexture()
+    // texture 0 is the particle texture, not the shader's util/white default
     m_passBinds = { { 0, "previous" } };
 
     auto refractIt = firstPass.combos.find ("REFRACT");
@@ -4553,11 +4549,8 @@ void CParticle::setupPass () {
 
     m_passFBOProvider = std::make_shared<FBOProvider> (this);
 
-    // REFRACT: create a copy FBO shadowing _rt_FullFrameBuffer. The shader reads g_Texture3
-    // (= _rt_FullFrameBuffer) while we render TO the scene FBO; reading and writing the same FBO
-    // is undefined behavior in OpenGL and causes black reads on NVIDIA. Placing a copy FBO under
-    // the same name in our FBOProvider makes CPass resolve g_Texture3 to the copy instead - we
-    // blit the scene content into it before each render.
+    // REFRACT reads _rt_FullFrameBuffer while drawing into the scene FBO (undefined, black on NVIDIA), so a copy is
+    // registered under that name and blitted before each render
     if (m_hasRefract) {
 	auto sceneFBO = getScene ().getFBO ();
 	float w = static_cast<float> (sceneFBO->getRealWidth ());
@@ -4574,7 +4567,6 @@ void CParticle::setupPass () {
     m_pass->setDestination (getScene ().getFBO ());
     m_pass->setInput (getTexture ());
 
-    // Set matrix pointers - CPass will dereference these each frame
     m_pass->setModelViewProjectionMatrix (&m_mvpMatrix);
     m_pass->setModelViewProjectionMatrixInverse (&m_mvpMatrixInverse);
     m_pass->setModelMatrix (&m_worldModelMatrix);
@@ -4594,9 +4586,7 @@ void CParticle::setupPass () {
     const GLuint program = m_pass->getProgramID ();
 
     if (m_useRopeRenderer) {
-	// Rope vertex layout: 7 attributes, 26 floats/vertex, stride=104 bytes
-	// a_PositionVec4(4) + a_TexCoordVec4(4) + a_TexCoordVec4C1(4) + a_TexCoordVec4C2(4)
-	// + a_TexCoordVec4C3(4) + a_TexCoordC4(2) + a_Color(4) = 26
+	// rope vertex: a_PositionVec4, a_TexCoordVec4, C1, C2, C3 (4 each), a_TexCoordC4 (2), a_Color (4) = 26 floats
 	const GLsizei stride = sizeof (float) * ROPE_FLOATS_PER_VERTEX;
 
 	const GLint loc0 = glGetAttribLocation (program, "a_PositionVec4");
@@ -4636,8 +4626,8 @@ void CParticle::setupPass () {
 	    glVertexAttribPointer (loc6, 4, GL_FLOAT, GL_FALSE, stride, (void*)(sizeof (float) * 22));
 	}
     } else {
-	// Sprite vertex layout: 5 attributes, 17 floats/vertex, stride=68 bytes
-	// a_Position(3) + a_TexCoordVec4(4) + a_Color(4) + a_TexCoordVec4C1(4) + a_TexCoordC2(2) = 17
+	// sprite vertex: a_Position (3), a_TexCoordVec4 (4), a_Color (4), a_TexCoordVec4C1 (4), a_TexCoordC2 (2) = 17
+	// floats
 	const GLsizei stride = sizeof (float) * SPRITE_FLOATS_PER_VERTEX;
 
 	const GLint loc0 = glGetAttribLocation (program, "a_Position");
@@ -4676,7 +4666,7 @@ void CParticle::setupPass () {
 
 void CParticle::setupGeometryCallbacks () {
     m_pass->setGeometryCallback (
-	// Setup attribs: save current VAO, bind particle VAO
+	// bind the particle VAO
 	[this] () {
 	    glGetIntegerv (GL_VERTEX_ARRAY_BINDING, &m_prevVAO);
 	    glBindVertexArray (m_vao);
@@ -4691,7 +4681,6 @@ void CParticle::setupGeometryCallbacks () {
 		glDrawElements (GL_TRIANGLES, m_activeIndexCount, GL_UNSIGNED_INT, nullptr);
 	    }
 	},
-	// Cleanup: restore previous VAO
 	[this] () {
 	    glFrontFace (GL_CCW);
 	    glBindVertexArray (m_prevVAO);
@@ -4700,8 +4689,7 @@ void CParticle::setupGeometryCallbacks () {
 }
 
 void CParticle::setupParticleUniforms () {
-    // Add particle-specific uniforms from common_particles.h that CPass doesn't provide
-    // These are pointer-based: CPass reads the current value each frame
+    // common_particles.h uniforms CPass doesn't provide, read every frame
     m_pass->addUniform ("g_ModelMatrixInverse", &m_modelMatrixInverse);
     m_pass->addUniform ("g_OrientationUp", &m_orientationUp);
     m_pass->addUniform ("g_OrientationRight", &m_orientationRight);
@@ -4712,7 +4700,7 @@ void CParticle::setupParticleUniforms () {
     m_pass->addUniform ("g_RenderVar0", &m_renderVar0);
     m_pass->addUniform ("g_RenderVar1", &m_renderVar1);
 
-    // REFRACT: set g_RefractAmount (shader default 0.05, may not be applied by CPass's parameter system)
+    // g_RefractAmount, the shader default may not be applied by CPass
     if (m_hasRefract) {
 	m_pass->addUniform ("g_RefractAmount", &m_refractAmount);
     }
@@ -4862,9 +4850,8 @@ void CParticle::renderSprites () {
 	return;
     }
 
-    // Build vertex data in WP shader layout:
-    // a_Position(3) + a_TexCoordVec4(uv.x, uv.y, rotZ, size)(4) + a_Color(4)
-    //   + a_TexCoordVec4C1(vel.x, vel.y, vel.z, lifetime)(4) + a_TexCoordC2(rotX, rotY)(2) = 17 floats
+    // a_Position, a_TexCoordVec4 (uv, rotZ, size), a_Color, a_TexCoordVec4C1 (velocity, lifetime), a_TexCoordC2 (rotX,
+    // rotY)
     uint32_t vertexIndex = 0;
     uint32_t indexOffset = 0;
 
@@ -4879,15 +4866,13 @@ void CParticle::renderSprites () {
 	    continue;
 	}
 
-	// Encode the CPU-computed frame (accounts for sequenceMultiplier and animation mode)
-	// into the lifetime value the WP shader's ComputeSpriteFrame expects: it derives the
-	// current frame via floor(frac(lifetime) * numFrames) and the inter-frame blend via
-	// frac(lifetime * numFrames).
+	// the CPU frame encoded as the lifetime ComputeSpriteFrame expects: floor(frac(lifetime) * frames), blend
+	// frac(lifetime * frames)
 	float lifetime = p.getLifetimePos ();
 
 	if (m_spritesheetFrames > 0 && p.frame >= 0.0f) {
 	    if (m_particle.animationMode == "randomframe") {
-		// Center within the frame to avoid floating-point edge cases
+		// frame center, away from float edges
 		lifetime = (p.frame + 0.5f) / static_cast<float> (m_spritesheetFrames);
 	    } else {
 		lifetime = p.frame / static_cast<float> (m_spritesheetFrames);
@@ -4899,26 +4884,21 @@ void CParticle::renderSprites () {
 
 	auto addVertex = [&] (float u, float v) {
 	    const uint32_t base = vertexIndex * SPRITE_FLOATS_PER_VERTEX;
-	    // a_Position (vec3)
 	    m_vertices[base + 0] = position.x;
 	    m_vertices[base + 1] = position.y;
 	    m_vertices[base + 2] = position.z;
-	    // a_TexCoordVec4 (vec4: uv.x, uv.y, rotZ, size)
 	    m_vertices[base + 3] = u;
 	    m_vertices[base + 4] = v;
 	    m_vertices[base + 5] = p.rotation.z;
 	    m_vertices[base + 6] = p.size;
-	    // a_Color (vec4: r, g, b, a)
 	    m_vertices[base + 7] = p.color.r;
 	    m_vertices[base + 8] = p.color.g;
 	    m_vertices[base + 9] = p.color.b;
 	    m_vertices[base + 10] = p.alpha;
-	    // a_TexCoordVec4C1 (vec4: vel.x, vel.y, vel.z, lifetime)
 	    m_vertices[base + 11] = velocity.x;
 	    m_vertices[base + 12] = velocity.y;
 	    m_vertices[base + 13] = velocity.z;
 	    m_vertices[base + 14] = lifetime;
-	    // a_TexCoordC2 (vec2: rotX, rotY)
 	    m_vertices[base + 15] = p.rotation.x;
 	    m_vertices[base + 16] = p.rotation.y;
 	    vertexIndex++;
@@ -4966,14 +4946,9 @@ void CParticle::renderSprites () {
 
     copyRefractSource ();
 
-    // ComputeParticleTrailTangents produces a right vector with a Z component (from
-    // cross(eyeDirection, velocity), where eyeDirection has an XY offset from the model
-    // transform). For 2D/ortho particles at z=0, the ortho near plane sits at ndc.z=-1, so any
-    // Z offset pushes vertices past it and clips half the quad. GL_DEPTH_CLAMP avoids that by
-    // clamping depth instead of clipping.
+    // trail tangents have a z component that pushes 2D quads past the ortho near plane, clamp depth instead of clipping
     glEnable (GL_DEPTH_CLAMP);
 
-    // CPass::render() handles: FBO binding, texture setup, uniforms, blending, draw call, cleanup
     m_pass->render ();
 
     glDisable (GL_DEPTH_CLAMP);
@@ -4990,10 +4965,9 @@ void CParticle::copyRefractSource () const {
 	return;
     }
 
-    // WE resolves whatever target is bound into _rt_FullFrameBuffer (sub_1402366F0 -> sub_1400D3310). Under a
-    // passthrough layer that is the layer's buffer, and the copy only works when it has _rt_FullFrameBuffer's size
-    // (the window's); both always share a color format (sub_1400D2A20: RGBA8, RGBA16F with renderer flag 0x2000).
-    // Otherwise the texture keeps what it had, the scene as it was before the layer, which is our scene buffer now
+    // WE resolves the bound target into _rt_FullFrameBuffer (sub_1402366F0 -> sub_1400D3310); under a passthrough layer
+    // that's its buffer, which only copies at the window's size (same color format, sub_1400D2A20), otherwise the
+    // texture keeps the scene from before the layer, our scene buffer
     std::shared_ptr<const CFBO> source = getScene ().getFBO ();
 
     if (const auto* layer = getScene ().getLayerTarget (); layer != nullptr) {

+ 5 - 9
src/WallpaperEngine/Render/Objects/CParticle.h

@@ -141,11 +141,8 @@ public:
     void finishEmitters ();
     void resumeEmitters ();
 
-    /**
-     * IParticleSystemInstance (the instance override struct at +1912, members sub_14024D940) beyond what the scene's
-     * instanceoverride set: colorn is -1 and control points have FLT_MAX in x until something writes them
-     * (sub_14024D760). angle picks controlpointangleN over controlpointN
-     */
+    // IParticleSystemInstance (instance override at +1912, sub_14024D940) beyond the scene's instanceoverride: colorn
+    // -1 and control point x FLT_MAX until written (sub_14024D760); angle picks controlpointangleN
     [[nodiscard]] glm::vec3 getInstanceColor () const;
     void setInstanceColor (const glm::vec3& color);
     [[nodiscard]] glm::vec3 getInstanceControlPoint (size_t index, bool angle) const;
@@ -356,7 +353,7 @@ private:
     TextureMap m_passBinds;
     GLsizei m_activeIndexCount { 0 };
 
-    // REFRACT: copy of scene FBO to avoid read/write conflict
+    // REFRACT: copy of the scene FBO, it can't be read while drawn into
     bool m_hasRefract { false };
     std::shared_ptr<CFBO> m_refractFBO;
 
@@ -365,8 +362,7 @@ private:
     GLuint m_ebo { 0 };
     GLint m_prevVAO { 0 };
 
-    // Particle-specific uniform data (stored here, pointed to by CPass)
-    /** m_worldModelMatrix in sceneMatrix () space */
+    // m_worldModelMatrix in sceneMatrix () space, CPass points at these
     glm::mat4 m_modelMatrix { 1.0f };
     /** WE's world, identity for world space systems */
     glm::mat4 m_worldModelMatrix { 1.0f };
@@ -392,7 +388,7 @@ private:
     float m_trailLength { 0.05f };
     float m_trailMaxLength { 10.0f };
     float m_trailMinLength { 0.0f };
-    // Rope renderer (rope + ropetrail both use genericropeparticle shader)
+    // rope and ropetrail both use genericropeparticle
     bool m_useRopeRenderer { false };
     int m_ropeSubdivision { 4 }; // Catmull-Rom subdivisions between points (smoothing)
     int m_ropeSegments { 4 }; // ropetrail: historical position snapshots per particle

+ 2 - 5
src/WallpaperEngine/Render/Objects/CRenderable.h

@@ -37,11 +37,8 @@ public:
     /** The effect's buffers whose conditions held, with their effect.json entries */
     using EffectBuffers = std::vector<std::pair<const FBO*, std::shared_ptr<CFBO>>>;
     void registerEffectBuffers (const ImageEffect& effect, EffectBuffers buffers);
-    /**
-     * IEffect.executeMaterialFunction (wallpaper64.exe 2.8.42 sub_1401EE3A0): a "clear" function clears as many of
-     * the effect's buffers as it names, but always the first ones, each to its own clear color. False when the effect
-     * isn't one of this object's
-     */
+    // IEffect.executeMaterialFunction (2.8.42 sub_1401EE3A0): "clear" clears as many buffers as it names, always the
+    // first ones, each to its clear color; false when the effect isn't ours
     bool executeEffectFunction (const ImageEffect& effect, const std::string& name) const;
     /** WE only keeps a material's first pass (sub_1401515B0), what IEffect.getMaterial hands out */
     void registerEffectMaterial (const ImageEffect& effect, size_t passIndex, Effects::CPass* pass);

+ 3 - 8
src/WallpaperEngine/Render/Objects/CSound.h

@@ -19,14 +19,9 @@ class CScene;
 namespace WallpaperEngine::Render::Objects {
 using namespace WallpaperEngine::Data::Model;
 
-/**
- * WE's sound object (wallpaper64.exe 2.8.42, vtable off_140490AE8). Every file of the object is a voice, only one plays
- * at a time: play() stops them all and starts a random one. Loop mode loops a single file and otherwise moves on to
- * another random file when the current one is over, random mode waits mintime..maxtime between files, single plays
- * one file once. WE plays them through OpenAL Soft 1.21.1 (mediaextensions64.dll), whose speaker panning and distance
- * attenuation are reproduced here for mono files. Its properties take scripts like any object's (WE's generic loaders,
- * sub_1401A4B00 -> sub_1401A4DB0 with the sound as owner).
- */
+// WE's sound object (2.8.42, off_140490AE8): one voice per file, play() stops all and starts a random one; loop moves
+// on to another random file when one ends, random waits mintime..maxtime between files, single plays once. OpenAL
+// Soft 1.21.1 panning and attenuation reproduced for mono files
 class CSound final : public Scripting::ScriptableObject {
 public:
     CSound (Wallpapers::CScene& scene, const Sound& sound);

+ 13 - 21
src/WallpaperEngine/Render/Objects/CText.cpp

@@ -30,7 +30,7 @@ using namespace WallpaperEngine::Render::Objects::Effects;
 using WallpaperEngine::Data::Parsers::MaterialParser;
 
 namespace {
-// Fallback fonts, used only when fontconfig finds nothing at all
+// only when fontconfig finds nothing
 const std::vector<std::string> kFontCandidates = {
     "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf",
     "/usr/share/fonts/TTF/DejaVuSans.ttf",
@@ -135,10 +135,9 @@ std::string installedFamily (const std::vector<std::string>& families) {
     return {};
 }
 
-// wallpaper64.exe's fallback fonts (off_140484C40, tried per character by sub_1401AD670): Windows fonts from the
-// system font folder and the assets' Twemoji. Here the Windows fonts count when they are installed under their own
-// family, arial.ttf also through its metric compatible clones like the systemfont_arial match, and the CJK ones
-// through the usual Linux CJK families since Windows always has YaHei/Malgun but Linux never does
+// WE's fallback fonts (off_140484C40, per character by sub_1401AD670): Windows fonts and the assets' Twemoji;
+// Windows fonts count when installed under their family (arial.ttf also via metric clones), CJK through the usual Linux
+// CJK families
 std::vector<TextFontSource> weFallbackFonts (const WallpaperEngine::Assets::AssetLocator& assets) {
     static std::shared_ptr<const std::vector<uint8_t>> twemoji;
     static bool twemojiRead = false;
@@ -246,7 +245,7 @@ private:
     GLuint m_textureID = GL_NONE;
 };
 
-// Final pass: blits the effect-processed buffer onto the actual scene
+// final pass: the effect buffer onto the scene
 MaterialUniquePtr buildCompositeMaterial () {
     auto pass = std::make_unique<MaterialPass> (MaterialPass {
 	.blending = BlendingMode_Translucent,
@@ -271,9 +270,7 @@ const Material& compositeMaterial () {
     return *material;
 }
 
-// Mirrors CImage.cpp's clampParallaxAxis: keeps an edge pair from sliding into the on-screen part
-// of the canvas once `offset` is added to both; a box too small to cover it on this axis has no
-// ground to uncover and moves freely.
+// same as CImage.cpp's clampParallaxAxis
 float clampParallaxAxis (float offset, float edgeA, float edgeB, float visibleLow, float visibleHigh) {
     const float low = std::min (edgeA, edgeB);
     const float high = std::max (edgeA, edgeB);
@@ -585,10 +582,8 @@ CText::PassLayout CText::currentPassLayout () const {
 	.blendMode = m_text.colorBlendMode->value->getInt (),
     };
 
-    // sub_1401E6F50: a blend mode other than 0 and 31 (additive) makes the text composite through
-    // effectpassthrough, like having effects, and so does fog (renderer flags 0x1800000 = scene fog flags 0x4000
-    // and 0x8000, sub_140186440). Its other trigger, image flag 0x100, is never set in 2.8.42. The scene loader adds
-    // 0x1010 to a text another object lists in its dependencies (sub_140186C90), the buffer is what it reads
+    // sub_1401E6F50: a blend mode other than 0 and 31 composites through effectpassthrough like effects do, and so does
+    // fog (sub_140186440); image flag 0x100 is never set in 2.8.42, dependency texts get 0x1010 (sub_140186C90)
     const bool fog = this->getScene ().hasDistanceFog () || this->getScene ().hasHeightFog ();
     layout.passthrough = (layout.blendMode != 0 && layout.blendMode != 31) || fog || m_isDependency;
     // sub_140258900: buffered for visible effects or flag 0x10
@@ -877,9 +872,8 @@ void CText::buildPasses () {
 
     const glm::vec2 fboSize = { static_cast<float> (layout.bufferSize.x), static_cast<float> (layout.bufferSize.y) };
 
-    // the same buffer setup as image layers (text and image vtables share slot 23, sub_1401EA500): scene buffers named
-    // _rt_imageLayerComposite_<id>_a/_b, which layers depending on the text sample, 16 bit float in HDR scene
-    // rendering. They keep their identity when the text box changes size, whoever resolved them keeps a working buffer
+    // same buffers as image layers (shared vtable slot 23, sub_1401EA500): _rt_imageLayerComposite_<id>_a/_b, RGBA16F
+    // in HDR, stable across box resizes
     const TextureFormat format = this->getScene ().isHDR () ? TextureFormat_RGBA16161616f : TextureFormat_ARGB8888;
     const auto sceneBuffer = [this, format, fboSize] (const std::string& suffix) {
 	auto& scene = this->getScene ();
@@ -1247,14 +1241,12 @@ void CText::updateTransform () {
     glm::mat4 model
 	= flipY * glm::translate (glm::mat4 (1.0f), glm::vec3 (-scene_w * 0.5f, -scene_h * 0.5f, 0.0f)) * world * flipY;
 
-    // Matches CImage's parallax handling (CImage.cpp:updateScreenSpacePosition): WE moves the view, so the offset
-    // lands outside the text's own rotation and scale
-    // CScene::renderFrame() already folds disableparallax into getParallaxDisplacement()
+    // like CImage's parallax, WE moves the view so the offset lands outside the text's rotation and scale;
+    // disableparallax is already folded in
     if (this->getScene ().getScene ().camera.parallax.enabled->value->getBool ()) {
 	glm::vec2 parallaxOffset = this->getScene ().getParallaxOffset (m_text);
 
-	// mirrors CImage's parallax clamp, or a text layer drifts past its edges while a same-depth
-	// CImage backing panel freezes, visibly separating the two
+	// same clamp as CImage, or the text drifts away from a same-depth image behind it
 	if (this->getScene ().getContext ().getApp ().getContext ().settings.mouse.clampParallaxToImageSize) {
 	    const float scaledHalfWidth = boxWidth * 0.5f * scale.x;
 	    const float scaledHalfHeight = boxHeight * 0.5f * scale.y;

+ 2 - 6
src/WallpaperEngine/Render/Objects/CText.h

@@ -24,12 +24,8 @@ class CScene;
 namespace WallpaperEngine::Render::Objects {
 using namespace WallpaperEngine::Data::Model;
 
-/**
- * Text objects the way wallpaper64.exe 2.8.42 draws them: HarfBuzz shaped glyphs from an atlas (plain coverage, or
- * MSDF when msdf/outline/blur/drop shadow is on) drawn with WE's own materials/fonts materials, an optional opaque
- * background quad, and when the text has effects everything goes through a buffer the size of the text box plus
- * padding first, the way images run their effects.
- */
+// text like 2.8.42 draws it: HarfBuzz glyphs from an atlas (coverage, or MSDF for msdf/outline/blur/drop shadow) with
+// WE's font materials, an optional background quad, through a padded buffer when it has effects
 class CText final : public CRenderable, public Scripting::ScriptableObject {
     friend CObject;
 

+ 21 - 32
src/WallpaperEngine/Render/Objects/Effects/CPass.cpp

@@ -249,8 +249,7 @@ std::optional<std::string> CPass::resolveUserTextureName (const std::string& pro
     const std::string& value = it->second->getString ();
 
     if (value.empty ()) {
-	// the "scenetexture" property exists but the user hasn't imported an image for it -
-	// this is the normal state for most wallpapers that expose this as an optional slot
+	// the user hasn't imported an image for this optional slot
 	return std::nullopt;
     }
 
@@ -331,9 +330,8 @@ void CPass::setupRenderFramebuffer () const {
 							   : target->getFramebuffer ()
     );
 
-    // Private per-object FBOs are never cleared elsewhere, so a blending pass would otherwise
-    // accumulate stale alpha across frames. The shared scene FBO must not be cleared here though,
-    // since it accumulates every object drawn this frame.
+    // private FBOs aren't cleared elsewhere, blending would accumulate stale alpha; the scene FBO collects every object
+    // so it stays
     if (this->m_drawTo != this->m_renderable.getScene ().getFBO () && !this->m_keepDestination) {
 	GLfloat previousClearColor[4] = {};
 	glGetFloatv (GL_COLOR_CLEAR_VALUE, previousClearColor);
@@ -451,15 +449,14 @@ void CPass::setupRenderTexture () {
 	this->m_texture0Resolution = *texture0->getResolution ();
     }
 
-    // used in animations when one of the frames is vertical instead of horizontal
-    // rotation with translation = origin and end of the image to display
+    // sprite frames stored rotated: rotation and translation give the origin and end of the image
     if (this->g_Texture0Rotation != -1) {
 	glUniform4f (
 	    this->g_Texture0Rotation, animation.rotation.x, animation.rotation.y, animation.rotation.z,
 	    animation.rotation.w
 	);
     }
-    // this actually picks the origin point of the image from the atlast
+    // the frame's origin in the atlas
     if (this->g_Texture0Translation != -1) {
 	glUniform2f (this->g_Texture0Translation, animation.translation.x, animation.translation.y);
     }
@@ -1111,16 +1108,14 @@ void CPass::setupShaders () {
 	}
     }
 
-    // TODO: review the shader textures here; ones passed to the shader shouldn't be in this list
-    // (used later to build the textures)
-    // use the combos copied from the pass so it includes the texture format
+    // TODO: textures passed to the shader shouldn't be in this list
+    // the pass's combos, texture format included
     const std::string& shaderName
 	= this->m_override.shaderOverride.has_value () ? this->m_override.shaderOverride.value () : this->m_pass.shader;
 
     TextureMap passTextures = this->m_pass.textures;
     for (const auto& [index, propertyName] : this->m_pass.usertextures) {
-	// leave the default texture (if any) in place when the user hasn't provided an override,
-	// same rule applied when the actual texture chain gets built in setupTextureUniforms()
+	// keep the default texture when the user hasn't set one, like setupTextureUniforms()
 	if (const auto resolved = this->resolveUserTextureName (propertyName); resolved.has_value ()) {
 	    passTextures.insert_or_assign (index, *resolved);
 	}
@@ -1227,9 +1222,8 @@ void CPass::setupShaders () {
 	}
     }
 
-    // passes with the same sources share one program (every particle system instance of a child would link its own
-    // otherwise, hundreds in the first seconds of a rain wallpaper). Uniforms are uploaded on every draw, the sampler
-    // units below are the same for all of them
+    // passes with the same sources share a program (child particle instances would link hundreds otherwise), uniforms
+    // go up every draw
     this->m_programKey = vertex + '\0' + fragment + '\0' + this->m_compiled->geometry;
     if (const auto cached = sharedPrograms ().find (this->m_programKey); cached != sharedPrograms ().end ()) {
 	this->m_programID = cached->second.program;
@@ -1251,7 +1245,7 @@ void CPass::setupShaders () {
 	}
     }
 
-    // first setup the default values, these will be overwritten by future values
+    // defaults first, later values overwrite them
     this->setupShaderVariables ();
     this->setupUniforms ();
     this->setupAttributes ();
@@ -1267,8 +1261,8 @@ std::unordered_map<std::string, std::weak_ptr<CPass::CompiledShader>>& CPass::sh
 std::shared_ptr<CPass::CompiledShader> CPass::compileShaderSources (
     const std::string& shaderName, const TextureMap& passTextures, const TextureMap& overrideTextures
 ) {
-    // parsing and translating a shader takes a few ms, and every instance of a child particle system builds the same
-    // one. Override constants can change the parsed defaults, those passes keep a shader of their own
+    // parsing a shader takes a few ms and every child particle instance builds the same one; override constants change
+    // the defaults, those passes keep their own
     const bool shareable = this->m_override.constants.empty ();
     std::string key;
 
@@ -1489,8 +1483,7 @@ void CPass::setupAttributes () {
 }
 
 void CPass::setupTextureUniforms () {
-    // Vertex shaders don't carry texture info in practice, but check them first anyway;
-    // fragment textures are checked after and override/extend the chain.
+    // vertex shaders rarely carry textures, the fragment ones override/extend the chain
     for (const auto& [index, textureName] : this->m_shader->getVertex ().getTextures ()) {
 	try {
 	    auto texture = this->resolveNamedTexture (textureName);
@@ -1555,8 +1548,7 @@ void CPass::setupTextureUniforms () {
     for (const auto& [index, propertyName] : this->m_pass.usertextures) {
 	const auto resolvedName = this->resolveUserTextureName (propertyName);
 	if (!resolvedName.has_value ()) {
-	    // optional user-provided texture slot, nothing configured - keep whatever the
-	    // regular "textures" entry already set for this index (if any)
+	    // unset user texture slot, keep the regular textures entry
 	    continue;
 	}
 
@@ -1583,7 +1575,6 @@ void CPass::setupTextureUniforms () {
 	}
     }
 
-    // override any texture
     for (const auto& [index, textureName] : this->m_override.textures) {
 	// WE writes every bound FBO into its slot on each draw (sub_1401EBF60), so overrides there are never sampled
 	if (const auto bind = this->m_binds.find (index); bind != this->m_binds.end () && bind->second != "previous") {
@@ -1647,7 +1638,7 @@ void CPass::setupTextureUniforms () {
 	}
     }
 
-    // binds are set last as they're the most important to be set
+    // binds last, they win
     for (const auto& [index, bind] : this->m_binds) {
 	const auto texture = bind == "previous" ? nullptr : this->resolveFBO (bind);
 	const auto it = this->m_textures.find (index);
@@ -1736,7 +1727,6 @@ void CPass::setupUniforms () {
     const auto& sceneData = this->m_renderable.getScene ().getScene ();
     const auto& recorder = this->m_renderable.getScene ().getAudioContext ().getRecorder ();
 
-    // lighting variables
     this->addUniform ("g_LightAmbientColor", &sceneData.colors.ambient->value->getVec3 ());
     this->addUniform ("g_LightSkylightColor", &sceneData.colors.skylight->value->getVec3 ());
     this->addUniform ("g_LightsPosition", UniformType::Vector3, scene.getLightsPosition (), 4);
@@ -1859,7 +1849,7 @@ template <typename T> void CPass::addUniform (const std::string& name, UniformTy
 }
 
 template <typename T> void CPass::addUniform (const std::string& name, UniformType type, T* value, int count) {
-    // this version is used to reference to system variables so things like g_Time works fine
+    // system variables like g_Time
     GLint id = glGetUniformLocation (this->m_programID, name.c_str ());
 
     if (id == -1) {
@@ -1874,7 +1864,7 @@ template <typename T> void CPass::addUniform (const std::string& name, UniformTy
 }
 
 template <typename T> void CPass::addUniform (const std::string& name, UniformType type, T** value) {
-    // this version is used to reference to system variables so things like g_Time works fine
+    // system variables like g_Time
     const GLint id = glGetUniformLocation (this->m_programID, name.c_str ());
 
     if (id == -1) {
@@ -2118,7 +2108,7 @@ void CPass::addConstantUniform (ShaderVariable* var, const UserSetting& setting)
 }
 
 void CPass::addUniform (ShaderVariable* value) {
-    // delegates to the (ShaderVariable*, DynamicValue*) overload, which handles the casting
+    // the (ShaderVariable*, DynamicValue*) overload does the casting
     this->addUniform (value, value);
 }
 
@@ -2217,9 +2207,8 @@ GLenum CPass::getDeclaredUniformType (const std::string& name) const {
 }
 
 void CPass::addUniform (const std::string& name, const glm::vec4* value) {
-    // resolution uniforms are always kept as a vec4 (texture size + real size), but shaders often declare
-    // them as a vec2 and glUniform4 on that is a GL error that leaves the uniform at 0 (color_key_plus
-    // then divides by a zero resolution and the whole layer comes out NaN)
+    // resolutions are kept as vec4, but a vec2 declaration makes glUniform4 fail and leave 0 (color_key_plus then
+    // divides by zero, NaN layer)
     switch (this->getDeclaredUniformType (name)) {
 	case GL_FLOAT_VEC2:
 	    this->addUniform (name, UniformType::Vector2, reinterpret_cast<const glm::vec2*> (value), 1);

+ 7 - 19
src/WallpaperEngine/Render/Objects/Effects/CPass.h

@@ -62,10 +62,8 @@ public:
     /** The pass draws in WE's world space (the fog composite of image layers), fog measures from WE's own eye then */
     void setFogWorld (bool world);
     void setViewProjectionMatrix (const glm::mat4* viewProjection);
-    /**
-     * Where the vertices of a lit pass really are in the scene (y up, WE's coordinates). Lit passes are built with
-     * PRELIGHTING so lighting goes through these while the pass keeps drawing with its own projection
-     */
+    // where a lit pass's vertices are in WE's scene coordinates (y up); lit passes use PRELIGHTING so lighting goes
+    // through these
     void setLightingTransform (const glm::mat4* model, const glm::mat3* normal, const glm::mat4* viewProjection);
     void setEffectTextureProjectionMatrix (const glm::mat4* projection, const glm::mat4* inverse);
     /** What a private destination is cleared to before drawing (transparent black when unset) */
@@ -119,12 +117,12 @@ public:
     /** The shader has a geometry stage (GS_ENABLED and a .geom, WE's particle shaders) */
     [[nodiscard]] bool hasGeometryStage () const;
 
-    // Custom geometry rendering support (for particles, etc.)
+    // custom geometry (particles)
     using GeometryCallback = std::function<void ()>;
     void
     setGeometryCallback (GeometryCallback setupAttribs, GeometryCallback drawGeometry, GeometryCallback cleanupAttribs);
 
-    // Public uniform setters for external callers (pointer-based, updated per-frame)
+    // pointer based, read every frame
     void addUniform (const std::string& name, const float* value, int count = 1);
     void addUniform (const std::string& name, const glm::vec3* value);
     void addUniform (const std::string& name, const glm::vec4* value);
@@ -160,9 +158,7 @@ private:
 	UniformType type;
 	const void* value;
 	int count;
-	// true when "value" is a heap copy this entry allocated (addUniform(name, type, T) by-value
-	// overload) rather than a pointer into a scene/shader-owned field (addUniform(..., T*, count)),
-	// so only owned entries may free their value.
+	// value is a heap copy from the by-value addUniform overload, only those are freed
 	bool owned;
     };
 
@@ -284,15 +280,8 @@ private:
 	std::shared_ptr<const TextureProvider> previous = nullptr
     );
 
-    /**
-     * "usertextures" entries in material/effect JSON are the *name* of a "scenetexture" general
-     * property, not a texture path - the actual texture to use is whatever the user configured that
-     * property to (which is commonly left unset). Resolves that indirection.
-     *
-     * @param propertyName The usertextures entry as it appears in the JSON
-     * @return The texture name to resolve, or nullopt if the slot is a known, intentionally unset
-     *         user-provided texture (no property value configured)
-     */
+    // usertextures entries name a "scenetexture" property, the texture is what the user set it to; nullopt when the
+    // slot is left unset
     [[nodiscard]] std::optional<std::string> resolveUserTextureName (const std::string& propertyName) const;
 
     CRenderable& m_renderable;
@@ -374,7 +363,6 @@ private:
     GLuint a_Position;
     GLuint m_vao;
 
-    // Custom geometry callbacks (for particles, etc.)
     GeometryCallback m_setupAttribsCallback;
     GeometryCallback m_drawGeometryCallback;
     GeometryCallback m_cleanupAttribsCallback;

+ 3 - 9
src/WallpaperEngine/Render/Objects/PuppetClipping.h

@@ -6,11 +6,8 @@
 #include <vector>
 
 namespace WallpaperEngine::Render::Objects {
-/**
- * Clipping masks of a puppet mesh (MDLV 23+), read and turned into draws the way wallpaper64.exe 2.8.42 does: the
- * loader (sub_140261880) reads the part ranges and the records, the image setup (sub_14020AE00, sub_14020B720) splits
- * the index buffer into draws and builds the command list the final draw (sub_140208670 / sub_140208C80) walks.
- */
+// puppet mesh clipping masks (MDLV 23+) like 2.8.42: part ranges and records from sub_140261880, split into draws and a
+// command list by sub_14020AE00/sub_14020B720, walked by sub_140208670/sub_140208C80
 struct PuppetClipping {
     enum RecordFlags : uint32_t {
 	/** the targets are drawn additively instead of translucent */
@@ -56,10 +53,7 @@ struct PuppetClipping {
 	NestedMask = 2,
     };
 
-    /**
-     * Reads what follows a puppet's index buffer. offset is the end of the index data, nullopt when the file has no
-     * clipping records
-     */
+    // what follows a puppet's index buffer (offset = its end), nullopt without clipping records
     static std::optional<PuppetClipping>
     read (const std::vector<char>& data, size_t offset, int version, size_t indexCount);
     /** Only the part ranges (MDLV 21+), what the animated draw order sorts */

+ 4 - 9
src/WallpaperEngine/Render/Objects/PuppetPhysics.h

@@ -57,11 +57,8 @@ struct PuppetBonePhysicsState {
     glm::vec3 velocity { 0.0f };
 };
 
-/**
- * One frame of a bone's physics (sub_1401FDF90). `world` is the bone's scene transform this frame before its own
- * physics, `previousWorld` last frame's after it, `objectScale` the average axis scale of the object. Returns the
- * matrix to apply in front of the bone's model-space transform (model * result).
- */
+// one frame of a bone's physics (sub_1401FDF90): world is this frame's scene transform before its physics,
+// previousWorld last frame's after; returns what goes in front of the model-space transform
 glm::mat4 stepPuppetBonePhysics (
     const PuppetBonePhysics& physics, PuppetBonePhysicsState& state, const glm::mat4& world,
     const glm::mat4& previousWorld, float dt, float objectScale
@@ -72,10 +69,8 @@ glm::vec4 puppetSlerp (const glm::vec4& a, const glm::vec4& b, float t);
 glm::vec4 puppetRotationArc (const glm::vec3& from, const glm::vec3& to);
 glm::mat3 puppetQuatRows (const glm::vec4& q);
 
-/**
- * Script `applyBonePhysicsImpulse` (sub_140210990): the directional impulse is added to the translation velocity,
- * the angular one (degrees) is turned into a quaternion and multiplied onto the angular velocity.
- */
+// applyBonePhysicsImpulse (sub_140210990): the directional impulse adds to the translation velocity, the angular one
+// (degrees) multiplies onto the angular velocity
 void applyPuppetBoneImpulse (
     PuppetBonePhysicsState& state, const glm::vec3& directional, const glm::vec3& angularDegrees
 );

+ 12 - 22
src/WallpaperEngine/Render/Objects/PuppetRig.cpp

@@ -137,9 +137,7 @@ float puppetLayerWeight (PuppetActiveAnimation& layer, float duration) {
 
 struct PuppetBoneSet {
     std::vector<PuppetBone> bones;
-    // Points at whatever section comes right after MDLS's second bone array: MDLA directly for
-    // puppets with no attachment points, or MDAT (attachment points) otherwise - the caller has to
-    // check which one it actually is.
+    // the section after MDLS's second bone array: MDLA, or MDAT with attachment points; the caller checks which
     size_t nextSectionOffset = 0;
     // MDLS v2+ records after the bones, every MDLA clip carries one track per entry of each
     uint32_t extraCount = 0;
@@ -152,9 +150,8 @@ struct PuppetBoneSet {
 
 void parsePuppetCapsules (const BinaryReader& reader, PuppetBoneSet& result, size_t nextSectionOffset);
 
-// Parses the MDLS bones (local bind-pose transforms, parent hierarchy and the per-bone physics JSON) and the
-// counts of the records after them that size the MDLA tracks. Inverse-bind matrices are derived from the bind
-// pose by walking the parent chain; the file's own copy is skipped.
+// MDLS bones (bind pose, parents, physics JSON) and the record counts sizing the MDLA tracks; inverse binds come from
+// the bind pose, the file's copy is skipped
 PuppetBoneSet parsePuppetBones (const BinaryReader& reader, size_t mdlsOffset) {
     reader.base ().seekg (static_cast<std::streamoff> (mdlsOffset), std::ios::beg);
 
@@ -164,8 +161,7 @@ PuppetBoneSet parsePuppetBones (const BinaryReader& reader, size_t mdlsOffset) {
     const uint32_t nextSectionOffset = reader.nextUInt32 ();
     const uint32_t boneCount = reader.nextUInt32 ();
 
-    // A bone count this large can only be a garbage read (wrong mdlsOffset or an unrecognized MDLS
-    // layout), not a real rig
+    // only a garbage read gives this many
     constexpr uint32_t maxPlausibleBoneCount = 512;
     if (boneCount > maxPlausibleBoneCount) {
 	sLog.error ("Puppet bone count (", boneCount, ") looks implausible, skipping puppet mesh skinning");
@@ -189,15 +185,13 @@ PuppetBoneSet parsePuppetBones (const BinaryReader& reader, size_t mdlsOffset) {
 	    for (float& value : m) {
 		value = reader.nextFloat ();
 	    }
-	    // the file stores a row-vector-convention, row-major matrix; feeding the 16 values straight
-	    // into glm's column-major constructor produces exactly its transpose, which is the
-	    // column-vector matrix glm needs to compute M * v
+	    // row-vector row-major in the file, glm's column-major constructor transposes it into the column-vector
+	    // matrix
 	    bindLocal = glm::mat4 (
 		m[0], m[1], m[2], m[3], m[4], m[5], m[6], m[7], m[8], m[9], m[10], m[11], m[12], m[13], m[14], m[15]
 	    );
 	} else {
-	    // an implausible byte count here means this bone record wasn't decoded correctly; bail out
-	    // rather than seeking by an untrusted amount and reading whatever garbage follows as bones
+	    // a bad decode, don't seek by an untrusted amount
 	    constexpr uint32_t maxPlausibleMatrixBytes = 4096;
 	    if (matrixBytes > maxPlausibleMatrixBytes) {
 		sLog.error (
@@ -464,8 +458,7 @@ void parsePuppetCapsules (const BinaryReader& reader, PuppetBoneSet& result, siz
     }
 }
 
-// Resolves each bone's world transform by walking up the parent chain: the MDL format doesn't
-// guarantee parents come before their children, and some rigs (puppet eyes/eyebrows) break that order
+// parents don't necessarily come before children (puppet eyes/eyebrows)
 void resolveBoneWorldTransform (
     size_t index, const std::vector<int>& parents, const std::vector<glm::mat4>& locals, std::vector<glm::mat4>& world,
     std::vector<bool>& resolved, std::vector<bool>& visiting
@@ -475,8 +468,7 @@ void resolveBoneWorldTransform (
     }
 
     const int parent = parents[index];
-    // a missing parent, an out-of-range index, or a cycle back onto a bone still being resolved are
-    // all treated the same way a genuine root bone would be: no parent transform to fold in
+    // missing, out-of-range or cyclic parents count as roots
     if (parent < 0 || static_cast<size_t> (parent) >= parents.size () || visiting[index]) {
 	world[index] = locals[index];
     } else {
@@ -1363,11 +1355,9 @@ void PuppetRig::updatePose (const glm::mat4& objectWorld, PuppetRootMotionHost*
 	return;
     }
 
-    // WE's layer blend (2.8.42 sub_1401FDF90, models sub_14021C480): each bone starts from its rest pose (the MDLS
-    // rest matrix as position, rotation and scale) and every visible layer in order steps its clock and blends
-    // towards its clip's sample (sub_1401F9020) or, when additive, adds the sample's difference from the rest pose
-    // (sub_1401F9820). Bones whose track is flagged off in a clip keep what they have.
-    // every layer runs its own clock, stepped by dt * rate while the layer is visible (sub_1401FDF90)
+    // WE's layer blend (2.8.42 sub_1401FDF90, models sub_14021C480): bones start at the MDLS rest pose, each visible
+    // layer steps its clock (dt * rate) and blends towards its clip's sample (sub_1401F9020) or adds its difference
+    // from rest when additive (sub_1401F9820); bones flagged off in a clip keep what they have
     const float dt = this->clockTime < 0.0f ? 0.0f : std::max (g_Time - this->clockTime, 0.0f);
     this->clockTime = g_Time;
 

+ 3 - 9
src/WallpaperEngine/Render/Objects/PuppetRig.h

@@ -196,11 +196,8 @@ struct PuppetLayerSample {
     float alpha
 );
 
-/**
- * The skeleton, animation layers and bone physics of a puppet image or a 3D model. Both run the same pose update in
- * wallpaper64.exe 2.8.42 (images sub_1401FDF90, models sub_14021C480): every bone starts at its rest pose, visible
- * layers blend their clips in, physics runs on the bones' scene transforms
- */
+// skeleton, animation layers and bone physics of a puppet or 3D model, the same pose update in 2.8.42 (images
+// sub_1401FDF90, models sub_14021C480): rest pose, layer blends, physics on scene transforms
 class PuppetRig {
 public:
     /** Reads MDLS at mdlsOffset and the MDAT/MDLA sections it leads to (sub_140261880). Throws on a broken file */
@@ -231,10 +228,7 @@ public:
     /** After the pose: every layer that ended runs dispatch (its ended callbacks), playSingleAnimation() ones go */
     void finishEndedLayers (const std::function<void (size_t)>& dispatch);
 
-    /**
-     * Steps the layer clocks and builds this frame's pose, objectWorld is the object's world matrix. Models pass
-     * themselves as host: their clips can play another clip's frames and move the object by root motion
-     */
+    // steps the layer clocks and builds the pose; models pass themselves as host for cross-clip frames and root motion
     void updatePose (const glm::mat4& objectWorld, PuppetRootMotionHost* host = nullptr);
     void updateMorphWeights (const std::vector<PuppetLayerSample>& samples);
     /** sub_1401FDF90 for meshes with flag 8: every bone's draw order from MDLS, moved by the layers' v6 tracks */

+ 5 - 12
src/WallpaperEngine/Render/Objects/PuppetRootMotion.h

@@ -32,23 +32,16 @@ struct PuppetRootMotionStep {
     float yaw = 0.0f;
 };
 
-/**
- * One layer's root motion (wallpaper64.exe 2.8.42 sub_140225900, models only): the root bone's movement since the
- * last frame goes to the object, measured against the clip's first frame and turned into the object's frame, and the
- * blended root bone is pulled back to where the first frame has it. flags are the clip's: 0x800/0x1000/0x2000 move
- * along x/y/z, 0x8000 turns. current is the root bone this frame, start what the layer starts from (only read when
- * state.started is false), time the layer clock, weight the layer's blend weight, rest what the layers above leave of
- * it and world the object's world matrix
- */
+// one layer's root motion (2.8.42 sub_140225900, models only): the root's movement since last frame, against the clip's
+// first frame, goes to the object and the root is pulled back; flags 0x800/0x1000/0x2000 move along x/y/z, 0x8000
+// turns; start is only read before state.started, rest is what the layers above leave
 [[nodiscard]] PuppetRootMotionStep stepPuppetRootMotion (
     uint32_t flags, const PuppetRootMotionFrames& frames, const glm::mat4& current, const glm::mat4& start, float time,
     float weight, float rest, const glm::mat3& world, PuppetRootMotionState& state, glm::vec3& rootPosition,
     glm::quat& rootOrientation
 );
 
-/**
- * The object's angles turned by yaw about the world y axis: added to the y angle (wrapped to one turn) while x and z
- * are about zero, otherwise through the rotation matrix (sub_140215020, sub_1401E2500, sub_1401E23D0)
- */
+// the object's angles turned by yaw about world y: added to y while x and z are about zero, else through the rotation
+// matrix (sub_140215020, sub_1401E2500, sub_1401E23D0)
 [[nodiscard]] glm::vec3 turnPuppetRootMotion (const glm::vec3& angles, float yaw);
 } // namespace WallpaperEngine::Render::Objects

+ 2 - 3
src/WallpaperEngine/Render/Objects/TextLayout.cpp

@@ -516,9 +516,8 @@ std::vector<TextLayout::ShapedGlyph> TextLayout::shape (const std::u32string& li
 		continue;
 	    }
 
-	    // the quad comes from the outline's box (sub_1401ADDB0, loaded without bitmaps). Segoe UI Emoji, the colour
-	    // font WE finds first on Windows, has monochrome outlines under its colour layers, Twemoji (the fallback
-	    // left on Linux) has none, which would give its emoji an empty quad: their bitmap's box stands in there
+	    // the quad comes from the outline box (sub_1401ADDB0); Twemoji has no outlines under its colour layers
+	    // (Segoe UI Emoji does), so its bitmap box stands in
 	    const GlyphBox* box = this->glyphBox (run.face, glyph);
 	    GlyphBox bounds = box != nullptr ? *box : GlyphBox {};
 

+ 3 - 6
src/WallpaperEngine/Render/Objects/TextLayout.h

@@ -64,12 +64,9 @@ struct TextFontSource {
     std::string path;
 };
 
-/**
- * Text layout of wallpaper64.exe 2.8.42 (sub_1401B0410): HarfBuzz shaped runs per font, wrapping, row limit with
- * ellipsis, justification, and a glyph atlas of either plain coverage (R8) or MSDF glyphs (RGBA, msdfgen, 32 px per em
- * plus 12 px of range on every side). Colour glyphs (FreeType's BGRA bitmaps) go to a second RGBA atlas, as distance
- * fields plus a colour texture in MSDF mode (sub_1401AE080). Everything is in raster pixels, before the object's scale.
- */
+// 2.8.42 text layout (sub_1401B0410): HarfBuzz runs per font, wrapping, row limit with ellipsis, justification, an R8
+// coverage or RGBA MSDF atlas (32 px per em + 12 px range); colour glyphs go to a second RGBA atlas, distance fields
+// plus a colour texture in MSDF mode (sub_1401AE080). Raster pixels, before the object's scale
 class TextLayout {
 public:
     TextLayout ();

+ 1 - 2
src/WallpaperEngine/Render/RenderContext.cpp

@@ -20,8 +20,7 @@ double millisSince (const Clock::time_point start) {
     return std::chrono::duration<double, std::milli> (Clock::now () - start).count ();
 }
 
-// LWE_FRAME_STATS=1 logs per-output frame timings every 2 seconds. It adds a glFinish after each step so
-// GPU work is attributed to the step that queued it, which costs some throughput while enabled
+// LWE_FRAME_STATS=1 logs per-output frame timings every 2 s, with a glFinish per step (costs throughput)
 struct FrameStats {
     Clock::time_point windowStart = Clock::now ();
     Clock::time_point lastFrame {};

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików